@dai_ming/plugin-deliverables 1.1.4 → 1.1.5
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/agents-rules/deliverables.md +19 -14
- package/index.js +115 -6
- package/openclaw-plugin.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/skills/deliverables/SKILL.md +7 -7
|
@@ -62,24 +62,29 @@ Tool name note:
|
|
|
62
62
|
7. If the user asks for PDF, upload a `.pdf` deliverable with `type=pdf`; do not substitute HTML or Markdown unless PDF generation truly failed and you clearly say so.
|
|
63
63
|
8. If the upload tool returns an error, retry with valid parameters or report the upload failure. Never invent OSS, preview, or download URLs.
|
|
64
64
|
9. If format is HTML, prefer `type=article` and file name ends with `.html`.
|
|
65
|
-
10.
|
|
66
|
-
11.
|
|
67
|
-
12. If
|
|
68
|
-
13.
|
|
69
|
-
14.
|
|
70
|
-
15.
|
|
71
|
-
16.
|
|
72
|
-
17.
|
|
73
|
-
18.
|
|
74
|
-
19.
|
|
75
|
-
20.
|
|
65
|
+
10. Local file names or relative paths such as `review.html` and `output/report.md` are not links. Do not use `type=link` for them; upload them with `file_path` or `content_text`.
|
|
66
|
+
11. Every single-file deliverable MUST use a file name with an explicit extension.
|
|
67
|
+
12. If format is markdown/text, use `type=article` and `.md`/`.txt`.
|
|
68
|
+
13. If the user did not specify a document/text format, default to Markdown and use a `.md` file name.
|
|
69
|
+
14. 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.
|
|
70
|
+
15. Static multi-file game/site deliverables SHOULD include a root `index.html` so the preview link can open the homepage directly.
|
|
71
|
+
16. 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.
|
|
72
|
+
17. 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.
|
|
73
|
+
18. For content deliverables such as articles, documents, reports, and PDFs, add 3-5 concise bullets after the intro summarizing the actual sections, highlights, or conclusions. Do not reply with only a one-sentence upload notice.
|
|
74
|
+
19. The intro and bullets must be based on the actual deliverable content/request, not a fixed sentence like `交付物已上传成功,可直接在线预览或下载。`
|
|
75
|
+
20. If tool result contains `reply_markdown`, append that field verbatim after your intro and content bullets on the following lines.
|
|
76
|
+
21. Otherwise final reply MUST include Markdown links (short label + full URL target):
|
|
76
77
|
`预览链接:[点击预览](<full_url>)`
|
|
77
78
|
`下载链接:[点击下载](<full_url>)`
|
|
78
|
-
|
|
79
|
+
22. For multi-file/game deliverables, if the tool gives directory-style output, the second line may be:
|
|
79
80
|
`文件列表:[查看目录](<full_url>)`
|
|
80
81
|
Keep that format instead of forcing a zip link.
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
23. Do NOT only say "已保存到工作空间".
|
|
83
|
+
24. Do NOT append workspace path or a raw URL block after the Markdown links.
|
|
84
|
+
25. 群聊场景(消息元数据包含 `is_group_chat == true` 或 `conversation_type == "group"`)调用上传工具时,MUST 传入 `group_id`(取自元数据的 `group_id` 或 `conversation_id`)和 `group_name`(取自元数据的 `group_name` 或 `group_subject`)。
|
|
85
|
+
26. 单聊/私聊场景,不传 `group_id` 或传 `"default"`,不传 `group_name`。
|
|
86
|
+
27. 无法判断会话类型时,若 `resource_id` 存在且不是 `"default"`,将 `resource_id` 作为 `group_id` 传入。
|
|
87
|
+
28. 调用上传工具时 MUST 传入 `user_id`:单聊取 `owner_id`,群聊取 `sender_id`。漏传 `user_id` 会导致 KB 上传失败(error 13002: 用户不存在),尤其在同时传了真实 `group_id` 的场景下。
|
|
83
88
|
|
|
84
89
|
### Exception
|
|
85
90
|
|
package/index.js
CHANGED
|
@@ -63,6 +63,7 @@ const INTERNAL_ABSOLUTE_PATH_RE =
|
|
|
63
63
|
/(?:\/data\/workspace-[^\s`"'<>,。;:、))\]}]+|\/home\/node\/\.openclaw\/workspace(?:-[A-Za-z0-9_.-]+)?\/[^\s`"'<>,。;:、))\]}]+)/gu;
|
|
64
64
|
const INLINE_FILE_REF_RE = /`([^`\n]{1,512}\.[A-Za-z0-9]{1,16})`/gu;
|
|
65
65
|
const OUTPUT_RELATIVE_REF_RE = /(?:^|[\s(::])((?:\.\/)?output\/[^\s`"'<>,。;:、))\]}]+\.[A-Za-z0-9]{1,16})/gu;
|
|
66
|
+
const MARKDOWN_FILE_LINK_RE = /\[[^\]\n]{0,200}\]\(([^)\s]+?\.[A-Za-z0-9]{1,16})\)/gu;
|
|
66
67
|
const FILE_EXTENSION_RE = /\.[A-Za-z0-9]{1,16}$/u;
|
|
67
68
|
const TEXT_EXTENSIONS = new Set([
|
|
68
69
|
".css",
|
|
@@ -121,8 +122,11 @@ const RUNTIME_DELIVERABLES_GUIDANCE = [
|
|
|
121
122
|
"- Every single-file deliverable must use a file name with an explicit extension. If the user did not specify a document/text format, default to Markdown and use a `.md` file name.",
|
|
122
123
|
"- Do not use direct message attachments to deliver generated files. This includes the message tool attachment fields such as `media`, `path`, `filePath`, `buffer`, `attachment`, or similar file-carrying fields.",
|
|
123
124
|
"- Do not emit `MEDIA:` file references for user-facing deliverables. Deliverable links must come from the deliverables upload tool instead.",
|
|
125
|
+
"- Never use `type: \"link\"` for local files, relative paths, or generated files such as `review.html`; use `file_path`, `content_text`, or `files` so the file is uploaded.",
|
|
124
126
|
"- If the deliverables upload tool returns an error, retry with a valid `file_path` or explain the upload failure; never invent or rewrite OSS/download URLs.",
|
|
125
127
|
"- After a successful upload, reply with a substantive content summary before the links. For documents/articles/reports/PDFs, include 1 short intro plus 3-5 concise bullets covering the actual sections, highlights, or findings; never respond with only a generic one-sentence upload notice.",
|
|
128
|
+
"- CRITICAL: In group chats (metadata `is_group_chat == true` or `conversation_type == \"group\"`), you MUST pass `group_id` (from metadata `group_id` or `conversation_id`) and `group_name` (from metadata `group_name` or `group_subject`) to `deliverables__upload_deliverable`. For single/direct chats, omit `group_id` or pass `\"default\"`. Omitting `group_id` in a group chat causes the deliverable to land in the wrong knowledge base.",
|
|
129
|
+
"- CRITICAL: You MUST always pass `user_id` to `deliverables__upload_deliverable`. In single/direct chats, use `owner_id`; in group chats, use `sender_id`. Omitting `user_id` causes KB upload failures (error 13002: 用户不存在) when `group_id` is set to a real group.",
|
|
126
130
|
].join("\n");
|
|
127
131
|
|
|
128
132
|
const UPLOAD_DELIVERABLE_TOOL = {
|
|
@@ -158,7 +162,7 @@ const UPLOAD_DELIVERABLE_TOOL = {
|
|
|
158
162
|
type: {
|
|
159
163
|
type: "string",
|
|
160
164
|
enum: ["article", "game", "zip", "image", "video", "ppt", "pdf", "link"],
|
|
161
|
-
description: "
|
|
165
|
+
description: "交付物类型。link 仅用于外部 http(s) URL;本地/生成文件必须使用 file_path、content_text 或 files。",
|
|
162
166
|
},
|
|
163
167
|
file_name: {
|
|
164
168
|
type: "string",
|
|
@@ -170,7 +174,7 @@ const UPLOAD_DELIVERABLE_TOOL = {
|
|
|
170
174
|
},
|
|
171
175
|
content_text: {
|
|
172
176
|
type: "string",
|
|
173
|
-
description: "文本内容(Markdown、HTML 等)。
|
|
177
|
+
description: "文本内容(Markdown、HTML 等)。",
|
|
174
178
|
},
|
|
175
179
|
content_base64: {
|
|
176
180
|
type: "string",
|
|
@@ -241,6 +245,15 @@ function isURLLike(value) {
|
|
|
241
245
|
return /^[a-z][a-z0-9+.-]*:\/\//i.test(String(value || ""));
|
|
242
246
|
}
|
|
243
247
|
|
|
248
|
+
function isHTTPURLLike(value) {
|
|
249
|
+
try {
|
|
250
|
+
const parsed = new URL(String(value || "").trim());
|
|
251
|
+
return (parsed.protocol === "http:" || parsed.protocol === "https:") && !!parsed.hostname;
|
|
252
|
+
} catch (_err) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
244
257
|
function fileExtension(filePath) {
|
|
245
258
|
return path.extname(stripTrailingPathPunctuation(filePath)).toLowerCase();
|
|
246
259
|
}
|
|
@@ -438,6 +451,9 @@ function extractFileReferencesFromText(text) {
|
|
|
438
451
|
for (const match of normalized.matchAll(OUTPUT_RELATIVE_REF_RE)) {
|
|
439
452
|
add(match[1], match[1], "relative");
|
|
440
453
|
}
|
|
454
|
+
for (const match of normalized.matchAll(MARKDOWN_FILE_LINK_RE)) {
|
|
455
|
+
add(match[0], match[1], "markdown-link");
|
|
456
|
+
}
|
|
441
457
|
return refs;
|
|
442
458
|
}
|
|
443
459
|
|
|
@@ -553,13 +569,87 @@ function payloadResourceId(body) {
|
|
|
553
569
|
}
|
|
554
570
|
|
|
555
571
|
function payloadGroupId(body) {
|
|
556
|
-
|
|
572
|
+
const explicit = extractStringField(body, ["group_id", "groupId"]);
|
|
573
|
+
if (explicit) {
|
|
574
|
+
return explicit;
|
|
575
|
+
}
|
|
576
|
+
const fallback = extractStringField(body, ["resource_id", "resourceId", "conversation_id", "conversationId"]);
|
|
577
|
+
return fallback && fallback !== "default" ? fallback : "";
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function enrichDeliverableGroupContext(event) {
|
|
581
|
+
if (!event || !event.params || typeof event.params !== "object") {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
const existingGroupId = trimString(event.params.group_id);
|
|
585
|
+
if (!existingGroupId) {
|
|
586
|
+
const inferredGroupId = extractContextString(event, [
|
|
587
|
+
"group_id", "groupId", "conversation_id", "conversationId",
|
|
588
|
+
]);
|
|
589
|
+
if (inferredGroupId && inferredGroupId !== "default") {
|
|
590
|
+
event.params.group_id = inferredGroupId;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
const existingGroupName = trimString(event.params.group_name);
|
|
594
|
+
if (!existingGroupName) {
|
|
595
|
+
const inferredGroupName = extractContextString(event, [
|
|
596
|
+
"group_name", "groupName", "group_subject", "groupSubject",
|
|
597
|
+
]);
|
|
598
|
+
if (inferredGroupName) {
|
|
599
|
+
event.params.group_name = inferredGroupName;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
const existingUserId = trimString(event.params.user_id);
|
|
603
|
+
if (!existingUserId || existingUserId === "default") {
|
|
604
|
+
const inferredUserId = extractContextString(event, [
|
|
605
|
+
"sender_id", "senderId", "owner_id", "ownerId", "user_id", "userId",
|
|
606
|
+
]);
|
|
607
|
+
if (inferredUserId && inferredUserId !== "default") {
|
|
608
|
+
event.params.user_id = inferredUserId;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
557
611
|
}
|
|
558
612
|
|
|
559
613
|
function payloadUserId(body) {
|
|
560
614
|
return extractStringField(body, ["user_id", "userId", "sender_id", "senderId", "owner_id", "ownerId"]);
|
|
561
615
|
}
|
|
562
616
|
|
|
617
|
+
function normalizeBareUserID(value) {
|
|
618
|
+
let raw = trimString(value);
|
|
619
|
+
if (!raw) {
|
|
620
|
+
return "";
|
|
621
|
+
}
|
|
622
|
+
if (raw.indexOf("user_") === 0 && raw.indexOf("_lobster_") > 0) {
|
|
623
|
+
raw = raw.slice("user_".length, raw.indexOf("_lobster_"));
|
|
624
|
+
} else if (raw.indexOf("user-") === 0 || raw.indexOf("user_") === 0) {
|
|
625
|
+
raw = raw.slice("user-".length);
|
|
626
|
+
}
|
|
627
|
+
return raw;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function userIDFromRelease(release) {
|
|
631
|
+
return normalizeBareUserID(release);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
function userIDFromResourceID(resourceID) {
|
|
635
|
+
const raw = trimString(resourceID);
|
|
636
|
+
if (raw.indexOf("user_") !== 0 && raw.indexOf("user-") !== 0) {
|
|
637
|
+
return "";
|
|
638
|
+
}
|
|
639
|
+
return normalizeBareUserID(raw);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function deriveReleaseName() {
|
|
643
|
+
let release = process.env.botID || process.env.OPENCLAW_RELEASE || process.env.BOT_ID || "";
|
|
644
|
+
if (!release) {
|
|
645
|
+
const tok = process.env.OPENCLAW_GATEWAY_TOKEN || "";
|
|
646
|
+
if (tok.indexOf("oc-") === 0) {
|
|
647
|
+
release = tok.slice(3);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return release;
|
|
651
|
+
}
|
|
652
|
+
|
|
563
653
|
function isWriteTool(toolName) {
|
|
564
654
|
const normalized = normalizeToolName(toolName);
|
|
565
655
|
return normalized === "write" || normalized.endsWith("__write") || normalized === "write_file" || normalized.endsWith("__write_file");
|
|
@@ -1029,7 +1119,11 @@ function buildNativeUploadRequestBody(args) {
|
|
|
1029
1119
|
if (fileCandidate) {
|
|
1030
1120
|
const stat = safeStat(fileCandidate.path);
|
|
1031
1121
|
const isDirectory = !!(stat && stat.isDirectory());
|
|
1032
|
-
|
|
1122
|
+
const requestedType = trimString(args.type);
|
|
1123
|
+
body.type =
|
|
1124
|
+
requestedType === "link"
|
|
1125
|
+
? deliverableTypeForPath(fileCandidate.path, isDirectory)
|
|
1126
|
+
: requestedType || deliverableTypeForPath(fileCandidate.path, isDirectory);
|
|
1033
1127
|
body.fileName = normalizeDeliverableFileName(args, fileCandidate.fileName);
|
|
1034
1128
|
if (isDirectory) {
|
|
1035
1129
|
const files = collectDirectoryFiles(fileCandidate.path);
|
|
@@ -1049,9 +1143,23 @@ function buildNativeUploadRequestBody(args) {
|
|
|
1049
1143
|
body.fileName = normalizeDeliverableFileName(args, "");
|
|
1050
1144
|
const files = normalizeNativeToolFiles(args && args.files);
|
|
1051
1145
|
if (files.length > 0) {
|
|
1146
|
+
if (body.type === "link") {
|
|
1147
|
+
body.type = "game";
|
|
1148
|
+
}
|
|
1052
1149
|
body.files = files;
|
|
1053
1150
|
return { body, isDirectory: true };
|
|
1054
1151
|
}
|
|
1152
|
+
if (body.type === "link") {
|
|
1153
|
+
const contentText = (args && (args.content_text || args.contentText)) || "";
|
|
1154
|
+
const contentBase64 = (args && (args.content_base64 || args.contentBase64)) || "";
|
|
1155
|
+
if (trimString(contentText) || trimString(contentBase64)) {
|
|
1156
|
+
body.type = deliverableTypeForPath(body.fileName, false);
|
|
1157
|
+
} else if (!isHTTPURLLike(body.fileName)) {
|
|
1158
|
+
throw new Error(
|
|
1159
|
+
"type=link requires file_name to be an absolute http(s) URL; use file_path or content_text for local/generated files",
|
|
1160
|
+
);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1055
1163
|
const contentText = (args && (args.content_text || args.contentText)) || "";
|
|
1056
1164
|
const contentBase64 = (args && (args.content_base64 || args.contentBase64)) || "";
|
|
1057
1165
|
if (body.type === "pdf" && trimString(contentText) && !trimString(contentBase64)) {
|
|
@@ -1066,8 +1174,8 @@ function buildNativeUploadRequestBody(args) {
|
|
|
1066
1174
|
async function uploadDeliverable(args) {
|
|
1067
1175
|
const { body, isDirectory } = buildNativeUploadRequestBody(args || {});
|
|
1068
1176
|
const userId = payloadUserId(args) || "default";
|
|
1069
|
-
const groupId =
|
|
1070
|
-
const groupName =
|
|
1177
|
+
const groupId = payloadGroupId(args) || DEFAULT_GROUP_ID;
|
|
1178
|
+
const groupName = extractStringField(args || {}, ["group_name", "groupName", "group_subject", "groupSubject"]);
|
|
1071
1179
|
const uploadPath = kbUploadPath(groupId, groupName);
|
|
1072
1180
|
const fileBuffers = buildFileBuffersFromBody(body, isDirectory);
|
|
1073
1181
|
const fields = {
|
|
@@ -2060,6 +2168,7 @@ const plugin = {
|
|
|
2060
2168
|
|
|
2061
2169
|
api.on("before_tool_call", async (event) => {
|
|
2062
2170
|
if (isDeliverablesUploadTool(event.toolName)) {
|
|
2171
|
+
enrichDeliverableGroupContext(event);
|
|
2063
2172
|
cacheUploadSummary(event.params);
|
|
2064
2173
|
return;
|
|
2065
2174
|
}
|
package/openclaw-plugin.json
CHANGED
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "plugin-deliverables",
|
|
3
3
|
"name": "Deliverables",
|
|
4
4
|
"description": "Deliverables runtime guard for upload-first file delivery with Palz split-send diagnostics.",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.5",
|
|
6
6
|
"skills": ["./skills"],
|
|
7
7
|
"configSchema": {
|
|
8
8
|
"type": "object",
|
package/package.json
CHANGED
|
@@ -28,25 +28,25 @@ description: 上传AI生成的文件到交付物系统,返回可分享的预
|
|
|
28
28
|
|
|
29
29
|
| 参数 | 必填 | 取值来源 | 示例 |
|
|
30
30
|
|------|------|---------|------|
|
|
31
|
-
| `user_id` |
|
|
31
|
+
| `user_id` | **是(必传)** | 单聊取 `owner_id`,群聊取 `sender_id`。**不可省略**,否则 KB 上传报错 13002 | `cbb0fab9...` |
|
|
32
32
|
| `group_id` | 群聊时必填 | 群聊取消息元数据中的 `group_id`;**单聊不传**(自动为 `default`) | `grp_43c75713` |
|
|
33
33
|
| `group_name` | 群聊时必填 | 群聊取消息元数据中的群聊名称;**单聊不传** | `项目讨论群` |
|
|
34
|
-
| `type` | 是 | 根据内容选择:`article`/`game`/`image`/`video`/`ppt`/`pdf`/`zip
|
|
34
|
+
| `type` | 是 | 根据内容选择:`article`/`game`/`image`/`video`/`ppt`/`pdf`/`zip`;`link` 仅用于外部 `http(s)` URL | `article` |
|
|
35
35
|
| `file_name` | 是 | 有意义的文件名,单文件必须含扩展名;若用户未指定文档格式,默认用 `.md` | `report-2026.html` |
|
|
36
|
-
| `content_text` | 按需 | 文件的完整文本内容(HTML/Markdown
|
|
36
|
+
| `content_text` | 按需 | 文件的完整文本内容(HTML/Markdown等) | `<html>...</html>` |
|
|
37
37
|
| `file_path` | 按需 | PDF/PPT/图片/zip 等二进制文件的本地路径,推荐使用,避免手工复制 base64 | `output/sample.pdf` |
|
|
38
38
|
|
|
39
39
|
> **单聊(direct chat)**:`user_id` 填 `owner_id`,不传 `group_id` 和 `group_name`。
|
|
40
40
|
> **群聊(group chat)**:`user_id` 填 `sender_id`,`group_id` 和 `group_name` 从群聊元数据获取。
|
|
41
|
+
> **⚠ 警告**:`user_id` 必须传入真实值。当 `group_id` 是真实群 ID 但 `user_id` 缺失或为 `"default"` 时,KB 后端会返回 `500: 用户不存在`。
|
|
41
42
|
|
|
42
43
|
## 二进制文件上传(强制)
|
|
43
44
|
|
|
44
|
-
-
|
|
45
|
-
- 已经生成好的 PDF、PPT、图片、视频、zip 等二进制文件必须优先传 `file_path`,不要把 `base64` 命令输出复制到 `content_base64`。
|
|
45
|
+
- PDF、PPT、图片、视频、zip 等二进制文件必须优先传 `file_path`,不要把 `base64` 命令输出复制到 `content_base64`。
|
|
46
46
|
- `file_path` 指向你已经写入 `output/` 的文件,例如 `output/sample.pdf`;上传工具会读取文件并自动编码。
|
|
47
|
-
-
|
|
48
|
-
- 用户要求 PDF 时,必须上传 `.pdf` 交付物,`type` 使用 `pdf`;不要只返回 HTML/Markdown 作为替代格式。
|
|
47
|
+
- 用户要求 PDF 时,必须上传生成好的 `.pdf` 文件,`type` 使用 `pdf`;不要只返回 HTML/Markdown 作为替代格式。
|
|
49
48
|
- 如果上传工具返回错误,必须修正参数后重试,或明确告诉用户上传失败;禁止编造 OSS、下载或预览链接。
|
|
49
|
+
- 本地文件名或相对路径(例如 `review.html`、`output/report.md`)不是外部链接,不能用 `type=link`;必须用 `file_path` 或 `content_text` 上传。
|
|
50
50
|
|
|
51
51
|
## 多文件(游戏)
|
|
52
52
|
|