pi-web-ui 0.114.0 → 0.114.1
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 +28 -0
- package/README.md +187 -187
- package/README.zh-CN.md +227 -227
- package/README.zh-TW.md +227 -227
- package/bin/device-hub-cli.mjs +577 -577
- package/bin/frp-manager.mjs +1573 -1573
- package/bin/pi-device-hub.mjs +9 -9
- package/bin/pi-web-ui.mjs +4081 -4073
- package/deploy/nginx-subpath.conf +100 -100
- package/deploy/pi-web-ui.service +36 -36
- package/dist/server/agent-service.js +131 -55
- package/dist/server/attachments.js +51 -5
- package/dist/server/canvas/canvas-agent-tool.js +3 -3
- package/dist/server/canvas/canvas-cards.js +1 -1
- package/dist/server/canvas/canvas-orchestrator.js +3 -3
- 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/compaction-instructions.js +8 -8
- package/dist/server/device-center/connector.js +33 -14
- package/dist/server/device-center/desktop-page.js +228 -228
- package/dist/server/device-center/hub-page.js +64 -64
- 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/native-desktop/macos.js +190 -190
- package/dist/server/device-center/native-desktop/windows.js +116 -116
- 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/dsh/runtime/cordis.yml +1 -1
- package/dist/server/dsh/runtime/custom-prompt.mjs +33 -33
- package/dist/server/dsh/runtime/goal-rpc.mjs +1309 -1309
- package/dist/server/dsh/runtime/launcher.mjs +235 -235
- package/dist/server/dsh/runtime/override.patch.yml +89 -89
- package/dist/server/dsh/runtime/runtime-root.mjs +405 -405
- package/dist/server/engine-probe.js +36 -6
- package/dist/server/eval-tool.js +135 -135
- package/dist/server/global-loader.js +40 -2
- package/dist/server/index.js +56 -32
- package/dist/server/patch-bash-process.js +125 -0
- package/dist/server/patch-tool.js +9 -9
- package/dist/server/patch-turn-end-boundary.js +3 -3
- package/dist/server/persona-chain.js +8 -8
- 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/remote-ssh-service.js +39 -39
- package/dist/server/resolve-global-sdk.js +2 -0
- package/dist/server/schedule-agent-tool.js +39 -21
- package/dist/server/scheduler-tasks.js +45 -9
- package/dist/server/scm-commitmsg.js +10 -10
- package/dist/server/settings-service.js +6 -0
- package/dist/server/setup-page.js +620 -620
- 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 +23 -0
- package/dist/server/vision-bridge.js +18 -18
- package/docs/device-center.md +148 -142
- package/docs/device-desktop.md +48 -48
- package/docs/dsh-engine.md +493 -493
- package/extensions/webui.ts +335 -335
- package/package.json +2 -2
- package/plugin-sdk/README.md +174 -174
- package/plugin-sdk/client-utils.mjs +279 -279
- package/plugin-sdk/import-check.mjs +210 -210
- package/plugin-sdk/index.d.ts +698 -698
- package/plugin-sdk/index.mjs +696 -696
- package/plugin-sdk/package.json +13 -13
- package/plugin-sdk/ssh-host-trust.mjs +225 -225
- package/plugins/catalog.json +10 -0
- package/themes/aetheris.css +501 -501
- package/themes/ayu-light.css +116 -116
- package/themes/bases/flow-base.css +1357 -1357
- package/themes/bases/obsidian-base.css +895 -895
- package/themes/bases/statusbar-flat-base.css +112 -112
- package/themes/bases/zhujian-base.css +688 -688
- package/themes/bases/zhupi-base.css +660 -660
- package/themes/catppuccin-latte.css +119 -119
- package/themes/catppuccin.css +116 -116
- package/themes/claude-code-dark.css +147 -147
- package/themes/codex.css +114 -114
- package/themes/cyberpunk.css +50 -50
- package/themes/dark-teal.css +264 -264
- package/themes/dazzle.css +38 -38
- package/themes/everforest-light.css +115 -115
- package/themes/flow-light.css +164 -164
- package/themes/flow.css +161 -161
- package/themes/geist.css +114 -114
- package/themes/gruvbox-light.css +115 -115
- package/themes/kanagawa-lotus.css +115 -115
- package/themes/md-preview.css +24 -24
- package/themes/mist.css +166 -166
- package/themes/nord.css +107 -107
- package/themes/one-dark.css +106 -106
- package/themes/paper.css +174 -174
- package/themes/rose-pine-dawn.css +114 -114
- package/themes/sakura.css +166 -166
- package/themes/solarized-light.css +114 -114
- package/themes/tokyo-night.css +115 -115
- package/themes/translucent.css +85 -85
- package/themes/transparent.css +116 -116
- package/themes/vs-code-dark.css +147 -147
- package/themes/wallpaper-flow.css +382 -382
- package/themes/wallpaper-obsidian.css +74 -74
- package/themes/white.css +164 -164
- package/themes/zhujian-dark.css +115 -115
- package/themes/zhujian.css +114 -114
- package/themes/zhupi-dark.css +115 -115
- package/themes/zhupi.css +114 -114
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/BgTasksModal-BcXJ20RO.js +1 -0
- package/web/dist/assets/BgTasksModal-DjQmiKnE.js +1 -0
- package/web/dist/assets/{CanvasStudio-BEJZE5BI.js → CanvasStudio-PI9pid0Y.js} +3 -3
- package/web/dist/assets/{CanvasStudio-CgUNHqos.js → CanvasStudio-nf5-HxLM.js} +3 -3
- package/web/dist/assets/DeviceCenter-CYttJw2a.js +3 -0
- package/web/dist/assets/DeviceCenter-DPe4sz74.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-C9Ut4Lq6.js +2 -0
- package/web/dist/assets/FilePreview-CvK3ZzX5.js +2 -0
- package/web/dist/assets/GlobalSearchModal-C5e-OCw2.js +1 -0
- package/web/dist/assets/GlobalSearchModal-H7pFK2UC.js +1 -0
- package/web/dist/assets/GroupConversation-C2wNM0dQ.js +1 -0
- package/web/dist/assets/GroupConversation-ChN3TWQK.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-buTGziDB.js +2 -0
- package/web/dist/assets/SCMPanel-kx-SCL2s.js +2 -0
- package/web/dist/assets/SettingsModal-BsUF8jqr.js +20 -0
- package/web/dist/assets/SettingsModal-D357Ky7P.js +20 -0
- package/web/dist/assets/{TerminalPanel-DL20uKgU.js → TerminalPanel-BBuM_Sez.js} +2 -2
- package/web/dist/assets/{TerminalPanel-D6cPRFei.js → TerminalPanel-D6x6xz8Q.js} +2 -2
- package/web/dist/assets/TuiOverlayModal-CdbGV3Za.js +1 -0
- package/web/dist/assets/TuiOverlayModal-d6x9u25n.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-BPvpea8t.js +85 -0
- package/web/dist/assets/index-D6u8xH0o.js +85 -0
- package/web/dist/assets/index-DDZMv6LO.css +1 -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 +37 -36
- package/web/dist/sw.js +179 -179
- package/web/public/sw.js +179 -179
- 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
|
@@ -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);
|
|
@@ -494,9 +494,9 @@ export class CanvasOrchestrator {
|
|
|
494
494
|
this.appendLog(graph.id, nodeId, "system", `AI 裁决启动(${node.engine}/${judgeModel}):${judgeAsk.slice(0, 200)}`);
|
|
495
495
|
}
|
|
496
496
|
else if (!isCanvasPassthroughRole(node.role) && node.role !== "transform") {
|
|
497
|
-
prompt += `\n\n【流水线自动化执行安全公约】:
|
|
498
|
-
1. 自治推进:这是无人值守的自动化协同流水线,严禁停留在向用户提问或等待人工决策阶段;遇分支情况请按最佳工程实践自主裁决并推进;
|
|
499
|
-
2. 避免前台阻塞:如需启动服务或验证测试,严禁启动阻塞终端的前台长进程;遇到端口占用(如 3000/3001 等)先检测并释放,验证完成后务必确保退出并清理所有后台子进程;
|
|
497
|
+
prompt += `\n\n【流水线自动化执行安全公约】:
|
|
498
|
+
1. 自治推进:这是无人值守的自动化协同流水线,严禁停留在向用户提问或等待人工决策阶段;遇分支情况请按最佳工程实践自主裁决并推进;
|
|
499
|
+
2. 避免前台阻塞:如需启动服务或验证测试,严禁启动阻塞终端的前台长进程;遇到端口占用(如 3000/3001 等)先检测并释放,验证完成后务必确保退出并清理所有后台子进程;
|
|
500
500
|
3. 交付明确:完成时请提供清晰的修改摘要、接口契约与当前状态,供下游节点或审查门禁接力。`;
|
|
501
501
|
}
|
|
502
502
|
this.appendLog(graph.id, nodeId, "prompt", prompt.slice(0, 2000));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { isSafeGraphId, loadCanvasGraph } from "./canvas-store.js";
|
|
4
|
+
import { assertCanvasGraph } from "./canvas-validation.js";
|
|
5
|
+
/** Scheduling must never recreate a deleted default graph. */
|
|
6
|
+
export function loadScheduledCanvas(dataDir, graphId) {
|
|
7
|
+
if (!isSafeGraphId(graphId))
|
|
8
|
+
throw new Error("Invalid canvas graph id");
|
|
9
|
+
if (!existsSync(join(dataDir, "canvas", `${graphId}.json`)))
|
|
10
|
+
throw new Error(`Canvas graph not found: ${graphId}`);
|
|
11
|
+
const graph = loadCanvasGraph(dataDir, graphId);
|
|
12
|
+
assertCanvasGraph(graph);
|
|
13
|
+
if (graph.id !== graphId)
|
|
14
|
+
throw new Error("Canvas graph id mismatch");
|
|
15
|
+
return graph;
|
|
16
|
+
}
|
|
17
|
+
export function validateScheduledCanvas(dataDir, task) {
|
|
18
|
+
if (task.target === "canvas")
|
|
19
|
+
loadScheduledCanvas(dataDir, task.graphId ?? "");
|
|
20
|
+
}
|
|
21
|
+
/** Await the existing orchestrator and report its actual outcome, including approval pauses. */
|
|
22
|
+
export async function executeScheduledCanvas(dataDir, orchestrator, task) {
|
|
23
|
+
const graphId = task.graphId ?? "";
|
|
24
|
+
let runId;
|
|
25
|
+
try {
|
|
26
|
+
const graph = loadScheduledCanvas(dataDir, graphId);
|
|
27
|
+
await orchestrator.runAll(graph, task.prompt || undefined, task.cwd);
|
|
28
|
+
runId = graph.run?.id;
|
|
29
|
+
if (!runId)
|
|
30
|
+
throw new Error("Canvas run did not start");
|
|
31
|
+
// Read back authoritative state to detect deletion, cancellation, or replacement during execution.
|
|
32
|
+
const current = loadScheduledCanvas(dataDir, graphId);
|
|
33
|
+
if (current.run?.id !== runId)
|
|
34
|
+
throw new Error("Canvas run was replaced before completion");
|
|
35
|
+
return {
|
|
36
|
+
ok: current.status === "completed",
|
|
37
|
+
graphId,
|
|
38
|
+
runId,
|
|
39
|
+
...(current.status === "completed" ? {} : { error: current.run?.error || `Canvas run ${current.status}` }),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return { ok: false, graphId, ...(runId ? { runId } : {}), error: error.message };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -911,6 +911,9 @@ export class ClientStateStore {
|
|
|
911
911
|
questionPresentation: stored?.questionPresentation === "all" || stored?.questionPresentation === "manual"
|
|
912
912
|
? stored.questionPresentation
|
|
913
913
|
: "queue",
|
|
914
|
+
toolApprovalPresentation: stored?.toolApprovalPresentation === "queue" || stored?.toolApprovalPresentation === "manual"
|
|
915
|
+
? stored.toolApprovalPresentation
|
|
916
|
+
: "all",
|
|
914
917
|
questionTimeoutSeconds: Number.isFinite(stored?.questionTimeoutSeconds) && Number(stored?.questionTimeoutSeconds) >= 0
|
|
915
918
|
? Math.floor(Number(stored?.questionTimeoutSeconds))
|
|
916
919
|
: 240,
|
|
@@ -996,6 +999,7 @@ export class ClientStateStore {
|
|
|
996
999
|
editSoftEnabled: settings.editSoftEnabled ?? cur.editSoftEnabled ?? false,
|
|
997
1000
|
questionnaireEnabled: settings.questionnaireEnabled ?? cur.questionnaireEnabled ?? true,
|
|
998
1001
|
questionPresentation: settings.questionPresentation ?? cur.questionPresentation ?? "queue",
|
|
1002
|
+
toolApprovalPresentation: settings.toolApprovalPresentation ?? cur.toolApprovalPresentation ?? "all",
|
|
999
1003
|
questionTimeoutSeconds: settings.questionTimeoutSeconds ?? cur.questionTimeoutSeconds ?? 240,
|
|
1000
1004
|
goalModeEnabled: settings.goalModeEnabled ?? cur.goalModeEnabled ?? true,
|
|
1001
1005
|
parallelReminderEnabled: settings.parallelReminderEnabled ?? cur.parallelReminderEnabled ?? true,
|
|
@@ -1490,7 +1494,7 @@ export class ClientStateStore {
|
|
|
1490
1494
|
/** 读取某客户端(标签页)上次使用的引擎(未设置返回 undefined)。 */
|
|
1491
1495
|
getClientEngine(clientId) {
|
|
1492
1496
|
const eng = this.load()[clientId]?.engine;
|
|
1493
|
-
return eng === "dsh" || eng === "pi" || eng === "claude" || eng === "durable" ? eng : undefined;
|
|
1497
|
+
return eng === "dsh" || eng === "pi" || eng === "codex" || eng === "claude" || eng === "durable" ? eng : undefined;
|
|
1494
1498
|
}
|
|
1495
1499
|
/** 保存某客户端(标签页)当前使用的引擎。 */
|
|
1496
1500
|
saveClientEngine(clientId, engine) {
|
|
@@ -1503,7 +1507,7 @@ export class ClientStateStore {
|
|
|
1503
1507
|
/** 读取全局默认引擎(存在 __settings__ 下,新标签页及服务重启后默认跟随)。 */
|
|
1504
1508
|
getDefaultEngine() {
|
|
1505
1509
|
const eng = this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY]?.defaultEngine;
|
|
1506
|
-
return eng === "dsh" || eng === "pi" || eng === "claude" || eng === "durable" ? eng : undefined;
|
|
1510
|
+
return eng === "dsh" || eng === "pi" || eng === "codex" || eng === "claude" || eng === "durable" ? eng : undefined;
|
|
1507
1511
|
}
|
|
1508
1512
|
/** 保存全局默认引擎。 */
|
|
1509
1513
|
saveDefaultEngine(engine) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** Additional focus for Pi's existing initial/update summary prompts; never replaces their format. */
|
|
2
|
-
export const COMPACTION_RETENTION_INSTRUCTIONS = `Preserve the SDK's default structured checkpoint format. Within its existing sections, always retain the following categories when present; mark missing information as unknown rather than inventing it:
|
|
3
|
-
- Goal: the active user goal, scope, and completion criteria.
|
|
4
|
-
- Constraints & Preferences: explicit user requirements, prohibitions, permissions, and corrections that still apply.
|
|
5
|
-
- Critical Context: verified facts and their evidence (observed outputs, exact paths, symbols, errors, and relevant references). Label hypotheses, inferences, and unverified claims explicitly; never promote them to facts.
|
|
6
|
-
- Progress / Done and In Progress: actual changes, affected files, decisions and rationale, and what remains incomplete. Distinguish proposed work from applied changes.
|
|
7
|
-
- Progress / Critical Context: validation commands, observed results, failures, and checks not run; never infer success from a proposed command or an absent error.
|
|
8
|
-
- Blocked / Next Steps: unresolved questions, blockers, and concrete next actions needed to continue.
|
|
9
|
-
Preserve all context-evidence:<sha256> references verbatim, including references in earlier summaries, with their associated claim and verification status. A reference alone does not prove a claim; do not invent, rewrite, or expand its contents.
|
|
2
|
+
export const COMPACTION_RETENTION_INSTRUCTIONS = `Preserve the SDK's default structured checkpoint format. Within its existing sections, always retain the following categories when present; mark missing information as unknown rather than inventing it:
|
|
3
|
+
- Goal: the active user goal, scope, and completion criteria.
|
|
4
|
+
- Constraints & Preferences: explicit user requirements, prohibitions, permissions, and corrections that still apply.
|
|
5
|
+
- Critical Context: verified facts and their evidence (observed outputs, exact paths, symbols, errors, and relevant references). Label hypotheses, inferences, and unverified claims explicitly; never promote them to facts.
|
|
6
|
+
- Progress / Done and In Progress: actual changes, affected files, decisions and rationale, and what remains incomplete. Distinguish proposed work from applied changes.
|
|
7
|
+
- Progress / Critical Context: validation commands, observed results, failures, and checks not run; never infer success from a proposed command or an absent error.
|
|
8
|
+
- Blocked / Next Steps: unresolved questions, blockers, and concrete next actions needed to continue.
|
|
9
|
+
Preserve all context-evidence:<sha256> references verbatim, including references in earlier summaries, with their associated claim and verification status. A reference alone does not prove a claim; do not invent, rewrite, or expand its contents.
|
|
10
10
|
Treat any supplied summary as candidate notes to verify against the conversation, not as authoritative evidence. Condense redundant exploration without dropping the retained categories or still-applicable user constraints.`;
|
|
11
11
|
/** Append without changing caller instructions; safe when both tool and adapter apply it. */
|
|
12
12
|
export function appendCompactionInstructions(instructions) {
|
|
@@ -206,23 +206,42 @@ export function createDeviceConnector(options) {
|
|
|
206
206
|
delete responseHeaders.location;
|
|
207
207
|
}
|
|
208
208
|
sendFrame(ws, { type: "response", id, status: res.statusCode, headers: responseHeaders });
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
209
|
+
void (async () => {
|
|
210
|
+
let bytes = 0;
|
|
211
|
+
try {
|
|
212
|
+
// Pull only as fast as the relay socket drains, instead of aborting bursts.
|
|
213
|
+
for await (const data of res) {
|
|
214
|
+
const chunk = Buffer.from(data);
|
|
215
|
+
bytes += chunk.length;
|
|
216
|
+
if (bytes > RELAY_LIMITS.body)
|
|
217
|
+
throw new Error("Response too large");
|
|
218
|
+
for (let offset = 0; offset < chunk.length; offset += RELAY_LIMITS.chunk) {
|
|
219
|
+
while (ws.bufferedAmount > RELAY_LIMITS.queue / 2) {
|
|
220
|
+
if (!streams.has(id) || ws.readyState !== WebSocket.OPEN)
|
|
221
|
+
throw new Error("Cancelled");
|
|
222
|
+
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
223
|
+
}
|
|
224
|
+
if (!streams.has(id) || ws.readyState !== WebSocket.OPEN)
|
|
225
|
+
throw new Error("Cancelled");
|
|
226
|
+
await new Promise((resolve, reject) => {
|
|
227
|
+
ws.send(JSON.stringify({
|
|
228
|
+
type: "response_body",
|
|
229
|
+
id,
|
|
230
|
+
data: chunk.subarray(offset, offset + RELAY_LIMITS.chunk).toString("base64"),
|
|
231
|
+
}), (error) => (error ? reject(error) : resolve()));
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
sendFrame(ws, { type: "response_end", id });
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
213
238
|
res.destroy();
|
|
214
|
-
dispose(id);
|
|
215
239
|
sendFrame(ws, { type: "error", id });
|
|
216
240
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
});
|
|
222
|
-
res.on("error", () => {
|
|
223
|
-
sendFrame(ws, { type: "error", id });
|
|
224
|
-
dispose(id);
|
|
225
|
-
});
|
|
241
|
+
finally {
|
|
242
|
+
dispose(id);
|
|
243
|
+
}
|
|
244
|
+
})();
|
|
226
245
|
});
|
|
227
246
|
stream.req = req;
|
|
228
247
|
req.on("error", () => {
|