docs: 修复 OGraph 安装指南三个踩坑问题 (#13)

鹿鸣 🦌 实际安装反馈:
- npm install 加 --ignore-scripts 避免 EPERM chmod 错误
- 明确 secret 应填 Gateway Token(已在之前版本修正)
- 代理环境下 Node.js fetch 不走系统代理,加 undici ProxyAgent 说明

— 小墨 🖊️(KUMA Team)
This commit is contained in:
小墨 🖊️ 2026-04-13 10:36:32 +00:00
parent 1b690ed3c9
commit 47619f4a16

View File

@ -90,9 +90,12 @@ curl -s -X POST https://ograph.shazhou.workers.dev/events \
cd ~/repos # 或你喜欢的目录 cd ~/repos # 或你喜欢的目录
git clone https://github.com/oc-xiaoju/openclaw-plugin-ograph.git git clone https://github.com/oc-xiaoju/openclaw-plugin-ograph.git
cd openclaw-plugin-ograph cd openclaw-plugin-ograph
npm install && npm run build npm install --ignore-scripts && npm run build
``` ```
!!! warning "npm install 报 EPERM?"
如果遇到 `EPERM: operation not permitted, chmod openclaw.mjs`,是因为全局安装的 OpenClaw 文件权限问题。加 `--ignore-scripts` 跳过 postinstall 即可。
### 2.2 注册到 OpenClaw ### 2.2 注册到 OpenClaw
编辑 `~/.openclaw/openclaw.json`,在 `plugins` 部分添加: 编辑 `~/.openclaw/openclaw.json`,在 `plugins` 部分添加:
@ -112,7 +115,7 @@ npm install && npm run build
"ograph": { "ograph": {
"enabled": true, "enabled": true,
"config": { "config": {
"secret": "<自定义一个密钥>", "secret": "your-gateway-token-here",
"topics": { "topics": {
"task-execution": { "task-execution": {
"description": "任务执行管理", "description": "任务执行管理",
@ -130,6 +133,19 @@ npm install && npm run build
!!! warning "路径必须是绝对路径" !!! warning "路径必须是绝对路径"
`load.paths` 里填 clone 目录的**绝对路径**,不能用 `~` `load.paths` 里填 clone 目录的**绝对路径**,不能用 `~`
!!! important "secret 字段说明"
`config.secret` 字段应填入你的 **OpenClaw Gateway Token**(不是自定义密钥)。
获取方法:在 `~/.openclaw/openclaw.json` 中找到 `gateway.auth.token` 的值,复制过来。
```json
"gateway": {
"auth": {
"token": "gw_abcd1234..." // ← 这个值
}
}
```
### 2.3 重启 Gateway ### 2.3 重启 Gateway
```bash ```bash
@ -192,7 +208,7 @@ mkdir -p ~/.config/ograph
{ {
"type": "oc-plugin", "type": "oc-plugin",
"url": "http://localhost:18789/plugins/ograph/dispatch", "url": "http://localhost:18789/plugins/ograph/dispatch",
"secret": "< Plugin config 里的 secret 一致>", "secret": "your-gateway-token-here",
"actor": "task-execution" "actor": "task-execution"
} }
], ],
@ -212,7 +228,7 @@ mkdir -p ~/.config/ograph
|------|------| |------|------|
| `discovery.agentId` | 你的 OGraph Agent ID | | `discovery.agentId` | 你的 OGraph Agent ID |
| `discovery.eventTypes` | 监听的事件类型 | | `discovery.eventTypes` | 监听的事件类型 |
| `agents[].secret` | **必须与 Plugin 的 `config.secret` 一致** | | `agents[].secret` | **必须与 OpenClaw Gateway Token 一致**(即 `~/.openclaw/openclaw.json` 中的 `gateway.auth.token` 值) |
| `agents[].actor` | 对应 Plugin 的 `topics` 里的 key | | `agents[].actor` | 对应 Plugin 的 `topics` 里的 key |
| `intervals.watcherIdle` | 无变化时的 poll 间隔(ms) | | `intervals.watcherIdle` | 无变化时的 poll 间隔(ms) |
| `intervals.watcherActive` | 有变化时的 poll 间隔(ms) | | `intervals.watcherActive` | 有变化时的 poll 间隔(ms) |
@ -224,6 +240,21 @@ cd ~/repos/ograph/packages/dispatcher
npm start npm start
``` ```
!!! warning "代理环境下 fetch 失败?"
Node.js 原生 fetch **不读取** `HTTP_PROXY` / `HTTPS_PROXY` 环境变量。如果你的网络需要代理,需要用 undici ProxyAgent 手动注入:
```js
// start-with-proxy.mjs
import { ProxyAgent, setGlobalDispatcher } from 'undici';
const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
if (proxy) setGlobalDispatcher(new ProxyAgent(proxy));
await import('./dist/index.js');
```
```bash
node start-with-proxy.mjs # 代替 npm start
```
正常输出: 正常输出:
``` ```
@ -320,7 +351,7 @@ curl -s -X POST "$API/events" \
| 问题 | 原因 | 解决 | | 问题 | 原因 | 解决 |
|------|------|------| |------|------|------|
| Plugin 返回 404 | Plugin 没加载 | 检查 `plugins.allow` 包含 `"ograph"` + `load.paths` 路径正确 | | Plugin 返回 404 | Plugin 没加载 | 检查 `plugins.allow` 包含 `"ograph"` + `load.paths` 路径正确 |
| Dispatcher 连不上 Plugin | secret 不匹配 | 确保 dispatcher.json `agents[].secret` 和 openclaw.json `ograph.config.secret` 一致 | | Dispatcher 连不上 Plugin | gateway token 不匹配 | 确保 dispatcher.json `agents[].secret` 和 openclaw.json `gateway.auth.token` 一致 |
| Watcher 没发现事件 | agentId 不对 | 确认 `discovery.agentId` 是你的 OGraph Agent ID | | Watcher 没发现事件 | agentId 不对 | 确认 `discovery.agentId` 是你的 OGraph Agent ID |
| Agent 没响应 | session busy / topic 不匹配 | 检查 `agents[].actor` 对应 Plugin `topics` 的 key | | Agent 没响应 | session busy / topic 不匹配 | 检查 `agents[].actor` 对应 Plugin `topics` 的 key |
| `agent #N = unknown` | 没发 profile 事件 | 回到 Step 1 发 `agent_profile_updated` 事件 | | `agent #N = unknown` | 没发 profile 事件 | 回到 Step 1 发 `agent_profile_updated` 事件 |