@core-workspace/infoflow-openclaw-plugin 2026.3.8 → 2026.3.27-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -0
- package/CLAUDE.md +135 -0
- package/COLLABORATION_REPORT.md +209 -0
- package/PROJECT_GUIDE.md +355 -0
- package/README.md +158 -66
- package/docs/dev-guide.md +63 -50
- package/docs/qa-feature-list.md +452 -0
- package/docs/webhook-guide.md +178 -0
- package/index.ts +28 -2
- package/openclaw.plugin.json +131 -21
- package/package.json +20 -3
- package/scripts/deploy.sh +66 -7
- package/scripts/postinstall.cjs +80 -0
- package/skills/infoflow-dev/SKILL.md +2 -2
- package/skills/infoflow-dev/references/api.md +1 -1
- package/src/adapter/inbound/webhook-parser.ts +27 -5
- package/src/adapter/inbound/ws-receiver.ts +304 -43
- package/src/adapter/outbound/markdown-local-images.ts +80 -0
- package/src/adapter/outbound/reply-dispatcher.ts +146 -65
- package/src/adapter/outbound/target-resolver.ts +4 -3
- package/src/channel/accounts.ts +97 -22
- package/src/channel/channel.ts +456 -12
- package/src/channel/media.ts +20 -6
- package/src/channel/monitor.ts +8 -3
- package/src/channel/outbound.ts +358 -21
- package/src/channel/streaming.ts +740 -0
- package/src/commands/changelog.ts +80 -0
- package/src/commands/doctor.ts +545 -0
- package/src/commands/logs.ts +449 -0
- package/src/commands/version.ts +20 -0
- package/src/compat/openclaw-sdk.ts +218 -0
- package/src/handler/message-handler.ts +673 -166
- package/src/logging.ts +1 -1
- package/src/runtime.ts +1 -1
- package/src/security/dm-policy.ts +1 -4
- package/src/security/group-policy.ts +174 -51
- package/src/tools/actions/index.ts +15 -13
- package/src/tools/cron/relay.ts +1154 -0
- package/src/tools/hooks/index.ts +13 -1
- package/src/tools/index.ts +714 -32
- package/src/types.ts +144 -25
- package/src/utils/audio/g722/dct_tables.ts +381 -0
- package/src/utils/audio/g722/decoder.ts +919 -0
- package/src/utils/audio/g722/defs.ts +105 -0
- package/src/utils/audio/g722/hd-parser.ts +247 -0
- package/src/utils/audio/g722/huff_tables.ts +240 -0
- package/src/utils/audio/g722/index.ts +78 -0
- package/src/utils/audio/g722/output_decoded.pcm +0 -0
- package/src/utils/audio/g722/output_decoded.wav +0 -0
- package/src/utils/audio/g722/tables.ts +173 -0
- package/src/utils/audio/g722/test_api.ts +31 -0
- package/src/utils/audio/g722/test_voice.hd +0 -0
- package/src/utils/bos/im-bos-client.ts +219 -0
- package/src/utils/group-agent-cache.ts +142 -0
- package/src/utils/token-adapter.ts +120 -51
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
- [配置](#配置)
|
|
15
15
|
- [插件架构](#插件架构)
|
|
16
16
|
- [开发指南](#开发指南)
|
|
17
|
+
- [内置命令](#内置命令)
|
|
17
18
|
- [扩展:Agent Tools](#扩展-agent-tools)
|
|
18
19
|
- [扩展:Agent Hooks](#扩展-agent-hooks)
|
|
19
20
|
- [扩展:Agent Skills](#扩展-agent-skills)
|
|
@@ -70,8 +71,8 @@ npm install
|
|
|
70
71
|
"channels": {
|
|
71
72
|
"infoflow": {
|
|
72
73
|
"connectionMode": "websocket",
|
|
73
|
-
"wsGateway": "infoflow-open-gateway.
|
|
74
|
-
"apiHost": "https://
|
|
74
|
+
"wsGateway": "infoflow-open-gateway.baidu.com",
|
|
75
|
+
"apiHost": "https://api.im.baidu.com",
|
|
75
76
|
"appKey": "填你的 appKey",
|
|
76
77
|
"appSecret": "填你的 appSecret",
|
|
77
78
|
"checkToken": "填你的 checkToken",
|
|
@@ -132,7 +133,7 @@ openclaw directory groups infoflow
|
|
|
132
133
|
{
|
|
133
134
|
channels: {
|
|
134
135
|
infoflow: {
|
|
135
|
-
apiHost: "https://
|
|
136
|
+
apiHost: "https://api.im.baidu.com",
|
|
136
137
|
checkToken: "your-check-token",
|
|
137
138
|
encodingAESKey: "your-encoding-aes-key",
|
|
138
139
|
appKey: "your-app-key",
|
|
@@ -150,9 +151,9 @@ openclaw directory groups infoflow
|
|
|
150
151
|
infoflow: {
|
|
151
152
|
// ── 基础连接 ──────────────────────────────────────────
|
|
152
153
|
enabled: true,
|
|
153
|
-
apiHost: "https://
|
|
154
|
+
apiHost: "https://api.im.baidu.com", // 如流 API 地址(必填)
|
|
154
155
|
connectionMode: "websocket", // "webhook"(默认)或 "websocket"
|
|
155
|
-
wsGateway: "infoflow-open-gateway.
|
|
156
|
+
wsGateway: "infoflow-open-gateway.baidu.com", // WebSocket 网关(websocket 模式专用)
|
|
156
157
|
checkToken: "your-check-token", // 消息验签 Token(必填)
|
|
157
158
|
encodingAESKey: "your-encoding-aes-key", // 消息 AES 加密密钥(必填)
|
|
158
159
|
appKey: "your-app-key", // 应用 Key(必填)
|
|
@@ -190,8 +191,13 @@ openclaw directory groups infoflow
|
|
|
190
191
|
groups: {
|
|
191
192
|
"12345678": {
|
|
192
193
|
replyMode: "proactive",
|
|
194
|
+
groupSessionMode: "user", // 此群按群+人拆分会话
|
|
193
195
|
systemPrompt: "你是该群的专属助手,回答要简洁。",
|
|
194
196
|
},
|
|
197
|
+
"87654321": {
|
|
198
|
+
replyMode: "record", // 此群仅记录不回复
|
|
199
|
+
groupSessionMode: "group", // 此群按群拆分会话
|
|
200
|
+
},
|
|
195
201
|
},
|
|
196
202
|
},
|
|
197
203
|
},
|
|
@@ -220,7 +226,7 @@ https://your-domain/webhook/infoflow
|
|
|
220
226
|
channels: {
|
|
221
227
|
infoflow: {
|
|
222
228
|
connectionMode: "websocket",
|
|
223
|
-
// wsGateway: "infoflow-open-gateway.
|
|
229
|
+
// wsGateway: "infoflow-open-gateway.baidu.com", // 可选,默认值
|
|
224
230
|
},
|
|
225
231
|
},
|
|
226
232
|
}
|
|
@@ -234,15 +240,15 @@ https://your-domain/webhook/infoflow
|
|
|
234
240
|
|
|
235
241
|
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|
|
236
242
|
|------|------|:----:|--------|------|
|
|
237
|
-
| `apiHost` | `string` | ✅ | — | 如流 API 地址,例如 `https://
|
|
238
|
-
| `checkToken` | `string` |
|
|
239
|
-
| `encodingAESKey` | `string` |
|
|
243
|
+
| `apiHost` | `string` | ✅ | — | 如流 API 地址,例如 `https://api.im.baidu.com` |
|
|
244
|
+
| `checkToken` | `string` | — | — | 消息验签 Token,从如流企业后台获取(**webhook 模式必填**)|
|
|
245
|
+
| `encodingAESKey` | `string` | — | — | 消息 AES 加密密钥,从如流企业后台获取(**webhook 模式必填**)|
|
|
240
246
|
| `appKey` | `string` | ✅ | — | 应用 Key,从如流企业后台获取 |
|
|
241
247
|
| `appSecret` | `string` | ✅ | — | 应用 Secret,从如流企业后台获取 |
|
|
242
248
|
| `appAgentId` | `number` | — | — | 企业后台"应用ID"(数字),私聊消息撤回需要此字段 |
|
|
243
|
-
| `robotName` | `string` | — | — | 机器人在群里的显示名称,用于检测消息中的 @
|
|
249
|
+
| `robotName` | `string` | — | — | 机器人在群里的显示名称,用于检测消息中的 @ 提及。**未配置时无法识别 @机器人,`mention-only` / `mention-and-watch` 模式将退化为对所有群消息触发** |
|
|
244
250
|
| `connectionMode` | `string` | — | `"webhook"` | 消息接收方式:`"webhook"` 如流主动推送;`"websocket"` 插件主动长连接 |
|
|
245
|
-
| `wsGateway` | `string` | — | `"infoflow-open-gateway.
|
|
251
|
+
| `wsGateway` | `string` | — | `"infoflow-open-gateway.baidu.com"` | WebSocket 网关域名,仅 `websocket` 模式使用 |
|
|
246
252
|
| `enabled` | `boolean` | — | `true` | 是否启用该插件 |
|
|
247
253
|
|
|
248
254
|
#### 访问控制
|
|
@@ -260,6 +266,7 @@ https://your-domain/webhook/infoflow
|
|
|
260
266
|
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|
|
261
267
|
|------|------|:----:|--------|------|
|
|
262
268
|
| `replyMode` | `string` | — | `"mention-and-watch"` | 群聊回复策略:`ignore`(丢弃)/ `record`(仅记录)/ `mention-only`(仅被@时)/ `mention-and-watch`(被@或关注人被@时)/ `proactive`(主动参与) |
|
|
269
|
+
| `groupSessionMode` | `string` | — | `"group"` | 群聊会话拆分模式:`"group"` = 按群拆分;`"user"` = 按群+人拆分 |
|
|
263
270
|
| `followUp` | `boolean` | — | `true` | 机器人回复后,时间窗口内自动识别追问,无需再次 @ |
|
|
264
271
|
| `followUpWindow` | `number` | — | `300` | 跟进时间窗口(秒) |
|
|
265
272
|
| `watchMentions` | `string[]` | — | `[]` | 监控指定人员被 @,机器人作为其助手代为判断是否回答,填写 uuapName |
|
|
@@ -271,6 +278,7 @@ https://your-domain/webhook/infoflow
|
|
|
271
278
|
|------|------|:----:|--------|------|
|
|
272
279
|
| `dmMessageFormat` | `string` | — | `"text"` | 私聊发出消息的格式:`"text"` 纯文本;`"markdown"` 富文本,支持标题/加粗/列表 |
|
|
273
280
|
| `groupMessageFormat` | `string` | — | `"text"` | 群聊发出消息的格式:`"text"` 纯文本;`"markdown"` 富文本。**注意:`markdown` 格式不支持引用回复** |
|
|
281
|
+
| `textChunkLimit` | `number` | — | `1800` | 长消息自动分片的每片最大字符数,超出部分拆成多条消息发送 |
|
|
274
282
|
| `processingHint` | `boolean` | — | `true` | LLM 响应较慢时,提前发送"⏳ 处理中..."提示;出错时发"处理出错,请稍后重试" |
|
|
275
283
|
| `processingHintDelay` | `number` | — | `5` | 发送"⏳ 处理中..."前等待的秒数;LLM 在此时间内响应则不发;设为 `0` 立即发送 |
|
|
276
284
|
|
|
@@ -289,6 +297,7 @@ https://your-domain/webhook/infoflow
|
|
|
289
297
|
| 字段 | 类型 | 说明 |
|
|
290
298
|
|------|------|------|
|
|
291
299
|
| `replyMode` | `string` | 覆盖该群的回复策略 |
|
|
300
|
+
| `groupSessionMode` | `string` | 覆盖该群的会话拆分模式:`"group"` = 按群拆分;`"user"` = 按群+人拆分 |
|
|
292
301
|
| `watchMentions` | `string[]` | 覆盖该群监控的人员列表 |
|
|
293
302
|
| `watchRegex` | `string` | 覆盖该群的正则匹配规则 |
|
|
294
303
|
| `followUp` | `boolean` | 覆盖该群的跟进开关 |
|
|
@@ -307,55 +316,66 @@ https://your-domain/webhook/infoflow
|
|
|
307
316
|
|
|
308
317
|
| 模块 | 文件 | 功能 |
|
|
309
318
|
|------|------|------|
|
|
310
|
-
| **插件入口** | `index.ts` | 注册 Channel、Webhook 路由、Tools、Hooks |
|
|
311
|
-
| **Channel 定义** | `src/channel.ts` | 插件结构、生命周期、Actions |
|
|
312
|
-
| **消息接收(Webhook)** | `src/inbound/webhook-parser.ts` | Webhook 解析、解密、去重 |
|
|
313
|
-
| **消息接收(WebSocket)** | `src/inbound/ws-receiver.ts` | WebSocket 长连接 |
|
|
314
|
-
| **接入管理** | `src/
|
|
315
|
-
| **消息处理** | `src/
|
|
316
|
-
| **消息发送** | `src/outbound
|
|
317
|
-
| **回复分发** | `src/outbound/reply-dispatcher.ts` | @mentions 解析、分块、引用回复构造 |
|
|
318
|
-
| **图片处理** | `src/
|
|
319
|
-
| **Actions** | `src/
|
|
319
|
+
| **插件入口** | `index.ts` | 注册 Channel、Webhook 路由、Tools、Hooks、Commands |
|
|
320
|
+
| **Channel 定义** | `src/channel/channel.ts` | 插件结构、生命周期、Actions |
|
|
321
|
+
| **消息接收(Webhook)** | `src/adapter/inbound/webhook-parser.ts` | Webhook 解析、解密、去重 |
|
|
322
|
+
| **消息接收(WebSocket)** | `src/adapter/inbound/ws-receiver.ts` | WebSocket 长连接 |
|
|
323
|
+
| **接入管理** | `src/channel/monitor.ts` | Webhook/WebSocket 启动管理 |
|
|
324
|
+
| **消息处理** | `src/handler/message-handler.ts` | replyMode 决策、历史注入、LLM 调用 |
|
|
325
|
+
| **消息发送** | `src/channel/outbound.ts` | 私聊/群聊发送 API |
|
|
326
|
+
| **回复分发** | `src/adapter/outbound/reply-dispatcher.ts` | @mentions 解析、分块、引用回复构造 |
|
|
327
|
+
| **图片处理** | `src/channel/media.ts` | 图片下载、压缩、Base64(含 SSRF 防护) |
|
|
328
|
+
| **Actions** | `src/tools/actions/index.ts` | Channel Actions(send/delete,供 LLM 通过 Channel 调用) |
|
|
320
329
|
| **Agent Tools** | `src/tools/index.ts` | `infoflow_send` / `infoflow_recall`(LLM Function Calling) |
|
|
321
|
-
| **Agent Hooks** | `src/hooks/index.ts` | `before_agent_start` 钩子(如流平台背景知识注入) |
|
|
322
|
-
| **多账号** | `src/
|
|
323
|
-
| **SDK 适配** | `src/
|
|
324
|
-
| **消息存储** | `src/
|
|
330
|
+
| **Agent Hooks** | `src/tools/hooks/index.ts` | `before_agent_start` 钩子(如流平台背景知识注入) |
|
|
331
|
+
| **多账号** | `src/channel/accounts.ts` | 账号解析、配置合并 |
|
|
332
|
+
| **SDK 适配** | `src/utils/token-adapter.ts` | Token 管理,封装 SDK TokenManager |
|
|
333
|
+
| **消息存储** | `src/utils/store/message-store.ts` | 已发送消息记录(支持撤回) |
|
|
334
|
+
| **安全策略** | `src/security/dm-policy.ts` | 私聊权限策略 |
|
|
335
|
+
| **群聊策略** | `src/security/group-policy.ts` | 群组权限、replyMode、followUp |
|
|
336
|
+
| **内置命令** | `src/commands/doctor.ts` | `/infoflow-doctor` 自检命令 |
|
|
337
|
+
| **内置命令** | `src/commands/logs.ts` | `/infoflow-logs` 日志查看命令 |
|
|
325
338
|
|
|
326
339
|
### 项目结构
|
|
327
340
|
|
|
328
341
|
```
|
|
329
|
-
|
|
330
|
-
├── index.ts
|
|
331
|
-
├── openclaw.plugin.json
|
|
332
|
-
├── skills/
|
|
333
|
-
│ └── infoflow-dev/
|
|
342
|
+
openclaw_infoflow/
|
|
343
|
+
├── index.ts # 插件入口
|
|
344
|
+
├── openclaw.plugin.json # 插件元数据
|
|
345
|
+
├── skills/
|
|
346
|
+
│ └── infoflow-dev/ # 如流开发者指南 skill
|
|
334
347
|
├── src/
|
|
335
|
-
│ ├──
|
|
336
|
-
│ ├──
|
|
337
|
-
│ ├──
|
|
338
|
-
│ ├──
|
|
339
|
-
│ ├──
|
|
340
|
-
│ │
|
|
341
|
-
│ ├──
|
|
342
|
-
│ │ ├──
|
|
343
|
-
│ │
|
|
344
|
-
│
|
|
345
|
-
│ │
|
|
346
|
-
│ ├──
|
|
347
|
-
│ │
|
|
348
|
-
│ │
|
|
349
|
-
│ │
|
|
350
|
-
│ │
|
|
351
|
-
│
|
|
352
|
-
│ │ └──
|
|
348
|
+
│ ├── types.ts # 类型定义
|
|
349
|
+
│ ├── runtime.ts # 插件运行时单例
|
|
350
|
+
│ ├── logging.ts # 日志模块
|
|
351
|
+
│ ├── channel/
|
|
352
|
+
│ │ ├── channel.ts # Channel 插件定义
|
|
353
|
+
│ │ ├── accounts.ts # 多账号解析
|
|
354
|
+
│ │ ├── monitor.ts # Webhook/WS 启动管理
|
|
355
|
+
│ │ ├── outbound.ts # 消息发送 API
|
|
356
|
+
│ │ └── media.ts # 图片处理
|
|
357
|
+
│ ├── adapter/
|
|
358
|
+
│ │ ├── inbound/
|
|
359
|
+
│ │ │ ├── webhook-parser.ts # Webhook 解析解密
|
|
360
|
+
│ │ │ └── ws-receiver.ts # WebSocket 长连接
|
|
361
|
+
│ │ └── outbound/
|
|
362
|
+
│ │ ├── reply-dispatcher.ts # 回复分发(分片/@mention/引用)
|
|
363
|
+
│ │ └── target-resolver.ts # 目标地址解析
|
|
364
|
+
│ ├── handler/
|
|
365
|
+
│ │ └── message-handler.ts # 消息处理核心(replyMode 决策)
|
|
366
|
+
│ ├── security/
|
|
367
|
+
│ │ ├── dm-policy.ts # 私聊权限策略
|
|
368
|
+
│ │ └── group-policy.ts # 群聊策略 + followUp
|
|
353
369
|
│ ├── tools/
|
|
354
|
-
│ │
|
|
355
|
-
│ ├──
|
|
356
|
-
│ │ └── index.ts
|
|
357
|
-
│
|
|
358
|
-
│
|
|
370
|
+
│ │ ├── index.ts # infoflow_send / infoflow_recall
|
|
371
|
+
│ │ ├── actions/index.ts # Channel Actions
|
|
372
|
+
│ │ └── hooks/index.ts # Agent Hooks
|
|
373
|
+
│ ├── commands/
|
|
374
|
+
│ │ ├── doctor.ts # /infoflow-doctor
|
|
375
|
+
│ │ └── logs.ts # /infoflow-logs
|
|
376
|
+
│ └── utils/
|
|
377
|
+
│ ├── token-adapter.ts # SDK Token 适配
|
|
378
|
+
│ └── store/message-store.ts # 已发消息存储
|
|
359
379
|
└── README.md
|
|
360
380
|
```
|
|
361
381
|
|
|
@@ -397,6 +417,46 @@ tail -200 ~/.openclaw/logs/gateway.log | grep "sendInfoflowMessage"
|
|
|
397
417
|
|
|
398
418
|
---
|
|
399
419
|
|
|
420
|
+
<a id="内置命令"></a>
|
|
421
|
+
|
|
422
|
+
## 内置命令
|
|
423
|
+
|
|
424
|
+
插件注册了两个可在如流中直接发送的内置命令。
|
|
425
|
+
|
|
426
|
+
### /infoflow-doctor — 自检
|
|
427
|
+
|
|
428
|
+
一键检查插件配置与 API 连通性,帮助排查收不到消息的问题。
|
|
429
|
+
|
|
430
|
+
**在如流私聊或群聊中发送:**
|
|
431
|
+
```
|
|
432
|
+
/infoflow-doctor
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**自检项:**
|
|
436
|
+
1. 账号配置完整性(appKey、appSecret、checkToken 等)
|
|
437
|
+
2. Access Token 获取(实际调用 Infoflow API)
|
|
438
|
+
3. 发私聊测试消息
|
|
439
|
+
4. 发群聊测试消息(仅在群中触发时执行)
|
|
440
|
+
5. 发图片测试消息
|
|
441
|
+
|
|
442
|
+
### /infoflow-logs — 日志查看
|
|
443
|
+
|
|
444
|
+
查看 Infoflow 最近的收发消息日志,方便排查消息丢失、发送失败等问题。
|
|
445
|
+
|
|
446
|
+
**用法:**
|
|
447
|
+
|
|
448
|
+
```
|
|
449
|
+
/infoflow-logs # 最近 50 条
|
|
450
|
+
/infoflow-logs 100 # 最近 100 条(最大 200)
|
|
451
|
+
/infoflow-logs 50-100 # 往前翻页:跳过最近 50 条,再往前看 50 条
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**日志来源:** `/tmp/openclaw/openclaw-YYYY-MM-DD.log`(优先今日,降级昨日)
|
|
455
|
+
|
|
456
|
+
**输出上限:** 20,000 字符,超出时自动丢弃最老的条目。长输出由框架自动拆成多条消息发送。
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
400
460
|
<a id="扩展-agent-tools"></a>
|
|
401
461
|
|
|
402
462
|
## 扩展:Agent Tools
|
|
@@ -559,8 +619,9 @@ description: Skill 描述,说明何时触发(这是触发机制,写清楚
|
|
|
559
619
|
```bash
|
|
560
620
|
tail -200 ~/.openclaw/logs/gateway.log | grep "webhook"
|
|
561
621
|
```
|
|
562
|
-
3. 检查 `robotName`
|
|
622
|
+
3. 检查 `robotName` 是否与如流后台机器人显示名一致(影响 @mention 检测)。**注意:不配置 `robotName` 时,`mention-only` / `mention-and-watch` 模式将退化为对所有群消息触发,而非完全不触发**
|
|
563
623
|
4. 检查 `groupPolicy` 是否允许该群
|
|
624
|
+
5. 在如流中发送 `/infoflow-doctor` 进行自检
|
|
564
625
|
|
|
565
626
|
### 3. 消息撤回失败?
|
|
566
627
|
|
|
@@ -596,6 +657,7 @@ Baidu Infoflow enterprise messaging platform — OpenClaw channel plugin. Suppor
|
|
|
596
657
|
- [Configuration](#configuration)
|
|
597
658
|
- [Architecture](#architecture)
|
|
598
659
|
- [Development Guide](#development-guide)
|
|
660
|
+
- [Built-in Commands](#built-in-commands)
|
|
599
661
|
- [Extending: Agent Tools](#extending-agent-tools)
|
|
600
662
|
- [Extending: Agent Hooks](#extending-agent-hooks)
|
|
601
663
|
- [Extending: Agent Skills](#extending-agent-skills)
|
|
@@ -651,8 +713,8 @@ Open `~/.openclaw/openclaw.json` and add the infoflow channel config:
|
|
|
651
713
|
"channels": {
|
|
652
714
|
"infoflow": {
|
|
653
715
|
"connectionMode": "websocket",
|
|
654
|
-
"wsGateway": "infoflow-open-gateway.
|
|
655
|
-
"apiHost": "https://
|
|
716
|
+
"wsGateway": "infoflow-open-gateway.baidu.com",
|
|
717
|
+
"apiHost": "https://api.im.baidu.com",
|
|
656
718
|
"appKey": "your-app-key",
|
|
657
719
|
"appSecret": "your-app-secret",
|
|
658
720
|
"checkToken": "your-check-token",
|
|
@@ -688,7 +750,7 @@ For more options (access control, group policies, message format, etc.) see [Con
|
|
|
688
750
|
{
|
|
689
751
|
channels: {
|
|
690
752
|
infoflow: {
|
|
691
|
-
apiHost: "https://
|
|
753
|
+
apiHost: "https://api.im.baidu.com",
|
|
692
754
|
checkToken: "your-check-token",
|
|
693
755
|
encodingAESKey: "your-encoding-aes-key",
|
|
694
756
|
appKey: "your-app-key",
|
|
@@ -706,9 +768,9 @@ For more options (access control, group policies, message format, etc.) see [Con
|
|
|
706
768
|
infoflow: {
|
|
707
769
|
// ── Connection ────────────────────────────────────────
|
|
708
770
|
enabled: true,
|
|
709
|
-
apiHost: "https://
|
|
771
|
+
apiHost: "https://api.im.baidu.com", // required
|
|
710
772
|
connectionMode: "websocket", // "webhook" (default) or "websocket"
|
|
711
|
-
wsGateway: "infoflow-open-gateway.
|
|
773
|
+
wsGateway: "infoflow-open-gateway.baidu.com", // websocket mode only
|
|
712
774
|
checkToken: "your-check-token", // required
|
|
713
775
|
encodingAESKey: "your-encoding-aes-key", // required
|
|
714
776
|
appKey: "your-app-key", // required
|
|
@@ -772,7 +834,7 @@ https://your-domain/webhook/infoflow
|
|
|
772
834
|
channels: {
|
|
773
835
|
infoflow: {
|
|
774
836
|
connectionMode: "websocket",
|
|
775
|
-
// wsGateway: "infoflow-open-gateway.
|
|
837
|
+
// wsGateway: "infoflow-open-gateway.baidu.com", // optional
|
|
776
838
|
},
|
|
777
839
|
},
|
|
778
840
|
}
|
|
@@ -784,15 +846,15 @@ https://your-domain/webhook/infoflow
|
|
|
784
846
|
|
|
785
847
|
| Field | Type | Required | Default | Description |
|
|
786
848
|
|-------|------|:--------:|---------|-------------|
|
|
787
|
-
| `apiHost` | `string` | ✅ | — | Infoflow API host, e.g. `https://
|
|
788
|
-
| `checkToken` | `string` |
|
|
789
|
-
| `encodingAESKey` | `string` |
|
|
849
|
+
| `apiHost` | `string` | ✅ | — | Infoflow API host, e.g. `https://api.im.baidu.com` |
|
|
850
|
+
| `checkToken` | `string` | — | — | Message verification token from Infoflow enterprise console (**required for webhook mode**) |
|
|
851
|
+
| `encodingAESKey` | `string` | — | — | AES encryption key from Infoflow enterprise console (**required for webhook mode**) |
|
|
790
852
|
| `appKey` | `string` | ✅ | — | App Key from Infoflow enterprise console |
|
|
791
853
|
| `appSecret` | `string` | ✅ | — | App Secret from Infoflow enterprise console |
|
|
792
854
|
| `appAgentId` | `number` | — | — | App Agent ID (numeric); required for private message recall |
|
|
793
|
-
| `robotName` | `string` | — | — | Bot display name in groups, used for @mention detection |
|
|
855
|
+
| `robotName` | `string` | — | — | Bot display name in groups, used for @mention detection. **Without this, `mention-only` / `mention-and-watch` modes fall back to triggering on every message** |
|
|
794
856
|
| `connectionMode` | `string` | — | `"webhook"` | `"webhook"` (Infoflow pushes to your server) or `"websocket"` (plugin connects to Infoflow) |
|
|
795
|
-
| `wsGateway` | `string` | — | `"infoflow-open-gateway.
|
|
857
|
+
| `wsGateway` | `string` | — | `"infoflow-open-gateway.baidu.com"` | WebSocket gateway hostname, only used in `websocket` mode |
|
|
796
858
|
| `enabled` | `boolean` | — | `true` | Whether to enable the plugin |
|
|
797
859
|
|
|
798
860
|
#### Access Control
|
|
@@ -821,6 +883,7 @@ https://your-domain/webhook/infoflow
|
|
|
821
883
|
|-------|------|:--------:|---------|-------------|
|
|
822
884
|
| `dmMessageFormat` | `string` | — | `"text"` | Format for private (DM) messages: `"text"` (plain) or `"markdown"` (rich text) |
|
|
823
885
|
| `groupMessageFormat` | `string` | — | `"text"` | Format for group messages: `"text"` (plain) or `"markdown"` (rich text). **Note: `markdown` does not support quote replies** |
|
|
886
|
+
| `textChunkLimit` | `number` | — | `1800` | Max characters per outbound message chunk; long messages are split into multiple messages |
|
|
824
887
|
| `processingHint` | `boolean` | — | `true` | Send "⏳ processing..." hint when LLM is slow; send error message on failure |
|
|
825
888
|
| `processingHintDelay` | `number` | — | `5` | Seconds to wait before sending the hint; set to `0` to send immediately |
|
|
826
889
|
|
|
@@ -878,6 +941,34 @@ tail -f ~/.openclaw/logs/gateway.log | grep -i infoflow
|
|
|
878
941
|
|
|
879
942
|
---
|
|
880
943
|
|
|
944
|
+
<a id="built-in-commands"></a>
|
|
945
|
+
|
|
946
|
+
## Built-in Commands
|
|
947
|
+
|
|
948
|
+
### /infoflow-doctor — Self-check
|
|
949
|
+
|
|
950
|
+
Diagnose configuration and API connectivity issues.
|
|
951
|
+
|
|
952
|
+
```
|
|
953
|
+
/infoflow-doctor
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
Checks: account config completeness, access token fetch, DM send test, group send test, image send test.
|
|
957
|
+
|
|
958
|
+
### /infoflow-logs — Log viewer
|
|
959
|
+
|
|
960
|
+
View recent Infoflow send/receive logs.
|
|
961
|
+
|
|
962
|
+
```
|
|
963
|
+
/infoflow-logs # last 50 entries
|
|
964
|
+
/infoflow-logs 100 # last 100 entries (max 200)
|
|
965
|
+
/infoflow-logs 50-100 # page back: skip last 50, show previous 50
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
Log source: `/tmp/openclaw/openclaw-YYYY-MM-DD.log`. Total output capped at 20,000 characters.
|
|
969
|
+
|
|
970
|
+
---
|
|
971
|
+
|
|
881
972
|
<a id="extending-agent-tools"></a>
|
|
882
973
|
|
|
883
974
|
## Extending: Agent Tools
|
|
@@ -965,8 +1056,9 @@ Declare the skill path in `openclaw.plugin.json`:
|
|
|
965
1056
|
|
|
966
1057
|
1. Check `replyMode` — confirm the group is allowed to trigger
|
|
967
1058
|
2. Check logs for incoming webhook requests
|
|
968
|
-
3. Verify `robotName` matches the bot's display name (affects @ detection)
|
|
1059
|
+
3. Verify `robotName` matches the bot's display name in Infoflow (affects @mention detection). **Note: without `robotName`, `mention-only` / `mention-and-watch` modes fall back to triggering on every message**
|
|
969
1060
|
4. Check `groupPolicy` allows the group
|
|
1061
|
+
5. Send `/infoflow-doctor` in Infoflow to run self-checks
|
|
970
1062
|
|
|
971
1063
|
### Message recall failing?
|
|
972
1064
|
|
package/docs/dev-guide.md
CHANGED
|
@@ -150,22 +150,22 @@ message-store 清理已撤回记录
|
|
|
150
150
|
|
|
151
151
|
配置路径:`channels.infoflow` 或 `channels.infoflow.accounts.<id>`
|
|
152
152
|
|
|
153
|
-
### 4.1
|
|
153
|
+
### 4.1 基础鉴权参数
|
|
154
154
|
|
|
155
|
-
| 参数 | 类型 | 说明 |
|
|
156
|
-
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `apiHost` | string | 如流 API 域名,默认 `https://im.baidu.com` |
|
|
155
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
156
|
+
|------|------|------|------|
|
|
157
|
+
| `appKey` | string | 是 | 应用 AppKey |
|
|
158
|
+
| `appSecret` | string | 是 | 应用 AppSecret |
|
|
159
|
+
| `checkToken` | string | webhook 模式必填 | Webhook 验证 Token(如流企业后台配置) |
|
|
160
|
+
| `encodingAESKey` | string | webhook 模式必填 | 消息加密 AES Key(43 位 Base64) |
|
|
161
|
+
| `apiHost` | string | 否 | 如流 API 域名,默认 `https://api.im.baidu.com` |
|
|
162
162
|
|
|
163
163
|
### 4.2 连接方式
|
|
164
164
|
|
|
165
165
|
| 参数 | 类型 | 默认 | 说明 |
|
|
166
166
|
|------|------|------|------|
|
|
167
|
-
| `connectionMode` | `"webhook"` \| `"websocket"` | `"
|
|
168
|
-
| `wsGateway` | string | - | WebSocket Gateway 域名(仅 websocket
|
|
167
|
+
| `connectionMode` | `"webhook"` \| `"websocket"` | `"websocket"` | 接入方式;websocket 只需 appKey+appSecret,推荐默认使用 |
|
|
168
|
+
| `wsGateway` | string | - | WebSocket Gateway 域名(仅 websocket 模式,通常不需配置) |
|
|
169
169
|
|
|
170
170
|
### 4.3 私聊策略(dmPolicy)
|
|
171
171
|
|
|
@@ -175,13 +175,9 @@ message-store 清理已撤回记录
|
|
|
175
175
|
| `"pairing"` | 配对模式,由框架处理(插件仅记录日志) |
|
|
176
176
|
| `"allowlist"` | 仅 `allowFrom` 列表内的 uuapName 可触发 |
|
|
177
177
|
|
|
178
|
-
```
|
|
179
|
-
channels
|
|
180
|
-
|
|
181
|
-
dmPolicy: allowlist
|
|
182
|
-
allowFrom:
|
|
183
|
-
- zhangsan
|
|
184
|
-
- lisi
|
|
178
|
+
```bash
|
|
179
|
+
openclaw config set channels.infoflow.dmPolicy "allowlist"
|
|
180
|
+
openclaw config set channels.infoflow.allowFrom '["zhangsan","lisi"]'
|
|
185
181
|
```
|
|
186
182
|
|
|
187
183
|
### 4.4 群聊策略(groupPolicy)
|
|
@@ -192,13 +188,9 @@ channels:
|
|
|
192
188
|
| `"disabled"` | 所有群消息忽略 |
|
|
193
189
|
| `"allowlist"` | 仅 `groupAllowFrom` 内的 groupId 可触发 |
|
|
194
190
|
|
|
195
|
-
```
|
|
196
|
-
channels
|
|
197
|
-
|
|
198
|
-
groupPolicy: allowlist
|
|
199
|
-
groupAllowFrom:
|
|
200
|
-
- "12345678"
|
|
201
|
-
- "87654321"
|
|
191
|
+
```bash
|
|
192
|
+
openclaw config set channels.infoflow.groupPolicy "allowlist"
|
|
193
|
+
openclaw config set channels.infoflow.groupAllowFrom '["12345678","87654321"]'
|
|
202
194
|
```
|
|
203
195
|
|
|
204
196
|
### 4.5 群聊触发模式(replyMode)
|
|
@@ -213,33 +205,43 @@ channels:
|
|
|
213
205
|
|
|
214
206
|
可在 account 级别配置,也可在 `groups.<groupId>` 级别覆盖:
|
|
215
207
|
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
208
|
+
```bash
|
|
209
|
+
# account 级别
|
|
210
|
+
openclaw config set channels.infoflow.replyMode "mention-only"
|
|
211
|
+
openclaw config set channels.infoflow.followUp true
|
|
212
|
+
openclaw config set channels.infoflow.followUpWindow 300
|
|
213
|
+
openclaw config set channels.infoflow.watchMentions '["xuejian","zhangsan"]'
|
|
214
|
+
openclaw config set channels.infoflow.watchRegex "上线|发布|故障"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
per-group 配置需直接编辑 `~/.openclaw/openclaw.json`(`openclaw config file` 查看路径):
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{
|
|
221
|
+
"channels": {
|
|
222
|
+
"infoflow": {
|
|
223
|
+
"groups": {
|
|
224
|
+
"12345678": {
|
|
225
|
+
"replyMode": "proactive",
|
|
226
|
+
"systemPrompt": "你是该群的专属助手,聚焦代码 review 相关问题"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
231
232
|
```
|
|
232
233
|
|
|
233
234
|
### 4.6 其他配置
|
|
234
235
|
|
|
235
236
|
| 参数 | 类型 | 默认 | 说明 |
|
|
236
237
|
|------|------|------|------|
|
|
237
|
-
| `robotName` | string | - |
|
|
238
|
+
| `robotName` | string | - | 机器人名称(可选,@mention 检测已不依赖此字段) |
|
|
238
239
|
| `processingHint` | boolean | `true` | LLM 超时后发送 "⏳ 处理中..." 提示 |
|
|
239
240
|
| `processingHintDelay` | number | `5` | 提示延迟秒数 |
|
|
240
|
-
| `dmMessageFormat` | `"text"` \| `"markdown"` | `"
|
|
241
|
-
| `groupMessageFormat` | `"text"` \| `"markdown"` | `"
|
|
241
|
+
| `dmMessageFormat` | `"text"` \| `"markdown"` | `"markdown"` | 私聊消息格式 |
|
|
242
|
+
| `groupMessageFormat` | `"text"` \| `"markdown"` | `"markdown"` | 群聊消息格式(markdown 不支持 reply-to) |
|
|
242
243
|
| `appAgentId` | number | - | 应用 AgentId(私聊消息撤回依赖此字段) |
|
|
244
|
+
| `textChunkLimit` | number | `1800` | 每条消息最大字符数,超长自动分片 |
|
|
243
245
|
|
|
244
246
|
---
|
|
245
247
|
|
|
@@ -507,17 +509,18 @@ vi.mock("../../src/channel/outbound.js", () => ({
|
|
|
507
509
|
# 1. 安装依赖
|
|
508
510
|
npm install
|
|
509
511
|
|
|
510
|
-
# 2.
|
|
511
|
-
|
|
512
|
-
--exclude node_modules --exclude dist --exclude .git
|
|
512
|
+
# 2. 部署到 openclaw(rsync + 重启 gateway,一键完成)
|
|
513
|
+
./scripts/deploy.sh
|
|
513
514
|
|
|
514
|
-
# 3.
|
|
515
|
-
|
|
515
|
+
# 3. 查看实时日志
|
|
516
|
+
tail -f /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log
|
|
516
517
|
|
|
517
|
-
# 4.
|
|
518
|
-
|
|
518
|
+
# 4. 如只需重启 gateway(不重新同步文件)
|
|
519
|
+
openclaw gateway restart
|
|
519
520
|
```
|
|
520
521
|
|
|
522
|
+
> `deploy.sh` 内部会 rsync 到 `~/.openclaw/extensions/infoflow-openclaw-plugin/` 并自动重启 gateway。
|
|
523
|
+
|
|
521
524
|
### 10.2 静态检查
|
|
522
525
|
|
|
523
526
|
项目无 `tsc` 可执行文件,使用 Python 脚本验证 import 路径:
|
|
@@ -601,7 +604,17 @@ import { sendInfoflowMessage } from "../channel/outbound";
|
|
|
601
604
|
|
|
602
605
|
### 11.6 WebSocket 模式
|
|
603
606
|
|
|
604
|
-
|
|
607
|
+
WebSocket 是推荐的接入方式,只需配置 `appKey` 和 `appSecret`,无需 Token 和 AESKey:
|
|
608
|
+
|
|
609
|
+
```bash
|
|
610
|
+
openclaw config set channels.infoflow.connectionMode "websocket"
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
WebSocket 模式由 `adapter/inbound/ws-receiver.ts` 处理,SDK 通过 `eventtype` 字段区分消息类型:
|
|
614
|
+
- `MESSAGE_RECEIVE`:@机器人 的消息(`wasMentioned = true`)
|
|
615
|
+
- `ALL_MESSAGE_FORWARD`:群内全量消息(需在如流后台开启全量订阅)
|
|
616
|
+
|
|
617
|
+
两种模式共享 `webhook-parser.ts` 的消息分发和 dedup 逻辑。
|
|
605
618
|
|
|
606
619
|
### 11.7 新增配置字段
|
|
607
620
|
|