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