pi-web-ui 0.114.3 → 0.116.0
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/CHANGELOG.md +62 -1
- package/bin/pi-web-ui.mjs +90 -8
- package/dist/gh-comment-781.md +5 -0
- package/dist/server/agent-service-daemon.js +522 -32
- package/dist/server/agent-service.js +954 -402
- package/dist/server/canvas/canvas-dispatch.js +13 -1
- package/dist/server/client-state.js +42 -2
- package/dist/server/communicate-tool.js +2 -0
- package/dist/server/conversation-communication.js +14 -0
- package/dist/server/conversation-identity.js +27 -0
- package/dist/server/device-center/approval-summary.js +31 -0
- package/dist/server/device-center/bot-catalog.js +21 -7
- package/dist/server/device-center/bot-execution.js +100 -9
- package/dist/server/device-center/bot-presets.js +46 -0
- package/dist/server/device-center/collab-service.js +362 -13
- package/dist/server/device-center/collab-tool.js +824 -13
- package/dist/server/device-center/connector.js +359 -23
- package/dist/server/device-center/desktop-page.js +22 -16
- package/dist/server/device-center/device-integration.js +595 -0
- package/dist/server/device-center/execution-guides.js +32 -0
- package/dist/server/device-center/execution-instructions.js +20 -0
- package/dist/server/device-center/execution-settings.js +213 -0
- package/dist/server/device-center/execution-system-prompt.js +38 -0
- package/dist/server/device-center/execution-workspace.js +20 -0
- package/dist/server/device-center/executor.js +392 -40
- package/dist/server/device-center/file-sync-paths.js +171 -0
- package/dist/server/device-center/file-sync.js +186 -96
- package/dist/server/device-center/group-context-delta.js +37 -0
- package/dist/server/device-center/group-context-message.js +210 -0
- package/dist/server/device-center/group-context.js +179 -0
- package/dist/server/device-center/group-events.js +136 -0
- package/dist/server/device-center/group-plan-guard.js +138 -0
- package/dist/server/device-center/hub-conversations.js +233 -0
- package/dist/server/device-center/hub-deliveries.js +277 -0
- package/dist/server/device-center/hub-integration.js +451 -0
- package/dist/server/device-center/hub-locks.js +320 -0
- package/dist/server/device-center/hub-page.js +13 -33
- package/dist/server/device-center/hub-webhooks.js +165 -0
- package/dist/server/device-center/hub.js +2379 -107
- package/dist/server/device-center/human-interaction.js +232 -0
- package/dist/server/device-center/integration-errors.js +25 -0
- package/dist/server/device-center/local-hub.js +20 -1
- package/dist/server/device-center/local-page.js +17 -0
- package/dist/server/device-center/local.js +430 -41
- package/dist/server/device-center/main.js +11 -1
- package/dist/server/device-center/partition-log.js +293 -0
- package/dist/server/device-center/path-portal.js +11 -3
- package/dist/server/device-center/relay.js +364 -35
- package/dist/server/device-center/report-metadata.js +66 -0
- package/dist/server/device-center/report-upload.js +63 -0
- package/dist/server/device-center/runtime.js +598 -41
- package/dist/server/device-center/smoke-preview.js +3 -0
- package/dist/server/device-center/store.js +203 -41
- package/dist/server/device-center/task-context-budget.js +161 -0
- package/dist/server/device-center/task-journal.js +385 -0
- package/dist/server/device-center/task-plan.js +33 -0
- package/dist/server/device-center/task-progress.js +141 -0
- package/dist/server/device-center/task-recovery.js +452 -0
- package/dist/server/device-center/task-report-outbox.js +216 -0
- package/dist/server/device-center/task-report.js +384 -0
- package/dist/server/device-center/task-scheduler.js +445 -0
- package/dist/server/device-center/task-state.js +333 -0
- package/dist/server/device-center/transfer-stream.js +1006 -0
- package/dist/server/device-center/transfers.js +841 -8
- package/dist/server/dispatch-domain-handlers.js +35 -6
- package/dist/server/dsh/dsh-agent-service.js +6 -0
- package/dist/server/durable/durable-capabilities.js +11 -0
- package/dist/server/engine-probe.js +112 -1
- package/dist/server/global-loader.js +119 -19
- package/dist/server/goal-service.js +10 -5
- package/dist/server/index.js +222 -29
- package/dist/server/managed.js +2 -0
- package/dist/server/markers/builtins/services.js +123 -0
- package/dist/server/markers/builtins/todo.js +189 -0
- package/dist/server/markers-list-tool.js +34 -0
- package/dist/server/message-deletion.js +40 -0
- package/dist/server/message-window.js +9 -0
- package/dist/server/model-admin.js +48 -6
- package/dist/server/model-enrich.js +10 -1
- package/dist/server/orchestrator.js +109 -0
- package/dist/server/patch-executable-lookup.js +396 -0
- package/dist/server/payload-limits.js +2 -0
- package/dist/server/plugin-llm.js +100 -9
- package/dist/server/plugins.js +65 -7
- package/dist/server/preset-fields.js +24 -0
- package/dist/server/preset-share.js +2 -0
- package/dist/server/prompt-base-store.js +85 -0
- package/dist/server/prompt-composer.js +44 -2
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/protocol.js +2 -2
- package/dist/server/reasoning-registry.js +207 -0
- package/dist/server/remote-ssh-service.js +22 -9
- package/dist/server/resolve-global-sdk.js +2 -0
- package/dist/server/session-search.js +1 -1
- package/dist/server/settings-service.js +90 -39
- package/dist/server/skill-content-filler.js +29 -8
- package/dist/server/skill-tool.js +12 -3
- package/dist/server/startup-banner.js +35 -0
- package/dist/server/subagent-helpers.js +4 -1
- package/dist/server/subagents.js +52 -37
- package/dist/server/system-prompt-soul.js +41 -0
- package/dist/server/tool-host-factories.js +1 -0
- package/dist/server/tool-manager.js +17 -9
- package/dist/server/unauthorized-page.js +319 -0
- package/dist/server/univer-service.js +448 -0
- package/dist/server/universal/drivers/dsh-driver.js +379 -0
- package/dist/server/universal/universal-session.js +5 -0
- package/dist/server/webui-context.js +25 -5
- package/dist/test-artifact.md +9 -0
- package/dist/test-preview-modal.md +11 -0
- package/dist/test-report.html +20 -0
- package/docs/README.md +94 -0
- package/docs/architecture-plugins.md +946 -0
- package/docs/device-center.md +106 -12
- package/docs/dsh-engine.md +10 -10
- package/extensions/webui.ts +43 -1
- package/package.json +2 -1
- package/themes/aetheris.css +5 -0
- package/themes/ayu-light.css +6 -0
- package/themes/bases/flow-base.css +68 -68
- package/themes/catppuccin-latte.css +6 -0
- package/themes/catppuccin.css +6 -0
- package/themes/claude-code-dark.css +5 -0
- package/themes/codex.css +6 -0
- package/themes/cyberpunk.css +6 -0
- package/themes/dark-teal.css +6 -1
- package/themes/dazzle.css +6 -0
- package/themes/everforest-light.css +6 -0
- package/themes/flow-light.css +8 -1
- package/themes/flow.css +6 -1
- package/themes/geist.css +6 -0
- package/themes/gruvbox-light.css +6 -0
- package/themes/kanagawa-lotus.css +6 -0
- package/themes/md-preview.css +6 -0
- package/themes/mist.css +6 -0
- package/themes/nord.css +6 -0
- package/themes/one-dark.css +6 -0
- package/themes/paper.css +6 -0
- package/themes/rose-pine-dawn.css +6 -0
- package/themes/sakura.css +6 -0
- package/themes/solarized-light.css +6 -0
- package/themes/tokyo-night.css +6 -0
- package/themes/translucent.css +6 -0
- package/themes/transparent.css +6 -0
- package/themes/vs-code-dark.css +5 -0
- package/themes/wallpaper-flow.css +5 -1
- package/themes/wallpaper-obsidian.css +6 -0
- package/themes/white.css +6 -0
- package/themes/zhujian-dark.css +6 -1
- package/themes/zhujian.css +6 -1
- package/themes/zhupi-dark.css +6 -1
- package/themes/zhupi.css +6 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/BgTasksModal-BDoOpj-F.js +1 -0
- package/web/dist/assets/BgTasksModal-C0i3O1FT.js +1 -0
- package/web/dist/assets/{CanvasStudio-BSg9ghPV.js → CanvasStudio-B8thymBN.js} +3 -3
- package/web/dist/assets/{CanvasStudio-DxW7C3Sz.js → CanvasStudio-zSxyIx1R.js} +3 -3
- package/web/dist/assets/DeviceCenter-DfAHKcid.js +3 -0
- package/web/dist/assets/DeviceCenter-ydvOTlzE.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +1 -0
- package/web/dist/assets/DeviceGroups-CI14_SRb.js +1 -0
- package/web/dist/assets/DeviceGroups-DvsB5IEU.js +1 -0
- package/web/dist/assets/Dropdown-C4LIhshN.js +1 -0
- package/web/dist/assets/FilePreview-BgGongmv.js +2 -0
- package/web/dist/assets/FilePreview-D4NrhF-U.js +2 -0
- package/web/dist/assets/GlobalSearchModal-BWgU8yPd.js +1 -0
- package/web/dist/assets/GlobalSearchModal-F7fNimKk.js +1 -0
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +17 -0
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +17 -0
- package/web/dist/assets/HintTip-c6d0TJoh.js +1 -0
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +2 -0
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +2 -0
- package/web/dist/assets/PiSetupModal-BmMrrgB9.js +1 -0
- package/web/dist/assets/ProviderOAuthControls-BGSBIKD7.js +1 -0
- package/web/dist/assets/SCMPanel-B8_EDxNr.js +2 -0
- package/web/dist/assets/SCMPanel-BU58qk3T.js +2 -0
- package/web/dist/assets/SettingsModal-CMUybq3J.js +32 -0
- package/web/dist/assets/SettingsModal-OBmGTh-5.js +32 -0
- package/web/dist/assets/TerminalPanel-0CYvD72B.js +3 -0
- package/web/dist/assets/TerminalPanel-DDavKvFr.js +3 -0
- package/web/dist/assets/TuiOverlayModal-BsA-QTvN.js +1 -0
- package/web/dist/assets/TuiOverlayModal-DzoVQBuG.js +1 -0
- package/web/dist/assets/app-globals-CZxzGvIo.js +123 -0
- package/web/dist/assets/canvas-client-CUnXlQYX.js +1 -0
- package/web/dist/assets/{desktop-7EvUHhKQ.js → desktop-aAKpvKJV.js} +1 -1
- package/web/dist/assets/group-view-state-CGCzYF8k.js +1 -0
- package/web/dist/assets/index-C6DwztqE.css +1 -0
- package/web/dist/assets/index-CuN802Sj.js +93 -0
- package/web/dist/assets/index-EH5Fw9fa.js +93 -0
- package/web/dist/assets/plugin-host-BRWib9DF.js +1 -0
- package/web/dist/assets/remote-ssh-client-CfYSMEZg.js +1 -0
- package/web/dist/assets/theme-D2l_mLNo.js +1 -0
- package/web/dist/index.html +10 -9
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/BgTasksModal-BvnUHjFe.js +0 -1
- package/web/dist/assets/BgTasksModal-DSC8ncW3.js +0 -1
- package/web/dist/assets/DeviceCenter-Bmgr-Bwm.js +0 -3
- package/web/dist/assets/DeviceCenter-Cl9MBXaH.js +0 -3
- package/web/dist/assets/DeviceGroups-aeLD2msl.js +0 -1
- package/web/dist/assets/Dropdown-D1Jl35dw.js +0 -1
- package/web/dist/assets/FilePreview-6CqoDF_P.js +0 -2
- package/web/dist/assets/FilePreview-CJa27G_Q.js +0 -2
- package/web/dist/assets/GlobalSearchModal-CJX35rZL.js +0 -1
- package/web/dist/assets/GlobalSearchModal-CMW0xz0P.js +0 -1
- package/web/dist/assets/GroupConversation-Cq4daBFb.js +0 -1
- package/web/dist/assets/GroupConversation-DoELa83U.js +0 -1
- package/web/dist/assets/ModelConfigModal-Bp7tfKYh.js +0 -2
- package/web/dist/assets/PiSetupModal-DD8srwBJ.js +0 -1
- package/web/dist/assets/ProviderOAuthControls-C6tfXb88.js +0 -1
- package/web/dist/assets/SCMPanel-CghgsyBN.js +0 -2
- package/web/dist/assets/SCMPanel-D8-8aqwC.js +0 -2
- package/web/dist/assets/SettingsModal-BbBe2rYo.js +0 -20
- package/web/dist/assets/SettingsModal-qETiVPKj.js +0 -20
- package/web/dist/assets/TerminalPanel-Da-Xs4Wk.js +0 -3
- package/web/dist/assets/TerminalPanel-DnS4tFQO.js +0 -3
- package/web/dist/assets/TuiOverlayModal-CGyGkKYl.js +0 -1
- package/web/dist/assets/TuiOverlayModal-CpBKjG6x.js +0 -1
- package/web/dist/assets/app-globals-DcyO0UPi.js +0 -1
- package/web/dist/assets/fi-NyN-ZrgD.js +0 -325
- package/web/dist/assets/index-DK3F5ZJo.js +0 -85
- package/web/dist/assets/index-DQMii2he.js +0 -85
- package/web/dist/assets/index-vwBnwzkr.css +0 -1
- package/web/dist/assets/plugin-host-BCnX3P8U.js +0 -1
- package/web/dist/assets/theme-D2DMH6tH.js +0 -1
package/dist/server/subagents.js
CHANGED
|
@@ -130,6 +130,9 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
130
130
|
// (按 runtime 身份查当前持有方),不能死用建时的旧 id —— 否则 wait_all
|
|
131
131
|
// 排除自省/展开后代时拿错锚点。传函数形式由建时点按 findConversationHome 解析。
|
|
132
132
|
const selfIdOf = () => (typeof selfConvId === "function" ? selfConvId() : selfConvId);
|
|
133
|
+
const executionOf = (snapshot) => snapshot.executionId ?? snapshot.convId;
|
|
134
|
+
const executionOfId = (id) => host.getSubagent(id)?.executionId ?? id;
|
|
135
|
+
const parentOf = (snapshot) => snapshot.executionId ? snapshot.parentExecutionId : snapshot.parentId;
|
|
133
136
|
const getLang = lang ?? host.lang ?? (() => "en");
|
|
134
137
|
const text = (t, details = {}) => ({
|
|
135
138
|
content: [{ type: "text", text: t }],
|
|
@@ -141,25 +144,26 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
141
144
|
const expandDescendants = (roots) => {
|
|
142
145
|
if (roots instanceof Set ? roots.size === 0 : roots.length === 0)
|
|
143
146
|
return [];
|
|
144
|
-
const rootSet =
|
|
147
|
+
const rootSet = new Set([...roots].map(executionOfId));
|
|
145
148
|
// B20:带 forSelfId(本会话的族)展开 —— 过户把整族搬到别的会话后,
|
|
146
149
|
// 只列本会话自己的列表会展不开后代,wait_all 会误报「没有需要等待的子代理」。
|
|
147
150
|
const all = host.listSubagents(undefined, selfIdOf());
|
|
148
151
|
const out = [];
|
|
149
152
|
for (const s of all) {
|
|
150
|
-
if (rootSet.has(s
|
|
153
|
+
if (rootSet.has(executionOf(s)))
|
|
151
154
|
continue;
|
|
152
|
-
let curParent = s
|
|
155
|
+
let curParent = parentOf(s);
|
|
153
156
|
const seen = new Set();
|
|
154
157
|
while (curParent) {
|
|
155
|
-
if (rootSet.has(curParent)) {
|
|
156
|
-
out.push(s
|
|
158
|
+
if (rootSet.has(executionOfId(curParent))) {
|
|
159
|
+
out.push(executionOf(s));
|
|
157
160
|
break;
|
|
158
161
|
}
|
|
159
162
|
if (seen.has(curParent))
|
|
160
163
|
break;
|
|
161
164
|
seen.add(curParent);
|
|
162
|
-
|
|
165
|
+
const parent = host.getSubagent(curParent);
|
|
166
|
+
curParent = parent ? parentOf(parent) : undefined;
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
return out;
|
|
@@ -168,15 +172,16 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
168
172
|
const target = host.getSubagent(targetId);
|
|
169
173
|
if (!target)
|
|
170
174
|
return false;
|
|
171
|
-
let curParent = target
|
|
175
|
+
let curParent = parentOf(target);
|
|
172
176
|
const seen = new Set([targetId]);
|
|
173
177
|
while (curParent) {
|
|
174
|
-
if (curParent === rootId)
|
|
178
|
+
if (executionOfId(curParent) === executionOfId(rootId))
|
|
175
179
|
return true;
|
|
176
180
|
if (seen.has(curParent))
|
|
177
181
|
break;
|
|
178
182
|
seen.add(curParent);
|
|
179
|
-
|
|
183
|
+
const parent = host.getSubagent(curParent);
|
|
184
|
+
curParent = parent ? parentOf(parent) : undefined;
|
|
180
185
|
}
|
|
181
186
|
return false;
|
|
182
187
|
};
|
|
@@ -184,12 +189,13 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
184
189
|
let d = 0;
|
|
185
190
|
let cur = host.getSubagent(targetId);
|
|
186
191
|
const seen = new Set([targetId]);
|
|
187
|
-
while (cur
|
|
188
|
-
|
|
192
|
+
while (cur && parentOf(cur)) {
|
|
193
|
+
const parentId = parentOf(cur);
|
|
194
|
+
if (seen.has(parentId))
|
|
189
195
|
break;
|
|
190
|
-
seen.add(
|
|
196
|
+
seen.add(parentId);
|
|
191
197
|
d++;
|
|
192
|
-
cur = host.getSubagent(
|
|
198
|
+
cur = host.getSubagent(parentId);
|
|
193
199
|
if (!cur)
|
|
194
200
|
break;
|
|
195
201
|
}
|
|
@@ -438,6 +444,8 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
438
444
|
error: msg,
|
|
439
445
|
}));
|
|
440
446
|
}
|
|
447
|
+
const executionId = host.getSubagent(convId)?.executionId;
|
|
448
|
+
const addressLine = executionId ? `\nrunId: ${executionId}` : "";
|
|
441
449
|
const subagentTitleText = subagentTitle(p.prompt);
|
|
442
450
|
const templateLineZh = templateName ? `\n模板:${templateName}` : "";
|
|
443
451
|
const templateLineEn = templateName ? `\nTemplate: ${templateName}` : "";
|
|
@@ -451,8 +459,8 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
451
459
|
const isolationLineEn = isolationMode === "worktree" ? "\nWorktree isolation: enabled (dedicated Git worktree & branch)" : "";
|
|
452
460
|
const kindLabelZh = p.persist ? "普通持久化对话" : "子代理";
|
|
453
461
|
const kindLabelEn = p.persist ? "Persistent conversation" : "Subagent";
|
|
454
|
-
return text(pick(getLang(), `${kindLabelZh}已启动(运行列表可见):${convId}\n类型:${subagentType} · 标题:${subagentTitleText}${templateLineZh}${modelLineZh}${thinkingLineZh}${notifyLineZh}${isolationLineZh}` +
|
|
455
|
-
`\n用 subagent(action="wait_all") 一次等全部完成(不用轮询),subagent(action="get_result") 取单个结果,subagent(action="list") 看运行态,subagent(action="steer") 改向,subagent(action="stop") 停止。`, `${kindLabelEn} started (visible in the running list): ${convId}\nType: ${subagentType} · Title: ${subagentTitleText}${templateLineEn}${modelLineEn}${thinkingLineEn}${notifyLineEn}${isolationLineEn}` +
|
|
462
|
+
return text(pick(getLang(), `${kindLabelZh}已启动(运行列表可见):${convId}\n类型:${subagentType} · 标题:${subagentTitleText}${templateLineZh}${modelLineZh}${thinkingLineZh}${notifyLineZh}${isolationLineZh}${addressLine}` +
|
|
463
|
+
`\n用 subagent(action="wait_all") 一次等全部完成(不用轮询),subagent(action="get_result") 取单个结果,subagent(action="list") 看运行态,subagent(action="steer") 改向,subagent(action="stop") 停止。`, `${kindLabelEn} started (visible in the running list): ${convId}\nType: ${subagentType} · Title: ${subagentTitleText}${templateLineEn}${modelLineEn}${thinkingLineEn}${notifyLineEn}${isolationLineEn}${addressLine}` +
|
|
456
464
|
`\nUse subagent(action="wait_all") to wait for all at once (no polling), subagent(action="get_result") for a single result, subagent(action="list") for live status, subagent(action="steer") to redirect, subagent(action="stop") to stop.`, "subagents.spawn.started", {
|
|
457
465
|
convId,
|
|
458
466
|
subagentType,
|
|
@@ -475,6 +483,7 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
475
483
|
kindLabelZh,
|
|
476
484
|
}), {
|
|
477
485
|
convId,
|
|
486
|
+
executionId,
|
|
478
487
|
template: p.template,
|
|
479
488
|
model: p.model,
|
|
480
489
|
thinking: p.thinking,
|
|
@@ -502,10 +511,11 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
502
511
|
return text(pick(getLang(), `子代理 ${runningId}(${r.type}${modelTag})仍在运行(状态 ${r.state})。\n当前输出:\n${runningOutput}`, `Subagent ${runningId} (${r.type}${modelTag}) is still running (state ${r.state}).\nCurrent output:\n${runningOutput}`, "subagents.get.running", { runningId, "r.type": r.type, modelTag, "r.state": r.state, runningOutput }), r);
|
|
503
512
|
}
|
|
504
513
|
// 终态结果被父对话取走,标记已消费,避免后续重复触发自动通知
|
|
505
|
-
|
|
514
|
+
const targetAddress = executionOf(r);
|
|
515
|
+
host.markSubagentsConsumed?.([targetAddress]);
|
|
506
516
|
if (host.finalizeSubagentWorktree) {
|
|
507
|
-
await host.finalizeSubagentWorktree(
|
|
508
|
-
r = host.getSubagent(
|
|
517
|
+
await host.finalizeSubagentWorktree(targetAddress);
|
|
518
|
+
r = host.getSubagent(targetAddress) ?? r;
|
|
509
519
|
}
|
|
510
520
|
let worktreeDetail = "";
|
|
511
521
|
if (r.worktree) {
|
|
@@ -530,7 +540,7 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
530
540
|
const missingSteerId = shortId(p.runId);
|
|
531
541
|
return text(pick(getLang(), `未找到子代理 ${missingSteerId}(可能已移出),消息未注入。请用 subagent(action="list") 确认仍在运行的子代理。`, `Subagent ${missingSteerId} not found (may have been dismissed); message not injected. Use subagent(action="list") to confirm running subagents.`, "subagents.steer.not.found", { missingSteerId }));
|
|
532
542
|
}
|
|
533
|
-
await host.steerSubagent(p.runId, p.message);
|
|
543
|
+
await host.steerSubagent(executionOfId(p.runId), p.message);
|
|
534
544
|
const steerId = shortId(p.runId);
|
|
535
545
|
return text(pick(getLang(), `已向子代理 ${steerId} 注入消息。`, `Message injected into subagent ${steerId}.`, "subagents.steer.injected", { steerId }));
|
|
536
546
|
}
|
|
@@ -548,7 +558,7 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
548
558
|
? "子代理"
|
|
549
559
|
: "subagent";
|
|
550
560
|
const modelTag = r.model ? ` · ${r.model}${r.thinkingLevel ? `:${r.thinkingLevel}` : ""}` : "";
|
|
551
|
-
return (`- ${r.convId} · ${r.type}${modelTag} · ${subagentVerdict(r, tLang)} · ${r.title}` +
|
|
561
|
+
return (`- ${r.convId}${r.executionId ? ` (runId: ${r.executionId})` : ""} · ${r.type}${modelTag} · ${subagentVerdict(r, tLang)} · ${r.title}` +
|
|
552
562
|
(tLang === "zh" ? `(${tag} · msg: ${r.messageCount})` : ` (${tag} · msg: ${r.messageCount})`));
|
|
553
563
|
});
|
|
554
564
|
return text(lines.join("\n"));
|
|
@@ -566,15 +576,18 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
566
576
|
return text(pick(getLang(), `已请求停止子代理 ${stopId}。`, `Stop requested for subagent ${stopId}.`, "subagents.stop.requested", { stopId }));
|
|
567
577
|
}
|
|
568
578
|
case "wait_all": {
|
|
569
|
-
const
|
|
579
|
+
const selfAddress = selfIdOf();
|
|
580
|
+
const selfId = selfAddress ? executionOfId(selfAddress) : undefined;
|
|
570
581
|
const ancestorIdsOf = (selfId) => {
|
|
571
582
|
const out = new Set();
|
|
572
583
|
const seen = new Set([selfId]);
|
|
573
|
-
|
|
584
|
+
const snapshot = host.getSubagent(selfAddress ?? selfId);
|
|
585
|
+
let cur = snapshot ? parentOf(snapshot) : undefined;
|
|
574
586
|
while (cur && !seen.has(cur)) {
|
|
575
587
|
seen.add(cur);
|
|
576
|
-
out.add(cur);
|
|
577
|
-
|
|
588
|
+
out.add(executionOfId(cur));
|
|
589
|
+
const parent = host.getSubagent(cur);
|
|
590
|
+
cur = parent ? parentOf(parent) : undefined;
|
|
578
591
|
}
|
|
579
592
|
return out;
|
|
580
593
|
};
|
|
@@ -583,7 +596,8 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
583
596
|
const selfAncestorIds = selfId ? ancestorIdsOf(selfId) : new Set();
|
|
584
597
|
if (explicit) {
|
|
585
598
|
const seedRoots = [];
|
|
586
|
-
for (const
|
|
599
|
+
for (const requestedId of p.runIds) {
|
|
600
|
+
const id = executionOfId(requestedId);
|
|
587
601
|
if (selfId && id === selfId)
|
|
588
602
|
continue;
|
|
589
603
|
if (selfAncestorIds.has(id))
|
|
@@ -610,7 +624,7 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
610
624
|
}
|
|
611
625
|
else {
|
|
612
626
|
for (const r of host.listSubagents()) {
|
|
613
|
-
wanted.add(r
|
|
627
|
+
wanted.add(executionOf(r));
|
|
614
628
|
}
|
|
615
629
|
}
|
|
616
630
|
if (selfId)
|
|
@@ -628,7 +642,8 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
628
642
|
if (!liveKeys.has(key))
|
|
629
643
|
deliveredConsults.delete(key);
|
|
630
644
|
}
|
|
631
|
-
const requests = pending.filter((r) => !deliveredConsults.has(consultKey(parentId, r.runId, r.requestId))
|
|
645
|
+
const requests = pending.filter((r) => !deliveredConsults.has(consultKey(parentId, r.runId, r.requestId)) &&
|
|
646
|
+
!host.isRequestSteering?.(parentId, r.requestId));
|
|
632
647
|
if (requests.length === 0)
|
|
633
648
|
return;
|
|
634
649
|
for (const r of requests)
|
|
@@ -786,7 +801,7 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
786
801
|
return text(pick(getLang(), `未找到目标子代理 ${missingId}(可能已移出或不存在)。请用 subagent(action="list") 确认可用的子代理。`, `Target subagent ${missingId} not found (may have been dismissed or non-existent). Use subagent(action="list") to check available subagents.`, "subagents.handoff.not.found", { missingId }));
|
|
787
802
|
}
|
|
788
803
|
try {
|
|
789
|
-
await host.handoffSubagent(fromId,
|
|
804
|
+
await host.handoffSubagent(fromId, executionOf(target), p.payload);
|
|
790
805
|
const fromShort = shortId(fromId);
|
|
791
806
|
const toShort = shortId(p.toRunId);
|
|
792
807
|
return text(pick(getLang(), `已成功将产物交接给同行子代理 ${toShort}(${target.type}),协同路由已建立并开始执行。`, `Successfully handed off payload to peer subagent ${toShort} (${target.type}); peer routing established and executing.`, "subagents.handoff.success", { from: fromShort, to: toShort, type: target.type }), { fromRunId: fromId, toRunId: p.toRunId, timestamp: Date.now() });
|
|
@@ -823,28 +838,28 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
823
838
|
let inScopeList = all;
|
|
824
839
|
if (selfId) {
|
|
825
840
|
const descIds = new Set(expandDescendants(new Set([selfId])));
|
|
826
|
-
inScopeList = all.filter((s) => descIds.has(s
|
|
841
|
+
inScopeList = all.filter((s) => descIds.has(executionOf(s)));
|
|
827
842
|
}
|
|
828
843
|
// 口径与 finishedSubagentCount 一致:isSubagent、非 streaming、非当前 active
|
|
829
844
|
candidateIds = inScopeList
|
|
830
845
|
.filter((s) => {
|
|
831
846
|
if (s.streaming || s.state === "running")
|
|
832
847
|
return false;
|
|
833
|
-
if (s
|
|
848
|
+
if (selfId && executionOf(s) === executionOfId(selfId))
|
|
834
849
|
return false;
|
|
835
|
-
if (activeConvId && s
|
|
850
|
+
if (activeConvId && executionOf(s) === executionOfId(activeConvId))
|
|
836
851
|
return false;
|
|
837
852
|
if (s.persisted && !p.includePersisted)
|
|
838
853
|
return false;
|
|
839
854
|
return true;
|
|
840
855
|
})
|
|
841
|
-
.map(
|
|
856
|
+
.map(executionOf);
|
|
842
857
|
if (candidateIds.length === 0) {
|
|
843
858
|
return text(pick(getLang(), "没有可移出的已结束子代理。", "No finished subagents to dismiss.", "subagents.dismiss.finished_all.empty"), { dismissed: [], skipped: [] });
|
|
844
859
|
}
|
|
845
860
|
}
|
|
846
861
|
else {
|
|
847
|
-
candidateIds = [...new Set(explicitIds)];
|
|
862
|
+
candidateIds = [...new Set(explicitIds.map(executionOfId))];
|
|
848
863
|
}
|
|
849
864
|
const isSingleExplicit = !isFinishedAll && explicitIds.length === 1;
|
|
850
865
|
if (isSingleExplicit) {
|
|
@@ -854,10 +869,10 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
854
869
|
const missingId = shortId(targetId);
|
|
855
870
|
return text(pick(getLang(), `未找到子代理 ${missingId}(可能已移出或不存在)。`, `Subagent ${missingId} not found (may have been dismissed or non-existent).`, "subagents.dismiss.not_found", { missingId }));
|
|
856
871
|
}
|
|
857
|
-
if (selfId && targetId === selfId) {
|
|
872
|
+
if (selfId && executionOfId(targetId) === executionOfId(selfId)) {
|
|
858
873
|
return text(pick(getLang(), "拒绝移出:不能移出当前会话自身。", "Refused: cannot dismiss the current conversation itself.", "subagents.dismiss.self"));
|
|
859
874
|
}
|
|
860
|
-
if (activeConvId && targetId === activeConvId) {
|
|
875
|
+
if (activeConvId && executionOfId(targetId) === executionOfId(activeConvId)) {
|
|
861
876
|
const activeId = shortId(targetId);
|
|
862
877
|
return text(pick(getLang(), `子代理 ${activeId} 正在前端处于活动打开状态,无法直接移出。`, `Subagent ${activeId} is currently active in the UI and cannot be dismissed.`, "subagents.dismiss.active", { activeId }));
|
|
863
878
|
}
|
|
@@ -912,11 +927,11 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
912
927
|
skipped.push({ runId: targetId, reason: "not_found" });
|
|
913
928
|
continue;
|
|
914
929
|
}
|
|
915
|
-
if (selfId && targetId === selfId) {
|
|
930
|
+
if (selfId && executionOfId(targetId) === executionOfId(selfId)) {
|
|
916
931
|
skipped.push({ runId: targetId, reason: "self" });
|
|
917
932
|
continue;
|
|
918
933
|
}
|
|
919
|
-
if (activeConvId && targetId === activeConvId) {
|
|
934
|
+
if (activeConvId && executionOfId(targetId) === executionOfId(activeConvId)) {
|
|
920
935
|
skipped.push({ runId: targetId, reason: "active" });
|
|
921
936
|
continue;
|
|
922
937
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 灵魂提示词(persona)替换纯函数。
|
|
3
|
+
*
|
|
4
|
+
* pi 的 buildSystemPrompt(SDK dist/core/system-prompt.js)【默认分支】把系统
|
|
5
|
+
* 提示词拼成:
|
|
6
|
+
*
|
|
7
|
+
* <人物设定/soul>
|
|
8
|
+
* \n\nAvailable tools:\n<工具列表>
|
|
9
|
+
* \n\nIn addition to the tools above…\n\nGuidelines:\n<指南>
|
|
10
|
+
* \n\nPi documentation (…):\n<文档路径提示>
|
|
11
|
+
* [追加段] [<project_context>] [技能段] \nCurrent working directory: <cwd>
|
|
12
|
+
*
|
|
13
|
+
* 「灵魂提示词」= 开头的人物设定段落(内置模板的 "You are an expert coding
|
|
14
|
+
* assistant operating inside pi…")。设置面板的「替换」模式只替换这一段落——
|
|
15
|
+
* 工具列表 / Guidelines / 文档指引 / 项目上下文 / 技能段属于自动拼装段,每次由
|
|
16
|
+
* SDK 用最新数据重新生成,不进入被替换的内容(见 docs/architecture-system-prompt.md)。
|
|
17
|
+
*
|
|
18
|
+
* 这两个纯函数以 "\n\nAvailable tools:" 为边界完成 提取/替换:该边界只在默认
|
|
19
|
+
* 分支出现(存在 SYSTEM.md / 自定义 base 时走 customPrompt 分支、没有工具列表),
|
|
20
|
+
* 因此天然区分「可做灵魂替换」与「base 已整体替换、无需再动」两种情形。
|
|
21
|
+
*/
|
|
22
|
+
/** 默认模板中分割「灵魂提示词」与自动拼装段的固定标记。 */
|
|
23
|
+
export const SYSTEM_PROMPT_SOUL_BOUNDARY = "\n\nAvailable tools:";
|
|
24
|
+
/** 从(默认分支拼出的)系统提示词里提取内置灵魂提示词段落——replace 模式编辑器
|
|
25
|
+
* 的种子。找不到边界(customPrompt 分支)返回 undefined,调用方此时退回
|
|
26
|
+
* SYSTEM.md 文件内容作种子。 */
|
|
27
|
+
export function extractSystemPromptSoul(composed) {
|
|
28
|
+
const boundary = composed.indexOf(SYSTEM_PROMPT_SOUL_BOUNDARY);
|
|
29
|
+
if (boundary === -1)
|
|
30
|
+
return undefined;
|
|
31
|
+
return composed.slice(0, boundary);
|
|
32
|
+
}
|
|
33
|
+
/** 把系统提示词开头的灵魂段落替换为自定义内容,其余自动拼装段原样保留。
|
|
34
|
+
* 找不到边界返回 undefined = 本次替换不适用(调用方原样使用)。 */
|
|
35
|
+
export function swapSystemPromptSoul(composed, soul) {
|
|
36
|
+
const boundary = composed.indexOf(SYSTEM_PROMPT_SOUL_BOUNDARY);
|
|
37
|
+
if (boundary === -1)
|
|
38
|
+
return undefined;
|
|
39
|
+
const next = soul.trimEnd() + composed.slice(boundary);
|
|
40
|
+
return next === composed ? undefined : next;
|
|
41
|
+
}
|
|
@@ -232,6 +232,7 @@ export function createCompactContextHost(ctx) {
|
|
|
232
232
|
/** 创建 skill 工具的数据宿主 */
|
|
233
233
|
export function createSkillToolHost(ctx) {
|
|
234
234
|
return {
|
|
235
|
+
maxFileBytes: ctx.getMaxFileBytes,
|
|
235
236
|
listSkills: () => {
|
|
236
237
|
try {
|
|
237
238
|
const target = ctx.resolveTarget(ctx.ownerId);
|
|
@@ -293,14 +293,6 @@ export const AGENT_TOOL_CATALOG = [
|
|
|
293
293
|
descKey: "toolsWorktreeDesc",
|
|
294
294
|
offHintKey: "toolsWorktreeOffHint",
|
|
295
295
|
},
|
|
296
|
-
{
|
|
297
|
-
name: DEVICE_COLLAB_TOOL_NAME,
|
|
298
|
-
group: "other",
|
|
299
|
-
defaultOn: false,
|
|
300
|
-
dshVisible: false,
|
|
301
|
-
descKey: "toolsDeviceCollabDesc",
|
|
302
|
-
offHintKey: "toolsDeviceCollabOffHint",
|
|
303
|
-
},
|
|
304
296
|
{
|
|
305
297
|
name: CANVAS_TOOL_NAME,
|
|
306
298
|
group: "other",
|
|
@@ -310,6 +302,21 @@ export const AGENT_TOOL_CATALOG = [
|
|
|
310
302
|
offHintKey: "canvasToolOffHint",
|
|
311
303
|
},
|
|
312
304
|
];
|
|
305
|
+
/**
|
|
306
|
+
* 群组/设备中心专有工具目录(不进普通用户 Web 设置页,仅供群任务 Bot 白名单配置与运行时按需挂载)。
|
|
307
|
+
* 普通会话在底层不挂载此工具,避免 Token 浪费与非群组调用报错;其授权由设备中心 Bot 的 tools 白名单完全掌控。
|
|
308
|
+
*/
|
|
309
|
+
export const GROUP_BOT_TOOL_CATALOG = [
|
|
310
|
+
{
|
|
311
|
+
name: DEVICE_COLLAB_TOOL_NAME,
|
|
312
|
+
group: "other",
|
|
313
|
+
defaultOn: false,
|
|
314
|
+
allowAgentToggle: false,
|
|
315
|
+
dshVisible: false,
|
|
316
|
+
descKey: "toolsDeviceCollabDesc",
|
|
317
|
+
offHintKey: "toolsDeviceCollabOffHint",
|
|
318
|
+
},
|
|
319
|
+
];
|
|
313
320
|
/** SDK 核心内置工具名(可被门控显式禁用或被预设白名单过滤)。 */
|
|
314
321
|
export const CORE_BUILTIN_TOOL_NAMES = ["bash", "read", "edit", "write", "powershell", "ls", "grep", "find"];
|
|
315
322
|
/**
|
|
@@ -334,7 +341,7 @@ export const CORE_TOOL_CATALOG = [
|
|
|
334
341
|
{ name: "grep", group: "core", defaultOn: true, allowAgentToggle: false, descKey: "toolCoreGrepDesc" },
|
|
335
342
|
{ name: "find", group: "core", defaultOn: true, allowAgentToggle: false, descKey: "toolCoreFindDesc" },
|
|
336
343
|
];
|
|
337
|
-
/** 系统全部已知可开关工具的统一声明式条目集合(核心内置 8 个 ∪ 宿主扩展
|
|
344
|
+
/** 系统全部已知可开关工具的统一声明式条目集合(核心内置 8 个 ∪ 宿主扩展 27 个 ∪ 群组专有 1 个,共 36 个)。 */
|
|
338
345
|
export const ALL_AGENT_TOOL_ENTRIES = [
|
|
339
346
|
...CORE_TOOL_CATALOG.map((c) => ({
|
|
340
347
|
name: c.name,
|
|
@@ -346,6 +353,7 @@ export const ALL_AGENT_TOOL_ENTRIES = [
|
|
|
346
353
|
descKey: c.descKey,
|
|
347
354
|
})),
|
|
348
355
|
...AGENT_TOOL_CATALOG,
|
|
356
|
+
...GROUP_BOT_TOOL_CATALOG,
|
|
349
357
|
];
|
|
350
358
|
const ALL_AGENT_TOOL_MAP = new Map(ALL_AGENT_TOOL_ENTRIES.map((t) => [t.name, t]));
|
|
351
359
|
/** 获取任意已知工具的元数据规范条目。未知名返回 undefined。 */
|