@searchfe/openclaw-baiduapp 0.1.6 → 0.1.7-beta.10

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 CHANGED
@@ -4,14 +4,47 @@
4
4
 
5
5
  ## 功能概览
6
6
 
7
- | 功能 | 状态 |
8
- | :----------- | :--: |
9
- | 文本消息 | ✅ |
10
- | 主动发送消息 | ✅ |
11
- | 私聊 | ✅ |
12
- | Webhook 回调 | ✅ |
7
+ | 功能 | 状态 |
8
+ | :----------------------- | :--: |
9
+ | 文本消息 | ✅ |
10
+ | 主动发送消息 | ✅ |
11
+ | 私聊 | ✅ |
12
+ | Webhook 回调 | ✅ |
13
+ | 入站文件下载与本地注入 | ✅ |
14
+ | 出站本地文件上传后发送 | ✅ |
13
15
 
14
- > 更多消息类型支持敬请期待。
16
+ > 百度文件消息当前仍挂在文本消息契约下:入站 payload 继续使用 `msgtype: "text"`,并在同层增加可选 `files` 数组;出站发送也继续走 JSON 文本消息协议,只是在顶层带 `files:[{url,fileType}]`,不会切到 `multipart/form-data` 消息发送接口。
17
+
18
+ ## 当前实现行为
19
+
20
+ ### 入站消息
21
+
22
+ - 纯文本消息照常进入 Agent。
23
+ - 携带附件时,百度回调仍是 `msgtype: "text"`,附件放在同层 `files` 字段,结构为 `files:[{url,fileType}]`。
24
+ - 当前已支持 **files-only** 和 **text+files** 两种入站形态;也就是 `text.content` 与 `files` 至少其一存在即可进入处理链。
25
+ - 插件会下载可访问的入站文件到本机临时目录 `openclaw-baiduapp/media`,并把成功下载的本地路径注入给 Agent。
26
+ - Agent 侧正文会保留原始文本,并在 `[local files]` 前追加 `[files]` 摘要行;其中 `[local files]` 只列出成功下载到本地的文件路径。单文件场景还会补充文件名和大小,下载失败时会追加明确的 failure placeholder,但不会伪造本地路径。
27
+
28
+ ### 出站消息
29
+
30
+ - 纯文本仍通过百度文本发送接口下发。
31
+ - 文件出站要求传入**本地文件路径**(如 `/tmp/report.pdf` 或 `file:///tmp/report.pdf`)。
32
+ - 插件会先向 `POST {apiBase}/file/sts?ak={account.appKey}&token={generatedToken}` 申请 SKS 凭证,再上传到固定 BOS 端点 `https://aisearch.bj.bcebos.com`,最后以顶层 `files:[{url,fileType}]` 的文本消息发送给百度。
33
+ - `fileType` 优先使用显式 MIME;未指定时按本地文件扩展名推断,未知类型回退 `application/octet-stream`。
34
+
35
+ ### 临时文件与清理
36
+
37
+ - 入站文件保留期固定为 **7 天**。
38
+ - 清理逻辑只遍历插件自有目录 `openclaw-baiduapp/media`,不会扫描或删除其他 tmp 路径内容。
39
+ - 清理在两个惰性时机触发:插件启动注册 webhook 后、以及每次入站文件处理结束后;失败只记录日志,不阻断主流程。
40
+
41
+ ## 已知限制
42
+
43
+ - 百度文件消息仍归属 `msgtype: "text"`,当前**没有**单独的 `msgtype: "file"` 协议分支。
44
+ - 出站文件发送只接受本地文件路径;远程 URL 不会被当作可发送附件直接透传。
45
+ - 发送消息接口仍是 JSON 请求体,当前**没有** `multipart/form-data` 消息发送实现。
46
+ - 只有成功下载到本地的入站文件才会出现在 Agent 的 `[local files]` 文本块与 `MediaPath/MediaPaths` 上下文里;下载失败的附件会在 agent 正文里留下 failure placeholder,但不会伪造本地路径。
47
+ - 本地 mock smoke 中,出站文件 happy/failure 闭环通过 `scripts/mock-server.ts` 的 `/simulate-file-flow` helper 验证,真实运行时代码本身由单元测试覆盖。
15
48
 
16
49
  ## 前置条件
17
50
 
@@ -95,8 +128,8 @@ openclaw gateway restart
95
128
  ## 步骤五:验证配置
96
129
 
97
130
  1. 在百度平台配置 Webhook 回调地址,指向你的 OpenClaw Gateway
98
- 2. 平台验证通过后,发送一条测试消息
99
- 3. 查看 OpenClaw 日志确认消息接收和回复
131
+ 2. 平台验证通过后,先发送一条测试文本消息,再发送一条带 `files` 的文本消息
132
+ 3. 查看 OpenClaw 日志,确认 webhook 接收生效;如果是文件消息,还要确认插件完成本地下载并把 `[local files]` / `MediaPaths` 注入给 Agent
100
133
 
101
134
  ## 常见问题
102
135
 
@@ -117,3 +150,16 @@ openclaw gateway restart
117
150
  ```bash
118
151
  pnpm test
119
152
  ```
153
+
154
+ ```bash
155
+ pnpm build
156
+ ```
157
+
158
+ 更多本地 smoke、文件传输验证和 mock 证据查看方式见 [`doc/testing.md`](./doc/testing.md)。
159
+
160
+ ## 发布前检查矩阵
161
+
162
+ | 检查项 | 命令 | 预期结果 | 证据 |
163
+ | :-- | :-- | :-- | :-- |
164
+ | 单元测试 | `pnpm test` | 全部通过 | Vitest exit code 0 |
165
+ | 构建 | `pnpm build` | 构建成功 | build exit code 0 |