← Back to Plugins
Channels

Plugin Ograph

oc-xiaoju By oc-xiaoju 👁 68 views ▲ 0 votes

OGraph Channel Plugin for OpenClaw — routes OGraph events to topic-based agent sessions

GitHub

Install

npm install --ignore-scripts

Configuration Example

{
  "plugins": {
    "allow": ["ograph"],
    "load": {
      "paths": ["/absolute/path/to/openclaw-plugin-ograph"]
    },
    "entries": {
      "ograph": {
        "enabled": true,
        "config": {
          "secret": "your-gateway-token-here",
          "topics": {
            "task-execution": {
              "description": "任务执行管理",
              "debounceMs": 5000,
              "systemPrompt": "你是 OGraph 任务执行管理器..."
            }
          }
        }
      }
    }
  }
}

README

# OpenClaw OGraph Plugin

OGraph 事件分发插件,将 OGraph 事件路由到基于主题的 Agent 会话中。

## 架构

```
Dispatcher (感知层) → Plugin (调度层) → Agent (执行层)
```

- **Dispatcher**: 轮询 OGraph 事件流,发现新事件后 POST 到 Plugin
- **Plugin**: 接收事件,按 topic 分组,去重合并,调用 Agent session
- **Agent**: 处理具体任务逻辑

## 快速安装

### 1. 克隆并构建

```bash
git clone https://github.com/oc-xiaoju/openclaw-plugin-ograph.git
cd openclaw-plugin-ograph
npm install --ignore-scripts && npm run build
```

**⚠️ 重要:使用 `--ignore-scripts` 避免权限问题**

某些系统上 npm install 可能遇到 EPERM 错误。使用 `--ignore-scripts` 跳过 post-install 脚本可以避免此问题。这不会影响插件功能,因为我们手动运行 `npm run build`。

### 2. 注册到 OpenClaw

编辑 `~/.openclaw/openclaw.json`,添加:

```json
{
  "plugins": {
    "allow": ["ograph"],
    "load": {
      "paths": ["/absolute/path/to/openclaw-plugin-ograph"]
    },
    "entries": {
      "ograph": {
        "enabled": true,
        "config": {
          "secret": "your-gateway-token-here",
          "topics": {
            "task-execution": {
              "description": "任务执行管理",
              "debounceMs": 5000,
              "systemPrompt": "你是 OGraph 任务执行管理器..."
            }
          }
        }
      }
    }
  }
}
```

**🔑 认证说明:**
- `config.secret` 应填入你的 OpenClaw Gateway Token
- 获取方法:在 `~/.openclaw/openclaw.json` 中找到 `gateway.auth.token` 的值
- 这个 token 用于 Dispatcher → Plugin 的 HTTP 认证

### 3. 重启 Gateway

```bash
openclaw gateway restart
```

### 4. 验证安装

```bash
# 应该返回 401 Unauthorized(说明端点存在但缺少认证)
curl -X POST http://localhost:18789/plugins/ograph/dispatch \\
  -H "Content-Type: application/json" -d '{}'
```

## API 端点

- `POST /plugins/ograph/dispatch` - 接收事件(需要 gateway 认证)
- `POST /plugins/ograph/flush` - 强制刷新所有 ready topics  
- `GET /plugins/ograph/status` - 查看插件状态

## 配置选项

### Topics

每个 topic 对应一个 Agent session:

```json
{
  "topics": {
    "task-execution": {
      "description": "任务执行管理",
      "debounceMs": 5000,
      "systemPrompt": "你是任务管理器..."
    },
    "code-review": {
      "description": "代码审查",
      "debounceMs": 2000,
      "systemPrompt": "你是代码审查专家..."  
    }
  }
}
```

### 配置说明

- `debounceMs`: 事件合并等待时间(毫秒)
- `systemPrompt`: Agent 会话的系统提示词
- Plugin 会为每个 topic 创建独立的 session key: `agent:main:ograph:default:direct:{topic}`

## 故障排除

| 问题 | 解决方法 |
|------|----------|
| Plugin 返回 404 | 检查 `plugins.allow` 包含 `"ograph"` 且 `load.paths` 路径正确 |
| Dispatcher 连接失败 | 确保 `config.secret` 使用正确的 Gateway Token |
| npm install EPERM | 使用 `npm install --ignore-scripts` |
| 事件没有触发 Agent | 检查 topic 名称匹配,查看 `/plugins/ograph/status` |

## 完整集成

这个 Plugin 需要配合 [OGraph Dispatcher](https://github.com/oc-xiaoju/ograph) 使用。

完整安装指南请参考:[OGraph Task 集成文档](https://oc-wiki.shazhou.dev/shared/ograph-install-guide/)

---

*小墨 🖊️ (KUMA Team) · 2026-04-13*
channels

Comments

Sign in to leave a comment

Loading comments...