pi-web-ui 0.114.0 → 0.114.2
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 +45 -0
- package/bin/pi-web-ui.mjs +15 -7
- package/dist/server/agent-service.js +190 -65
- package/dist/server/attachments.js +48 -2
- package/dist/server/canvas/canvas-agent-tool.js +3 -3
- package/dist/server/canvas/canvas-cards.js +1 -1
- package/dist/server/canvas/canvas-scheduled-task.js +45 -0
- package/dist/server/canvas/canvas-validation.js +1 -1
- package/dist/server/client-state.js +6 -2
- package/dist/server/communicate-tool.js +37 -11
- package/dist/server/device-center/connector.js +33 -14
- package/dist/server/device-center/hub-page.js +1 -1
- package/dist/server/device-center/hub.js +2 -1
- package/dist/server/device-center/local-hub.js +92 -0
- package/dist/server/device-center/local.js +60 -7
- package/dist/server/device-center/path-portal.js +1 -1
- package/dist/server/device-center/relay.js +45 -8
- package/dist/server/dispatch-domain-handlers.js +1 -0
- package/dist/server/dsh/dsh-agent-service.js +5 -1
- package/dist/server/durable/durable-event-projector.js +19 -3
- package/dist/server/durable/durable-models.js +134 -65
- package/dist/server/engine-probe.js +36 -6
- package/dist/server/global-loader.js +40 -2
- package/dist/server/index.js +56 -32
- package/dist/server/model-resolver.js +4 -1
- package/dist/server/patch-bash-process.js +125 -0
- package/dist/server/plugins.js +26 -2
- package/dist/server/preset-fields.js +7 -0
- package/dist/server/preset-share.js +1 -0
- package/dist/server/prompt-templates.js +106 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/resolve-global-sdk.js +2 -0
- package/dist/server/schedule-agent-tool.js +49 -26
- package/dist/server/scheduler-tasks.js +129 -11
- package/dist/server/settings-service.js +6 -0
- package/dist/server/text-quote.js +9 -0
- package/dist/server/tool-manager.js +2 -1
- package/dist/server/universal/drivers/claude-code.js +5 -0
- package/dist/server/universal/drivers/codex.js +336 -0
- package/dist/server/universal/index.js +1 -0
- package/dist/server/universal/universal-attachments.js +24 -1
- package/dist/server/universal/universal-session.js +42 -18
- package/docs/device-center.md +9 -3
- package/package.json +2 -2
- package/plugins/catalog.json +10 -0
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/BgTasksModal-BIlQ89vr.js +1 -0
- package/web/dist/assets/BgTasksModal-Ck2sjlPM.js +1 -0
- package/web/dist/assets/{CanvasStudio-BEJZE5BI.js → CanvasStudio-B3W6b_rA.js} +3 -3
- package/web/dist/assets/{CanvasStudio-CgUNHqos.js → CanvasStudio-Csv1Sj1-.js} +3 -3
- package/web/dist/assets/DeviceCenter-BQdDcO8A.js +3 -0
- package/web/dist/assets/DeviceCenter-CHRKL0Vy.js +3 -0
- package/web/dist/assets/DeviceGroups-D2rogxEN.js +1 -0
- package/web/dist/assets/Dropdown-ZLS04O8p.js +1 -0
- package/web/dist/assets/FilePreview-B9xoU6ON.js +2 -0
- package/web/dist/assets/FilePreview-DUQpVZkH.js +2 -0
- package/web/dist/assets/GlobalSearchModal-BXEGvUZq.js +1 -0
- package/web/dist/assets/GlobalSearchModal-CnVPmfOI.js +1 -0
- package/web/dist/assets/GroupConversation-CyIpQzDd.js +1 -0
- package/web/dist/assets/GroupConversation-DgYV3uYS.js +1 -0
- package/web/dist/assets/ModelConfigModal-DDZccDYt.js +2 -0
- package/web/dist/assets/PiSetupModal-DHbqfx8T.js +1 -0
- package/web/dist/assets/ProviderOAuthControls-C-MK36Dk.js +1 -0
- package/web/dist/assets/SCMPanel-imYI2Ecw.js +2 -0
- package/web/dist/assets/SCMPanel-sVZcV7dR.js +2 -0
- package/web/dist/assets/SettingsModal-Xw1Yoi3_.js +20 -0
- package/web/dist/assets/SettingsModal-mb4e34-0.js +20 -0
- package/web/dist/assets/{TerminalPanel-DL20uKgU.js → TerminalPanel-CLkJJvxg.js} +2 -2
- package/web/dist/assets/{TerminalPanel-D6cPRFei.js → TerminalPanel-DpcIellm.js} +2 -2
- package/web/dist/assets/TuiOverlayModal-4-fFAZe7.js +1 -0
- package/web/dist/assets/TuiOverlayModal-DCu01lks.js +1 -0
- package/web/dist/assets/app-globals-DcyO0UPi.js +1 -0
- package/web/dist/assets/{desktop-DPyTy4M3.js → desktop-YguLbrX1.js} +1 -1
- package/web/dist/assets/fi-DaSO0Q-m.js +325 -0
- package/web/dist/assets/index-Cdh3sibd.js +85 -0
- package/web/dist/assets/index-DDZMv6LO.css +1 -0
- package/web/dist/assets/index-DWw_SxRq.js +85 -0
- package/web/dist/assets/{plugin-host-CqA4yW6w.js → plugin-host-BRBg6zmQ.js} +1 -1
- package/web/dist/assets/theme-DDl-Oy1b.js +1 -0
- package/web/dist/index.html +10 -9
- package/web/dist/sw.js +1 -1
- package/dist/gh-comment-781.md +0 -5
- package/dist/server/device-center/local-page.js +0 -17
- package/dist/server/device-center/smoke-preview.js +0 -3
- package/dist/server/durable/durable-capabilities.js +0 -11
- package/dist/server/markers/builtins/services.js +0 -123
- package/dist/server/markers/builtins/todo.js +0 -189
- package/dist/server/markers-list-tool.js +0 -34
- package/dist/server/orchestrator.js +0 -109
- package/dist/server/system-prompt-soul.js +0 -41
- package/dist/server/univer-service.js +0 -448
- package/dist/server/universal/drivers/dsh-driver.js +0 -379
- package/dist/test-artifact.md +0 -9
- package/dist/test-preview-modal.md +0 -11
- package/dist/test-report.html +0 -20
- package/web/dist/assets/BgTasksModal-CS7UNzcw.js +0 -1
- package/web/dist/assets/BgTasksModal-Dk-tp78W.js +0 -1
- package/web/dist/assets/DeviceCenter-C8_CbxQ3.js +0 -3
- package/web/dist/assets/DeviceCenter-CVblvhNX.js +0 -3
- package/web/dist/assets/Dropdown-Oug0DDte.js +0 -1
- package/web/dist/assets/FilePreview-CvdX6nr6.js +0 -2
- package/web/dist/assets/FilePreview-kCZhfBAF.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BLH63yYP.js +0 -1
- package/web/dist/assets/GlobalSearchModal-DAkvlvp6.js +0 -1
- package/web/dist/assets/GroupConversation-Cgo4xbpa.js +0 -1
- package/web/dist/assets/GroupConversation-DZ71jEi8.js +0 -1
- package/web/dist/assets/ModelConfigModal-BpWdFdQC.js +0 -2
- package/web/dist/assets/PiSetupModal-mkWPSxMj.js +0 -1
- package/web/dist/assets/ProviderOAuthControls-VK_jqXYS.js +0 -1
- package/web/dist/assets/SCMPanel-BP1TUT-V.js +0 -2
- package/web/dist/assets/SCMPanel-BscPm9kf.js +0 -2
- package/web/dist/assets/SettingsModal-C8UgMjVM.js +0 -20
- package/web/dist/assets/SettingsModal-VynB7jNb.js +0 -20
- package/web/dist/assets/TuiOverlayModal-Dst3BmT8.js +0 -1
- package/web/dist/assets/TuiOverlayModal-NCkpNtTp.js +0 -1
- package/web/dist/assets/UniversalPathPicker-CfQFc_c3.js +0 -1
- package/web/dist/assets/UniversalPathPicker-DwxwNcFw.js +0 -1
- package/web/dist/assets/app-globals-CnO6KlEM.js +0 -325
- package/web/dist/assets/index-CPgAH5q7.js +0 -83
- package/web/dist/assets/index-Cje8iugL.js +0 -83
- package/web/dist/assets/index-DnKeiDbj.css +0 -1
- package/web/dist/assets/theme-BqdAjEjF.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,50 @@
|
|
|
12
12
|
|
|
13
13
|
暂无未发布内容。
|
|
14
14
|
|
|
15
|
+
## [0.114.2] — 2026-10-31
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- 无。
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **工具参数兼容性(#803)**:`communicate` 使用顶层对象参数,兼容 OpenAI、Anthropic 与 Google 的工具声明转换,同时保留各操作的执行前参数校验。
|
|
24
|
+
- **Durable 模型配置(#802)**:支持已有的 Vertex 协议,地址和模型覆盖保留内置目录、认证、动态发现与非聊天模型能力,并按实际协议发送请求。
|
|
25
|
+
- **流式消息与工具状态(#800、#801)**:Durable 工具输出不再混入助手正文;多步思考保持时间顺序,已完成工具在回合结束前显示结果,避免快照与增量交替引起滚动抖动。
|
|
26
|
+
- **重问时撤销任务(#799)**:编辑重问或重新发送时,撤销被丢弃历史中创建且尚未开始的定时任务;保留已开始、其他会话及缺少创建来源的历史任务。写入失败会停止重问并报告错误。
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- 增加真实 SDK 请求、Durable 事件投影、浏览器滚动与工具状态,以及定时任务持久化和失败恢复回归验证。
|
|
31
|
+
|
|
32
|
+
## [0.114.1] — 2026-10-31
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- **设备协作与引擎**:更新设备群组、远程桌面连接与引导,扩展 Codex 引擎、画布定时任务、对话通信与问卷队列,支持提示词模板命令。
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- **bash 精确停止**:停止命令仅作用于目标会话,控制器随会话过户和改名迁移,避免误停其他对话或子代理,以及把停止提示写到错误会话。
|
|
41
|
+
- **原生进程收尾**:限制退出后的输出排空和取消等待,防止命令完成或中止后工具仍挂起。
|
|
42
|
+
- **临时会话与标题**:保留已开始的临时对话,并通过运行中的会话管理器持久保存标题修改。
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- **回归验证**:新增双真实进程的跨客户端取消检查,修正历史分页集成测试游标并验证无效锚点触发重新同步。
|
|
47
|
+
|
|
48
|
+
<!-- auto-i18n:start -->
|
|
49
|
+
|
|
50
|
+
### i18n
|
|
51
|
+
|
|
52
|
+
- 前端新增 key(45):`settingsEngineCodexTitle`、`settingsEngineCodexDesc`、`engineCodexModelDesc`、`tpl.fieldCommand`、`tpl.commandHint`、`tpl.commandInvalid`、`tpl.commandDuplicate`、`tpl.storageError`、`deviceSetupServer`、`deviceSetupSshPort`、`deviceSetupUsername`、`deviceSetupAuth`、`deviceSetupAuthPassword`、`deviceSetupAuthKey`、`deviceSetupAuthExisting`、`deviceSetupServicePort`、`deviceSetupCredentialHint`、`deviceSetupOptionalTls`、`deviceSetupDomain`、`deviceSetupEnableHttps`、`deviceSetupTlsHint`、`deviceSetupPreview`、`deviceSetupPreviewEmpty`、`deviceSetupUserActions`、`deviceSetupCloudPorts`、`deviceSetupSourceScope`、`deviceSetupAfterStart`、`deviceSetupGuide`、`deviceSetupRemoteInvalid`、`deviceSetupStartAi`、`pendingQueueDefer`、`toolApprovalPresentation`、`toolApprovalPresentationDesc`、`toolApprovalPresentationAll`、`communicateEnabledDesc`、`communicateOffHint`、`schedulerTargetLabel`、`schedulerTargetConversation`、`schedulerTargetCanvas`、`schedulerGraphLabel`、`schedulerGraphPlaceholder`、`schedulerGraphUnavailable`、`schedulerGraphHint`、`schedulerRunBaseLabel`、`schedulerCanvasPromptPlaceholder`
|
|
53
|
+
- 前端删除 key(3):`deviceSetupNoServer`、`deviceSetupNoServerHint`、`deviceSetupCliHint`
|
|
54
|
+
- 前端中文变更(4):`deviceSetupRemote`、`deviceSetupRemoteHint`、`questionPresentationDesc`、`toolDescSubagent`
|
|
55
|
+
- 前端英文变更(4):`deviceSetupRemote`、`deviceSetupRemoteHint`、`questionPresentationDesc`、`toolDescSubagent`
|
|
56
|
+
|
|
57
|
+
<!-- auto-i18n:end -->
|
|
58
|
+
|
|
15
59
|
## [0.114.0] — 2026-10-30
|
|
16
60
|
|
|
17
61
|
### Added
|
|
@@ -2063,6 +2107,7 @@ when?, children?}`,也收 `topbar` / `settings` 这类简写别名);宿主
|
|
|
2063
2107
|
- 0.29.0(2026-08-23):全局搜索弹窗(Ctrl+K)+ 消息列表惰性窗口化。
|
|
2064
2108
|
|
|
2065
2109
|
[Unreleased]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.114.0...main
|
|
2110
|
+
[0.114.1]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.114.0...v0.114.1
|
|
2066
2111
|
[0.114.0]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.113.1...v0.114.0
|
|
2067
2112
|
[0.113.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.113.0
|
|
2068
2113
|
[0.112.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.112.0
|
package/bin/pi-web-ui.mjs
CHANGED
|
@@ -121,7 +121,7 @@ server 选项:
|
|
|
121
121
|
--port <n> 端口(默认 8787,或 $PI_WEB_PORT)
|
|
122
122
|
--cwd <dir> 工作目录(默认 $PI_WEB_CWD 或用户主目录;前台启动默认当前目录)
|
|
123
123
|
--data-dir <dir> 会话数据目录(默认 <cwd>/.pi-web)
|
|
124
|
-
--engine <pi|dsh> 智能体引擎(默认 $PI_WEB_ENGINE 或 pi)
|
|
124
|
+
--engine <pi|dsh|claude|codex|durable> 智能体引擎(默认 $PI_WEB_ENGINE 或 pi)
|
|
125
125
|
--host <addr> 监听地址(默认 $PI_WEB_HOST 或 127.0.0.1;0.0.0.0 供局域网/容器)
|
|
126
126
|
--agent-dir <dir> pi 配置目录(默认 $PI_CODING_AGENT_DIR 或 ~/.pi/agent)
|
|
127
127
|
--name <name> 服务名(默认 pi-web-ui;仅限字母/数字/-/_,字母或数字开头,
|
|
@@ -187,7 +187,7 @@ Server options:
|
|
|
187
187
|
--port <n> Port (default 8787, or $PI_WEB_PORT)
|
|
188
188
|
--cwd <dir> Working directory (default $PI_WEB_CWD or home dir; foreground uses current dir)
|
|
189
189
|
--data-dir <dir> Session data directory (default <cwd>/.pi-web)
|
|
190
|
-
--engine <pi|dsh> Agent engine (default $PI_WEB_ENGINE or pi)
|
|
190
|
+
--engine <pi|dsh|claude|codex|durable> Agent engine (default $PI_WEB_ENGINE or pi)
|
|
191
191
|
--host <addr> Listen address (default $PI_WEB_HOST or 127.0.0.1; 0.0.0.0 for LAN/containers)
|
|
192
192
|
--agent-dir <dir> pi config directory (default $PI_CODING_AGENT_DIR or ~/.pi/agent)
|
|
193
193
|
--name <name> Service name (default pi-web-ui; alphanumeric, "-" and "_" only,
|
|
@@ -448,8 +448,12 @@ async function startForeground(opts) {
|
|
|
448
448
|
if (opts.cwd) process.env.PI_WEB_CWD = resolve(opts.cwd);
|
|
449
449
|
if (opts.dataDir) process.env.PI_WEB_DATA_DIR = resolve(opts.dataDir);
|
|
450
450
|
if (opts.engine) {
|
|
451
|
-
if (
|
|
452
|
-
fail(
|
|
451
|
+
if (!["pi", "dsh", "claude", "codex", "durable"].includes(opts.engine))
|
|
452
|
+
fail(
|
|
453
|
+
ZH
|
|
454
|
+
? `无效引擎: ${opts.engine}(仅支持 pi / dsh / claude / codex / durable)`
|
|
455
|
+
: `Invalid engine: ${opts.engine} (pi, dsh, claude, codex, durable only)`,
|
|
456
|
+
);
|
|
453
457
|
process.env.PI_WEB_ENGINE = opts.engine;
|
|
454
458
|
}
|
|
455
459
|
if (opts.host) process.env.PI_WEB_HOST = opts.host;
|
|
@@ -1287,8 +1291,12 @@ function serviceOptions(opts) {
|
|
|
1287
1291
|
}
|
|
1288
1292
|
// 引擎/监听地址/agent 配置目录:flag 优先,环境变量后备(token 不走命令行,仅环境变量)。
|
|
1289
1293
|
const engine = opts.engine ?? process.env.PI_WEB_ENGINE ?? "pi";
|
|
1290
|
-
if (
|
|
1291
|
-
fail(
|
|
1294
|
+
if (!["pi", "dsh", "claude", "codex", "durable"].includes(engine))
|
|
1295
|
+
fail(
|
|
1296
|
+
ZH
|
|
1297
|
+
? `无效引擎: ${engine}(仅支持 pi / dsh / claude / codex / durable)`
|
|
1298
|
+
: `Invalid engine: ${engine} (pi, dsh, claude, codex, durable only)`,
|
|
1299
|
+
);
|
|
1292
1300
|
const host = opts.host ?? process.env.PI_WEB_HOST;
|
|
1293
1301
|
const agentDir = opts.agentDir ? resolve(opts.agentDir) : process.env.PI_CODING_AGENT_DIR;
|
|
1294
1302
|
return { name, port, cwd, dataDir, engine, host, agentDir };
|
|
@@ -1328,7 +1336,7 @@ function serviceEnv(port, cwd, dataDir, engine, host, agentDir, service = {}) {
|
|
|
1328
1336
|
if (!isWin && process.env.LANG) env.LANG = process.env.LANG;
|
|
1329
1337
|
if (!isWin && process.env.LC_ALL) env.LC_ALL = process.env.LC_ALL;
|
|
1330
1338
|
if (dataDir) env.PI_WEB_DATA_DIR = dataDir;
|
|
1331
|
-
if (engine
|
|
1339
|
+
if (engine !== "pi") env.PI_WEB_ENGINE = engine; // 仅非默认引擎才烘焙,保持服务单元简洁
|
|
1332
1340
|
if (host) env.PI_WEB_HOST = host;
|
|
1333
1341
|
if (agentDir) env.PI_CODING_AGENT_DIR = agentDir;
|
|
1334
1342
|
return env;
|
|
@@ -95,7 +95,7 @@ import { goalReviewDenial, shouldDeferPromptForReview } from "./goal-review-gate
|
|
|
95
95
|
import { readPlanModeFromSession, readPlanFromSession } from "./permission-preset.js";
|
|
96
96
|
import { readDelegateModeFromSession } from "./permission-preset.js";
|
|
97
97
|
import { applyHeadTail, makePersistentTerminalTools, makeTerminalBashTool, stripAnsi, TERMINAL_TOOLS_GUIDANCE, } from "./terminals.js";
|
|
98
|
-
import { applyAgentToolsGating, ASK_USER_QUESTION_TOOL_NAME, effectiveDisabledAgentTools, filterToolsByPreset, isAgentToolEnabled, isTerminalGuidanceOn, LAZY_CORE_TOOL_NAMES, lazyLoadingDisabledTools, LOAD_TOOLS_TOOL_NAME, localizedName, PI_AGENT_PRESETS, PI_PERMISSION_OPTIONS, PRESENT_FILES_TOOL_NAME, presetAllowsPluginTools, presetHasQuestionnaire, presetShowsSkillCatalog, } from "./tool-manager.js";
|
|
98
|
+
import { applyAgentToolsGating, ASK_USER_QUESTION_TOOL_NAME, effectiveDisabledAgentTools, filterToolsByPreset, isAgentToolEnabled, isTerminalGuidanceOn, LAZY_CORE_TOOL_NAMES, lazyLoadingDisabledTools, LOAD_TOOLS_TOOL_NAME, CANVAS_TOOL_NAME, localizedName, PI_AGENT_PRESETS, PI_PERMISSION_OPTIONS, PRESENT_FILES_TOOL_NAME, presetAllowsPluginTools, presetHasQuestionnaire, presetShowsSkillCatalog, } from "./tool-manager.js";
|
|
99
99
|
import { makeLoadToolsTool } from "./load-tools-tool.js";
|
|
100
100
|
import { formatCompactSignature } from "./tool-signature.js";
|
|
101
101
|
import { WebUIContext } from "./webui-context.js";
|
|
@@ -335,9 +335,10 @@ export class ClientSession {
|
|
|
335
335
|
* considered stopped once its agent_end event arrives. If it doesn't
|
|
336
336
|
* (model stream stuck before the run even started), force-reset. */
|
|
337
337
|
static HARD_ABORT_SETTLE_MS = 8_000;
|
|
338
|
-
/**
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
/** Resolve only an explicit execution owner; never borrow the active conversation. */
|
|
339
|
+
bashKillsOf(conv) {
|
|
340
|
+
return (conv.bashKills ??= new Set());
|
|
341
|
+
}
|
|
341
342
|
/** Background-server tracking (port snapshots + 后台任务 panel state) —
|
|
342
343
|
* 自包含模块,见 bg-servers.ts。列表按 CLIENT 存活,不随对话切换/结束消失。 */
|
|
343
344
|
/** 用户直接创建的交互式终端(按 CLIENT/工作区 存活,始终显示,不受单个对话切换、生命周期与过滤影响) */
|
|
@@ -1892,6 +1893,19 @@ export class ClientSession {
|
|
|
1892
1893
|
}
|
|
1893
1894
|
return { loaded, rejected };
|
|
1894
1895
|
}
|
|
1896
|
+
/** A canvas reference loads the existing tool only within this session's permissions. */
|
|
1897
|
+
prepareCanvasReference(session, conv) {
|
|
1898
|
+
if (this.lazyLoadingOn())
|
|
1899
|
+
this.loadLazyTools(session, conv, [CANVAS_TOOL_NAME]);
|
|
1900
|
+
if (!session.getActiveToolNames().includes(CANVAS_TOOL_NAME)) {
|
|
1901
|
+
this.emit({
|
|
1902
|
+
type: "notice",
|
|
1903
|
+
level: "warning",
|
|
1904
|
+
text: "当前会话无法调用画布工具,请检查工具开关、预设与执行权限。",
|
|
1905
|
+
textEn: "Canvas is unavailable in this conversation. Check tool settings, preset, and execution permissions.",
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1895
1909
|
/**
|
|
1896
1910
|
* JIT Auto-activation: if an allowed catalog tool is executed without prior load_tools,
|
|
1897
1911
|
* automatically mark it as loaded so subsequent turns track it as fully active.
|
|
@@ -2254,13 +2268,27 @@ export class ClientSession {
|
|
|
2254
2268
|
},
|
|
2255
2269
|
};
|
|
2256
2270
|
/** schedule_* 工具的数据宿主:全局调度存储+创建时刻 live 的 cwd/活动对话。 */
|
|
2257
|
-
scheduleToolHost() {
|
|
2258
|
-
|
|
2271
|
+
scheduleToolHost(anchor) {
|
|
2272
|
+
const source = () => {
|
|
2273
|
+
const home = anchor?.session ? this.toolConversationHome(anchor.session) : undefined;
|
|
2274
|
+
if (!home)
|
|
2275
|
+
throw new Error("Scheduled-task source session is no longer available");
|
|
2276
|
+
return home;
|
|
2277
|
+
};
|
|
2278
|
+
const host = createScheduleToolHost({
|
|
2259
2279
|
getSchedulerStore: () => this.schedulerStore,
|
|
2260
2280
|
getCwd: () => this.cwd,
|
|
2261
2281
|
getActiveId: () => this.activeId,
|
|
2262
2282
|
getConversation: (id) => this.convs.get(id),
|
|
2263
2283
|
});
|
|
2284
|
+
if (anchor) {
|
|
2285
|
+
host.store = () => source().client.schedulerStore;
|
|
2286
|
+
host.executionSource = () => {
|
|
2287
|
+
const { conv } = source();
|
|
2288
|
+
return { cwd: conv.cwd, conversationId: conv.id, sessionFile: conv.session.sessionFile ?? "" };
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
return host;
|
|
2264
2292
|
}
|
|
2265
2293
|
/** conversation_read 工具的数据宿主 */
|
|
2266
2294
|
conversationReadHost() {
|
|
@@ -3485,7 +3513,7 @@ export class ClientSession {
|
|
|
3485
3513
|
// 发起对话(ownerId,无则活动对话),到期 steer 语义唤醒它;子代理
|
|
3486
3514
|
// 会话同样注册(owner 即真正派发的父对话)。开关走统一工具 tab。
|
|
3487
3515
|
// DSH 引擎无 customTool 注册面,不接。
|
|
3488
|
-
makeScheduleTool(this.scheduleToolHost(), ownerId, () => this.getLang()),
|
|
3516
|
+
makeScheduleTool(this.scheduleToolHost(bridgeAnchor), ownerId, () => this.getLang()),
|
|
3489
3517
|
// 持久代码求值沙箱(eval):开关走统一工具 tab(ActiveSet 门控,默认关)。
|
|
3490
3518
|
// ownerId 绑定当前会话;DSH 引擎无 customTool 注册面,不接。
|
|
3491
3519
|
makeEvalTool({
|
|
@@ -5333,6 +5361,7 @@ export class ClientSession {
|
|
|
5333
5361
|
pendingQuestion: this.pendingQuestionForSnapshot(),
|
|
5334
5362
|
actionSuggestions: this.markerSvc.getActionSuggestions(this.activeId) ?? null,
|
|
5335
5363
|
pendingApproval: this.pendingApprovalForSnapshot(),
|
|
5364
|
+
pendingApprovals: this.pendingApprovalsForSnapshot(),
|
|
5336
5365
|
// 任务计划看板状态同样是会话级:快照恒给 PlanState 或 null(不用 undefined),
|
|
5337
5366
|
// 否则 snapshot_delta 里 key 缺席 → 前端 spread 浅合并会残留上一对话的 plan。
|
|
5338
5367
|
plan: this.planManager.getPlan(this.activeId) ?? null,
|
|
@@ -5636,6 +5665,12 @@ export class ClientSession {
|
|
|
5636
5665
|
};
|
|
5637
5666
|
return {
|
|
5638
5667
|
...this.subagentHost,
|
|
5668
|
+
spawnSubagent: (prompt, type, cwd, templateName, model, _parentId, persist, thinking, notifyOnDone, isolation, extra, signal) => {
|
|
5669
|
+
// Resolve by runtime identity: a moved parent's new id can also name
|
|
5670
|
+
// the replacement conversation in the original client.
|
|
5671
|
+
const home = current();
|
|
5672
|
+
return home.session.spawnSubagentViaHost(prompt, type, cwd, templateName, model, home.convId, persist, thinking, notifyOnDone, isolation, extra, signal);
|
|
5673
|
+
},
|
|
5639
5674
|
handoffSubagent: async (_from, to, payload) => {
|
|
5640
5675
|
const home = current();
|
|
5641
5676
|
await home.session.communicate(home.convId, "send", { to, message: payload });
|
|
@@ -6297,6 +6332,24 @@ export class ClientSession {
|
|
|
6297
6332
|
this.settingsSvc.push();
|
|
6298
6333
|
this.flushSnapshot();
|
|
6299
6334
|
}
|
|
6335
|
+
pendingApprovalsForSnapshot() {
|
|
6336
|
+
return [...this.convs.values()]
|
|
6337
|
+
.flatMap((conv) => [...(conv.pendingApprovals?.values() ?? [])].map((entry) => ({
|
|
6338
|
+
id: entry.id,
|
|
6339
|
+
toolCallId: entry.toolCallId,
|
|
6340
|
+
toolName: entry.toolName,
|
|
6341
|
+
params: entry.params,
|
|
6342
|
+
reason: entry.reason,
|
|
6343
|
+
reasonEn: entry.reasonEn,
|
|
6344
|
+
category: entry.category,
|
|
6345
|
+
hits: entry.hits,
|
|
6346
|
+
parentTool: entry.parentTool,
|
|
6347
|
+
conversationId: entry.conversationId,
|
|
6348
|
+
conversationTitle: entry.conversationTitle,
|
|
6349
|
+
createdAt: entry.createdAt,
|
|
6350
|
+
})))
|
|
6351
|
+
.sort((a, b) => a.createdAt - b.createdAt);
|
|
6352
|
+
}
|
|
6300
6353
|
pendingApprovalForSnapshot() {
|
|
6301
6354
|
const conv = this.conv;
|
|
6302
6355
|
if (!conv?.pendingApprovals || conv.pendingApprovals.size === 0)
|
|
@@ -8260,45 +8313,63 @@ export class ClientSession {
|
|
|
8260
8313
|
const composeWrite = (base) => planGate(wrapWriteToolWithPermission(cwd, currentPermission, () => this.roots, () => this.getLang(), approve, () => ownerId, () => this.approvalRules.list(), base));
|
|
8261
8314
|
const composeEdit = (base) => planGate(wrapEditToolWithPermission(cwd, currentPermission, () => this.roots, () => this.getLang(), approve, () => ownerId, () => this.approvalRules.list(), base));
|
|
8262
8315
|
const composeBash = (base) => {
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8316
|
+
const makeCore = (convKills) => {
|
|
8317
|
+
let core;
|
|
8318
|
+
if (base) {
|
|
8319
|
+
// 扩展提供了同名 bash:以扩展定义为基底,保留其 schema/描述/guidelines,
|
|
8320
|
+
// 同时挂载 abort_bash 信号中断支持与 head/tail 输出后处理。
|
|
8321
|
+
core = {
|
|
8322
|
+
...base,
|
|
8323
|
+
execute: async (toolCallId, params, signal, onUpdate, ctx) => {
|
|
8324
|
+
const ac = new AbortController();
|
|
8325
|
+
convKills.add(ac);
|
|
8326
|
+
try {
|
|
8327
|
+
const signals = [signal, ac.signal].filter((s) => s !== undefined);
|
|
8328
|
+
const combinedSignal = signals.length > 1 ? AbortSignal.any(signals) : signals[0];
|
|
8329
|
+
const result = (await base.execute(toolCallId, params, combinedSignal, onUpdate, ctx));
|
|
8330
|
+
const p = params;
|
|
8331
|
+
if ((p?.head || p?.tail) && result?.content?.[0]?.text != null) {
|
|
8332
|
+
result.content[0].text = applyHeadTail(result.content[0].text, p.head, p.tail, this.getLang());
|
|
8333
|
+
}
|
|
8334
|
+
return result;
|
|
8279
8335
|
}
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
}
|
|
8336
|
+
finally {
|
|
8337
|
+
convKills.delete(ac);
|
|
8338
|
+
}
|
|
8339
|
+
},
|
|
8340
|
+
};
|
|
8341
|
+
}
|
|
8342
|
+
else {
|
|
8343
|
+
// 没有扩展 bash:完整的原生与终端自适应分流 bash(行为与改动前逐字一致)。
|
|
8344
|
+
core = makeAdaptiveBashTool(makeKillableBashTool(cwd, convKills, () => this.getLang()), terminals
|
|
8345
|
+
? makeTerminalBashTool(terminals, {
|
|
8346
|
+
cwd,
|
|
8347
|
+
defaultPersist: () => false,
|
|
8348
|
+
idleMs: () => Math.max(0, Math.floor(this.settingsSvc.current.terminalBashIdleMs) || 0),
|
|
8349
|
+
maxForegroundMs: () => Math.max(0, Math.floor(this.settingsSvc.current.terminalBashMaxForegroundMs) || 0),
|
|
8350
|
+
kills: convKills,
|
|
8351
|
+
notifyBackgroundDone: (info) => this.notifyTerminalBashDone(terminals, info),
|
|
8352
|
+
lang: () => this.getLang(),
|
|
8353
|
+
})
|
|
8354
|
+
: makeKillableBashTool(cwd, convKills, () => this.getLang()), () => Boolean(terminals && this.settingsSvc.current.terminalBash));
|
|
8355
|
+
}
|
|
8356
|
+
return core;
|
|
8357
|
+
};
|
|
8358
|
+
// SDK constructs tools before registering the Conversation. Resolve ownership
|
|
8359
|
+
// when execution begins; bindOwner supplies the current holder/session after takeover.
|
|
8360
|
+
const core = {
|
|
8361
|
+
...makeCore(new Set()),
|
|
8362
|
+
execute: (...args) => {
|
|
8363
|
+
const conv = evidenceSession
|
|
8364
|
+
? this.toolConversationHome(evidenceSession)?.conv
|
|
8365
|
+
: ownerId
|
|
8366
|
+
? this.convs.get(ownerId)
|
|
8367
|
+
: undefined;
|
|
8368
|
+
if (!conv)
|
|
8369
|
+
throw new Error("Tool conversation is no longer available");
|
|
8370
|
+
return makeCore(this.bashKillsOf(conv)).execute(...args);
|
|
8371
|
+
},
|
|
8372
|
+
};
|
|
8302
8373
|
const guarded = withToolGuard(withWorkspaceSnapshotGate(core, () => this.awaitPendingWorkspaceSnapshot(ownerId)), {
|
|
8303
8374
|
toolName: "bash",
|
|
8304
8375
|
guard: this.lateToolGuard,
|
|
@@ -9887,6 +9958,9 @@ export class ClientSession {
|
|
|
9887
9958
|
});
|
|
9888
9959
|
return;
|
|
9889
9960
|
}
|
|
9961
|
+
if (asides.some((aside) => aside.message.details?.mode === "canvas")) {
|
|
9962
|
+
this.prepareCanvasReference(s, conv);
|
|
9963
|
+
}
|
|
9890
9964
|
// 空闲前置:若当前未处于流式运行且上下文超标,提早在注入附件前执行软上限主动压缩(issue #716)。
|
|
9891
9965
|
// 必须在任何 nextTurn 注入之前完成,避免耗时压缩期间发生状态变化导致附件残留泄漏(fixes #717)。
|
|
9892
9966
|
if (!s.isStreaming) {
|
|
@@ -10365,12 +10439,17 @@ export class ClientSession {
|
|
|
10365
10439
|
const thresholdMs = (minutes > 0 ? minutes : BG_CLEANUP_FALLBACK_MIN) * 60_000;
|
|
10366
10440
|
return this.bg.cleanStale(thresholdMs, { manual: true });
|
|
10367
10441
|
}
|
|
10368
|
-
/** Kill only the running bash command(s) — the agent run
|
|
10369
|
-
* (the bash tool returns an aborted error and
|
|
10370
|
-
* the per-
|
|
10371
|
-
* ({@link makeKillableBashTool} / {@link makeTerminalBashTool})
|
|
10372
|
-
|
|
10373
|
-
|
|
10442
|
+
/** Kill only the running bash command(s) of ONE conversation — the agent run and
|
|
10443
|
+
* every other conversation continue (the bash tool returns an aborted error and
|
|
10444
|
+
* the model moves on). Targets the per-conversation bucket registered by the
|
|
10445
|
+
* bash tool paths ({@link makeKillableBashTool} / {@link makeTerminalBashTool});
|
|
10446
|
+
* without an explicit id it targets only the active conversation. */
|
|
10447
|
+
async abortBash(convId) {
|
|
10448
|
+
const ownerConv = this.convs.get(convId ?? this.activeId);
|
|
10449
|
+
// Abort listeners run synchronously and may detach, replace, or reset the owner.
|
|
10450
|
+
const runtime = ownerConv?.runtime;
|
|
10451
|
+
const kills = ownerConv?.bashKills;
|
|
10452
|
+
if (!kills || kills.size === 0) {
|
|
10374
10453
|
this.emit({
|
|
10375
10454
|
type: "notice",
|
|
10376
10455
|
level: "info",
|
|
@@ -10381,7 +10460,7 @@ export class ClientSession {
|
|
|
10381
10460
|
return;
|
|
10382
10461
|
}
|
|
10383
10462
|
// eslint-disable-next-line unicorn/no-useless-spread -- snapshot: handlers may unsubscribe mid-emit
|
|
10384
|
-
for (const ac of [...
|
|
10463
|
+
for (const ac of [...kills])
|
|
10385
10464
|
ac.abort();
|
|
10386
10465
|
this.emit({
|
|
10387
10466
|
type: "notice",
|
|
@@ -10392,9 +10471,11 @@ export class ClientSession {
|
|
|
10392
10471
|
// 让 AI 明确知道是用户手动停止:sendUserMessage 触发下一轮,agent
|
|
10393
10472
|
// 会看到「命令被用户中止」而不是普通失败,并据此继续(不会困惑于
|
|
10394
10473
|
// 为什么命令失败了)。
|
|
10474
|
+
// 停止提示发给命令真正所属的那个对话,别写进用户正在看的另一个对话。
|
|
10395
10475
|
try {
|
|
10396
|
-
|
|
10397
|
-
|
|
10476
|
+
if (ownerConv)
|
|
10477
|
+
this.assertSubagentWorktreeAdmission(ownerConv);
|
|
10478
|
+
await runtime?.session.sendUserMessage("(系统:用户手动停止了刚才的 bash 命令——命令被中止,终止前已输出的内容在对应工具结果里。请据此继续,不要重跑被中止的命令,除非确实必要。)");
|
|
10398
10479
|
}
|
|
10399
10480
|
catch {
|
|
10400
10481
|
// best effort — 消息注入失败不影响命令已停止的事实
|
|
@@ -11112,7 +11193,10 @@ export class ClientSession {
|
|
|
11112
11193
|
// points at it: dropping an idle in-memory parent orphans the child row
|
|
11113
11194
|
// (the child vanishes from Running Chats with no result available).
|
|
11114
11195
|
const hasLiveChild = [...this.convs.values()].some((child) => child.parentId === conv.id);
|
|
11115
|
-
|
|
11196
|
+
// Ephemeral transcripts have no history fallback: once started, only an
|
|
11197
|
+
// explicit close may discard them, even after revisiting without a prompt.
|
|
11198
|
+
const retainFinished = (Boolean(conv.isEphemeral) || Boolean(this.settingsSvc?.current.retainFinishedConversations)) &&
|
|
11199
|
+
this.isConversationStarted(conv);
|
|
11116
11200
|
const retained = hasLiveChild ||
|
|
11117
11201
|
retainFinished ||
|
|
11118
11202
|
shouldRetainActive({
|
|
@@ -12244,9 +12328,14 @@ export class ClientSession {
|
|
|
12244
12328
|
return;
|
|
12245
12329
|
conv.title = trimmed;
|
|
12246
12330
|
try {
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12331
|
+
// Write through the LIVE session manager, not a throwaway SessionManager.open().
|
|
12332
|
+
// Only the live manager keeps its in-memory entry list and the transcript in
|
|
12333
|
+
// sync, so the title also rides along when the file is created later: a
|
|
12334
|
+
// brand-new conversation has no .jsonl yet (pi's _persist() refuses to write
|
|
12335
|
+
// before the first user/assistant message), and a freshly opened manager on a
|
|
12336
|
+
// missing path silently drops appendSessionInfo(). That made a rename of a
|
|
12337
|
+
// not-yet-flushed conversation disappear after a server restart.
|
|
12338
|
+
conv.session.setSessionName(trimmed);
|
|
12250
12339
|
}
|
|
12251
12340
|
catch {
|
|
12252
12341
|
// in-memory title still updated; transcript write is best-effort
|
|
@@ -13036,6 +13125,7 @@ export class ClientSession {
|
|
|
13036
13125
|
const conv = this.makeConversation(openedRuntime, conversationId, openedTerminals);
|
|
13037
13126
|
// Deliberately resumed — must not be dismissed when the user later
|
|
13038
13127
|
// switches away without sending a new message.
|
|
13128
|
+
conv.listed = true;
|
|
13039
13129
|
conv.promptedSinceActive = true;
|
|
13040
13130
|
if (this.stateStore?.isSessionPinned(targetCwd, targetPath)) {
|
|
13041
13131
|
conv.pinned = true;
|
|
@@ -13519,13 +13609,48 @@ export class ClientSession {
|
|
|
13519
13609
|
return;
|
|
13520
13610
|
const manager = session.sessionManager;
|
|
13521
13611
|
const baseEntryId = findTurnBaseEntryId(manager, entryId);
|
|
13522
|
-
|
|
13523
|
-
manager.
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13612
|
+
const commitReask = () => {
|
|
13613
|
+
const previousLeaf = manager.getLeafId();
|
|
13614
|
+
try {
|
|
13615
|
+
if (baseEntryId)
|
|
13616
|
+
manager.branch(baseEntryId);
|
|
13617
|
+
else
|
|
13618
|
+
manager.resetLeaf();
|
|
13619
|
+
manager.appendCustomEntry("pi-web-ui:reask", { version: 1 });
|
|
13620
|
+
}
|
|
13621
|
+
catch (err) {
|
|
13622
|
+
// SDK append mutates indexes before writing; discard an uncommitted marker too.
|
|
13623
|
+
if (sessionFile)
|
|
13624
|
+
manager.setSessionFile(sessionFile);
|
|
13625
|
+
if (previousLeaf)
|
|
13626
|
+
manager.branch(previousLeaf);
|
|
13627
|
+
else
|
|
13628
|
+
manager.resetLeaf();
|
|
13629
|
+
throw err;
|
|
13630
|
+
}
|
|
13631
|
+
};
|
|
13632
|
+
// Cancel only tasks proven to originate in the suffix being discarded.
|
|
13633
|
+
// Persist cancellation first: a failed scheduler write must leave its transcript visible.
|
|
13634
|
+
if (this.schedulerStore && sessionFile) {
|
|
13635
|
+
const discardedCalls = new Set();
|
|
13636
|
+
const branch = manager.getBranch();
|
|
13637
|
+
const baseIndex = baseEntryId ? branch.findIndex((entry) => entry.id === baseEntryId) : -1;
|
|
13638
|
+
if (baseEntryId && baseIndex < 0)
|
|
13639
|
+
throw new Error("Reask base is no longer on the current branch");
|
|
13640
|
+
for (const entry of branch.slice(baseIndex + 1)) {
|
|
13641
|
+
if (entry.type !== "message" || entry.message.role !== "assistant")
|
|
13642
|
+
continue;
|
|
13643
|
+
for (const block of entry.message.content) {
|
|
13644
|
+
if (block.type === "toolCall" && block.name === "schedule")
|
|
13645
|
+
discardedCalls.add(block.id);
|
|
13646
|
+
}
|
|
13647
|
+
}
|
|
13648
|
+
this.schedulerStore.cancelUnstartedFromCalls(sessionFile, discardedCalls, commitReask);
|
|
13649
|
+
}
|
|
13650
|
+
else {
|
|
13651
|
+
// Persist the selection so calibration cannot resurrect abandoned history.
|
|
13652
|
+
commitReask();
|
|
13653
|
+
}
|
|
13529
13654
|
session.agent.state.messages = manager.buildSessionContext().messages;
|
|
13530
13655
|
// reload() refreshes resources; it does not replace the manager/leaf.
|
|
13531
13656
|
await session.reload();
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { uploadLimitBytes, isUploadDataTooLong } from "./payload-limits.js";
|
|
2
2
|
import { formatTextQuote, readTextQuote } from "./text-quote.js";
|
|
3
3
|
import { sniffImageMime } from "./text-sniff.js";
|
|
4
|
-
import { saveUpload, uploadsRoot } from "./uploads.js";
|
|
4
|
+
import { resolveDataDir, saveUpload, uploadsRoot } from "./uploads.js";
|
|
5
|
+
import { isSafeGraphId, loadCanvasGraph } from "./canvas/canvas-store.js";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
5
8
|
import { isAbsoluteWirePath, wireToAbs } from "./files-service.js";
|
|
6
9
|
import { buildVisionBridgePrompt, findVisionModels, transcribeImages } from "./vision-bridge.js";
|
|
7
10
|
import { saveAttachment } from "./attachment-store.js";
|
|
8
11
|
import { getGlobalRemoteSshService, isRemoteWorkspaceUri, parseRemoteWorkspaceUri, resolveRemoteWorkspacePath, } from "./remote-ssh-service.js";
|
|
12
|
+
/** Resolve reference metadata without creating the store's implicit default graph. */
|
|
13
|
+
export function getCanvasReference(graphId) {
|
|
14
|
+
const dataDir = resolveDataDir();
|
|
15
|
+
if (!isSafeGraphId(graphId) || !existsSync(join(dataDir, "canvas", `${graphId}.json`))) {
|
|
16
|
+
throw new Error("Invalid or missing canvas reference");
|
|
17
|
+
}
|
|
18
|
+
const graph = loadCanvasGraph(dataDir, graphId);
|
|
19
|
+
if (graph.id !== graphId)
|
|
20
|
+
throw new Error("Canvas graph id mismatch");
|
|
21
|
+
return { id: graphId, title: graph.name || graphId };
|
|
22
|
+
}
|
|
9
23
|
/** 跨快照的视觉转写缓存:批次 hash(名称 + base64 头 + 提示词)→ 转写文本。
|
|
10
24
|
* 编辑重问重发相同图片不再重复耗视觉 token。进程级共享即可。
|
|
11
25
|
* 长驻进程下无界 Map 会随图片种类缓慢吃内存(单条转写可达数十 KB),
|
|
@@ -138,7 +152,7 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
138
152
|
}
|
|
139
153
|
continue;
|
|
140
154
|
}
|
|
141
|
-
if (att.fileData || !att.path)
|
|
155
|
+
if (att.mode === "canvas" || att.fileData || !att.path)
|
|
142
156
|
continue;
|
|
143
157
|
const ext = extname(att.path).toLowerCase();
|
|
144
158
|
if (!IMAGE_EXT.has(ext) || ext === ".svg")
|
|
@@ -342,6 +356,38 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
342
356
|
});
|
|
343
357
|
continue;
|
|
344
358
|
}
|
|
359
|
+
// Canvas identifiers are not filesystem paths. Resolve only through the canvas store.
|
|
360
|
+
if (att.mode === "canvas") {
|
|
361
|
+
const graphId = att.path;
|
|
362
|
+
try {
|
|
363
|
+
const { title } = getCanvasReference(graphId);
|
|
364
|
+
out.push({
|
|
365
|
+
message: {
|
|
366
|
+
customType: "file",
|
|
367
|
+
content: [
|
|
368
|
+
{
|
|
369
|
+
type: "text",
|
|
370
|
+
text: `
|
|
371
|
+
<canvas-ref id="${attr(graphId)}" title="${attr(title)}">
|
|
372
|
+
The user referenced this canvas. First use canvas(action="get", graphId="${attr(graphId)}") to inspect its topology and status. Only when the user requests execution, use canvas(action="run_all", graphId="${attr(graphId)}", prompt="the user requirements"); prompt supplies the run initialPrompt. Use canvas(action="get_log", graphId="${attr(graphId)}") for logs, and action="get" for status. This reference alone does not authorize or start a run.
|
|
373
|
+
</canvas-ref>`,
|
|
374
|
+
},
|
|
375
|
+
],
|
|
376
|
+
display: true,
|
|
377
|
+
details: { mode: "canvas", path: graphId, name: title, title },
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
ctx.emit({
|
|
383
|
+
type: "notice",
|
|
384
|
+
level: "warning",
|
|
385
|
+
text: `画布引用无效或不存在,已跳过:${graphId}`,
|
|
386
|
+
textEn: `Invalid or missing canvas reference, skipped: ${graphId}`,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
345
391
|
// Granted web page (page-picker extension): `path` is the page origin,
|
|
346
392
|
// NOT a workspace path — never stat/read it. The model gets the exact
|
|
347
393
|
// browser_page target plus the fact that this page is already granted,
|
|
@@ -173,9 +173,9 @@ export function makeCanvasTool(host, lang) {
|
|
|
173
173
|
name: CANVAS_TOOL_NAME,
|
|
174
174
|
label: "Canvas pipeline",
|
|
175
175
|
description: "Read and edit canvas workflow graphs: list/get/create/delete graphs, add/update/delete nodes and edges, replace the DAG, layout/rearrange nodes on a tidy grid, run all or one node, stop, steer a running node, approve/reject review gates, read node logs, reset status, manage reusable custom cards. Use it when the user asks to create, change, run, or debug a pipeline.",
|
|
176
|
-
promptSnippet: "
|
|
176
|
+
promptSnippet: "Inspect, edit, run, or debug canvas workflows and canvas references.",
|
|
177
177
|
promptGuidelines: [
|
|
178
|
-
"
|
|
178
|
+
"Get the referenced graph before editing or running it; a canvas reference alone does not request execution",
|
|
179
179
|
"Running nodes costs tokens/time: prefer run_node for single-node debug, run_all only when the user asks",
|
|
180
180
|
"After steering or review, use get_log to confirm the node state before summarizing",
|
|
181
181
|
"New nodes default their cwd to the user's current project (getCwd); pass an absolute cwd only to pin another project",
|
|
@@ -320,7 +320,7 @@ export function makeCanvasTool(host, lang) {
|
|
|
320
320
|
x: 80 + (graph.nodes.length % 3) * 380,
|
|
321
321
|
y: 80 + Math.floor(graph.nodes.length / 3) * 260,
|
|
322
322
|
width: 300,
|
|
323
|
-
engine: ["pi", "dsh", "claude", "durable"].includes(card.engine)
|
|
323
|
+
engine: ["pi", "dsh", "codex", "claude", "durable"].includes(card.engine)
|
|
324
324
|
? card.engine
|
|
325
325
|
: "pi",
|
|
326
326
|
model: card.model || graph.nodes[0]?.model || "pi/default",
|
|
@@ -8,7 +8,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
import { writeJsonAtomicSync } from "../atomic-file.js";
|
|
10
10
|
import { isSafeGraphId } from "./canvas-store.js";
|
|
11
|
-
const VALID_ENGINES = new Set(["pi", "dsh", "claude", "durable"]);
|
|
11
|
+
const VALID_ENGINES = new Set(["pi", "dsh", "codex", "claude", "durable"]);
|
|
12
12
|
/** 卡片 id 与节点 id 同一安全口径:可作文件名/分支名,不穿越。 */
|
|
13
13
|
export function isSafeCardId(id) {
|
|
14
14
|
return isSafeGraphId(id);
|