@dai_ming/plugin-deliverables 1.0.14 → 1.0.15

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/INSTALL.md ADDED
@@ -0,0 +1,215 @@
1
+ # plugin-deliverables 安装文档
2
+
3
+ 本文档描述 `@dai_ming/plugin-deliverables@1.0.15` 的安装、升级与验证方式。
4
+
5
+ ## 1. 目标
6
+
7
+ 安装完成后,插件应同时提供三类能力:
8
+
9
+ 1. MCP 工具:`deliverables__upload_deliverable`
10
+ 2. Prompt/Skill 注入:自动把文档类产物收敛到交付物上传流程
11
+ 3. Runtime Hook 兜底:
12
+ - `before_prompt_build`
13
+ - `before_tool_call`
14
+ - `message_sending`
15
+
16
+ 也就是说,这个版本不只是“把上传工具装进去”,还会阻止 `message + file/media` 这种旁路发送。
17
+
18
+ ## 2. 推荐安装方式
19
+
20
+ ### 2.1 通过 OpenClaw 原生插件安装
21
+
22
+ 适用于已经支持 `openclaw plugins install` 的运行环境。
23
+
24
+ ```bash
25
+ openclaw plugins install @dai_ming/plugin-deliverables@1.0.15 --pin
26
+ openclaw plugins enable plugin-deliverables
27
+ ```
28
+
29
+ 安装后建议检查:
30
+
31
+ ```bash
32
+ openclaw plugins info plugin-deliverables
33
+ openclaw plugins list
34
+ ```
35
+
36
+ 确认点:
37
+
38
+ - 插件 id 为 `plugin-deliverables`
39
+ - 入口文件为 `index.js`
40
+ - 插件状态为 `enabled`
41
+
42
+ ### 2.2 通过 claw-gateway Helm 参数安装
43
+
44
+ 适用于当前我们这套 pod 生成链路。
45
+
46
+ 在 release 的插件列表中加入:
47
+
48
+ ```yaml
49
+ installPlugins:
50
+ - "@dai_ming/plugin-deliverables@1.0.15"
51
+ ```
52
+
53
+ Helm 初始化时会自动完成:
54
+
55
+ 1. `npm pack` 下载插件
56
+ 2. 解压到扩展目录
57
+ 3. 读取 `openclaw-plugin.json` 注入 MCP / skills / AGENTS 规则
58
+ 4. 由 OpenClaw 读取 `openclaw.plugin.json` + `index.js` 激活 runtime hooks
59
+
60
+ ## 3. 手动安装方式
61
+
62
+ 适用于需要在单个 pod 内热修验证的场景。
63
+
64
+ ### 3.1 下载与解压
65
+
66
+ ```bash
67
+ mkdir -p /home/node/.openclaw/extensions-extra/plugin-deliverables
68
+ cd /tmp
69
+ npm pack @dai_ming/plugin-deliverables@1.0.15 --registry https://registry.npmjs.org
70
+ tar xzf dai_ming-plugin-deliverables-1.0.15.tgz \
71
+ -C /home/node/.openclaw/extensions-extra/plugin-deliverables \
72
+ --strip-components=1
73
+ ```
74
+
75
+ ### 3.2 安装 MCP 脚本
76
+
77
+ ```bash
78
+ mkdir -p /home/node/.openclaw/mcp-servers
79
+ cp /home/node/.openclaw/extensions-extra/plugin-deliverables/mcp-servers/deliverables.js \
80
+ /home/node/.openclaw/mcp-servers/deliverables.js
81
+ ```
82
+
83
+ ### 3.3 安装 Skill
84
+
85
+ ```bash
86
+ mkdir -p /home/node/.openclaw/workspace/skills/deliverables
87
+ cp /home/node/.openclaw/extensions-extra/plugin-deliverables/skills/deliverables/SKILL.md \
88
+ /home/node/.openclaw/workspace/skills/deliverables/SKILL.md
89
+ ```
90
+
91
+ ### 3.4 注入 AGENTS 规则
92
+
93
+ ```bash
94
+ AGENTS=/home/node/.openclaw/workspace/AGENTS.md
95
+ RULES=/home/node/.openclaw/extensions-extra/plugin-deliverables/agents-rules/deliverables.md
96
+
97
+ node - <<'NODE'
98
+ const fs = require("fs");
99
+ const agents = process.env.AGENTS;
100
+ const rules = process.env.RULES;
101
+ const block = fs.readFileSync(rules, "utf8").trim();
102
+ let body = "";
103
+ try {
104
+ body = fs.readFileSync(agents, "utf8");
105
+ } catch {
106
+ body = "";
107
+ }
108
+ const re = /<!--\s*DELIVERABLE_LINK_RULES_START\s*-->[\s\S]*?<!--\s*DELIVERABLE_AUTO_UPLOAD_RULES_END\s*-->/g;
109
+ const next = re.test(body) ? body.replace(re, block) : `${body.trim()}\n\n${block}\n`.trimStart();
110
+ fs.writeFileSync(agents, `${next.replace(/\s*$/, "")}\n`);
111
+ NODE
112
+ ```
113
+
114
+ 执行前先导出环境变量:
115
+
116
+ ```bash
117
+ export AGENTS=/home/node/.openclaw/workspace/AGENTS.md
118
+ export RULES=/home/node/.openclaw/extensions-extra/plugin-deliverables/agents-rules/deliverables.md
119
+ ```
120
+
121
+ ### 3.5 启用 runtime plugin
122
+
123
+ 确保 OpenClaw 配置里存在:
124
+
125
+ ```json
126
+ {
127
+ "plugins": {
128
+ "entries": {
129
+ "plugin-deliverables": {}
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ 如果运行环境支持 `openclaw plugins install/enable`,优先使用原生命令;否则要确保插件目录在 OpenClaw 可扫描的 extensions 路径下。
136
+
137
+ ## 4. 升级后的验证清单
138
+
139
+ ### 4.1 文件级验证
140
+
141
+ 确认插件目录内存在:
142
+
143
+ ```bash
144
+ ls -la /home/node/.openclaw/extensions-extra/plugin-deliverables
145
+ ```
146
+
147
+ 必须看到:
148
+
149
+ - `index.js`
150
+ - `openclaw.plugin.json`
151
+ - `openclaw-plugin.json`
152
+ - `mcp-servers/deliverables.js`
153
+
154
+ ### 4.2 Prompt/Skill 验证
155
+
156
+ 确认:
157
+
158
+ ```bash
159
+ rg -n "DELIVERABLE_LINK_RULES_START|DELIVERABLE_AUTO_UPLOAD_RULES_START" /home/node/.openclaw/workspace/AGENTS.md
160
+ ls -la /home/node/.openclaw/workspace/skills/deliverables
161
+ ```
162
+
163
+ ### 4.3 行为验证
164
+
165
+ 建议发两类请求:
166
+
167
+ 1. 文档类
168
+ - `帮我写一篇关于卡卡的介绍,生成 Markdown 并保存为交付物`
169
+ 2. 多文件类
170
+ - `做一个简单静态网页小游戏,并保存为交付物`
171
+
172
+ 预期结果:
173
+
174
+ 1. 第一条回复:模型自己的简短内容介绍
175
+ 2. 第二条回复:纯一个 https 链接
176
+ 3. 不再出现 `message + file_url/media` 的旁路发送
177
+
178
+ ## 5. 常见问题
179
+
180
+ ### 5.1 安装后工具没出来
181
+
182
+ 检查:
183
+
184
+ ```bash
185
+ ls /home/node/.openclaw/mcp-servers
186
+ cat /home/node/.openclaw/openclaw.json
187
+ ```
188
+
189
+ 确认:
190
+
191
+ - `deliverables.js` 已复制
192
+ - `mcp.servers.deliverables` 已存在
193
+ - `tools.allow` 未把 `deliverables__upload_deliverable` 拦掉
194
+
195
+ ### 5.2 文档还是只保存工作区,不上传
196
+
197
+ 优先检查:
198
+
199
+ 1. `AGENTS.md` 是否有 deliverables 规则块
200
+ 2. `skills/deliverables/SKILL.md` 是否存在
201
+ 3. runtime plugin 是否被实际加载
202
+
203
+ ### 5.3 第二条消息不是纯链接
204
+
205
+ 这是上层 prompt 或插件旧版本未生效的典型现象。先确认实际安装版本:
206
+
207
+ ```bash
208
+ cat /home/node/.openclaw/extensions-extra/plugin-deliverables/package.json
209
+ ```
210
+
211
+ 必须是:
212
+
213
+ ```json
214
+ { "version": "1.0.15" }
215
+ ```
package/README.md CHANGED
@@ -1,152 +1,248 @@
1
1
  # @dai_ming/plugin-deliverables
2
2
 
3
- OpenClaw 交付物插件。安装后会把交付物 MCP、skill、AGENTS 规则和 `openclaw.json` 配置一次性落到运行目录里,让 Agent 默认把生成文件上传成可访问的交付物链接。
3
+ OpenClaw 交付物插件 AI Agent 将生成的文件(文章、HTML 页面、多文件游戏/网站、图片等)自动上传到 OSS,并在会话消息中回显可点击的预览/下载链接。
4
4
 
5
- 当前版本增强点:
5
+ ---
6
6
 
7
- - 上传成功后返回标准 Markdown 链接块;同时通过运行时补丁把 palz-connector 中的“简介 + 链接”交付物回复拆成两条独立消息
8
- - 单文件交付物会尽量保留原始文件后缀;如果模型漏掉后缀,插件会按内容类型自动补齐(如 `.md` / `.html`)
9
-
10
- ## 包内文件
7
+ ## 插件包含什么
11
8
 
12
9
  | 文件 | 作用 |
13
10
  |------|------|
14
- | `install.js` | 安装器:负责复制插件、注册 MCP、安装 skill、注入 AGENTS 规则、补齐 `plugins.allow`、清 session,并刷新旧的 deliverables MCP 进程 |
15
- | `mcp-servers/deliverables.js` | MCP Server,暴露 `upload_deliverable` |
16
- | `skills/deliverables/SKILL.md` | 约束模型优先走交付物上传,并统一写到 `output/` |
17
- | `agents-rules/deliverables.md` | 注入到 `AGENTS.md` 的强约束规则 |
18
- | `openclaw-plugin.json` | 兼容当前安装脚本的清单,声明 MCP、skill、rules 和运行时配置 |
19
- | `openclaw.plugin.json` | OpenClaw 运行时插件清单,用于真正加载 `index.js` 扩展 |
11
+ | `index.js` | Native OpenClaw runtime 入口:注册 `before_prompt_build`、`before_tool_call`、`message_sending` 三个 hook,阻止旁路文件发送 |
12
+ | `openclaw.plugin.json` | Native OpenClaw 插件清单:让 OpenClaw 以 runtime plugin 方式发现并加载本插件 |
13
+ | `mcp-servers/deliverables.js` | MCP Server 脚本:实现 `upload_deliverable` 工具,通过 HTTP 调用 claw-gateway API 上传文件 |
14
+ | `skills/deliverables/SKILL.md` | OpenClaw Skill:强制文档产出走 `upload_deliverable`,规范写入路径和参数 |
15
+ | `agents-rules/deliverables.md` | AGENTS.md 规则块:URL 回显规则 + 自动上传规则(硬约束,注入到每个 workspace 的 AGENTS.md) |
16
+ | `openclaw-plugin.json` | claw-gateway 兼容清单:声明 MCP server、skill、AGENTS 规则、openclaw.json 配置段 |
17
+
18
+ ---
19
+
20
+ ## 安装方式
21
+
22
+ ### 方式零:作为原生 OpenClaw runtime 插件安装
23
+
24
+ 现在这个包同时支持 OpenClaw 原生插件加载。也就是说,除了网关侧用 `openclaw-plugin.json` 注入 MCP/skill/AGENTS 规则外,OpenClaw 还会读取 `openclaw.plugin.json` + `index.js`,把运行时 hook 也一并启用。
25
+
26
+ ```bash
27
+ openclaw plugins install @dai_ming/plugin-deliverables@1.0.15 --pin
28
+ openclaw plugins enable plugin-deliverables
29
+ ```
30
+
31
+ 这一步启用后,插件会额外提供三层兜底:
20
32
 
21
- ## 推荐安装方式
33
+ 1. `before_prompt_build`:把“交付物必须 upload-first”的硬规则注入到主 agent 和子 agent 的系统上下文
34
+ 2. `before_tool_call`:阻止通过 `message` 附件字段直接发文件
35
+ 3. `message_sending`:如果仍然有媒体/文件旁路发送,最终发送前直接取消
22
36
 
23
- ### 方式一:claw-gateway Helm 部署
37
+ > 注意:`message_sending` 只能改文本或取消发送,不能自动把错误发送重写成 `upload_deliverable`。所以它的职责是“兜底阻断”,不是“自动修正”。
24
38
 
25
- 把插件加入 `installPlugins`:
39
+ ### 方式一:通过 claw-gateway Helm 部署(推荐)
40
+
41
+ 只需在 Helm values 里把插件加入 `installPlugins` 列表,gateway 和 Helm initContainer 会自动完成所有配置:
26
42
 
27
43
  ```yaml
44
+ # values.yaml(或 claw-gateway 管理界面的 Helm 参数)
28
45
  installPlugins:
29
- - "@dai_ming/plugin-deliverables@1.0.14"
46
+ - "@dai_ming/plugin-deliverables@1.0.15"
30
47
  ```
31
48
 
32
- 现有 chart 会在 init 阶段完成安装。
49
+ initContainer 执行顺序:
50
+ 1. **Phase 3**:`npm pack @dai_ming/plugin-deliverables@1.0.15` 下载 tarball → 解压到 `/data/extensions-extra/plugin-deliverables/`
51
+ 2. **Phase 3b**:在插件目录执行 `npm install --omit=dev`(本插件无运行时依赖,此步骤跳过)
52
+ 3. **Phase 3e**:读取 `openclaw-plugin.json` 清单,自动:
53
+ - 复制 `mcp-servers/deliverables.js` → `/data/mcp-servers/deliverables.js`
54
+ - 安装 `skills/deliverables/SKILL.md` → 所有 workspace 的 `skills/deliverables/SKILL.md`
55
+ - 注入 `agents-rules/deliverables.md` 内容到所有 workspace 的 `AGENTS.md`(幂等,按 marker 替换)
56
+ 4. **OpenClaw runtime 加载**:OpenClaw 发现 `openclaw.plugin.json` + `index.js` 后,会自动启用 runtime hooks
57
+
58
+ > **env 变量**:MCP Server 需要以下变量(claw-gateway 在生成 `mcp.servers` 配置时会自动注入):
59
+ >
60
+ > | 变量 | 说明 | 默认值 |
61
+ > |------|------|--------|
62
+ > | `CLAW_GATEWAY_URL` | gateway 内部地址 | `http://claw-gateway:8080` |
63
+ > | `CLAW_GATEWAY_PUBLIC_URL` | gateway 公网地址(用于生成预览链接) | 同上 |
64
+ > | `CLAW_GATEWAY_API_KEY` | API Key | `api-key-1` |
33
65
 
34
- ### 方式二:npm 安装后执行安装脚本
66
+ ### 方式二:手动安装(不使用 claw-gateway 自动部署)
35
67
 
36
- 这就是给运行中 pod / 自定义镜像准备的最小落地方式。
68
+ 适用于自行管理 OpenClaw 容器的场景。
69
+
70
+ **Step 1 — 下载并解压插件**
37
71
 
38
72
  ```bash
39
73
  npm config set registry https://registry.npmmirror.com
40
- npm install @dai_ming/plugin-deliverables@1.0.14
41
- node node_modules/@dai_ming/plugin-deliverables/install.js
74
+ mkdir -p ~/.openclaw/extensions-extra/plugin-deliverables
75
+ cd /tmp && npm pack @dai_ming/plugin-deliverables
76
+ tar xzf openclaw-plugin-deliverables-*.tgz -C ~/.openclaw/extensions-extra/plugin-deliverables --strip-components=1
77
+ ```
78
+
79
+ **Step 2 — 复制 MCP Server 脚本**
80
+
81
+ ```bash
82
+ mkdir -p ~/.openclaw/mcp-servers
83
+ cp ~/.openclaw/extensions-extra/plugin-deliverables/mcp-servers/deliverables.js \
84
+ ~/.openclaw/mcp-servers/deliverables.js
85
+ ```
86
+
87
+ **Step 3 — 安装 Skill**
88
+
89
+ ```bash
90
+ WORKSPACE=~/.openclaw/workspace # 替换为实际 workspace 路径
91
+ mkdir -p "$WORKSPACE/skills/deliverables"
92
+ cp ~/.openclaw/extensions-extra/plugin-deliverables/skills/deliverables/SKILL.md \
93
+ "$WORKSPACE/skills/deliverables/SKILL.md"
42
94
  ```
43
95
 
44
- 如果 OpenClaw home 不在默认位置,可以显式传入:
96
+ **Step 4 注入 AGENTS.md 规则**
45
97
 
46
98
  ```bash
47
- node node_modules/@dai_ming/plugin-deliverables/install.js \
48
- --home /home/node/.openclaw
99
+ AGENTS="$WORKSPACE/AGENTS.md"
100
+ RULES=~/.openclaw/extensions-extra/plugin-deliverables/agents-rules/deliverables.md
101
+
102
+ if grep -q "DELIVERABLE_LINK_RULES_START" "$AGENTS" 2>/dev/null; then
103
+ # 已有旧规则,用 Node.js 按 marker 替换
104
+ node -e "
105
+ var fs=require('fs');
106
+ var a=fs.readFileSync('$AGENTS','utf8');
107
+ var r=fs.readFileSync('$RULES','utf8').trim();
108
+ var re=/<!--\s*DELIVERABLE_LINK_RULES_START\s*-->[\s\S]*?<!--\s*DELIVERABLE_AUTO_UPLOAD_RULES_END\s*-->/g;
109
+ fs.writeFileSync('$AGENTS', re.test(a) ? a.replace(re,r) : a+'\n\n'+r+'\n');
110
+ "
111
+ else
112
+ # 首次注入
113
+ printf '\n\n' >> "$AGENTS"
114
+ cat "$RULES" >> "$AGENTS"
115
+ fi
49
116
  ```
50
117
 
51
- ## `install.js` 会做什么
118
+ **Step 5 — 配置 openclaw.json**
119
+
120
+ 在 `~/.openclaw/openclaw.json` 的 `mcp.servers` 下添加:
121
+
122
+ ```json
123
+ {
124
+ "mcp": {
125
+ "servers": {
126
+ "deliverables": {
127
+ "command": "node",
128
+ "args": ["/home/node/.openclaw/mcp-servers/deliverables.js"],
129
+ "env": {
130
+ "CLAW_GATEWAY_URL": "http://<your-gateway-host>:8080",
131
+ "CLAW_GATEWAY_PUBLIC_URL": "https://<public-domain>",
132
+ "CLAW_GATEWAY_API_KEY": "<your-api-key>"
133
+ }
134
+ }
135
+ }
136
+ },
137
+ "plugins": {
138
+ "entries": {
139
+ "plugin-deliverables": { "enabled": true }
140
+ }
141
+ }
142
+ }
143
+ ```
52
144
 
53
- 执行一次脚本后,会自动完成这些动作:
145
+ ---
54
146
 
55
- 1. 复制插件到:
56
- - `~/.openclaw/extensions/plugin-deliverables`
57
- - `~/.openclaw/extensions-extra/plugin-deliverables`
58
- 2. 复制 `deliverables.js` 到 `~/.openclaw/mcp-servers/`
59
- 3. 把 `SKILL.md` 写入所有已发现 workspace 和 agent skill 目录
60
- 4. 把交付物规则幂等注入到实际使用中的 `AGENTS.md`
61
- 5. 在各 workspace 下补出 `output/` 目录
62
- 6. 更新 `~/.openclaw/openclaw.json`
63
- - 注册 `mcp.servers.deliverables`
64
- - 启用 `skills.entries.deliverables`
65
- - 启用 `plugins.entries.plugin-deliverables`
66
- - 把 `~/.openclaw/extensions-extra/plugin-deliverables` 写入 `plugins.load.paths`
67
- - 把 `plugin-deliverables` 加入 `plugins.allow`
68
- 7. 清理 session,让下一条消息重新读取 prompt / skill / tool 配置
69
- 8. 如果 agent 或全局存在 `tools.allow` 白名单,自动补上 `deliverables__upload_deliverable`
70
- 9. 如果当前 pod 里已经跑着旧版 `deliverables.js` MCP 进程,会自动结束旧进程,让它按新文件重新拉起,避免“磁盘已更新但 toolResult 还是旧格式”
147
+ ## AGENTS.md 规则说明
71
148
 
72
- 补充说明:
149
+ 插件向每个 workspace 的 `AGENTS.md` 注入两段硬约束规则:
73
150
 
74
- - 当前 OpenClaw 运行时默认只扫描 `~/.openclaw/extensions`;`extensions-extra` 里的 JS 插件只有进入 `plugins.load.paths` 才会被当成可执行 `openclaw` 插件加载
75
- - 安装脚本会先把插件源码暂存到系统临时目录再复制,避免在 `extensions-extra` 原地执行安装时把源目录自己删掉
151
+ | 规则段 | Marker | 作用 |
152
+ |--------|--------|------|
153
+ | URL 回显规则 | `DELIVERABLE_LINK_RULES_START` … `DELIVERABLE_LINK_RULES_END` | 强制 Agent 上传后在消息中输出可点击的 Markdown 链接 |
154
+ | 自动上传规则 | `DELIVERABLE_AUTO_UPLOAD_RULES_START` … `DELIVERABLE_AUTO_UPLOAD_RULES_END` | 当用户要求生成文件时默认自动上传,写入 `output/` 目录 |
76
155
 
77
- ## 是否需要重启 Pod
156
+ 规则使用 HTML 注释 Marker 包裹,initContainer 和 Guardian 进程每次同步时都会幂等替换,不会产生重复块。
78
157
 
79
- 不需要重启 Pod。
158
+ ---
80
159
 
81
- 原因:
82
- - 安装脚本会直接改 `~/.openclaw/openclaw.json`
83
- - `plugins.allow` / `plugins.load.paths` 变化会触发 OpenClaw 的 watcher,进程级重载大约 15 秒
84
- - session 也会被清掉,所以下一条消息会重新读取最新的 `AGENTS.md` / skill
160
+ ## Skill 说明
85
161
 
86
- 建议做法:
162
+ `skills/deliverables/SKILL.md` 是 OpenClaw Skill,被注入到 workspace 后由 Agent 在工具调用前读取。它规定:
87
163
 
88
- ```bash
89
- node node_modules/@dai_ming/plugin-deliverables/install.js
90
- sleep 20
91
- ```
164
+ - 始终使用会话中实际暴露的工具名(`deliverables__upload_deliverable`)
165
+ - 生成文件统一写入 `output/` 子目录
166
+ - 多文件(游戏/网站)优先用 `type=game` + `files[]`,不要提前打 zip
167
+ - 上传成功后回复必须附带 Markdown 格式的预览/下载链接
92
168
 
93
- 然后再发一条新的用户消息测试。
169
+ ---
94
170
 
95
- ## 常用参数
171
+ ## MCP Server 说明
96
172
 
97
- ```bash
98
- node install.js --help
99
- ```
173
+ `mcp-servers/deliverables.js` 是一个符合 [MCP 协议(2024-11-05)](https://modelcontextprotocol.io/) 的 Node.js stdio server,暴露单个工具:
174
+
175
+ ### `upload_deliverable`
100
176
 
101
- | 参数 | 说明 |
177
+ | 参数 | 类型 | 必填 | 说明 |
178
+ |------|------|------|------|
179
+ | `resource_id` | string | ✅ | 当前会话唯一 ID |
180
+ | `type` | enum | ✅ | `article` / `game` / `zip` / `image` / `video` / `ppt` / `link` |
181
+ | `file_name` | string | ✅ | 用户可见文件名(含扩展名)或目录名 |
182
+ | `group_id` | string | — | 群聊 ID |
183
+ | `user_id` | string | — | 用户 ID |
184
+ | `content_text` | string | — | 文本内容(单文件场景) |
185
+ | `content_base64` | string | — | Base64 编码的二进制内容(单文件场景) |
186
+ | `files` | array | — | 多文件列表(游戏/站点场景,优先使用) |
187
+
188
+ 返回值包含 `preview_url`、`download_url`、`reply_markdown`(可直接附在回复消息中)。
189
+
190
+ ---
191
+
192
+ ## Runtime Hook 说明
193
+
194
+ `index.js` 会在 OpenClaw runtime 中注册三个 hook:
195
+
196
+ | Hook | 作用 |
102
197
  |------|------|
103
- | `--home <dir>` | 指定 OpenClaw home,默认 `~/.openclaw` |
104
- | `--plugin-root <dir>` | 指定插件源码目录,默认当前包目录 |
105
- | `--no-clear-sessions` | 不清 session |
106
- | `--dry-run` | 只打印计划,不落盘 |
198
+ | `before_prompt_build` | 把“生成文件必须走交付物上传”的硬规则注入系统上下文,覆盖主 agent 和子 agent |
199
+ | `before_tool_call` | 阻止通过 `message` 工具的 `media/path/filePath/buffer` 等字段直接发送文件 |
200
+ | `message_sending` | 如果上游仍然产生了媒体/文件旁路发送,在最终出站前直接取消 |
201
+
202
+ 这三层一起工作的目标是:即使 prompt 漂移,也尽量把“message + file/media”这条旁路堵住,统一收敛到 `deliverables__upload_deliverable`。
107
203
 
108
- ## 返回结果
204
+ ---
109
205
 
110
- 安装脚本成功后会输出一段 JSON 摘要,包含:
206
+ ## 版本与发布
111
207
 
112
- - 目标 OpenClaw home
113
- - 写入的 extension 目录
114
- - 写入的 MCP 文件
115
- - 修改的 `AGENTS.md`
116
- - 清理的 session 数量
208
+ ### claw-gateway 仓库内发布
117
209
 
118
- ## 发布
210
+ 插件源码位于 `packages/plugin-deliverables/` 目录,与 claw-gateway 主仓库同步维护。更新流程:
119
211
 
120
212
  ```bash
213
+ # 1. 修改 packages/plugin-deliverables/package.json 中的 version
214
+ # 2. 同步更新 packages/plugin-deliverables/mcp-servers/deliverables.js(如有变更)
215
+ # 3. 打包并发布到 npmmirror 兼容的私有或公开 registry
121
216
  cd packages/plugin-deliverables
122
217
  npm publish --registry https://registry.npmjs.org --access public
123
218
  ```
124
219
 
125
- ## 排障
220
+ ### 版本对齐建议
126
221
 
127
- ### Agent 没看到工具
222
+ | claw-gateway 版本 | plugin 版本 |
223
+ |-------------------|-------------|
224
+ | 当前 | 1.0.15 |
128
225
 
129
- 重点检查:
226
+ ---
130
227
 
131
- 1. `~/.openclaw/openclaw.json` 里是否有 `mcp.servers.deliverables`
132
- 2. `plugins.allow` 是否含 `plugin-deliverables`
133
- 3. `~/.openclaw/mcp-servers/deliverables.js` 是否存在
134
- 4. 当前 workspace 的 `AGENTS.md` 是否已经注入 deliverables 规则
228
+ ## 常见问题
135
229
 
136
- ### 上传返回 401 / 404
230
+ **Q: 插件安装后 Agent 没有 `upload_deliverable` 工具怎么办?**
137
231
 
138
- 优先检查容器环境变量:
232
+ 检查以下几点:
233
+ 1. `openclaw.json` 的 `mcp.servers.deliverables` 是否存在
234
+ 2. MCP Server 是否在运行:`kubectl exec <pod> -- ls /home/node/.openclaw/mcp-servers/`
235
+ 3. Agent 的 `tools.allow` 是否包含 `deliverables__upload_deliverable`
139
236
 
140
- ```bash
141
- env | grep -E 'CLAW_GATEWAY|OPENCLAW_GATEWAY|botID'
142
- ```
237
+ **Q: 上传后没有返回链接怎么办?**
143
238
 
144
- 以及直接请求 gateway:
239
+ 确认 `CLAW_GATEWAY_URL` 和 `CLAW_GATEWAY_API_KEY` 注入正确,可在容器内测试:
145
240
 
146
241
  ```bash
147
- curl -H "X-API-Key: $CLAW_GATEWAY_API_KEY" "$CLAW_GATEWAY_URL/healthz"
242
+ curl -H "X-API-Key: $CLAW_GATEWAY_API_KEY" $CLAW_GATEWAY_URL/healthz
148
243
  ```
149
244
 
150
- ### 返回的是 `/preview/:uuid` 或内部地址
245
+ **Q: claw-gateway 已经内置了 deliverables,会和插件冲突吗?**
151
246
 
152
- `1.0.14` 起,安装脚本会在落盘新的 `deliverables.js` 后自动刷新正在运行的旧 MCP 进程,避免出现“插件目录和 `extensions-extra` 都是新代码,但 `~/.openclaw/mcp-servers/deliverables.js` 对应的常驻进程仍返回旧 `reply_markdown`”的问题。此前 `1.0.13` 已经完成 `output` 直链修正、后缀保留,以及 palz-connector 中“内容简介 + 链接”自动拆成两条消息,第二条只保留一个最终 HTTPS 链接。
247
+ 不会冲突。claw-gateway 通过 ConfigMap 注入的 MCP 脚本、skill、AGENTS 规则与插件内容完全一致。
248
+ Phase 3e(插件注入)在前,ConfigMap 阶段(Phase 4/4c/4d)在后;ConfigMap 的内容会覆盖插件安装的内容,两者互为备份。
@@ -1,7 +1,7 @@
1
1
  <!-- DELIVERABLE_LINK_RULES_START -->
2
2
  ## Deliverables -- URL Echo Rule (HARD CONSTRAINT)
3
3
 
4
- When you call the deliverables upload tool, the user-facing output MUST make the deliverable easy to open and easy to understand.
4
+ When you call the deliverables upload tool, your final assistant message MUST include clickable URLs in Markdown link format (short label + full URL target).
5
5
 
6
6
  Tool name note:
7
7
 
@@ -12,28 +12,29 @@ Tool name note:
12
12
 
13
13
  ### Required output behavior
14
14
 
15
- 0. Your final assistant message MUST start with a richer Markdown intro section, not a single short confirmation sentence.
15
+ 0. Your final assistant message MUST start with 1-2 short sentences in your own words, briefly describing what you produced for the user.
16
16
  1. The intro must be based on the actual content/request, not a fixed boilerplate like `交付物已上传成功,可直接在线预览或下载。`
17
- 2. The intro SHOULD use Markdown structure, preferably:
18
- - a short title or summary line
19
- - a `### 内容概览` section
20
- - 3-6 bullet points describing the actual sections, highlights, features, or focus of the deliverable
21
- 3. The intro should be noticeably more informative than one sentence. For normal articles/reports/introductions, aim for roughly 80-200 Chinese characters total before the links.
22
- 4. The bullet points must describe the real deliverable content. Do not use empty filler like "内容丰富" / "结构清晰" / "值得阅读" unless paired with concrete details.
23
- 5. If tool result contains `reply_markdown`, append a `### 访问链接` heading and then append that field verbatim on the following line. Do not rewrite the URL inside it.
24
- 6. Otherwise, if tool result has `primary_url`, output only that one full URL on its own line after `### 访问链接`.
25
- 7. If `primary_url` is missing, fall back to exactly one link: prefer `preview_url`, otherwise `download_url`.
26
- 8. Keep URL target value exactly from tool result (no shortening, no masking, no redirect rewrite).
27
- 9. Only output one final deliverable URL. Do not output both preview and download.
28
- 10. Keep the intro concise but substantive; do not paste the full file content, saved-path text, or a huge essay after the URL.
17
+ 2. If tool result contains `reply_markdown`, append that field verbatim after your intro on the following lines. Do not rewrite the links inside it.
18
+ 3. If tool result has `preview_url`, include one line:
19
+ `预览链接:[点击预览](<full_url>)`
20
+ 4. If tool result has `download_url`, include one line:
21
+ `下载链接:[点击下载](<full_url>)`
22
+ 5. For multi-file/game deliverables, if tool result already formats the second line as
23
+ `文件列表:[查看目录](<full_url>)`
24
+ then keep that exact label and URL. Do not rewrite it back to a raw long link.
25
+ 6. Keep URL target value exactly from tool result (no shortening, no masking, no redirect rewrite).
26
+ 7. Use short link labels (`点击预览` / `点击下载` / `查看目录`) to avoid exposing long raw URLs.
27
+ 8. Do not say "已上传/已完成" without links.
28
+ 9. Do not output naked long URLs outside Markdown link syntax.
29
+ 10. Keep the intro concise; do not paste the full file content, saved-path text, or a long summary after the Markdown links.
29
30
 
30
31
  ### Forbidden output behavior
31
32
 
32
33
  - "可点击预览链接查看" but no actual URL
33
- - A single short sentence plus links when the deliverable is an article/report/introduction and concrete highlights are available
34
34
  - Replacing URL target with a non-original URL
35
- - Omitting the final URL when the tool already returned one
36
- - Outputting both preview and download when one shareable URL is enough
35
+ - Omitting both links when tool already returned links
36
+ - Outputting only naked long URL without Markdown link label
37
+ - Replacing `文件列表:[查看目录](...)` with a naked URL or a zip description
37
38
  - Using a generic boilerplate intro that does not mention the actual deliverable content
38
39
  <!-- DELIVERABLE_LINK_RULES_END -->
39
40
 
@@ -53,27 +54,22 @@ Tool name note:
53
54
  1. Create content under current agent workspace `output/` directory first (for example `output/report.md`), then call the deliverables upload tool exposed in this session.
54
55
  2. If you need to use the `write` tool, the target path MUST be inside `output/`. Never write deliverable files to the workspace root.
55
56
  3. If you already wrote the file to the wrong place, move/copy it into `output/` before finalizing the task and before describing the saved path to the user.
56
- 4. The deliverable file name MUST preserve the intended extension exactly. Examples:
57
- - Markdown article: `刘德华介绍.md`
58
- - Markdown note: `周杰伦.md`
59
- - HTML page: `996专题.html`
60
- - Text file: `旅行清单.txt`
61
- 5. Never drop the suffix from the final deliverable file name. If the user asked for Markdown, keep `.md`; if HTML, keep `.html`.
57
+ 4. If format is HTML, prefer `type=article` and file name ends with `.html`.
58
+ 5. If format is markdown/text, use `type=article` and `.md`/`.txt`.
62
59
  6. For multi-file deliverables (game/site), you MUST prefer `type=game` with `files[]`, keep files as a folder structure, and do NOT zip before upload unless the user explicitly asks for a zip package.
63
60
  7. Static multi-file game/site deliverables SHOULD include a root `index.html` so the preview link can open the homepage directly.
64
61
  8. If a generated project requires starting a separate backend service, custom port, database, or long-running process to work, do NOT pretend the deliverables preview can run it. Tell the user that deliverables preview only supports static output, and that runtime projects need deployment/ingress instead.
65
- 9. After successful upload, the final assistant message MUST start with a richer Markdown intro section, not just one short sentence.
62
+ 9. After successful upload, the final assistant message MUST start with 1-2 short sentences in your own words, briefly describing what you generated for the user.
66
63
  10. The intro must be based on the actual deliverable content/request, not a fixed sentence like `交付物已上传成功,可直接在线预览或下载。`
67
- 11. Prefer this Markdown structure:
68
- - a short title or summary line
69
- - `### 内容概览`
70
- - 3-6 bullet points summarizing the actual content sections, highlights, or key features
71
- 12. For ordinary articles/reports/introductions, the intro before the links should normally reach roughly 80-200 Chinese characters total.
72
- 13. If tool result contains `reply_markdown`, add `### 访问链接` and append that field verbatim on the following line.
73
- 14. Otherwise final reply MUST include exactly one full URL after `### 访问链接`: prefer `primary_url`, otherwise `preview_url`, otherwise `download_url`.
74
- 15. Do NOT output preview/download two条链接,也不要把目录链接再包装成 zip 说明。
75
- 16. Do NOT only say "已保存到工作空间".
76
- 17. Do NOT append workspace path or extra raw URL blocks after the final URL.
64
+ 11. If tool result contains `reply_markdown`, append that field verbatim after your intro on the following lines.
65
+ 12. Otherwise final reply MUST include Markdown links (short label + full URL target):
66
+ `预览链接:[点击预览](<full_url>)`
67
+ `下载链接:[点击下载](<full_url>)`
68
+ 13. For multi-file/game deliverables, if the tool gives directory-style output, the second line may be:
69
+ `文件列表:[查看目录](<full_url>)`
70
+ Keep that format instead of forcing a zip link.
71
+ 14. Do NOT only say "已保存到工作空间".
72
+ 15. Do NOT append workspace path or a raw URL block after the Markdown links.
77
73
 
78
74
  ### Exception
79
75