OpenClaw 对接指南
通过 OpenClaw 渠道插件连接微织 Weave,实现 AI 智能对话
概览
OpenClaw 是开源的 AI Agent 系统。通过安装 Weave 渠道插件,OpenClaw Gateway 可以作为 AI 联系人接入微织 Weave,用户通过浏览器即可与 OpenClaw 对话。
OpenClaw Gateway(内网)
↓ 渠道插件(反向 WebSocket)
微织 Weave(weaveai.chat)
↓
用户浏览器
前置条件
步骤一:在 Weave 中添加 OpenClaw 联系人
- 登录 weaveai.chat
- 点击左侧「联系人」-> 添加 -> 选择「OpenClaw」
- 输入联系人名称(如:我的 OpenClaw)
- 填写 WS ID(可点击「生成」自动创建,或手动输入)
- 可选:填写 API Key(用于连接认证)
- 点击「创建」
创建完成后,页面会显示 连接地址,格式为:
请记录此地址,后续配置需要使用。
wss://www.weaveai.chat/api/v1/openclaw/ws/your-ws-id请记录此地址,后续配置需要使用。
步骤二:下载 Weave 渠道插件
方式一:一键安装(推荐)
macOS / Linux:
curl -sSL https://raw.githubusercontent.com/Weave-chat/openclaw-weave-plugin/main/install.sh | bash Windows (PowerShell):
irm https://raw.githubusercontent.com/Weave-chat/openclaw-weave-plugin/main/install.ps1 | iex 方式二:手动安装
# 克隆插件到 OpenClaw 扩展目录
git clone https://github.com/Weave-chat/openclaw-weave-plugin.git ~/.openclaw/extensions/weave-channel
# 安装依赖并构建
cd ~/.openclaw/extensions/weave-channel
npm install
npm run build Windows 用户也可以从 GitHub Releases 下载 ZIP,解压到 %USERPROFILE%\.openclaw\extensions\weave-channel\
步骤三:安装依赖并构建
cd ~/.openclaw/extensions/weave-channel
# 安装依赖
npm install
# 编译 TypeScript
npm run build
# 验证构建产物
ls dist/
# 应显示 index.js 和 index.d.ts 步骤四:安装插件到 OpenClaw
# 安装插件
openclaw plugins install ~/.openclaw/extensions/weave-channel 步骤五:配置 OpenClaw
编辑 ~/.openclaw/openclaw.json,添加 Weave 渠道配置:
{
"plugins": {
"weave-channel": {
"enabled": true,
"wsUrl": "wss://www.weaveai.chat/api/v1/openclaw/ws/your-ws-id",
"apiKey": "your-api-key"
}
}
}
将
如果在 Weave 中设置了 API Key,也需要填写
your-ws-id 替换为步骤一中生成的 WS ID。如果在 Weave 中设置了 API Key,也需要填写
apiKey 字段。
步骤六:重启 Gateway 并验证
# 重启 OpenClaw Gateway
openclaw gateway --restart
# 查看日志确认连接
openclaw logs --follow 预期日志输出:
[weave] Connecting to wss://www.weaveai.chat/api/v1/openclaw/ws/...
[weave] WebSocket opened, waiting for challenge
[weave] Handshake complete, connection established 看到「connection established」即表示连接成功。返回 weaveai.chat,OpenClaw 联系人状态应显示为「在线」。
步骤七:开始对话
- 在 weaveai.chat 中点击 OpenClaw 联系人
- 输入消息,如「你好」
- OpenClaw Gateway 处理消息并流式回复
功能说明
| 功能 | 支持 | 说明 |
|---|---|---|
| 流式输出 | ✅ | 逐字流式显示回复 |
| 多轮对话 | ✅ | 完整的上下文记忆 |
| 工具调用 | ✅ | OpenClaw 原生工具能力 |
| 会话管理 | ✅ | 多会话切换 |
| 断线重连 | ✅ | 指数退避自动重连 |
| 心跳保活 | ✅ | 2 分钟 ping 间隔 |
| 认证 | ✅ | Gateway WS 协议握手 |
常见问题
WebSocket 连接失败(1006)?
1006 表示协议不匹配。请确认:
- 不要使用
gateway.mode: "remote"- 这是 OpenClaw 网关间协议,不是 Weave 中继协议 - 使用渠道插件方式连接(本文档描述的方式)
- 检查
wsUrl是否正确,格式为wss://www.weaveai.chat/api/v1/openclaw/ws/your-ws-id
插件未加载?
# 检查插件状态
openclaw plugins
# 确认 enabled: true
# 如果未启用,编辑 openclaw.json 将 enabled 改为 true
# 重启 Gateway
openclaw gateway --restart 编译失败?
# 确认 Node.js 版本
node --version
# 需要 v22.19 或更高
# 清理重试
rm -rf node_modules dist
npm install
npm run build 如何使用多个 OpenClaw Gateway?
在 Weave 中添加多个 OpenClaw 联系人,每个联系人会生成不同的 WS ID。在每台 OpenClaw Gateway 机器上使用对应的 wsUrl 配置即可。
配置参考
| 配置项 | 必填 | 说明 |
|---|---|---|
wsUrl | 是 | Weave 中继 WebSocket 地址 |
apiKey | 否 | 认证密钥(如设置) |
reconnectDelay | 否 | 断线重连延迟(秒,默认 5) |
插件文件结构
weave-channel/
├── package.json # npm 包配置
├── plugin.yaml # OpenClaw 插件清单
├── tsconfig.json # TypeScript 配置
├── src/
│ └── index.ts # 插件主代码
└── dist/ # 编译产物(npm run build 后生成)
├── index.js
└── index.d.ts 协议说明
Weave 中继端点实现 OpenClaw Gateway WS 协议服务端,OpenClaw 渠道插件实现客户端。握手流程:
1. Weave -> 插件: connect.challenge(含 nonce)
2. 插件 -> Weave: connect(含 auth.token)
3. Weave -> 插件: hello-ok(握手成功)
4. 消息循环:
- Weave -> 插件: chat.send(用户消息)
- 插件 -> Weave: chat.delta(流式回复)
- 插件 -> Weave: assistant.completed(回复完成)
- 双向: ping/pong(心跳保活)