0.1.14 上线前更改
This commit is contained in:
@@ -30,6 +30,7 @@ const safeParseJsonObject = (raw: string): Record<string, unknown> | null => {
|
||||
|
||||
const buildSystemPrompt = (allowedTools: Set<string>, systemContextText?: string) => {
|
||||
const toolLines: string[] = [];
|
||||
const guideLines: string[] = [];
|
||||
if (allowedTools.has("search_web")) {
|
||||
toolLines.push("- search_web:<search_web>{\"query\":\"...\",\"count\":6}</search_web>");
|
||||
}
|
||||
@@ -47,6 +48,45 @@ const buildSystemPrompt = (allowedTools: Set<string>, systemContextText?: string
|
||||
if (allowedTools.has("image_read")) {
|
||||
toolLines.push("- image_read:<image_read>{\"attachmentRef\":\"...\"}</image_read>");
|
||||
}
|
||||
if (allowedTools.has("asset_extract_outline")) {
|
||||
toolLines.push(
|
||||
"- asset_extract_outline:<asset_extract_outline>{\"attachmentRef\":\"...\"}</asset_extract_outline>",
|
||||
);
|
||||
}
|
||||
if (allowedTools.has("asset_to_mindmap")) {
|
||||
toolLines.push(
|
||||
"- asset_to_mindmap:<asset_to_mindmap>{\"mindmapId\":\"...\",\"assetId\":\"...\",\"maxItems\":120,\"reason\":\"...\"}</asset_to_mindmap>",
|
||||
);
|
||||
}
|
||||
if (allowedTools.has("oo_get_selection")) {
|
||||
toolLines.push("- oo_get_selection:<oo_get_selection>{\"format\":\"text\"}</oo_get_selection>");
|
||||
}
|
||||
if (allowedTools.has("oo_replace_selection")) {
|
||||
toolLines.push(
|
||||
"- oo_replace_selection:<oo_replace_selection>{\"text\":\"...\",\"format\":\"text\",\"reason\":\"...\"}</oo_replace_selection>",
|
||||
);
|
||||
}
|
||||
if (allowedTools.has("oo_insert_text")) {
|
||||
toolLines.push("- oo_insert_text:<oo_insert_text>{\"text\":\"...\",\"reason\":\"...\"}</oo_insert_text>");
|
||||
}
|
||||
if (allowedTools.has("oo_insert_html")) {
|
||||
toolLines.push("- oo_insert_html:<oo_insert_html>{\"html\":\"<p>...</p>\",\"reason\":\"...\"}</oo_insert_html>");
|
||||
}
|
||||
if (allowedTools.has("oo_insert_image")) {
|
||||
toolLines.push(
|
||||
"- oo_insert_image:<oo_insert_image>{\"imageRef\":\"...\",\"width\":320,\"height\":180,\"reason\":\"...\"}</oo_insert_image>",
|
||||
);
|
||||
}
|
||||
if (
|
||||
allowedTools.has("oo_get_selection") ||
|
||||
allowedTools.has("oo_replace_selection") ||
|
||||
allowedTools.has("oo_insert_text") ||
|
||||
allowedTools.has("oo_insert_html") ||
|
||||
allowedTools.has("oo_insert_image")
|
||||
) {
|
||||
guideLines.push("- OnlyOffice 增/删/改:先 oo_get_selection 读选区,再用 oo_replace_selection / oo_insert_* 写回。");
|
||||
guideLines.push("- oo_* 属于客户端插件工具:会直接修改当前 OnlyOffice 文档的选区/光标位置。");
|
||||
}
|
||||
if (allowedTools.has("slash_run")) {
|
||||
toolLines.push("- slash_run:<slash_run>{\"text\":\"/new 新页面标题\"}</slash_run>");
|
||||
}
|
||||
@@ -113,8 +153,6 @@ const buildSystemPrompt = (allowedTools: Set<string>, systemContextText?: string
|
||||
if (allowedTools.has("mindmap_expand_node")) {
|
||||
toolLines.push("- mindmap_expand_node:<mindmap_expand_node>{\"targetUid\":\"...\",\"instruction\":\"...\"}</mindmap_expand_node>");
|
||||
}
|
||||
|
||||
const guideLines: string[] = [];
|
||||
guideLines.push("- 先用只读工具定位(需要时再检索),再做最小范围写入。");
|
||||
if (allowedTools.has("search_web")) {
|
||||
guideLines.push("- 需要来源时先 search_web,再把 URL 放进最终回答或写入引用字段。");
|
||||
@@ -128,6 +166,10 @@ const buildSystemPrompt = (allowedTools: Set<string>, systemContextText?: string
|
||||
if (allowedTools.has("image_read")) {
|
||||
guideLines.push("- 需要读图:用 image_read 从 media_assets.ocr_text 获取文字(attachmentRef 可用附件 id/title/url 片段)。");
|
||||
}
|
||||
if (allowedTools.has("asset_extract_outline") || allowedTools.has("asset_to_mindmap")) {
|
||||
guideLines.push("- PDF→导图(M3):先 asset_extract_outline 提取标题层级/页码,再根据需要调用 asset_to_mindmap 落盘到指定 mindmap。");
|
||||
guideLines.push("- 注意:asset_to_mindmap 是写工具,只有在用户明确要求“生成/写入思维导图”时才调用。");
|
||||
}
|
||||
if (allowedTools.has("slash_run")) {
|
||||
guideLines.push("- 需要创建/改名:用 slash_run 执行 /new 或 /rename(这是写工具,只有在用户明确要求时才调用)。");
|
||||
}
|
||||
@@ -160,6 +202,18 @@ const buildSystemPrompt = (allowedTools: Set<string>, systemContextText?: string
|
||||
if (allowedTools.has("slash_run")) {
|
||||
hardRules.push("- slash_run 属于写工具:只有在用户明确要求“创建/改名/执行斜杠命令”时才调用;否则不要擅自创建新文档。");
|
||||
}
|
||||
if (allowedTools.has("asset_to_mindmap")) {
|
||||
hardRules.push("- asset_to_mindmap 属于写工具:只有在用户明确要求“从附件生成/写入思维导图”时才调用;否则不要擅自写入导图。");
|
||||
}
|
||||
if (
|
||||
allowedTools.has("oo_replace_selection") ||
|
||||
allowedTools.has("oo_insert_text") ||
|
||||
allowedTools.has("oo_insert_html") ||
|
||||
allowedTools.has("oo_insert_image")
|
||||
) {
|
||||
hardRules.push("- oo_* 属于写工具:只有在用户明确要求“修改/补全/插入 OnlyOffice 文档内容”时才调用;否则不要擅自改文档。");
|
||||
hardRules.push("- 删除选区:用 oo_replace_selection 且 text 传空字符串。");
|
||||
}
|
||||
if (allowedTools.has("mindmap_apply_ops") || allowedTools.has("mindmap_expand_node")) {
|
||||
hardRules.push("- 涉及思维导图写入时:只能通过 mindmap_* 写工具落盘;不要输出整棵树覆盖。");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user