@searchfe/openclaw-baiduapp 0.1.9-beta.2 → 0.1.9
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/README.md +30 -19
- package/dist/index.js +23514 -867
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,23 +13,23 @@
|
|
|
13
13
|
| 入站文件下载与本地注入 | ✅ |
|
|
14
14
|
| 出站本地文件上传后发送 | ✅ |
|
|
15
15
|
|
|
16
|
-
>
|
|
16
|
+
> 百度文件消息当前仍挂在文本消息契约下:入站 payload 继续使用 `msgtype: "text"`,并在同层增加可选 `files` 数组;出站发送也继续走 JSON 文本消息协议,只是在顶层带 `files:[{url,fileType}]`,不会切到 `multipart/form-data` 消息发送接口。
|
|
17
17
|
|
|
18
18
|
## 当前实现行为
|
|
19
19
|
|
|
20
20
|
### 入站消息
|
|
21
21
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
22
|
+
- 纯文本消息照常进入 Agent。
|
|
23
|
+
- 携带附件时,百度回调仍是 `msgtype: "text"`,附件放在同层 `files` 字段,结构为 `files:[{url,fileType}]`。
|
|
24
|
+
- 当前已支持 **files-only** 和 **text+files** 两种入站形态;也就是 `text.content` 与 `files` 至少其一存在即可进入处理链。
|
|
25
25
|
- 插件会下载可访问的入站文件到本机临时目录 `openclaw-baiduapp/media`,并把成功下载的本地路径注入给 Agent。
|
|
26
26
|
- Agent 侧正文会保留原始文本,并在 `[local files]` 前追加 `[files]` 摘要行;其中 `[local files]` 只列出成功下载到本地的文件路径。单文件场景还会补充文件名和大小,下载失败时会追加明确的 failure placeholder,但不会伪造本地路径。
|
|
27
27
|
|
|
28
28
|
### 出站消息
|
|
29
29
|
|
|
30
|
-
-
|
|
30
|
+
- 纯文本仍通过百度文本发送接口下发。
|
|
31
31
|
- 文件出站要求传入**本地文件路径**(如 `/tmp/report.pdf` 或 `file:///tmp/report.pdf`)。
|
|
32
|
-
-
|
|
32
|
+
- 插件会先向 `POST {apiBase}/file/sts?ak={account.appKey}&token={generatedToken}` 申请 SKS 凭证,再上传到固定 BOS 端点 `https://aisearch.bj.bcebos.com`,最后以顶层 `files:[{url,fileType}]` 的文本消息发送给百度。
|
|
33
33
|
- `fileType` 优先使用显式 MIME;未指定时按本地文件扩展名推断,未知类型回退 `application/octet-stream`。
|
|
34
34
|
|
|
35
35
|
### 临时文件与清理
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
|
|
41
41
|
## 已知限制
|
|
42
42
|
|
|
43
|
+
- 百度文件消息仍归属 `msgtype: "text"`,当前**没有**单独的 `msgtype: "file"` 协议分支。
|
|
43
44
|
- 出站文件发送只接受本地文件路径;远程 URL 不会被当作可发送附件直接透传。
|
|
44
|
-
-
|
|
45
|
+
- 发送消息接口仍是 JSON 请求体,当前**没有** `multipart/form-data` 消息发送实现。
|
|
45
46
|
- 只有成功下载到本地的入站文件才会出现在 Agent 的 `[local files]` 文本块与 `MediaPath/MediaPaths` 上下文里;下载失败的附件会在 agent 正文里留下 failure placeholder,但不会伪造本地路径。
|
|
46
47
|
- 本地 mock smoke 中,出站文件 happy/failure 闭环通过 `scripts/mock-server.ts` 的 `/simulate-file-flow` helper 验证,真实运行时代码本身由单元测试覆盖。
|
|
47
48
|
|
|
@@ -65,12 +66,16 @@ openclaw plugins install @searchfe/openclaw-baiduapp
|
|
|
65
66
|
|
|
66
67
|
- **App Key**:应用标识
|
|
67
68
|
- **App Secret**:应用密钥
|
|
69
|
+
- **Token**:消息校验 Token
|
|
70
|
+
- **EncodingAESKey**:消息加密密钥(43 位字符)
|
|
68
71
|
|
|
69
72
|
## 步骤三:配置 OpenClaw
|
|
70
73
|
|
|
71
74
|
### 使用命令行配置
|
|
72
75
|
|
|
73
76
|
```bash
|
|
77
|
+
openclaw config set channels.openclaw-baiduapp.token your-token
|
|
78
|
+
openclaw config set channels.openclaw-baiduapp.encodingAESKey your-43-char-encoding-aes-key
|
|
74
79
|
openclaw config set channels.openclaw-baiduapp.appKey your-app-key
|
|
75
80
|
openclaw config set channels.openclaw-baiduapp.appSecret your-app-secret
|
|
76
81
|
```
|
|
@@ -83,6 +88,8 @@ openclaw config set channels.openclaw-baiduapp.appSecret your-app-secret
|
|
|
83
88
|
{
|
|
84
89
|
"channels": {
|
|
85
90
|
"openclaw-baiduapp": {
|
|
91
|
+
"token": "your-token",
|
|
92
|
+
"encodingAESKey": "your-43-char-encoding-aes-key",
|
|
86
93
|
"appKey": "your-app-key",
|
|
87
94
|
"appSecret": "your-app-secret"
|
|
88
95
|
}
|
|
@@ -92,21 +99,25 @@ openclaw config set channels.openclaw-baiduapp.appSecret your-app-secret
|
|
|
92
99
|
|
|
93
100
|
### 配置说明
|
|
94
101
|
|
|
95
|
-
| 字段
|
|
96
|
-
|
|
|
97
|
-
| `enabled`
|
|
98
|
-
| `webhookPath`
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
102
|
+
| 字段 | 必填 | 说明 |
|
|
103
|
+
| :--------------- | :--: | :------------------------------ |
|
|
104
|
+
| `enabled` | ✅ | 是否启用该渠道 |
|
|
105
|
+
| `webhookPath` | ✅ | 回调路径,需与百度平台配置一致 |
|
|
106
|
+
| `token` | ✅ | 消息校验 Token |
|
|
107
|
+
| `encodingAESKey` | ✅ | 消息加密密钥(43 位) |
|
|
108
|
+
| `appKey` | ✅ | 应用 App Key(主动发送必需) |
|
|
109
|
+
| `appSecret` | ✅ | 应用 App Secret(主动发送必需) |
|
|
101
110
|
|
|
102
111
|
### 环境变量支持
|
|
103
112
|
|
|
104
113
|
默认账户的凭证也可以通过环境变量设置:
|
|
105
114
|
|
|
106
|
-
| 环境变量
|
|
107
|
-
|
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
115
|
+
| 环境变量 | 对应配置 |
|
|
116
|
+
| :--------------------------- | :--------------- |
|
|
117
|
+
| `BAIDU_APP_TOKEN` | `token` |
|
|
118
|
+
| `BAIDU_APP_ENCODING_AES_KEY` | `encodingAESKey` |
|
|
119
|
+
| `BAIDU_APP_KEY` | `appKey` |
|
|
120
|
+
| `BAIDU_APP_SECRET` | `appSecret` |
|
|
110
121
|
|
|
111
122
|
## 步骤四:重启 Gateway
|
|
112
123
|
|
|
@@ -117,7 +128,7 @@ openclaw gateway restart
|
|
|
117
128
|
## 步骤五:验证配置
|
|
118
129
|
|
|
119
130
|
1. 在百度平台配置 Webhook 回调地址,指向你的 OpenClaw Gateway
|
|
120
|
-
2.
|
|
131
|
+
2. 平台验证通过后,先发送一条测试文本消息,再发送一条带 `files` 的文本消息
|
|
121
132
|
3. 查看 OpenClaw 日志,确认 webhook 接收生效;如果是文件消息,还要确认插件完成本地下载并把 `[local files]` / `MediaPaths` 注入给 Agent
|
|
122
133
|
|
|
123
134
|
## 常见问题
|
|
@@ -126,7 +137,7 @@ openclaw gateway restart
|
|
|
126
137
|
|
|
127
138
|
1. 检查 OpenClaw 是否已启动并监听正确端口
|
|
128
139
|
2. 确认 `webhookPath` 与平台 URL 路径一致
|
|
129
|
-
3. 确认 `
|
|
140
|
+
3. 确认 `token` 和 `encodingAESKey` 与平台配置完全一致
|
|
130
141
|
4. 确认服务器公网可访问
|
|
131
142
|
|
|
132
143
|
### Q: 消息接收成功但发送失败?
|