pi-web-ui 0.115.0 → 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 +29 -0
- package/bin/pi-web-ui.mjs +21 -1
- package/dist/gh-comment-781.md +5 -0
- package/dist/server/agent-service-daemon.js +84 -2
- package/dist/server/agent-service.js +107 -26
- package/dist/server/client-state.js +17 -2
- package/dist/server/device-center/bot-execution.js +29 -1
- package/dist/server/device-center/collab-service.js +36 -5
- package/dist/server/device-center/collab-tool.js +90 -5
- package/dist/server/device-center/execution-guides.js +2 -2
- package/dist/server/device-center/execution-instructions.js +2 -1
- package/dist/server/device-center/execution-settings.js +138 -25
- package/dist/server/device-center/executor.js +4 -1
- package/dist/server/device-center/file-sync.js +14 -13
- package/dist/server/device-center/group-context-message.js +3 -1
- package/dist/server/device-center/group-context.js +73 -3
- package/dist/server/device-center/hub-conversations.js +58 -3
- 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 +872 -64
- package/dist/server/device-center/local-hub.js +2 -1
- package/dist/server/device-center/local-page.js +17 -0
- package/dist/server/device-center/local.js +74 -1
- package/dist/server/device-center/partition-log.js +293 -0
- package/dist/server/device-center/runtime.js +49 -0
- package/dist/server/device-center/smoke-preview.js +3 -0
- package/dist/server/device-center/store.js +163 -64
- package/dist/server/device-center/task-scheduler.js +48 -3
- package/dist/server/device-center/transfers.js +41 -15
- package/dist/server/dispatch-domain-handlers.js +14 -3
- 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/index.js +133 -16
- 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/model-admin.js +48 -6
- package/dist/server/model-enrich.js +10 -1
- package/dist/server/orchestrator.js +109 -0
- package/dist/server/plugins.js +64 -7
- package/dist/server/prompt-composer.js +39 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/reasoning-registry.js +207 -0
- package/dist/server/startup-banner.js +35 -0
- package/dist/server/subagents.js +2 -1
- package/dist/server/system-prompt-soul.js +41 -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/test-artifact.md +9 -0
- package/dist/test-preview-modal.md +11 -0
- package/dist/test-report.html +20 -0
- package/docs/architecture-plugins.md +946 -0
- package/docs/device-center.md +6 -0
- package/package.json +2 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BYzPgmoq.js → BgTasksModal-BDoOpj-F.js} +1 -1
- package/web/dist/assets/{BgTasksModal-ni0VTmAQ.js → BgTasksModal-C0i3O1FT.js} +1 -1
- package/web/dist/assets/{CanvasStudio-BCUeEf25.js → CanvasStudio-B8thymBN.js} +3 -3
- package/web/dist/assets/{CanvasStudio-DNmDNBod.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-CGXD0DfT.js → Dropdown-C4LIhshN.js} +1 -1
- package/web/dist/assets/FilePreview-BgGongmv.js +2 -0
- package/web/dist/assets/FilePreview-D4NrhF-U.js +2 -0
- package/web/dist/assets/{GlobalSearchModal-mevF-ySi.js → GlobalSearchModal-BWgU8yPd.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-qL99FN_F.js → GlobalSearchModal-F7fNimKk.js} +1 -1
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +17 -0
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +17 -0
- package/web/dist/assets/{HintTip-LHwkS2jV.js → HintTip-c6d0TJoh.js} +1 -1
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +2 -0
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +2 -0
- package/web/dist/assets/{PiSetupModal-DE5-gEtI.js → PiSetupModal-BmMrrgB9.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-6UMARucA.js → ProviderOAuthControls-BGSBIKD7.js} +1 -1
- 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-CTp_BZ4S.js → TerminalPanel-0CYvD72B.js} +2 -2
- package/web/dist/assets/{TerminalPanel-CkYxC-Gh.js → TerminalPanel-DDavKvFr.js} +2 -2
- package/web/dist/assets/{TuiOverlayModal-1cRLP8IF.js → TuiOverlayModal-BsA-QTvN.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-2xlptqWX.js → TuiOverlayModal-DzoVQBuG.js} +1 -1
- package/web/dist/assets/app-globals-CZxzGvIo.js +123 -0
- package/web/dist/assets/{canvas-client-Bye9nSFO.js → canvas-client-CUnXlQYX.js} +1 -1
- package/web/dist/assets/{desktop-kjBoE3Nu.js → desktop-aAKpvKJV.js} +1 -1
- 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-C8mNgghx.js → plugin-host-BRWib9DF.js} +1 -1
- package/web/dist/assets/{remote-ssh-client-CeP3CLUW.js → remote-ssh-client-CfYSMEZg.js} +1 -1
- package/web/dist/assets/{theme-BXGpyTMh.js → theme-D2l_mLNo.js} +1 -1
- package/web/dist/index.html +10 -10
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/DeviceCenter-BcBhRgL6.js +0 -3
- package/web/dist/assets/DeviceCenter-CmL5FZmt.js +0 -3
- package/web/dist/assets/DeviceGroups-CLdpdnI7.js +0 -1
- package/web/dist/assets/DeviceGroups-CgBaDPrD.js +0 -1
- package/web/dist/assets/FilePreview-B8iqnBjy.js +0 -2
- package/web/dist/assets/FilePreview-BqviZKCN.js +0 -2
- package/web/dist/assets/GroupConversation-B88Yy-lt.js +0 -3
- package/web/dist/assets/GroupConversation-BwP5NVOE.js +0 -3
- package/web/dist/assets/ModelConfigModal-Do3Fe3jH.js +0 -2
- package/web/dist/assets/SCMPanel-Hi6QqC1Q.js +0 -2
- package/web/dist/assets/SCMPanel-ezY_ZtCu.js +0 -2
- package/web/dist/assets/SettingsModal-6HgeEsJ8.js +0 -20
- package/web/dist/assets/SettingsModal-CF-7MwqS.js +0 -20
- package/web/dist/assets/app-globals-DZNa9v8u.js +0 -325
- package/web/dist/assets/index-CsFs_HMb.css +0 -1
- package/web/dist/assets/index-DHeeHS_l.js +0 -85
- package/web/dist/assets/index-DTZch8uz.js +0 -85
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,35 @@
|
|
|
13
13
|
<!-- auto-i18n:start -->
|
|
14
14
|
<!-- auto-i18n:end -->
|
|
15
15
|
|
|
16
|
+
## [0.116.0] — 2026-11-05
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **群组出站 Webhook 支持**:设备中心群组新增 Webhook 外部通知支持,可订阅群消息(`message`)、任务完成(`task_completed`)、任务失败(`task_failed`)与投递事件;支持配置 HMAC-SHA256 签名密钥(`X-Pi-Signature`),并提供连通性测试与 5 秒隔离超时保护。
|
|
21
|
+
- **对话图片高清灯箱(Image Lightbox)**:点击聊天消息中的图片可一键唤起独立灯箱浮层,支持原图缩放、平移浏览、自适应居中与下载,大幅提升大图细节审阅体验。
|
|
22
|
+
- **代码块快捷运行到终端**:在助手生成的 Shell/可执行代码块右上角新增「在终端运行」按钮,点击可直接发送至内置交互终端执行,简化复制执行链路。
|
|
23
|
+
- **会话时间分组与未读标记**:左侧栏历史会话按今天、昨天、过去一周及更早进行时间聚类;后台完成任务的会话提供醒目的未读徽标与状态追踪,多任务并行不迷路。
|
|
24
|
+
- **LX-Music 音乐插件全面重构**:升级流媒体代理与 User API 脚本虚拟机,支持载入外部音源脚本、高品质音频代理试听、排行榜单检索与播放控制。
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **禁止服务端热路径同步子进程**(#830):全量清理服务端热路径上的 `spawnSync`/`execSync` 调用,解决 Windows 全局 npm 根目录探测阻塞事件循环的问题,新增严格的门禁回归守卫。
|
|
29
|
+
- **并发通信与连带生命周期修复**(#828、#829、#832、#833、#834):修复组件终端通信更新、worktree 状态同步、中断时连带停止子代理、排队消息防丢以及设备中心协作去重展示。
|
|
30
|
+
- **未授权访问与启动引导优化**:新增格式化启动横幅与未授权访问友好说明页,提升多宿主反代与外网访问配置体验。
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- 设备中心协作策略配置升级:支持细粒度调整饿死防范时间、任务调度深度、工作区文件同步字节上限与资源锁默认 TTL。
|
|
35
|
+
|
|
36
|
+
<!-- auto-i18n:start -->
|
|
37
|
+
### i18n
|
|
38
|
+
|
|
39
|
+
- 前端新增 key(76):`runInTerminal`、`executedInTerminal`、`engineUninstall`、`engineUninstalling`、`engineUninstallConfirm`、`engineUninstallTip`、`engineActiveNoUninstall`、`scheduledTaskBadge`、`schedulerViewTip`、`waitingQuestionShort`、`tabRunning`、`completedUnreadBadge`、`completedUnreadTooltip`、`tabProjects`、`deviceGroups`、`createGroup`、`timeGroupToday`、`timeGroupYesterday`、`timeGroupPastWeek`、`timeGroupEarlier`、`questionQueuedOffline`、`thinkingConfigTitle`、`thinkingConfigBtn`、`thinkingCustomized`、`thinkingQuickApply`、`thinkingResetDefault`、`thinkingFixedNotice`、`thinkingFormatLabel`、`thinkingRawBodyLabel`、`thinkingCustomBudgetBtn`、`thinkingCustomBudgetPlaceholder`、`thinkingCustomBudgetTitle`、`tpl.sk.clarify`、`tpl.sk.clarify.desc`、`tpl.sk.clarify.prompt`、`tpl.sk.toplan`、`tpl.sk.toplan.desc`、`tpl.sk.toplan.prompt`、`loadingSessions`、`noSessionsYet`、`deviceExecSchedulingTitle`、`deviceExecStarvationMs`、`deviceExecStarvationMsHint`、`deviceExecMaxSkips`、`deviceExecMaxSkipsHint`、`deviceExecDispatchTitle`、`deviceExecMaxDepth`、`deviceExecMaxDepthHint`、`deviceExecMaxBudget`、`deviceExecMaxBudgetHint`、`deviceExecAllowBotMentions`、`deviceExecAllowBotMentionsHint`、`deviceExecContextTitle`、`deviceExecContextBytes`、`deviceExecContextBytesHint`、`deviceExecRetention`、`deviceExecRetentionHint`、`deviceExecFileSyncTitle`、`deviceExecFileSyncBytes`、`deviceExecFileSyncBytesHint`、`deviceExecFileSyncFiles`、`deviceExecFileSyncFilesHint`、`deviceExecFileSyncStagedBytes`、`deviceExecFileSyncStagedBytesHint`、`deviceExecLocksTitle`、`deviceExecLockTtl`、`deviceExecLockTtlHint`、`deviceExecBlackboardBytes`、`deviceExecBlackboardBytesHint`、`deviceExecResetDefaults`、`deviceExecResetDefaultsTip`、`promptTok_plugin_dev`、`promptTok_plugin_dev_desc`、`settingsDeviceCollab`、`settingsDeviceCollabHint`、`sandboxNewShort`
|
|
40
|
+
- 前端删除 key(81):`ephemeralBadge`、`thinkingUnsupported`、`manageProjects`、`elsewherePseudoTip`、`subagentBadgeCount`、`subagentsStreamingTip`、`subagentsQuestionTip`、`subagentsErrorTip`、`subagentsCountTip`、`convErrorBadge`、`tuiTip`、`forkedSessionBadge`、`forkedSessionTip`、`dismissFinishedOnly`、`forkBadge`、`forkBadgeTip`、`tpl.newTitle`、`tpl.editTitle`、`tpl.fieldTitle`、`tpl.sk.setup`、`tpl.sk.setup.desc`、`tpl.sk.setup.prompt`、`tpl.sk.ask`、`tpl.sk.ask.desc`、`tpl.sk.ask.prompt`、`tpl.sk.grilldocs`、`tpl.sk.grilldocs.desc`、`tpl.sk.grilldocs.prompt`、`tpl.sk.tospec`、`tpl.sk.tospec.desc`、`tpl.sk.tospec.prompt`、`tpl.sk.totickets`、`tpl.sk.wayfinder`、`tpl.sk.wayfinder.desc`、`tpl.sk.wayfinder.prompt`、`tpl.sk.arch`、`tpl.sk.arch.desc`、`tpl.sk.arch.prompt`、`tpl.sk.triage`、`tpl.sk.triage.desc`、`tpl.sk.triage.prompt`、`tpl.sk.wizard`、`tpl.sk.wizard.desc`、`tpl.sk.wizard.prompt`、`tpl.sk.grillme`、`tpl.sk.grillme.desc`、`tpl.sk.grillme.prompt`、`tpl.sk.handoff`、`tpl.sk.handoff.desc`、`tpl.sk.handoff.prompt`、`tpl.sk.questionnaire`、`tpl.sk.questionnaire.desc`、`tpl.sk.questionnaire.prompt`、`tpl.sk.teach`、`tpl.sk.teach.desc`、`tpl.sk.teach.prompt`、`tpl.sk.ww`、`tpl.sk.ww.desc`、`tpl.sk.ww.prompt`、`tpl.sk.wfa`、`tpl.sk.wfa.desc`、`tpl.sk.wfa.prompt`、`tpl.sk.codesign`、`tpl.sk.codesign.desc`、`tpl.sk.codesign.prompt`、`tpl.sk.domain`、`tpl.sk.domain.desc`、`tpl.sk.domain.prompt`、`tpl.sk.grilling`、`tpl.sk.grilling.desc`、`tpl.sk.grilling.prompt`、`tpl.sk.tdd`、`tpl.sk.tdd.desc`、`tpl.sk.tdd.prompt`、`deviceSetupNext`、`deviceSetupNextHint`、`deviceSetupManage`、`deviceHubOverview`、`deviceHubSettings`、`deviceHubGroups`、`sandboxNewBtn`
|
|
41
|
+
- 前端中文变更(13):`historySessions`、`openHistory`、`tpl.sk.implement`、`tpl.sk.implement.desc`、`tpl.sk.implement.prompt`、`tpl.sk.codeview.desc`、`tpl.sk.codeview.prompt`、`tpl.sk.prototype.prompt`、`tpl.sk.research.prompt`、`tpl.sk.debug.prompt`、`tpl.sk.merge.prompt`、`deviceExecMaxActive`、`deviceExecMaxWaiting`
|
|
42
|
+
- 前端英文变更(12):`tpl.sk.implement`、`tpl.sk.implement.desc`、`tpl.sk.implement.prompt`、`tpl.sk.codeview.desc`、`tpl.sk.codeview.prompt`、`tpl.sk.debug`、`tpl.sk.debug.desc`、`tpl.sk.debug.prompt`、`tpl.sk.merge.desc`、`tpl.sk.merge.prompt`、`deviceExecMaxActive`、`deviceExecMaxWaiting`
|
|
43
|
+
<!-- auto-i18n:end -->
|
|
44
|
+
|
|
16
45
|
## [0.115.0] — 2026-11-02
|
|
17
46
|
|
|
18
47
|
### Added
|
package/bin/pi-web-ui.mjs
CHANGED
|
@@ -443,6 +443,24 @@ function openBrowserWhenUp(url) {
|
|
|
443
443
|
attempt();
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
+
function loadStoredFileToken(dataDir) {
|
|
447
|
+
try {
|
|
448
|
+
const raw = readFileSync(join(dataDir, "server-config.json"), "utf8");
|
|
449
|
+
const parsed = JSON.parse(raw);
|
|
450
|
+
if (typeof parsed?.token === "string" && parsed.token.trim()) return parsed.token.trim();
|
|
451
|
+
} catch {
|
|
452
|
+
/* ignore */
|
|
453
|
+
}
|
|
454
|
+
return "";
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function resolveCliAuthToken(opts) {
|
|
458
|
+
const envToken = (process.env.PI_WEB_TOKEN || "").trim();
|
|
459
|
+
if (envToken) return envToken;
|
|
460
|
+
const dataDir = resolve(opts?.dataDir ?? process.env.PI_WEB_DATA_DIR ?? join(homedir(), ".pi-web"));
|
|
461
|
+
return loadStoredFileToken(dataDir);
|
|
462
|
+
}
|
|
463
|
+
|
|
446
464
|
async function startForeground(opts) {
|
|
447
465
|
if (opts.port) process.env.PI_WEB_PORT = opts.port;
|
|
448
466
|
if (opts.cwd) process.env.PI_WEB_CWD = resolve(opts.cwd);
|
|
@@ -458,7 +476,9 @@ async function startForeground(opts) {
|
|
|
458
476
|
}
|
|
459
477
|
if (opts.host) process.env.PI_WEB_HOST = opts.host;
|
|
460
478
|
if (opts.agentDir) process.env.PI_CODING_AGENT_DIR = resolve(opts.agentDir);
|
|
461
|
-
const
|
|
479
|
+
const token = resolveCliAuthToken(opts);
|
|
480
|
+
const tokenQuery = token ? `?token=${encodeURIComponent(token)}` : "";
|
|
481
|
+
const url = `http://localhost:${effectivePort(opts)}${tokenQuery}`;
|
|
462
482
|
if (HAS_SDK_HOOK) await import(pathToFileURL(SDK_HOOK).href);
|
|
463
483
|
try {
|
|
464
484
|
await import(pathToFileURL(SERVER_ENTRY).href);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
已在 commit 9e04e099 中彻底修复并闭环:
|
|
2
|
+
|
|
3
|
+
1. **Markdown 链接与图片拦截转写**:在 `web/src/components/Markdown.tsx` 中拦截相对路径(如 `output/summary.md`)和绝对路径,自动转换为受鉴权保护的工作区直链(HTML 文件走 `/api/preview` 沙箱隔离预览,其他文件走 `/api/file` 原生打开/流式播放);
|
|
4
|
+
2. **服务端直开权限完善**:更新 `server/index.ts` 放行合法工作区文本/数据文件(配合 `nosniff` 与沙箱),不再返回 400 阻断;
|
|
5
|
+
3. **适配远程访问**:`present_files` 探测到远程访问时,自动将本地窗口唤醒按钮替换为新标签页打开。
|
|
@@ -39,7 +39,12 @@ export class AgentService {
|
|
|
39
39
|
const viewer = this.clients.get(viewerClientId);
|
|
40
40
|
const owner = this.clients.get(ownerClientId);
|
|
41
41
|
const conversation = owner?.getConversation(convId);
|
|
42
|
-
|
|
42
|
+
const isScheduler = ownerClientId.startsWith("scheduler:");
|
|
43
|
+
if (!viewer ||
|
|
44
|
+
!owner ||
|
|
45
|
+
!conversation ||
|
|
46
|
+
(conversation.independent !== false && !isScheduler) ||
|
|
47
|
+
conversation.isSubagent)
|
|
43
48
|
return false;
|
|
44
49
|
this.closeSharedConversation(viewerClientId);
|
|
45
50
|
const binding = { owner, conversation, ownerClientId, conversationId: convId, close: () => { }, send };
|
|
@@ -108,7 +113,7 @@ export class AgentService {
|
|
|
108
113
|
if (binding &&
|
|
109
114
|
this.clients.get(binding.ownerClientId) === binding.owner &&
|
|
110
115
|
binding.owner.getConversation(binding.conversationId) === binding.conversation &&
|
|
111
|
-
binding.conversation.independent === false)
|
|
116
|
+
(binding.conversation.independent === false || binding.ownerClientId.startsWith("scheduler:")))
|
|
112
117
|
return binding;
|
|
113
118
|
if (binding)
|
|
114
119
|
this.closeSharedConversation(viewerClientId);
|
|
@@ -353,6 +358,77 @@ export class AgentService {
|
|
|
353
358
|
return false;
|
|
354
359
|
}
|
|
355
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* 关闭对话(支持本端自身会话,或跨端关闭群组 Bot / 共享执行 / 离线残骸 / elsewhere 会话)。
|
|
363
|
+
*/
|
|
364
|
+
async dismissConversation(requesterClientId, msg) {
|
|
365
|
+
const requester = this.clients.get(requesterClientId);
|
|
366
|
+
// 1. 本客户端自己持有该会话:走当前客户端正常流程
|
|
367
|
+
if (requester?.getConversation(msg.id)) {
|
|
368
|
+
await requester.dismissConversation(msg.id, msg.withFinishedSubagents, msg.force);
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
// 2. 跨客户端定位持有该会话的 owner
|
|
372
|
+
let ownerId = msg.owner;
|
|
373
|
+
let owner = ownerId ? this.clients.get(ownerId) : undefined;
|
|
374
|
+
let conv = owner?.getConversation(msg.id);
|
|
375
|
+
if (!owner || !conv) {
|
|
376
|
+
for (const [cid, c] of this.clients) {
|
|
377
|
+
const found = c.getConversation(msg.id);
|
|
378
|
+
if (found) {
|
|
379
|
+
ownerId = cid;
|
|
380
|
+
owner = c;
|
|
381
|
+
conv = found;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (!owner || !conv || !ownerId) {
|
|
387
|
+
requester?.sendNotice({
|
|
388
|
+
type: "notice",
|
|
389
|
+
level: "warning",
|
|
390
|
+
text: "该对话不存在或已关闭",
|
|
391
|
+
textEn: "This conversation does not exist or is already closed",
|
|
392
|
+
});
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
// 3. 针对共享执行客户端(如群组 Bot device-task-、定时任务、无头残骸)
|
|
396
|
+
const isSharedExecution = isSharedExecutionClientId(ownerId);
|
|
397
|
+
const isOffline = owner.sinkCount() === 0;
|
|
398
|
+
if (isSharedExecution || isOffline) {
|
|
399
|
+
if (owner.conversationStreaming(conv) && !msg.force) {
|
|
400
|
+
requester?.sendNotice({
|
|
401
|
+
type: "notice",
|
|
402
|
+
level: "warning",
|
|
403
|
+
text: `对话「${conv.title}」仍在运行中,请先等待结束或点击强行关闭`,
|
|
404
|
+
textEn: `Conversation "${conv.title}" is still running. Wait for it to finish or force dismiss.`,
|
|
405
|
+
});
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
if (owner.conversationStreaming(conv)) {
|
|
409
|
+
await owner.abortConversation(conv);
|
|
410
|
+
}
|
|
411
|
+
for (const [viewerId, binding] of this.sharedViewers) {
|
|
412
|
+
if (binding.owner === owner || binding.ownerClientId === ownerId) {
|
|
413
|
+
this.closeSharedConversation(viewerId);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
this.clients.delete(ownerId);
|
|
417
|
+
await owner.dispose().catch(() => { });
|
|
418
|
+
this.pokeExternalRunning(ownerId);
|
|
419
|
+
requester?.sendNotice({
|
|
420
|
+
type: "notice",
|
|
421
|
+
level: "info",
|
|
422
|
+
text: `已关闭并移出对话「${conv.title}」`,
|
|
423
|
+
textEn: `Closed and dismissed conversation "${conv.title}"`,
|
|
424
|
+
});
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
// 4. 普通在线客户端持有的 shared/可过户会话
|
|
428
|
+
await owner.dismissConversation(conv.id, msg.withFinishedSubagents, msg.force);
|
|
429
|
+
this.pokeExternalRunning(ownerId);
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
356
432
|
/** 客户端 -> 最后一个浏览器断开的时刻(离线行宽限期起点;重连/认领即删)。 */
|
|
357
433
|
offlineSince = new Map();
|
|
358
434
|
/** 客户端 -> 离线行宽限期到期定时器(到期后让其他客户端重推,行消失)。 */
|
|
@@ -1130,6 +1206,10 @@ export class AgentService {
|
|
|
1130
1206
|
}
|
|
1131
1207
|
}
|
|
1132
1208
|
const conversationId = cs.readConversationForPlugins()?.conversationId ?? "";
|
|
1209
|
+
const taskTitle = (task.name || "").trim() || (text.length > 30 ? text.slice(0, 30) : text);
|
|
1210
|
+
if (conversationId && taskTitle) {
|
|
1211
|
+
void cs.renameConversation(conversationId, taskTitle);
|
|
1212
|
+
}
|
|
1133
1213
|
void cs.prompt(`[定时任务] ${text}`);
|
|
1134
1214
|
// 等待运行结束:每 2s 轮询,最长 10 分钟。超时按失败记录(运行继续)。
|
|
1135
1215
|
const deadline = Date.now() + 10 * 60 * 1000;
|
|
@@ -1658,6 +1738,7 @@ export class AgentService {
|
|
|
1658
1738
|
if (clientId.startsWith("device-task-") && !isBotExecutionRegistered(clientId) && cs.sinkCount() === 0) {
|
|
1659
1739
|
this.clients.delete(clientId);
|
|
1660
1740
|
await cs.dispose();
|
|
1741
|
+
this.pokeExternalRunning(clientId);
|
|
1661
1742
|
return cs;
|
|
1662
1743
|
}
|
|
1663
1744
|
}
|
|
@@ -1760,6 +1841,7 @@ export class AgentService {
|
|
|
1760
1841
|
// Keep uncertain/disconnected executions owned until that confirmation.
|
|
1761
1842
|
this.clients.delete(clientId);
|
|
1762
1843
|
void cs.dispose().catch(() => { });
|
|
1844
|
+
this.pokeExternalRunning(clientId);
|
|
1763
1845
|
return;
|
|
1764
1846
|
}
|
|
1765
1847
|
// 最后一个 sink 断开 = 该客户端不再在线 → 它的行从「另一处」变成「另一处
|
|
@@ -32,7 +32,7 @@ import { BG_CLEANUP_FALLBACK_MIN, BgServerTracker } from "./bg-servers.js";
|
|
|
32
32
|
import { checkAll as checkAllUpdates, collectTargets, compareVersions as compareSemver, detectPiSdkSplit, resolveNpmRegistry, sortUpdateItems, } from "./update-check.js";
|
|
33
33
|
import { collectInstalledEngineTargets } from "./engine-probe.js";
|
|
34
34
|
import { checkPluginUpdates } from "./plugin-updater.js";
|
|
35
|
-
import { getAppVersion } from "./pkg-info.js";
|
|
35
|
+
import { getAppVersion, getPkgRoot } from "./pkg-info.js";
|
|
36
36
|
import { isBundledInUse, sdkCopies } from "./sdk-origin.js";
|
|
37
37
|
import { hasActiveSubagentRun, hasPendingWaitSubscription, hasRunningBackgroundTask, shouldRetainActive, } from "./wait-subscription-scan.js";
|
|
38
38
|
import { looksLikeChainCorruption, repairSessionFile } from "./compaction-markers.js";
|
|
@@ -885,6 +885,8 @@ export class ClientSession {
|
|
|
885
885
|
owner.scheduleSubagentCompletionNotice(conv);
|
|
886
886
|
owner.emitConversations();
|
|
887
887
|
});
|
|
888
|
+
// spawn 成功派发后解除与父工具信号的绑定;后续父对话停止不连带中止已派出的子代理(issue #833)
|
|
889
|
+
signal?.removeEventListener("abort", onSpawnAbort);
|
|
888
890
|
if (persist) {
|
|
889
891
|
holder.pushProjects().catch(() => { });
|
|
890
892
|
}
|
|
@@ -1474,6 +1476,26 @@ export class ClientSession {
|
|
|
1474
1476
|
return;
|
|
1475
1477
|
}
|
|
1476
1478
|
}
|
|
1479
|
+
// 若父对话正在 wait_all 等待中,完成通知暂不投递进 steering 队列,避免与 wait_all 返回重复(issue #828)
|
|
1480
|
+
if (consultWaitingParents.has(targetConv)) {
|
|
1481
|
+
if (retryCount < 60) {
|
|
1482
|
+
const retryTimer = setTimeout(() => {
|
|
1483
|
+
const current = toNotify.filter(isCurrent);
|
|
1484
|
+
if (current.length === 0)
|
|
1485
|
+
return;
|
|
1486
|
+
const pending = this.pendingSubagentNotices.get(parentId);
|
|
1487
|
+
if (pending?.timer)
|
|
1488
|
+
clearTimeout(pending.timer);
|
|
1489
|
+
this.pendingSubagentNotices.set(parentId, {
|
|
1490
|
+
timer: retryTimer,
|
|
1491
|
+
subagents: new Set([...(pending?.subagents ?? []), ...current]),
|
|
1492
|
+
});
|
|
1493
|
+
void this.flushSubagentCompletionNotice(parentId, retryCount + 1);
|
|
1494
|
+
}, 400);
|
|
1495
|
+
this.pendingSubagentNotices.set(parentId, { timer: retryTimer, subagents: new Set(toNotify) });
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1477
1499
|
for (const c of toNotify) {
|
|
1478
1500
|
c.subagentDoneNotified = true;
|
|
1479
1501
|
}
|
|
@@ -2024,6 +2046,9 @@ export class ClientSession {
|
|
|
2024
2046
|
piReadme: PI_DOC_PATHS.readme,
|
|
2025
2047
|
piDocs: PI_DOC_PATHS.docs,
|
|
2026
2048
|
piExamples: PI_DOC_PATHS.examples,
|
|
2049
|
+
pluginDocs: join(getPkgRoot(), "docs", "architecture-plugins.md"),
|
|
2050
|
+
pluginSdk: join(getPkgRoot(), "plugin-sdk"),
|
|
2051
|
+
pluginsDir: join(this.stateStore.dataDir, "plugins"),
|
|
2027
2052
|
appendFiles: [...promptBase.append],
|
|
2028
2053
|
windowsPersona: isRemote
|
|
2029
2054
|
? buildRemoteWorkspacePersona(realCwd)
|
|
@@ -2262,6 +2287,11 @@ export class ClientSession {
|
|
|
2262
2287
|
consultWaitingParents.delete(parent);
|
|
2263
2288
|
}
|
|
2264
2289
|
},
|
|
2290
|
+
isRequestSteering: (parentId, requestId) => {
|
|
2291
|
+
const owner = this.subagentOwnerOf(parentId);
|
|
2292
|
+
const parent = owner.convs.get(this.subagentCurrentId(parentId));
|
|
2293
|
+
return !!parent?.queuedSteeringRequestIds?.has(requestId);
|
|
2294
|
+
},
|
|
2265
2295
|
spawnSubagent: (prompt, type, cwd, templateName, model, parentId, persist, thinking, notifyOnDone, isolation, extra, signal) => {
|
|
2266
2296
|
// B20:过户后 parentId 的主对话可能已搬去另一个 ClientSession ——
|
|
2267
2297
|
// 委托给真正持有父对话的会话 spawn(模板/上限/注册/左栏全随它),
|
|
@@ -3681,7 +3711,8 @@ export class ClientSession {
|
|
|
3681
3711
|
askApproval: (toolCallId, toolName, params, reason, reasonEn, convId, category) => this.askApproval(toolCallId, toolName, params, reason, reasonEn, convId, category),
|
|
3682
3712
|
getConversationId: () => ownerId,
|
|
3683
3713
|
}, () => this.getLang()),
|
|
3684
|
-
|
|
3714
|
+
// 设备中心群任务协作工具(仅在群任务 Bot 执行上下文注入;普通单聊完全不挂载)。
|
|
3715
|
+
...(this.botExecution ? [makeDeviceCollabTool()] : []),
|
|
3685
3716
|
// Git 工作树管理工具(worktree:list/create/switch/remove)。
|
|
3686
3717
|
makeWorktreeTool({
|
|
3687
3718
|
getCwd: () => (ownerId ? this.convs.get(ownerId)?.cwd : undefined) ?? effectiveCwd,
|
|
@@ -3878,10 +3909,17 @@ export class ClientSession {
|
|
|
3878
3909
|
if (this.convs.get(conv.id) !== conv)
|
|
3879
3910
|
return;
|
|
3880
3911
|
conv.goalGeneration++;
|
|
3912
|
+
try {
|
|
3913
|
+
conv.session.clearQueue?.();
|
|
3914
|
+
}
|
|
3915
|
+
catch (err) {
|
|
3916
|
+
console.error("[agent-service] clearQueue failed during abortConversation:", err);
|
|
3917
|
+
}
|
|
3881
3918
|
conv.queueSteering = [];
|
|
3882
3919
|
conv.queueFollowUp = [];
|
|
3883
3920
|
conv.queuedSteeringEntries = [];
|
|
3884
3921
|
conv.queuedFollowUpEntries = [];
|
|
3922
|
+
conv.queuedSteeringRequestIds?.clear();
|
|
3885
3923
|
await this.interruptRun(conv, "已停止");
|
|
3886
3924
|
for (const push of this.conversationViewers?.get(conv) ?? [])
|
|
3887
3925
|
push();
|
|
@@ -6009,8 +6047,6 @@ export class ClientSession {
|
|
|
6009
6047
|
const seen = new Set();
|
|
6010
6048
|
while (!seen.has(conv)) {
|
|
6011
6049
|
seen.add(conv);
|
|
6012
|
-
if (conv.subagentWorktree && isSameOrSubpath(conv.cwd, conv.subagentWorktree.worktreePath))
|
|
6013
|
-
return normalizePathKey(conv.subagentWorktree.mainRepoPath);
|
|
6014
6050
|
if (!conv.parentId)
|
|
6015
6051
|
break;
|
|
6016
6052
|
const parent = this.parentExecution(conv)?.conv;
|
|
@@ -6018,6 +6054,8 @@ export class ClientSession {
|
|
|
6018
6054
|
break;
|
|
6019
6055
|
conv = parent;
|
|
6020
6056
|
}
|
|
6057
|
+
if (conv.subagentWorktree && isSameOrSubpath(conv.cwd, conv.subagentWorktree.worktreePath))
|
|
6058
|
+
return normalizePathKey(conv.subagentWorktree.mainRepoPath);
|
|
6021
6059
|
// A child may execute in an independent checkout. Its registered ancestry,
|
|
6022
6060
|
// rather than that checkout's path, determines the collaboration project.
|
|
6023
6061
|
return normalizePathKey(conv.cwd);
|
|
@@ -6146,8 +6184,16 @@ export class ClientSession {
|
|
|
6146
6184
|
conv.wakeReason = "other";
|
|
6147
6185
|
conv.wakeTurnHadAction = false;
|
|
6148
6186
|
}
|
|
6187
|
+
if (busy && envelope.requestId) {
|
|
6188
|
+
conv.queuedSteeringRequestIds = conv.queuedSteeringRequestIds ?? new Set();
|
|
6189
|
+
conv.queuedSteeringRequestIds.add(envelope.requestId);
|
|
6190
|
+
}
|
|
6149
6191
|
// SDK queue acceptance is delivery to this conversation, not proof that the model read it.
|
|
6150
6192
|
const delivery = conv.session.sendUserMessage(text, busy ? { deliverAs: "steer" } : undefined);
|
|
6193
|
+
void delivery.finally(() => {
|
|
6194
|
+
if (envelope.requestId)
|
|
6195
|
+
conv.queuedSteeringRequestIds?.delete(envelope.requestId);
|
|
6196
|
+
});
|
|
6151
6197
|
void delivery.catch((error) => {
|
|
6152
6198
|
owner.sendNotice({
|
|
6153
6199
|
type: "notice",
|
|
@@ -10459,6 +10505,18 @@ export class ClientSession {
|
|
|
10459
10505
|
if (Array.isArray(this.conv.session?._pendingNextTurnMessages)) {
|
|
10460
10506
|
this.conv.session._pendingNextTurnMessages = [];
|
|
10461
10507
|
}
|
|
10508
|
+
// 停止时先清空 SDK 队列与本地排队镜像,防止 agent-loop 工具结束后消费排队消息导致写入对话却被中止丢消息(issue #834)
|
|
10509
|
+
try {
|
|
10510
|
+
this.conv.session.clearQueue?.();
|
|
10511
|
+
}
|
|
10512
|
+
catch (err) {
|
|
10513
|
+
console.error("[agent-service] clearQueue failed during abort:", err);
|
|
10514
|
+
}
|
|
10515
|
+
this.conv.queueSteering = [];
|
|
10516
|
+
this.conv.queueFollowUp = [];
|
|
10517
|
+
this.conv.queuedSteeringEntries = [];
|
|
10518
|
+
this.conv.queuedFollowUpEntries = [];
|
|
10519
|
+
this.conv.queuedSteeringRequestIds?.clear();
|
|
10462
10520
|
const isRunning = this.conversationStreaming(this.conv) || !this.conv.session.isIdle;
|
|
10463
10521
|
if (!isRunning) {
|
|
10464
10522
|
this.flushSnapshot();
|
|
@@ -12426,6 +12484,28 @@ export class ClientSession {
|
|
|
12426
12484
|
if (this.sessionsRequested)
|
|
12427
12485
|
void this.refreshSessions();
|
|
12428
12486
|
}
|
|
12487
|
+
buildSessionSummaries(targetCwd, infos) {
|
|
12488
|
+
const showForkedParents = this.settingsSvc.current.showForkedParentSessions === true;
|
|
12489
|
+
const visibleInfos = filterForkedParentSessions(infos, showForkedParents);
|
|
12490
|
+
const sessions = new Map();
|
|
12491
|
+
for (const s of visibleInfos) {
|
|
12492
|
+
const isPinned = this.stateStore?.isSessionPinned(targetCwd, s.path);
|
|
12493
|
+
const displayName = s.name?.trim() || (s.firstMessage ? s.firstMessage.trim().replace(/\s+/g, " ") : undefined);
|
|
12494
|
+
sessions.set(s.path, {
|
|
12495
|
+
path: s.path,
|
|
12496
|
+
...(s.id ? { sessionId: s.id } : {}),
|
|
12497
|
+
name: s.name,
|
|
12498
|
+
displayName,
|
|
12499
|
+
firstMessage: s.firstMessage,
|
|
12500
|
+
messageCount: s.messageCount,
|
|
12501
|
+
modified: s.modified.getTime(),
|
|
12502
|
+
source: "web",
|
|
12503
|
+
...(isPinned ? { pinned: true } : {}),
|
|
12504
|
+
...(s.parentSessionPath ? { parentSessionPath: s.parentSessionPath } : {}),
|
|
12505
|
+
});
|
|
12506
|
+
}
|
|
12507
|
+
return [...sessions.values()].sort((a, b) => b.modified - a.modified).slice(0, 200);
|
|
12508
|
+
}
|
|
12429
12509
|
async pushSessions() {
|
|
12430
12510
|
if (!this.sessionsRequested)
|
|
12431
12511
|
return;
|
|
@@ -12434,34 +12514,24 @@ export class ClientSession {
|
|
|
12434
12514
|
// (<agentDir>/sessions/--<cwd>--/), the same files the pi CLI/TUI
|
|
12435
12515
|
// use — one listing covers every conversation of the current folder.
|
|
12436
12516
|
const infos = await this.loadSessionInfos();
|
|
12437
|
-
|
|
12438
|
-
// 开启 showForkedParentSessions 时保留全部会话(全文搜索 searchSessions 始终保留全部)。
|
|
12439
|
-
const showForkedParents = this.settingsSvc.current.showForkedParentSessions === true;
|
|
12440
|
-
const visibleInfos = filterForkedParentSessions(infos, showForkedParents);
|
|
12441
|
-
const sessions = new Map();
|
|
12442
|
-
for (const s of visibleInfos) {
|
|
12443
|
-
const isPinned = this.stateStore?.isSessionPinned(this.cwd, s.path);
|
|
12444
|
-
const displayName = s.name?.trim() || (s.firstMessage ? s.firstMessage.trim().replace(/\s+/g, " ") : undefined);
|
|
12445
|
-
sessions.set(s.path, {
|
|
12446
|
-
path: s.path,
|
|
12447
|
-
...(s.id ? { sessionId: s.id } : {}),
|
|
12448
|
-
name: s.name,
|
|
12449
|
-
displayName,
|
|
12450
|
-
firstMessage: s.firstMessage,
|
|
12451
|
-
messageCount: s.messageCount,
|
|
12452
|
-
modified: s.modified.getTime(),
|
|
12453
|
-
source: "web",
|
|
12454
|
-
...(isPinned ? { pinned: true } : {}),
|
|
12455
|
-
...(s.parentSessionPath ? { parentSessionPath: s.parentSessionPath } : {}),
|
|
12456
|
-
});
|
|
12457
|
-
}
|
|
12458
|
-
const sorted = [...sessions.values()].sort((a, b) => b.modified - a.modified).slice(0, 200); // newest first — the panel shows recent history
|
|
12517
|
+
const sorted = this.buildSessionSummaries(this.cwd, infos);
|
|
12459
12518
|
this.emit({ type: "sessions", sessions: sorted });
|
|
12460
12519
|
}
|
|
12461
12520
|
catch {
|
|
12462
12521
|
this.emit({ type: "sessions", sessions: [] });
|
|
12463
12522
|
}
|
|
12464
12523
|
}
|
|
12524
|
+
/** Push the persisted session list for a specific project directory (on demand, e.g. expanding an unopened project). */
|
|
12525
|
+
async pushSessionsForCwd(targetCwd) {
|
|
12526
|
+
try {
|
|
12527
|
+
const infos = await this.loadSessionInfos(targetCwd);
|
|
12528
|
+
const sorted = this.buildSessionSummaries(targetCwd, infos);
|
|
12529
|
+
this.emit({ type: "sessions", sessions: sorted, cwd: targetCwd });
|
|
12530
|
+
}
|
|
12531
|
+
catch {
|
|
12532
|
+
this.emit({ type: "sessions", sessions: [], cwd: targetCwd });
|
|
12533
|
+
}
|
|
12534
|
+
}
|
|
12465
12535
|
/** Remove an entry from the client's recent-project list (UI state only, or destroy if sandbox). */
|
|
12466
12536
|
async removeProject(path) {
|
|
12467
12537
|
const sbx = this.sandboxes.get(path) ?? this.sandboxes.getByCwd(path);
|
|
@@ -13362,8 +13432,19 @@ export class ClientSession {
|
|
|
13362
13432
|
/* ignore */
|
|
13363
13433
|
}
|
|
13364
13434
|
if (sid === wantSid || conv.id === wantSid) {
|
|
13435
|
+
if (independent !== undefined)
|
|
13436
|
+
this.setConversationIndependent(conv.id, independent);
|
|
13365
13437
|
await this.switchConversation(conv.id);
|
|
13366
13438
|
outcome = "reused";
|
|
13439
|
+
this.emit({
|
|
13440
|
+
type: "transition_progress",
|
|
13441
|
+
kind: "session",
|
|
13442
|
+
target: wantSid,
|
|
13443
|
+
phase: "done",
|
|
13444
|
+
progress: 100,
|
|
13445
|
+
text: "会话加载完成",
|
|
13446
|
+
textEn: "Session loaded",
|
|
13447
|
+
});
|
|
13367
13448
|
return;
|
|
13368
13449
|
}
|
|
13369
13450
|
}
|
|
@@ -15,10 +15,21 @@ import { normalizeSoftCapByModel, normalizeSoftCapTokens } from "./soft-cap.js";
|
|
|
15
15
|
import { deriveLegacy, legacyToDisabled, normalizeDisabledAgentTools } from "./tool-manager.js";
|
|
16
16
|
import { normalizeToolPromptOverrides } from "./tool-prompt-overrides.js";
|
|
17
17
|
import { UI_SLOTS } from "./plugin-ui-slots.js";
|
|
18
|
+
import { DEFAULT_PROMPT_DISABLED } from "./prompt-composer.js";
|
|
18
19
|
/** Persisted queue modes fall back to processing all queued messages. */
|
|
19
20
|
export function normalizeQueueMode(value) {
|
|
20
21
|
return value === "one-at-a-time" ? value : "all";
|
|
21
22
|
}
|
|
23
|
+
export function normalizePromptDisabled(stored) {
|
|
24
|
+
if (!stored || stored.promptDisabled === undefined) {
|
|
25
|
+
return [...DEFAULT_PROMPT_DISABLED];
|
|
26
|
+
}
|
|
27
|
+
const list = [...stored.promptDisabled];
|
|
28
|
+
if (!stored._promptPluginDevConfigured && !list.includes("plugin_dev")) {
|
|
29
|
+
list.push("plugin_dev");
|
|
30
|
+
}
|
|
31
|
+
return list;
|
|
32
|
+
}
|
|
22
33
|
/** 大模型 API 出错自动重试次数的默认值(SDK 默认 3)。 */
|
|
23
34
|
export const DEFAULT_RETRY_MAX_ATTEMPTS = 6;
|
|
24
35
|
/** 工具执行看门狗超时的默认值(默认 20 分钟;环境变量 PI_WEB_TOOL_TIMEOUT_MS 覆盖)。 */
|
|
@@ -903,7 +914,8 @@ export class ClientStateStore {
|
|
|
903
914
|
customSystemPrompt: stored?.customSystemPrompt ?? "",
|
|
904
915
|
promptTemplate,
|
|
905
916
|
promptOverrides,
|
|
906
|
-
promptDisabled: stored
|
|
917
|
+
promptDisabled: normalizePromptDisabled(stored),
|
|
918
|
+
_promptPluginDevConfigured: stored?._promptPluginDevConfigured,
|
|
907
919
|
toolPromptOverrides: normalizeToolPromptOverrides(stored?.toolPromptOverrides),
|
|
908
920
|
disabledSkills: stored?.disabledSkills ?? [],
|
|
909
921
|
disabledExtensions: stored?.disabledExtensions ?? [],
|
|
@@ -1002,7 +1014,10 @@ export class ClientStateStore {
|
|
|
1002
1014
|
customSystemPrompt: settings.customSystemPrompt ?? cur.customSystemPrompt ?? "",
|
|
1003
1015
|
promptTemplate: settings.promptTemplate ?? cur.promptTemplate ?? "",
|
|
1004
1016
|
promptOverrides: { ...(settings.promptOverrides ?? cur.promptOverrides) },
|
|
1005
|
-
promptDisabled: settings.promptDisabled
|
|
1017
|
+
promptDisabled: settings.promptDisabled !== undefined
|
|
1018
|
+
? [...settings.promptDisabled]
|
|
1019
|
+
: (cur.promptDisabled ?? [...DEFAULT_PROMPT_DISABLED]),
|
|
1020
|
+
_promptPluginDevConfigured: settings.promptDisabled !== undefined ? true : (cur._promptPluginDevConfigured ?? false),
|
|
1006
1021
|
toolPromptOverrides: normalizeToolPromptOverrides(settings.toolPromptOverrides ?? cur.toolPromptOverrides),
|
|
1007
1022
|
disabledSkills: settings.disabledSkills ?? cur.disabledSkills ?? [],
|
|
1008
1023
|
disabledExtensions: settings.disabledExtensions ?? cur.disabledExtensions ?? [],
|
|
@@ -7,6 +7,9 @@ const bindings = new Map();
|
|
|
7
7
|
const interactionReplies = new Map();
|
|
8
8
|
// Advisory only: these tools can create execution contexts or mutate host policy.
|
|
9
9
|
const highPrivilegeTools = new Set([
|
|
10
|
+
"bash",
|
|
11
|
+
"powershell",
|
|
12
|
+
"terminal",
|
|
10
13
|
"conversation",
|
|
11
14
|
"subagent",
|
|
12
15
|
"worktree",
|
|
@@ -27,6 +30,11 @@ const highPrivilegeTools = new Set([
|
|
|
27
30
|
export function isBotToolHighPrivilege(name) {
|
|
28
31
|
return highPrivilegeTools.has(name) || name.startsWith("subagent_") || name.startsWith("team_");
|
|
29
32
|
}
|
|
33
|
+
/** Compute tools that must be stripped due to capability attenuation when a task is dispatched cross-bot. */
|
|
34
|
+
export function computeAttenuatedTools(sourceTools, targetTools) {
|
|
35
|
+
const sourceSet = new Set(sourceTools);
|
|
36
|
+
return targetTools.filter((tool) => isBotToolHighPrivilege(tool) && !sourceSet.has(tool));
|
|
37
|
+
}
|
|
30
38
|
export function registerBotExecution(bot, authorizedResumePath, context) {
|
|
31
39
|
if (!bot?.enabled || !bot.id || !isAbsolute(bot.cwd) || !Number.isSafeInteger(bot.revision)) {
|
|
32
40
|
throw new Error("An enabled, versioned local Bot with an absolute cwd is required");
|
|
@@ -53,31 +61,51 @@ export function registerBotExecution(bot, authorizedResumePath, context) {
|
|
|
53
61
|
}
|
|
54
62
|
Object.freeze(groupContext.members);
|
|
55
63
|
Object.freeze(groupContext.messages);
|
|
64
|
+
if (groupContext.blackboard) {
|
|
65
|
+
Object.freeze(groupContext.blackboard.updatedBy);
|
|
66
|
+
Object.freeze(groupContext.blackboard);
|
|
67
|
+
}
|
|
56
68
|
Object.freeze(groupContext);
|
|
57
69
|
}
|
|
58
70
|
let active = true;
|
|
59
71
|
let model = snapshot.model;
|
|
60
72
|
const tools = new Set(snapshot.tools);
|
|
61
73
|
const skills = new Set(snapshot.skills);
|
|
74
|
+
const attenuatedList = context?.attenuatedTools ? Array.from(new Set(context.attenuatedTools)) : undefined;
|
|
75
|
+
const attenuatedSet = attenuatedList && attenuatedList.length > 0 ? new Set(attenuatedList) : undefined;
|
|
76
|
+
const sourceBotLabel = context?.sourceBotId ?? "unknown";
|
|
77
|
+
const attenuationWarning = attenuatedList && attenuatedList.length > 0
|
|
78
|
+
? `\n\n[SECURITY ATTENUATION] This task originated from bot '${sourceBotLabel}' without privileges for [${attenuatedList.join(", ")}]. Those tools have been strictly disabled for this execution.`
|
|
79
|
+
: "";
|
|
80
|
+
const blackboardBlock = context?.groupContext?.blackboard
|
|
81
|
+
? `\n\n[GROUP BLACKBOARD v${context.groupContext.blackboard.version}]${context.groupContext.blackboard.title ? ` ${context.groupContext.blackboard.title}` : ""}\n${context.groupContext.blackboard.content}`
|
|
82
|
+
: "";
|
|
62
83
|
const capability = {
|
|
63
84
|
bot: snapshot,
|
|
64
85
|
instructions: getBotExecutionInstructions(context?.primary === true) +
|
|
65
86
|
(context?.planOnly
|
|
66
87
|
? "\n\n[PLAN MODE HARD ENFORCEMENT]\nThis task is strictly PLAN ONLY. You are prohibited from mutating files, creating files, running state-changing terminal commands, or dispatching tasks. You must only read, inspect, and draft an executable plan via plan_update. Provide 1–32 steps with unique IDs, nonempty titles (max 200 characters), explicit pending/in_progress/done/failed status, and optional descriptions (max 1000 characters)."
|
|
67
|
-
: "")
|
|
88
|
+
: "") +
|
|
89
|
+
attenuationWarning +
|
|
90
|
+
blackboardBlock,
|
|
68
91
|
groupContext,
|
|
69
92
|
authorizedResumePath,
|
|
70
93
|
planOnly: context?.planOnly === true,
|
|
94
|
+
attenuatedTools: attenuatedList ? Object.freeze([...attenuatedList]) : undefined,
|
|
71
95
|
assertActive() {
|
|
72
96
|
if (!active)
|
|
73
97
|
throw new Error("Bot execution capability has been revoked");
|
|
74
98
|
},
|
|
75
99
|
allowsToolRegistration(name) {
|
|
100
|
+
if (attenuatedSet?.has(name))
|
|
101
|
+
return false;
|
|
76
102
|
return active && tools.has(name) && !isGroupToolForbiddenInPlanCatalog(name, context?.planOnly === true);
|
|
77
103
|
},
|
|
78
104
|
allowsTool(name, params) {
|
|
79
105
|
if (!active)
|
|
80
106
|
return false;
|
|
107
|
+
if (attenuatedSet?.has(name))
|
|
108
|
+
return false;
|
|
81
109
|
if (context?.planOnly) {
|
|
82
110
|
if (name === "plan_update")
|
|
83
111
|
return tools.has(name) && !checkGroupTaskPlanGuard(name, params, true);
|