@dai_ming/plugin-deliverables 1.0.10 → 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 +215 -0
- package/README.md +188 -86
- package/agents-rules/deliverables.md +22 -44
- package/index.js +149 -0
- package/mcp-servers/deliverables.js +26 -308
- package/openclaw-plugin.json +2 -4
- package/openclaw.plugin.json +12 -0
- package/package.json +10 -2
- package/skills/deliverables/SKILL.md +11 -25
- package/install.js +0 -463
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,146 +1,248 @@
|
|
|
1
1
|
# @dai_ming/plugin-deliverables
|
|
2
2
|
|
|
3
|
-
OpenClaw
|
|
3
|
+
OpenClaw 交付物插件 — 让 AI Agent 将生成的文件(文章、HTML 页面、多文件游戏/网站、图片等)自动上传到 OSS,并在会话消息中回显可点击的预览/下载链接。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 第一条是内容摘要
|
|
9
|
-
- 第二条是纯 Markdown 链接
|
|
10
|
-
- 单文件交付物会尽量保留原始文件后缀;如果模型漏掉后缀,插件会按内容类型自动补齐(如 `.md` / `.html`)
|
|
11
|
-
|
|
12
|
-
## 包内文件
|
|
7
|
+
## 插件包含什么
|
|
13
8
|
|
|
14
9
|
| 文件 | 作用 |
|
|
15
10
|
|------|------|
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
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
|
+
这一步启用后,插件会额外提供三层兜底:
|
|
21
32
|
|
|
22
|
-
|
|
33
|
+
1. `before_prompt_build`:把“交付物必须 upload-first”的硬规则注入到主 agent 和子 agent 的系统上下文
|
|
34
|
+
2. `before_tool_call`:阻止通过 `message` 附件字段直接发文件
|
|
35
|
+
3. `message_sending`:如果仍然有媒体/文件旁路发送,最终发送前直接取消
|
|
23
36
|
|
|
24
|
-
|
|
37
|
+
> 注意:`message_sending` 只能改文本或取消发送,不能自动把错误发送重写成 `upload_deliverable`。所以它的职责是“兜底阻断”,不是“自动修正”。
|
|
25
38
|
|
|
26
|
-
|
|
39
|
+
### 方式一:通过 claw-gateway Helm 部署(推荐)
|
|
40
|
+
|
|
41
|
+
只需在 Helm values 里把插件加入 `installPlugins` 列表,gateway 和 Helm initContainer 会自动完成所有配置:
|
|
27
42
|
|
|
28
43
|
```yaml
|
|
44
|
+
# values.yaml(或 claw-gateway 管理界面的 Helm 参数)
|
|
29
45
|
installPlugins:
|
|
30
|
-
- "@dai_ming/plugin-deliverables@1.0.
|
|
46
|
+
- "@dai_ming/plugin-deliverables@1.0.15"
|
|
31
47
|
```
|
|
32
48
|
|
|
33
|
-
|
|
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` |
|
|
65
|
+
|
|
66
|
+
### 方式二:手动安装(不使用 claw-gateway 自动部署)
|
|
34
67
|
|
|
35
|
-
|
|
68
|
+
适用于自行管理 OpenClaw 容器的场景。
|
|
36
69
|
|
|
37
|
-
|
|
70
|
+
**Step 1 — 下载并解压插件**
|
|
38
71
|
|
|
39
72
|
```bash
|
|
40
73
|
npm config set registry https://registry.npmmirror.com
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
43
77
|
```
|
|
44
78
|
|
|
45
|
-
|
|
79
|
+
**Step 2 — 复制 MCP Server 脚本**
|
|
46
80
|
|
|
47
81
|
```bash
|
|
48
|
-
|
|
49
|
-
|
|
82
|
+
mkdir -p ~/.openclaw/mcp-servers
|
|
83
|
+
cp ~/.openclaw/extensions-extra/plugin-deliverables/mcp-servers/deliverables.js \
|
|
84
|
+
~/.openclaw/mcp-servers/deliverables.js
|
|
50
85
|
```
|
|
51
86
|
|
|
52
|
-
|
|
87
|
+
**Step 3 — 安装 Skill**
|
|
53
88
|
|
|
54
|
-
|
|
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"
|
|
94
|
+
```
|
|
55
95
|
|
|
56
|
-
|
|
57
|
-
- `~/.openclaw/extensions/plugin-deliverables`
|
|
58
|
-
- `~/.openclaw/extensions-extra/plugin-deliverables`
|
|
59
|
-
2. 复制 `deliverables.js` 到 `~/.openclaw/mcp-servers/`
|
|
60
|
-
3. 把 `SKILL.md` 写入所有已发现 workspace 和 agent skill 目录
|
|
61
|
-
4. 把交付物规则幂等注入到实际使用中的 `AGENTS.md`
|
|
62
|
-
5. 在各 workspace 下补出 `output/` 目录
|
|
63
|
-
6. 更新 `~/.openclaw/openclaw.json`
|
|
64
|
-
- 注册 `mcp.servers.deliverables`
|
|
65
|
-
- 启用 `skills.entries.deliverables`
|
|
66
|
-
- 启用 `plugins.entries.plugin-deliverables`
|
|
67
|
-
- 把 `plugin-deliverables` 加入 `plugins.allow`
|
|
68
|
-
7. 清理 session,让下一条消息重新读取 prompt / skill / tool 配置
|
|
69
|
-
8. 如果 agent 或全局存在 `tools.allow` 白名单,自动补上 `deliverables__upload_deliverable`
|
|
96
|
+
**Step 4 — 注入 AGENTS.md 规则**
|
|
70
97
|
|
|
71
|
-
|
|
98
|
+
```bash
|
|
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
|
|
116
|
+
```
|
|
72
117
|
|
|
73
|
-
|
|
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
|
+
```
|
|
74
144
|
|
|
75
|
-
|
|
76
|
-
- 安装脚本会直接改 `~/.openclaw/openclaw.json`
|
|
77
|
-
- `plugins.allow` 变化会触发 OpenClaw 的 watcher,进程级重载大约 15 秒
|
|
78
|
-
- session 也会被清掉,所以下一条消息会重新读取最新的 `AGENTS.md` / skill
|
|
145
|
+
---
|
|
79
146
|
|
|
80
|
-
|
|
147
|
+
## AGENTS.md 规则说明
|
|
81
148
|
|
|
82
|
-
|
|
83
|
-
node node_modules/@dai_ming/plugin-deliverables/install.js
|
|
84
|
-
sleep 20
|
|
85
|
-
```
|
|
149
|
+
插件向每个 workspace 的 `AGENTS.md` 注入两段硬约束规则:
|
|
86
150
|
|
|
87
|
-
|
|
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/` 目录 |
|
|
88
155
|
|
|
89
|
-
|
|
156
|
+
规则使用 HTML 注释 Marker 包裹,initContainer 和 Guardian 进程每次同步时都会幂等替换,不会产生重复块。
|
|
90
157
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Skill 说明
|
|
161
|
+
|
|
162
|
+
`skills/deliverables/SKILL.md` 是 OpenClaw Skill,被注入到 workspace 后由 Agent 在工具调用前读取。它规定:
|
|
163
|
+
|
|
164
|
+
- 始终使用会话中实际暴露的工具名(`deliverables__upload_deliverable`)
|
|
165
|
+
- 生成文件统一写入 `output/` 子目录
|
|
166
|
+
- 多文件(游戏/网站)优先用 `type=game` + `files[]`,不要提前打 zip
|
|
167
|
+
- 上传成功后回复必须附带 Markdown 格式的预览/下载链接
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## MCP Server 说明
|
|
172
|
+
|
|
173
|
+
`mcp-servers/deliverables.js` 是一个符合 [MCP 协议(2024-11-05)](https://modelcontextprotocol.io/) 的 Node.js stdio server,暴露单个工具:
|
|
94
174
|
|
|
95
|
-
|
|
175
|
+
### `upload_deliverable`
|
|
176
|
+
|
|
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 | 作用 |
|
|
96
197
|
|------|------|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
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`。
|
|
101
203
|
|
|
102
|
-
|
|
204
|
+
---
|
|
103
205
|
|
|
104
|
-
|
|
206
|
+
## 版本与发布
|
|
105
207
|
|
|
106
|
-
|
|
107
|
-
- 写入的 extension 目录
|
|
108
|
-
- 写入的 MCP 文件
|
|
109
|
-
- 修改的 `AGENTS.md`
|
|
110
|
-
- 清理的 session 数量
|
|
208
|
+
### 在 claw-gateway 仓库内发布
|
|
111
209
|
|
|
112
|
-
|
|
210
|
+
插件源码位于 `packages/plugin-deliverables/` 目录,与 claw-gateway 主仓库同步维护。更新流程:
|
|
113
211
|
|
|
114
212
|
```bash
|
|
213
|
+
# 1. 修改 packages/plugin-deliverables/package.json 中的 version
|
|
214
|
+
# 2. 同步更新 packages/plugin-deliverables/mcp-servers/deliverables.js(如有变更)
|
|
215
|
+
# 3. 打包并发布到 npmmirror 兼容的私有或公开 registry
|
|
115
216
|
cd packages/plugin-deliverables
|
|
116
217
|
npm publish --registry https://registry.npmjs.org --access public
|
|
117
218
|
```
|
|
118
219
|
|
|
119
|
-
|
|
220
|
+
### 版本对齐建议
|
|
120
221
|
|
|
121
|
-
|
|
222
|
+
| claw-gateway 版本 | plugin 版本 |
|
|
223
|
+
|-------------------|-------------|
|
|
224
|
+
| 当前 | 1.0.15 |
|
|
122
225
|
|
|
123
|
-
|
|
226
|
+
---
|
|
124
227
|
|
|
125
|
-
|
|
126
|
-
2. `plugins.allow` 是否含 `plugin-deliverables`
|
|
127
|
-
3. `~/.openclaw/mcp-servers/deliverables.js` 是否存在
|
|
128
|
-
4. 当前 workspace 的 `AGENTS.md` 是否已经注入 deliverables 规则
|
|
228
|
+
## 常见问题
|
|
129
229
|
|
|
130
|
-
|
|
230
|
+
**Q: 插件安装后 Agent 没有 `upload_deliverable` 工具怎么办?**
|
|
131
231
|
|
|
132
|
-
|
|
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`
|
|
133
236
|
|
|
134
|
-
|
|
135
|
-
env | grep -E 'CLAW_GATEWAY|OPENCLAW_GATEWAY|botID'
|
|
136
|
-
```
|
|
237
|
+
**Q: 上传后没有返回链接怎么办?**
|
|
137
238
|
|
|
138
|
-
|
|
239
|
+
确认 `CLAW_GATEWAY_URL` 和 `CLAW_GATEWAY_API_KEY` 注入正确,可在容器内测试:
|
|
139
240
|
|
|
140
241
|
```bash
|
|
141
|
-
curl -H "X-API-Key: $CLAW_GATEWAY_API_KEY"
|
|
242
|
+
curl -H "X-API-Key: $CLAW_GATEWAY_API_KEY" $CLAW_GATEWAY_URL/healthz
|
|
142
243
|
```
|
|
143
244
|
|
|
144
|
-
|
|
245
|
+
**Q: claw-gateway 已经内置了 deliverables,会和插件冲突吗?**
|
|
145
246
|
|
|
146
|
-
|
|
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
|
-
## Deliverables --
|
|
2
|
+
## Deliverables -- URL Echo Rule (HARD CONSTRAINT)
|
|
3
3
|
|
|
4
|
-
When you call the deliverables upload tool,
|
|
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,36 +12,25 @@ Tool name note:
|
|
|
12
12
|
|
|
13
13
|
### Required output behavior
|
|
14
14
|
|
|
15
|
-
0.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- be based on the actual content/request, not a fixed boilerplate
|
|
20
|
-
- contain no links, no raw URL, no workspace path
|
|
21
|
-
- use Markdown structure, preferably:
|
|
22
|
-
- a short title or summary line
|
|
23
|
-
- `### 内容概览`
|
|
24
|
-
- 3-6 bullet points describing the real sections, highlights, features, or focus
|
|
25
|
-
- be noticeably more informative than one sentence; for normal articles/reports/introductions, aim for roughly 80-220 Chinese characters total
|
|
26
|
-
2. The second reply (final assistant reply) MUST contain links only, with no extra intro, no trailing explanation, no workspace path, and no naked long URL.
|
|
27
|
-
3. If tool result contains `reply_markdown`, the second reply MUST be exactly that link block verbatim. Do not rewrite the links inside it.
|
|
28
|
-
4. If tool result has `preview_url`, include one line:
|
|
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
|
+
1. The intro must be based on the actual content/request, not a fixed boilerplate like `交付物已上传成功,可直接在线预览或下载。`
|
|
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:
|
|
29
19
|
`预览链接:[点击预览](<full_url>)`
|
|
30
|
-
|
|
20
|
+
4. If tool result has `download_url`, include one line:
|
|
31
21
|
`下载链接:[点击下载](<full_url>)`
|
|
32
|
-
|
|
22
|
+
5. For multi-file/game deliverables, if tool result already formats the second line as
|
|
33
23
|
`文件列表:[查看目录](<full_url>)`
|
|
34
24
|
then keep that exact label and URL. Do not rewrite it back to a raw long link.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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.
|
|
39
30
|
|
|
40
31
|
### Forbidden output behavior
|
|
41
32
|
|
|
42
33
|
- "可点击预览链接查看" but no actual URL
|
|
43
|
-
- Putting links into the first summary reply
|
|
44
|
-
- Putting extra narrative text into the second pure-links reply
|
|
45
34
|
- Replacing URL target with a non-original URL
|
|
46
35
|
- Omitting both links when tool already returned links
|
|
47
36
|
- Outputting only naked long URL without Markdown link label
|
|
@@ -65,33 +54,22 @@ Tool name note:
|
|
|
65
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.
|
|
66
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.
|
|
67
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.
|
|
68
|
-
4.
|
|
69
|
-
|
|
70
|
-
- Markdown note: `周杰伦.md`
|
|
71
|
-
- HTML page: `996专题.html`
|
|
72
|
-
- Text file: `旅行清单.txt`
|
|
73
|
-
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`.
|
|
74
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.
|
|
75
60
|
7. Static multi-file game/site deliverables SHOULD include a root `index.html` so the preview link can open the homepage directly.
|
|
76
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.
|
|
77
|
-
9. After successful upload,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
11. Prefer this Markdown structure for the first summary reply:
|
|
82
|
-
- a short title or summary line
|
|
83
|
-
- `### 内容概览`
|
|
84
|
-
- 3-6 bullet points summarizing the actual content sections, highlights, or key features
|
|
85
|
-
12. For ordinary articles/reports/introductions, the summary should normally reach roughly 80-220 Chinese characters total.
|
|
86
|
-
13. If tool result contains `reply_markdown`, the second reply MUST output that field verbatim and nothing else.
|
|
87
|
-
14. Otherwise the second reply MUST include only Markdown links (short label + full URL target):
|
|
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.
|
|
63
|
+
10. The intro must be based on the actual deliverable content/request, not a fixed sentence like `交付物已上传成功,可直接在线预览或下载。`
|
|
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):
|
|
88
66
|
`预览链接:[点击预览](<full_url>)`
|
|
89
67
|
`下载链接:[点击下载](<full_url>)`
|
|
90
|
-
|
|
68
|
+
13. For multi-file/game deliverables, if the tool gives directory-style output, the second line may be:
|
|
91
69
|
`文件列表:[查看目录](<full_url>)`
|
|
92
70
|
Keep that format instead of forcing a zip link.
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
14. Do NOT only say "已保存到工作空间".
|
|
72
|
+
15. Do NOT append workspace path or a raw URL block after the Markdown links.
|
|
95
73
|
|
|
96
74
|
### Exception
|
|
97
75
|
|