@tea-agent/loop-agent 0.52.0-next.1 → 0.52.0-next.10
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 +99 -21
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +1 -75
- package/dist/cli/help.js +1 -1
- package/dist/cli/program.js +1 -28
- package/dist/commands/init-accepted-merge.js +46 -0
- package/dist/commands/init-upgrade.js +115 -2
- package/dist/commands/init.js +79 -12
- package/dist/executors/pi-sdk-executor.js +3 -3
- package/dist/governance/path-guard.js +2 -0
- package/dist/records/harvest.js +1 -1
- package/dist/shared/git-progress.js +3 -0
- package/dist/shared/operator/capabilities.js +0 -122
- package/dist/shared/pi-context-pressure/checkpoint.js +94 -24
- package/dist/shared/pi-context-pressure/compaction-policy.js +152 -66
- package/dist/shared/pi-context-pressure/extension.js +25 -8
- package/dist/shared/pi-context-pressure/index.js +1 -1
- package/dist/shared/pi-context-pressure/telemetry.js +10 -0
- package/dist/shared/update/npm-client.js +14 -3
- package/dist/task/config-types.js +5 -10
- package/dist/task/delegate.js +1 -1
- package/dist/task/read-model.js +0 -4
- package/dist/task/runtime.js +0 -1
- package/dist/task/worktree.js +1 -1
- package/dist/worker/console/chat/api-workbench-core.js +17 -6
- package/dist/worker/console/chat/api-workbench.js +2 -0
- package/dist/worker/console/chat/assistant-content.js +21 -3
- package/dist/worker/console/chat/chat-event-projection.js +6 -0
- package/dist/worker/console/chat/chat-event-store.js +32 -2
- package/dist/worker/console/chat/chat-references.js +4 -0
- package/dist/worker/console/chat/compaction-errors.js +14 -2
- package/dist/worker/console/chat/context-insights.js +41 -4
- package/dist/worker/console/chat/context-usage.js +4 -1
- package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +65 -3
- package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +2 -2
- package/dist/worker/console/chat/pi-runtime/extension-bindings.js +39 -0
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +4 -0
- package/dist/worker/console/chat/pi-runtime.js +389 -191
- package/dist/worker/console/chat/repo-browser.js +5 -2
- package/dist/worker/console/chat/repo-preview-kind.js +16 -6
- package/dist/worker/console/chat/routes.js +299 -25
- package/dist/worker/console/chat/scheduled-goal-request.js +1 -1
- package/dist/worker/console/chat/subagents/jobs.js +115 -4
- package/dist/worker/console/chat/terminal-sessions.js +52 -6
- package/dist/worker/console/chat/tool-exposure-catalog.js +1 -1
- package/dist/worker/console/chat/tool-presentation.js +17 -10
- package/dist/worker/console/chat/tool-preview.js +22 -0
- package/dist/worker/console/chat/turn-process.js +49 -0
- package/dist/worker/console/chat/vcp-prompt.js +14 -9
- package/dist/worker/console/chat/workspace-changes.js +17 -0
- package/dist/worker/console/console-update-runtime.js +5 -1
- package/dist/worker/console/operator-actions.js +7 -6
- package/dist/worker/console/operator-user-error.js +5 -1
- package/dist/worker/console/pi-compaction-settings.js +220 -0
- package/dist/worker/console/routes.js +1 -1
- package/dist/worker/console/server.js +148 -6
- package/dist/worker/console/static/assets/FilePreviewDocx-ybM3ZqSl.js +9 -0
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-CT26sIgH.js +1 -0
- package/dist/worker/console/static/assets/{arc-Bkf_oc0_.js → arc-CPwLqDB0.js} +1 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-CzTSMPU_.js +36 -0
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-D62uVvbI.js → blockDiagram-VBNYF7ZC-BfgbtJLH.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-Iq0Y8Afx.js → c4Diagram-5PPSVZJV-B9pTjB8U.js} +1 -1
- package/dist/worker/console/static/assets/channel-DtYRMDck.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D1TxRE3k.js → chunk-2GRJ4B5K-xORV8QsC.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-BE-DHkAO.js → chunk-2Q5K7J3B-BzpYWAHK.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-t0iYO8Cc.js → chunk-5RXB4S5H-D8zcRP6c.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-Clo2nExi.js → chunk-5VM5RSS4-DVEXxzQJ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-C7bSpo-3.js → chunk-6Q2QTUOP-CKZOJU2z.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DorZaymh.js → chunk-GF5L2VYU-Cgx34Dj8.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Ch_4HvyJ.js → chunk-JWPE2WC7-ehcSKOcx.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-yaSoFe-3.js → chunk-KBJHAD2P-CiY9emCG.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-QpjaXecS.js → chunk-RYQCIY6F-Bk9X-ksQ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-B3t6cycg.js → chunk-XXDRQBXY-DC0xXfHy.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DyesHbs5.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DyesHbs5.js +1 -0
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-C_EVg5l9.js +1 -0
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CP8LtrOl.js → cynefin-VYW2F7L2-BIFL8KrA.js} +1 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-DjtUYOlE.js +62 -0
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BK0ua9V8.js → dagre-VZM6K2ZE-D2aN2V9t.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-t9-HP13j.js → diagram-7IWD3JNH-D_twhmFi.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-L5Sg9jMD.js → diagram-B4RE2ZJO-ChzncqLV.js} +1 -1
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-B6LO-bF2.js +24 -0
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-GrzM7AFc.js +24 -0
- package/dist/worker/console/static/assets/diagram-UB23O5K3-Bv-lntaq.js +41 -0
- package/dist/worker/console/static/assets/docx-preview-CAbT0VNs.js +23 -0
- package/dist/worker/console/static/assets/docxPreview-D_T4B7qe.js +1 -0
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-BvD2jkO_.js +1 -0
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CNOuj3BO.js → erDiagram-JOGREHBK-BirPCcmA.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-h_Cyayai.js → flowDiagram-UKHOOZJN-Chu1YnGQ.js} +1 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-Djn17xhB.js +292 -0
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-Bx1qbGHx.js +106 -0
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D-TLMqmb.js +2 -0
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DAdf5lHp.js → ishikawaDiagram-WSZJBQD7-DbJoh-6T.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BQbGtg66.js → journeyDiagram-NVQOT4AX-DsyokZ6e.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CetLubYc.js → kanban-definition-27J2QSJJ-DlzXTxic.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DLZOjaVz.js → linear-ClnZn3vw.js} +1 -1
- package/dist/worker/console/static/assets/main-D-ZQ4gLb.css +1 -0
- package/dist/worker/console/static/assets/main-fc3P1HID.js +645 -0
- package/dist/worker/console/static/assets/{mermaid.core-B_xZl_gM.js → mermaid.core-DqSlcvbf.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Dzo3dzp0.js → mindmap-definition-FAOFIHXS-CSFbzpiX.js} +1 -1
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-DK80yQqe.js +1 -0
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Cp3YrVzQ.js → pieDiagram-7S7Q4E2Y-DWX7SFGb.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-4tI5mUgW.js → quadrantDiagram-CIZ2JOQS-BEPPhtXs.js} +1 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-Ck_s6fQn.js +1 -0
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DY-0JqdT.js → requirementDiagram-LRYGKXZP-CYig27Rj.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DuJIzRKC.js → sankeyDiagram-W5VNT64P-u-0aSx5s.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BTbVJ85l.js → sequenceDiagram-SI44F4Z6-NsEJI9sM.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-BPPh1uLw.js → sheet-workbook-kZ_HK4Sg.js} +2 -2
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-8vneVM5U.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-CMIobUBh.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Bd0pHHKP.js +1 -0
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-D4Qzt6ug.js +2 -0
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BzmSZnl_.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-GR6lxokn.js → timeline-definition-Z64GVDOM-DMb1LpED.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DEkwyzsF.js → vennDiagram-T6HMQDX7-C_9eFOs3.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-W5jnvEJ3.js → wardleyDiagram-T6FBY63Y-DJYMe3uT.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-cqsloioo.js → xychartDiagram-ELKLHX3M-Cv_1Mi3u.js} +1 -1
- package/dist/worker/console/static/docx-preview.html +25 -0
- package/dist/worker/console/static/index.html +3 -2
- package/dist/worker/console/static/vcp/fonts/README.md +28 -0
- package/dist/worker/console/static/vcp/vendor/vcp-engine-v1.js +4 -4
- package/dist/worker/console/static-src/operator-chat/StateDot.js +17 -0
- package/dist/worker/console/static-src/operator-chat/changed-file-diff.js +15 -0
- package/dist/worker/console/static-src/operator-chat/chat-font-size.js +90 -0
- package/dist/worker/console/static-src/operator-chat/chat-session-order.js +96 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +8 -1
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +4 -0
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +2 -0
- package/dist/worker/console/static-src/operator-chat/file-touch.js +107 -0
- package/dist/worker/console/static-src/operator-chat/format-file-size.js +26 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +44 -0
- package/dist/worker/console/static-src/operator-chat/reference-display.js +7 -1
- package/dist/worker/console/static-src/operator-chat/tasks-auto-open.js +100 -0
- package/dist/worker/console/static-src/operator-chat/tasks-layout-tween.js +103 -0
- package/dist/worker/console/static-src/operator-chat/tasks-model.js +657 -0
- package/dist/worker/console/static-src/operator-chat/tasks-view-glide.js +96 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +1 -0
- package/dist/worker/console/static-src/operator-chat/use-auto-animate.js +61 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +194 -47
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +4 -0
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +111 -21
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +91 -47
- package/dist/worker/console/static-src/operator-chat/useVcpPreferences.js +1 -1
- package/dist/worker/console/static-src/operator-chat/user-turn-anchors-merge.js +50 -0
- package/dist/worker/console/static-src/operator-chat/vcp-fonts.js +180 -22
- package/dist/worker/console/static-src/operator-chat/vcp-frame.js +3 -3
- package/dist/worker/console/static-src/shell/console-update-progress.js +16 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +4 -1
- package/dist/worker/console/static-src/shell/workspace-route.js +0 -2
- package/dist/worker/console/vite.config.js +5 -1
- package/dist/worker/console/workspace-registry.js +62 -19
- package/dist/worker/observe/static/operator-chrome.js +0 -1
- package/dist/worker/scheduler/git-base.js +3 -0
- package/dist/worker/scheduler/night-git-finalizer.js +1 -1
- package/dist/worker/scheduler/night-harvest.js +1 -1
- package/dist/worker/scheduler/prepared-attempt-recovery.js +1 -1
- package/dist/worker/scheduler/scheduled-goal-evidence.js +1 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +60 -4
- package/dist/workflows/dag/dynamic-runtime/reduction.js +7 -2
- package/dist/workflows/dag/frontend-test-framework-adapters.js +11 -2
- package/dist/workflows/script/windows/guest.js +13 -2
- package/dist/workflows/script/windows/native.js +21 -3
- package/docs/architecture/dag-execution.md +2 -13
- package/docs/architecture/facts-and-state.md +2 -3
- package/docs/architecture/runtime-boundaries.md +2 -2
- package/package.json +9 -7
- package/resource-catalog.v1.json +6 -6
- package/scripts/patch-pi-sdk-windows-hide.mjs +3 -3
- package/skills/loop-agent/references/command-reference.md +2 -41
- package/skills/loop-agent/references/harness-policy.md +3 -30
- package/skills/loop-agent/references/long-running-loop.md +6 -54
- package/dist/application/loop/run-action.js +0 -19
- package/dist/commands/dag-workflow-compile.js +0 -93
- package/dist/commands/dag-workflow-plan.js +0 -132
- package/dist/commands/dag-workflow-validate.js +0 -68
- package/dist/commands/loop-benchmark.js +0 -74
- package/dist/commands/loop.js +0 -251
- package/dist/commands/workflow.js +0 -259
- package/dist/infrastructure/harness/loop-store.js +0 -41
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-FQePHM07.js +0 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-p_mwm8cd.js +0 -36
- package/dist/worker/console/static/assets/channel-CIBAg8WF.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-BPXf8ZYr.js +0 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-CNsL9N2-.js +0 -62
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-BipWFRgs.js +0 -24
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-T2p4xa38.js +0 -24
- package/dist/worker/console/static/assets/diagram-UB23O5K3-CVwz6LVu.js +0 -41
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-CybQrGSA.js +0 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-D411_55h.js +0 -292
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-DpVtzs9z.js +0 -106
- package/dist/worker/console/static/assets/index-B7cwOTL9.js +0 -649
- package/dist/worker/console/static/assets/index-CATbSkPc.css +0 -1
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D74Uvx6K.js +0 -2
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-CSwoBOpM.js +0 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-n0Mt3Yia.js +0 -1
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-Dmf1pC7B.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-4-jdPUHD.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DojWfYnC.js +0 -1
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DNhjjaAU.js +0 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CJo4AKWH.js +0 -8
- package/dist/worker/console/static/vcp/fonts/Lanxi-/345/217/257/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/346/234/227/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/350/266/205/347/262/227/351/273/221.woff2 +0 -0
- package/dist/workflows/dynamic/compile.js +0 -371
- package/dist/workflows/dynamic/compileTypes.js +0 -1
- package/dist/workflows/dynamic/errors.js +0 -5
- package/dist/workflows/dynamic/profiles.js +0 -156
- package/dist/workflows/dynamic/spec.js +0 -115
- package/dist/workflows/dynamic/validate.js +0 -275
- package/dist/workflows/loop/actions/dag-action.js +0 -129
- package/dist/workflows/loop/actions/pi-review.js +0 -267
- package/dist/workflows/loop/actions/shared.js +0 -157
- package/dist/workflows/loop/actions/shell-verify.js +0 -82
- package/dist/workflows/loop/actions/types.js +0 -1
- package/dist/workflows/loop/actions/workflow-action.js +0 -255
- package/dist/workflows/loop/actions.js +0 -160
- package/dist/workflows/loop/benchmark.js +0 -513
- package/dist/workflows/loop/closeout.js +0 -135
- package/dist/workflows/loop/context.js +0 -47
- package/dist/workflows/loop/events.js +0 -26
- package/dist/workflows/loop/hash.js +0 -32
- package/dist/workflows/loop/index.js +0 -8
- package/dist/workflows/loop/paths.js +0 -17
- package/dist/workflows/loop/policy/auto-policy.js +0 -112
- package/dist/workflows/loop/policy/path-patterns.js +0 -13
- package/dist/workflows/loop/rounds.js +0 -81
- package/dist/workflows/loop/signals.js +0 -52
- package/dist/workflows/loop/state.js +0 -116
- package/dist/workflows/loop/templates.js +0 -54
- package/dist/workflows/loop/types.js +0 -28
- /package/dist/workflows/{dynamic/artifacts.js → dag/dynamic-runtime/reduction-artifacts.js} +0 -0
|
@@ -1,78 +1,148 @@
|
|
|
1
1
|
import { parseBoundedNumber, readContextPressureMode, } from "./env.js";
|
|
2
|
+
/**
|
|
3
|
+
* Pi's own fallback reserve. Only used when the window is unusable, so Pi keeps
|
|
4
|
+
* a finite threshold instead of compacting on every request.
|
|
5
|
+
*/
|
|
2
6
|
export const PI_DEFAULT_RESERVE_TOKENS = 16_384;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Output tokens reserved out of the window before pressure is computed.
|
|
9
|
+
*
|
|
10
|
+
* DSH derives this from the routed adapter's `defaultMaxTokens`. Pi only
|
|
11
|
+
* exposes the model's `maxTokens`, which is the model's *capability*, not the
|
|
12
|
+
* budget reserved for this request. Using it would drag the trigger far down on
|
|
13
|
+
* small-window models: a 150k window with `maxTokens = 32768` triggers at
|
|
14
|
+
* 51,696 tokens (34.5% of the window) instead of 76,272 (50.8%), which compacts
|
|
15
|
+
* far more often than intended. A fixed conservative reservation avoids that.
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_RESERVED_COMPLETION_TOKENS = 8_192;
|
|
18
|
+
/** DSH defaults, adopted verbatim. See `compaction-basic/src/config.ts`. */
|
|
19
|
+
export const DEFAULT_THRESHOLD_RATIO = 0.8;
|
|
20
|
+
export const DEFAULT_HEADROOM_TOKENS = 65_536;
|
|
21
|
+
export const DEFAULT_RETAIN_RATIO = 0.16;
|
|
7
22
|
export function parseCompactionPolicy(env = process.env) {
|
|
8
23
|
const diagnostics = [];
|
|
9
24
|
const modeResult = readContextPressureMode(env);
|
|
10
25
|
if (modeResult.diagnostic)
|
|
11
26
|
diagnostics.push(modeResult.diagnostic);
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
diagnostics.push(
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
diagnostics.push(
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
diagnostics.push(
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
: parseBoundedNumber(explicit, PI_DEFAULT_RESERVE_TOKENS, 1_024, 1_000_000);
|
|
25
|
-
if (explicitReserve?.diagnostic)
|
|
26
|
-
diagnostics.push(explicitReserve.diagnostic);
|
|
27
|
+
const ratio = parseBoundedNumber(env.HARNESS_COMPACTION_THRESHOLD_RATIO, DEFAULT_THRESHOLD_RATIO, 0.05, 1);
|
|
28
|
+
if (ratio.diagnostic)
|
|
29
|
+
diagnostics.push(ratio.diagnostic);
|
|
30
|
+
const headroom = parseBoundedNumber(env.HARNESS_COMPACTION_HEADROOM_TOKENS, DEFAULT_HEADROOM_TOKENS, 0, 10_000_000);
|
|
31
|
+
if (headroom.diagnostic)
|
|
32
|
+
diagnostics.push(headroom.diagnostic);
|
|
33
|
+
const retain = parseBoundedNumber(env.HARNESS_COMPACTION_RETAIN_RATIO, DEFAULT_RETAIN_RATIO, 0.01, 0.99);
|
|
34
|
+
if (retain.diagnostic)
|
|
35
|
+
diagnostics.push(retain.diagnostic);
|
|
36
|
+
const reserved = parseBoundedNumber(env.HARNESS_COMPACTION_RESERVED_COMPLETION_TOKENS, DEFAULT_RESERVED_COMPLETION_TOKENS, 0, 1_000_000);
|
|
37
|
+
if (reserved.diagnostic)
|
|
38
|
+
diagnostics.push(reserved.diagnostic);
|
|
27
39
|
return {
|
|
28
40
|
mode: modeResult.mode,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
...(explicitReserve ? { explicitReserveTokens: explicitReserve.value } : {}),
|
|
41
|
+
thresholdRatio: ratio.value,
|
|
42
|
+
headroomTokens: headroom.value,
|
|
43
|
+
retainRatio: retain.value,
|
|
44
|
+
reservedCompletionTokens: reserved.value,
|
|
34
45
|
diagnostics,
|
|
35
46
|
};
|
|
36
47
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the pressure threshold and the retained tail for one model window.
|
|
50
|
+
*
|
|
51
|
+
* Mirrors DSH's `resolveCompactSpec`:
|
|
52
|
+
*
|
|
53
|
+
* messageBudget = contextWindow - reservedCompletion
|
|
54
|
+
* pressureBudget = messageBudget - headroomTokens
|
|
55
|
+
* thresholdTokens = min(contextWindow × thresholdRatio, pressureBudget)
|
|
56
|
+
* retainTokens = messageBudget × retainRatio
|
|
57
|
+
*
|
|
58
|
+
* DSH throws when the window cannot support the policy, because it is a
|
|
59
|
+
* library and the host can fix its configuration. The Console must keep the
|
|
60
|
+
* session usable instead, so it falls back to Pi's default reserve and records
|
|
61
|
+
* a diagnostic.
|
|
62
|
+
*/
|
|
63
|
+
export function resolveCompactSpec(contextWindow, policy) {
|
|
64
|
+
const diagnostics = [];
|
|
65
|
+
const declared = Math.floor(contextWindow);
|
|
66
|
+
if (!Number.isFinite(declared) || declared <= 0) {
|
|
67
|
+
return {
|
|
68
|
+
thresholdTokens: 0,
|
|
69
|
+
retainTokens: 0,
|
|
70
|
+
contextWindow: 0,
|
|
71
|
+
messageBudgetTokens: 0,
|
|
72
|
+
fallback: true,
|
|
73
|
+
diagnostics: ["invalid-context-window"],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const reserved = Math.max(0, Math.floor(policy.reservedCompletionTokens));
|
|
77
|
+
const messageBudget = declared - reserved;
|
|
78
|
+
if (messageBudget <= 0) {
|
|
79
|
+
const thresholdTokens = Math.max(0, declared - PI_DEFAULT_RESERVE_TOKENS);
|
|
40
80
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
81
|
+
thresholdTokens,
|
|
82
|
+
retainTokens: Math.max(0, Math.floor(thresholdTokens * policy.retainRatio)),
|
|
83
|
+
contextWindow: declared,
|
|
84
|
+
messageBudgetTokens: 0,
|
|
43
85
|
fallback: true,
|
|
86
|
+
diagnostics: ["reserved-completion-exhausts-window"],
|
|
44
87
|
};
|
|
45
88
|
}
|
|
46
|
-
|
|
47
|
-
|
|
89
|
+
const pressureBudget = messageBudget - policy.headroomTokens;
|
|
90
|
+
if (pressureBudget <= 0) {
|
|
91
|
+
const thresholdTokens = Math.max(0, declared - PI_DEFAULT_RESERVE_TOKENS);
|
|
48
92
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
93
|
+
thresholdTokens,
|
|
94
|
+
retainTokens: Math.max(0, Math.floor(thresholdTokens * policy.retainRatio)),
|
|
95
|
+
contextWindow: declared,
|
|
96
|
+
messageBudgetTokens: messageBudget,
|
|
97
|
+
fallback: true,
|
|
98
|
+
diagnostics: ["headroom-exhausts-message-budget"],
|
|
52
99
|
};
|
|
53
100
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
policy.safetyMarginTokens;
|
|
57
|
-
const rawReserve = W - rawTrigger;
|
|
58
|
-
const maxReserve = Math.max(1, W - policy.minimumWorkingSet);
|
|
59
|
-
if (!Number.isFinite(rawTrigger) ||
|
|
60
|
-
!Number.isFinite(rawReserve) ||
|
|
61
|
-
maxReserve < PI_DEFAULT_RESERVE_TOKENS) {
|
|
62
|
-
const recommendedReserve = Math.min(PI_DEFAULT_RESERVE_TOKENS, Math.max(1, W - 1));
|
|
101
|
+
const thresholdTokens = Math.floor(Math.min(declared * policy.thresholdRatio, pressureBudget));
|
|
102
|
+
if (thresholdTokens <= 0) {
|
|
63
103
|
return {
|
|
64
|
-
|
|
65
|
-
|
|
104
|
+
thresholdTokens: 0,
|
|
105
|
+
retainTokens: 0,
|
|
106
|
+
contextWindow: declared,
|
|
107
|
+
messageBudgetTokens: messageBudget,
|
|
66
108
|
fallback: true,
|
|
109
|
+
diagnostics: ["non-positive-threshold"],
|
|
67
110
|
};
|
|
68
111
|
}
|
|
69
|
-
|
|
112
|
+
let retainTokens = Math.floor(messageBudget * policy.retainRatio);
|
|
113
|
+
if (retainTokens >= thresholdTokens) {
|
|
114
|
+
// DSH rejects this configuration. Retaining as much as we compact would
|
|
115
|
+
// make the summary cover nothing, so clamp and say so.
|
|
116
|
+
retainTokens = Math.max(0, thresholdTokens - 1);
|
|
117
|
+
diagnostics.push("retain-clamped-below-threshold");
|
|
118
|
+
}
|
|
70
119
|
return {
|
|
71
|
-
|
|
72
|
-
|
|
120
|
+
thresholdTokens,
|
|
121
|
+
retainTokens,
|
|
122
|
+
contextWindow: declared,
|
|
123
|
+
messageBudgetTokens: messageBudget,
|
|
73
124
|
fallback: false,
|
|
125
|
+
diagnostics,
|
|
74
126
|
};
|
|
75
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* The `reserveTokens` to hand Pi so that its own threshold lands exactly on
|
|
130
|
+
* `thresholdTokens`.
|
|
131
|
+
*
|
|
132
|
+
* Pi decides with `contextTokens > contextWindow - reserveTokens` and reads
|
|
133
|
+
* `contextWindow` from the model definition, so the reserve must be expressed
|
|
134
|
+
* against that same number.
|
|
135
|
+
*/
|
|
136
|
+
export function piReserveTokensFor(contextWindow, thresholdTokens) {
|
|
137
|
+
const declared = Math.floor(contextWindow);
|
|
138
|
+
if (!Number.isFinite(declared) || declared <= 0) {
|
|
139
|
+
return PI_DEFAULT_RESERVE_TOKENS;
|
|
140
|
+
}
|
|
141
|
+
if (!Number.isFinite(thresholdTokens) || thresholdTokens <= 0) {
|
|
142
|
+
return Math.min(PI_DEFAULT_RESERVE_TOKENS, Math.max(1, declared - 1));
|
|
143
|
+
}
|
|
144
|
+
return Math.min(Math.max(1, declared - Math.floor(thresholdTokens)), Math.max(1, declared - 1));
|
|
145
|
+
}
|
|
76
146
|
export function conservativeTokenEstimate(text, imageCount = 0) {
|
|
77
147
|
const chars = Array.from(text);
|
|
78
148
|
let cjk = 0;
|
|
@@ -108,23 +178,38 @@ function isExplicitlyDisabled(manager) {
|
|
|
108
178
|
const global = manager.getGlobalSettings?.()?.compaction?.enabled;
|
|
109
179
|
return project === false || (project === undefined && global === false);
|
|
110
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Apply the resolved spec to Pi's settings manager.
|
|
183
|
+
*
|
|
184
|
+
* Writes both knobs Pi reads:
|
|
185
|
+
*
|
|
186
|
+
* - `reserveTokens` positions Pi's own threshold on `thresholdTokens`.
|
|
187
|
+
* - `keepRecentTokens` becomes the retained tail, so Pi's summary request
|
|
188
|
+
* carries the same amount of verbatim history the policy intends.
|
|
189
|
+
*/
|
|
111
190
|
export function applyProcessCompactionOverride(manager, input) {
|
|
112
191
|
if (!manager?.applyOverrides || input.policy.mode === "off") {
|
|
113
192
|
return { applied: false };
|
|
114
193
|
}
|
|
115
194
|
const explicitOff = input.policy.mode === "safe" && isExplicitlyDisabled(manager);
|
|
116
195
|
const enabled = input.policy.mode === "strict" ? true : explicitOff ? false : true;
|
|
117
|
-
const
|
|
118
|
-
?
|
|
196
|
+
const contextWindow = typeof input.contextWindow === "number" && input.contextWindow > 0
|
|
197
|
+
? input.contextWindow
|
|
119
198
|
: undefined;
|
|
199
|
+
const spec = contextWindow === undefined ? undefined : resolveCompactSpec(contextWindow, input.policy);
|
|
120
200
|
const compaction = { enabled };
|
|
121
|
-
if (enabled) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
201
|
+
if (enabled && spec !== undefined) {
|
|
202
|
+
/*
|
|
203
|
+
* Write the reserve even in the fallback case.
|
|
204
|
+
*
|
|
205
|
+
* `resolveCompactSpec` still returns a usable threshold there (the window
|
|
206
|
+
* minus Pi's default reserve), and Pi has to be told about it. Skipping
|
|
207
|
+
* the write left Pi on its own defaults while the Console reported a
|
|
208
|
+
* different threshold — two thresholds again, which is exactly the class
|
|
209
|
+
* of bug this change removes.
|
|
210
|
+
*/
|
|
211
|
+
compaction.reserveTokens = piReserveTokensFor(spec.contextWindow, spec.thresholdTokens);
|
|
212
|
+
compaction.keepRecentTokens = spec.retainTokens;
|
|
128
213
|
}
|
|
129
214
|
manager.applyOverrides({ compaction });
|
|
130
215
|
return {
|
|
@@ -136,20 +221,21 @@ export function applyProcessCompactionOverride(manager, input) {
|
|
|
136
221
|
...(typeof compaction.keepRecentTokens === "number"
|
|
137
222
|
? { keepRecentTokens: compaction.keepRecentTokens }
|
|
138
223
|
: {}),
|
|
139
|
-
...(
|
|
140
|
-
|
|
224
|
+
...(spec ? { thresholdTokens: spec.thresholdTokens, retainTokens: spec.retainTokens, fallback: spec.fallback } : {}),
|
|
225
|
+
...(spec && spec.diagnostics.length > 0
|
|
226
|
+
? { diagnostic: spec.diagnostics.join(",") }
|
|
141
227
|
: {}),
|
|
142
228
|
};
|
|
143
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Settings for harness runs that build a Pi session without a Console window.
|
|
232
|
+
*
|
|
233
|
+
* DSH's policy needs a context window, which a harness-owned session does not
|
|
234
|
+
* know up front, so this keeps Pi's defaults and only honours the mode switch.
|
|
235
|
+
*/
|
|
144
236
|
export function inMemoryCompactionSettings(policy) {
|
|
145
237
|
if (policy.mode === "off") {
|
|
146
238
|
return { enabled: true };
|
|
147
239
|
}
|
|
148
|
-
return {
|
|
149
|
-
enabled: true,
|
|
150
|
-
keepRecentTokens: DEFAULT_KEEP_RECENT_TOKENS,
|
|
151
|
-
...(policy.explicitReserveTokens
|
|
152
|
-
? { reserveTokens: policy.explicitReserveTokens }
|
|
153
|
-
: {}),
|
|
154
|
-
};
|
|
240
|
+
return { enabled: true };
|
|
155
241
|
}
|
|
@@ -9,6 +9,7 @@ export function createCompactionController() {
|
|
|
9
9
|
return {
|
|
10
10
|
proactiveCompaction: false,
|
|
11
11
|
manualCheckpointFallbackArmed: false,
|
|
12
|
+
summaryRetryPending: undefined,
|
|
12
13
|
pruneArmed: false,
|
|
13
14
|
pruneStatus: undefined,
|
|
14
15
|
pruneDiagnostic: undefined,
|
|
@@ -67,9 +68,12 @@ export function createContextPressureExtension(options) {
|
|
|
67
68
|
}
|
|
68
69
|
if (l2) {
|
|
69
70
|
api.on("session_compact_failed", (event) => {
|
|
71
|
+
// A provider summary that itself hit the context ceiling is the
|
|
72
|
+
// signal to stop asking the model and fall back locally. This
|
|
73
|
+
// covers both entry points: an automatic overflow retry and a
|
|
74
|
+
// manual compaction whose summary request was rejected.
|
|
70
75
|
options.controller.manualCheckpointFallbackArmed =
|
|
71
|
-
event.
|
|
72
|
-
!event.fromExtension &&
|
|
76
|
+
!event.fromExtension &&
|
|
73
77
|
!event.aborted &&
|
|
74
78
|
isContextOverflow(event.errorMessage);
|
|
75
79
|
return undefined;
|
|
@@ -91,14 +95,27 @@ export function createContextPressureExtension(options) {
|
|
|
91
95
|
if (reason === "manual") {
|
|
92
96
|
incrementCounter(options.controller.counters, "manual");
|
|
93
97
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
/*
|
|
99
|
+
* The provider summary is tried FIRST, even after the gateway
|
|
100
|
+
* rejected the previous request.
|
|
101
|
+
*
|
|
102
|
+
* Taking over on the first overflow is what made every session
|
|
103
|
+
* end on the deterministic checkpoint: one 400 from the gateway
|
|
104
|
+
* permanently downgraded the summary quality for that compaction,
|
|
105
|
+
* with no chance to see whether a smaller request would have
|
|
106
|
+
* worked. Only a FAILED summary request arms the local fallback
|
|
107
|
+
* (see session_compact_failed above), so reaching this branch
|
|
108
|
+
* means the model already declined.
|
|
109
|
+
*/
|
|
110
|
+
const useCheckpoint = options.controller.manualCheckpointFallbackArmed;
|
|
111
|
+
if (!useCheckpoint) {
|
|
112
|
+
if (reason === "overflow" && providerOverflow) {
|
|
113
|
+
incrementCounter(options.controller.counters, "overflow-summary-retry");
|
|
114
|
+
options.controller.summaryRetryPending = true;
|
|
115
|
+
}
|
|
98
116
|
return undefined;
|
|
99
|
-
if (reason === "manual") {
|
|
100
|
-
options.controller.manualCheckpointFallbackArmed = false;
|
|
101
117
|
}
|
|
118
|
+
options.controller.manualCheckpointFallbackArmed = false;
|
|
102
119
|
const checkpoint = buildOverflowCheckpoint({
|
|
103
120
|
preparation: event.preparation,
|
|
104
121
|
customInstructions: event.customInstructions,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { isContextOverflow, CONTEXT_OVERFLOW_PHRASES, OVERFLOW_FIXTURES, NORMALIZED_OVERFLOW_PREFIX, shouldRewriteAssistantOverflow, normalizeOverflowErrorMessage, buildGeneratedOverflowClassifierSource, } from "./overflow.js";
|
|
2
|
-
export { parseCompactionPolicy,
|
|
2
|
+
export { parseCompactionPolicy, resolveCompactSpec, piReserveTokensFor, conservativeTokenEstimate, projectPromptPressure, applyProcessCompactionOverride, inMemoryCompactionSettings, PI_DEFAULT_RESERVE_TOKENS, DEFAULT_THRESHOLD_RATIO, DEFAULT_HEADROOM_TOKENS, DEFAULT_RETAIN_RATIO, DEFAULT_RESERVED_COMPLETION_TOKENS, } from "./compaction-policy.js";
|
|
3
3
|
export { buildOverflowCheckpoint, normalizeCompactionPreparation, } from "./checkpoint.js";
|
|
4
4
|
export { deriveCompactionAccounting, readCompactionAccounting, } from "./compaction-accounting.js";
|
|
5
5
|
export { PI_TOOL_RESULT_PRUNE_MARKER, DEFAULT_PI_TOOL_RESULT_PRUNE_CONFIG, resolvePiToolResultPruneConfig, parsePiToolResultPruneConfig, piCodePointLength, prunePiToolResultMessages, } from "./tool-result-pruner.js";
|
|
@@ -2,7 +2,9 @@ export function emptyContextPressureCounters() {
|
|
|
2
2
|
return {
|
|
3
3
|
prePromptThreshold: 0,
|
|
4
4
|
overflow: 0,
|
|
5
|
+
overflowSummaryRetry: 0,
|
|
5
6
|
manual: 0,
|
|
7
|
+
compactionRetry: 0,
|
|
6
8
|
wireCompression: 0,
|
|
7
9
|
failOpen: 0,
|
|
8
10
|
usageUnavailable: 0,
|
|
@@ -25,9 +27,15 @@ export function incrementCounter(counters, reason, amount = 1) {
|
|
|
25
27
|
case "overflow":
|
|
26
28
|
counters.overflow += amount;
|
|
27
29
|
break;
|
|
30
|
+
case "overflow-summary-retry":
|
|
31
|
+
counters.overflowSummaryRetry += amount;
|
|
32
|
+
break;
|
|
28
33
|
case "manual":
|
|
29
34
|
counters.manual += amount;
|
|
30
35
|
break;
|
|
36
|
+
case "compaction-retry":
|
|
37
|
+
counters.compactionRetry += amount;
|
|
38
|
+
break;
|
|
31
39
|
case "wire-compression":
|
|
32
40
|
counters.wireCompression += amount;
|
|
33
41
|
break;
|
|
@@ -48,7 +56,9 @@ export function projectSafeTelemetry(counters) {
|
|
|
48
56
|
return {
|
|
49
57
|
prePromptThreshold: counters.prePromptThreshold,
|
|
50
58
|
overflow: counters.overflow,
|
|
59
|
+
overflowSummaryRetry: counters.overflowSummaryRetry,
|
|
51
60
|
manual: counters.manual,
|
|
61
|
+
compactionRetry: counters.compactionRetry,
|
|
52
62
|
wireCompression: counters.wireCompression,
|
|
53
63
|
failOpen: counters.failOpen,
|
|
54
64
|
tokensSavedEstimate: counters.tokensSavedEstimate,
|
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import semver from "semver";
|
|
5
5
|
const PACKAGE_NAME = "@tea-agent/loop-agent";
|
|
6
6
|
export const DEFAULT_NPM_QUERY_TIMEOUT_MS = 15_000;
|
|
7
|
+
export const DEFAULT_NPM_INSTALL_TIMEOUT_MS = 300_000;
|
|
7
8
|
function quoteWindowsCommandArgument(value) {
|
|
8
9
|
if (/[%!^&|<>]/.test(value)) {
|
|
9
10
|
throw new Error("unsafe Windows update command argument");
|
|
@@ -89,12 +90,22 @@ export function createNpmUpdateClient(options) {
|
|
|
89
90
|
return { ok: false, reason: "invalid-version" };
|
|
90
91
|
}
|
|
91
92
|
const result = await runner(npmCommand, buildExactInstallArgs(version, channel), {
|
|
92
|
-
timeoutMs: Math.max(timeoutMs,
|
|
93
|
+
timeoutMs: Math.max(timeoutMs, DEFAULT_NPM_INSTALL_TIMEOUT_MS),
|
|
93
94
|
cwd,
|
|
94
95
|
env,
|
|
95
96
|
});
|
|
96
|
-
if (result.
|
|
97
|
-
return { ok: false, reason: "install-
|
|
97
|
+
if (result.timedOut)
|
|
98
|
+
return { ok: false, reason: "install-timeout" };
|
|
99
|
+
if (result.exitCode !== 0) {
|
|
100
|
+
// Only allowlisted npm error codes cross into operation/UI state.
|
|
101
|
+
// Raw npm output may contain credentials or private registry URLs.
|
|
102
|
+
const code = /(?:npm (?:ERR!|error) code)\s+(\w+)/i.exec(result.stderr)?.[1]?.toUpperCase();
|
|
103
|
+
const reason = code === "EACCES" || code === "EPERM" ? "install-permission-denied"
|
|
104
|
+
: code === "ENOSPC" ? "install-disk-full"
|
|
105
|
+
: code && ["ECONNRESET", "ECONNREFUSED", "ETIMEDOUT", "EAI_AGAIN", "ENOTFOUND"].includes(code) ? "install-network-failed"
|
|
106
|
+
: "install-failed";
|
|
107
|
+
return { ok: false, reason };
|
|
108
|
+
}
|
|
98
109
|
return { ok: true };
|
|
99
110
|
},
|
|
100
111
|
async verifyInstalled(version) {
|
|
@@ -118,12 +118,8 @@ export const dagVerifyStrategySchema = z
|
|
|
118
118
|
.default("adapter"),
|
|
119
119
|
})
|
|
120
120
|
.optional();
|
|
121
|
-
export const
|
|
122
|
-
|
|
123
|
-
"approval-required",
|
|
124
|
-
"enabled",
|
|
125
|
-
]);
|
|
126
|
-
export const LOOP_AUTO_WRITE_POLICY_REMOVED_ERROR = "task field loopAutoWritePolicy is no longer supported; use loopAutoExecutionPolicy (off | approval-required | enabled)";
|
|
121
|
+
export const LOOP_AUTO_EXECUTION_POLICY_REMOVED_ERROR = "task field loopAutoExecutionPolicy is no longer supported; use Console Chat /goal or Agent DAG";
|
|
122
|
+
export const LOOP_AUTO_WRITE_POLICY_REMOVED_ERROR = "task field loopAutoWritePolicy is no longer supported";
|
|
127
123
|
export const CURSOR_TASK_FIELD_REMOVED_ERROR = 'task fields "executor" and "cursorModel" are no longer supported; governed runtime is Pi-only';
|
|
128
124
|
export const PI_SUBAGENT_MODE_REMOVED_ERROR = 'task field "piSubagentMode" is no longer supported; omit it. DAG task config has no subagent mode, and Console Agent is a separate protocol';
|
|
129
125
|
export const frontendMockPolicySchema = z.enum(["auto", "required", "disabled"]);
|
|
@@ -421,10 +417,6 @@ const taskConfigObjectSchema = z.object({
|
|
|
421
417
|
.strict()
|
|
422
418
|
.optional(),
|
|
423
419
|
frontendExecutionPolicy: frontendExecutionPolicySchema.optional(),
|
|
424
|
-
/** Outer loop auto mode never writes by default; DAG execute requires this policy plus path/writeSet gates. */
|
|
425
|
-
loopAutoExecutionPolicy: loopAutoExecutionPolicySchema
|
|
426
|
-
.optional()
|
|
427
|
-
.default("off"),
|
|
428
420
|
requireRetrospective: z.boolean().optional().default(false),
|
|
429
421
|
/** inherit: use host shell env; clean: sanitized env for deterministic verify */
|
|
430
422
|
verifyEnv: z.enum(["inherit", "clean"]).optional().default("clean"),
|
|
@@ -448,6 +440,9 @@ export const taskConfigSchema = z.preprocess((raw) => {
|
|
|
448
440
|
if ("loopAutoWritePolicy" in obj) {
|
|
449
441
|
throw new Error(LOOP_AUTO_WRITE_POLICY_REMOVED_ERROR);
|
|
450
442
|
}
|
|
443
|
+
if ("loopAutoExecutionPolicy" in obj) {
|
|
444
|
+
throw new Error(LOOP_AUTO_EXECUTION_POLICY_REMOVED_ERROR);
|
|
445
|
+
}
|
|
451
446
|
if ("executor" in obj || "cursorModel" in obj) {
|
|
452
447
|
throw new Error(CURSOR_TASK_FIELD_REMOVED_ERROR);
|
|
453
448
|
}
|
package/dist/task/delegate.js
CHANGED
|
@@ -192,7 +192,7 @@ async function tryRunGit(repoRoot, args) {
|
|
|
192
192
|
return new Promise((resolve) => {
|
|
193
193
|
const child = spawn('git', args, {
|
|
194
194
|
cwd: repoRoot,
|
|
195
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
195
|
+
stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true,
|
|
196
196
|
});
|
|
197
197
|
const out = [];
|
|
198
198
|
child.stdout?.on('data', (chunk) => out.push(chunk));
|
package/dist/task/read-model.js
CHANGED
|
@@ -119,10 +119,6 @@ export async function buildTaskReadModel(repoRoot, taskId) {
|
|
|
119
119
|
path: closeout,
|
|
120
120
|
exists: closeoutExists,
|
|
121
121
|
},
|
|
122
|
-
loopState: {
|
|
123
|
-
path: path.join(taskDir, "loop-state.json"),
|
|
124
|
-
exists: await exists(path.join(taskDir, "loop-state.json")),
|
|
125
|
-
},
|
|
126
122
|
legacyWorkflowState: {
|
|
127
123
|
status: legacyState.status,
|
|
128
124
|
currentStep: legacyState.currentStep,
|
package/dist/task/runtime.js
CHANGED
package/dist/task/worktree.js
CHANGED
|
@@ -291,7 +291,7 @@ export async function removeWorktree(repoRoot, manifest, opts) {
|
|
|
291
291
|
async function runGit(cwd, args) {
|
|
292
292
|
return new Promise((resolve, reject) => {
|
|
293
293
|
const child = spawn("git", ["-C", cwd, ...args], {
|
|
294
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
294
|
+
stdio: ["ignore", "pipe", "pipe"], windowsHide: true,
|
|
295
295
|
});
|
|
296
296
|
const stdoutChunks = [];
|
|
297
297
|
const stderrChunks = [];
|
|
@@ -487,9 +487,11 @@ function validateResponseFields(pointers) {
|
|
|
487
487
|
throw new ApiWorkbenchCoreError("API_WB_RESPONSE_FIELDS", "最多选择 10 个有效 JSON Pointer 标量字段");
|
|
488
488
|
}
|
|
489
489
|
/** Default output contains no arbitrary business body. Explicit JSON Pointers opt in to scalar fields only. */
|
|
490
|
-
function projectResponseBody(text, pointers, redact) {
|
|
490
|
+
function projectResponseBody(text, pointers, redact, mode = "hidden") {
|
|
491
|
+
if (mode === "full")
|
|
492
|
+
return redact(text);
|
|
491
493
|
if (!pointers.length)
|
|
492
|
-
return "
|
|
494
|
+
return "正文默认隐藏;可在“鉴权与断言”里选择 JSON 字段,或点“查看完整正文”";
|
|
493
495
|
if (pointers.length > 10)
|
|
494
496
|
throw new ApiWorkbenchCoreError("API_WB_RESPONSE_FIELDS", "最多选择 10 个响应字段");
|
|
495
497
|
let value;
|
|
@@ -734,9 +736,15 @@ export function createApiWorkbenchService(repoRoot, file, options = {}) {
|
|
|
734
736
|
const visible = truncated ? buffer.subarray(0, MAX_RESPONSE_BYTES) : buffer;
|
|
735
737
|
const contentType = response.headers.get("content-type") ?? "";
|
|
736
738
|
const responseHeaders = {};
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
739
|
+
if (input.bodyView === "full") {
|
|
740
|
+
for (const [name, value] of response.headers)
|
|
741
|
+
responseHeaders[name] = redact(value);
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
const mime = /^(?:application|text|image|audio|video)\/[a-z0-9.+-]+/i.exec(contentType)?.[0];
|
|
745
|
+
if (mime)
|
|
746
|
+
responseHeaders["content-type"] = redact(mime);
|
|
747
|
+
}
|
|
740
748
|
const elapsedMs = Date.now() - started;
|
|
741
749
|
const assertionResults = evaluateAssertions(assertions, response.status, responseHeaders, decodeBodyText(visible, contentType));
|
|
742
750
|
const responseText = decodeBodyText(visible, contentType);
|
|
@@ -760,7 +768,10 @@ export function createApiWorkbenchService(repoRoot, file, options = {}) {
|
|
|
760
768
|
statusText: STATUS_CODES[response.status] ?? "HTTP 响应",
|
|
761
769
|
elapsedMs,
|
|
762
770
|
headers: responseHeaders,
|
|
763
|
-
bodyText:
|
|
771
|
+
bodyText: (() => {
|
|
772
|
+
const projected = projectResponseBody(decodeBodyText(visible, contentType), input.responseFields ?? [], redact, input.bodyView ?? "hidden");
|
|
773
|
+
return input.bodyView === "full" && truncated ? projected + "\n[已截断:响应超过大小上限]" : projected;
|
|
774
|
+
})(),
|
|
764
775
|
bodySize: buffer.length,
|
|
765
776
|
truncated,
|
|
766
777
|
};
|
|
@@ -89,6 +89,8 @@ async function handleSend(req, res, deps) {
|
|
|
89
89
|
queryParams: parseQueryParams(body.queryParams),
|
|
90
90
|
...(typeof body.environmentId === "string" ? { environmentId: body.environmentId } : {}),
|
|
91
91
|
...(Array.isArray(body.responseFields) && body.responseFields.every(field => typeof field === "string") ? { responseFields: body.responseFields } : {}),
|
|
92
|
+
// Human UI always wants the redacted full body so the response is readable without picking pointers.
|
|
93
|
+
bodyView: "full",
|
|
92
94
|
...(body.authRef && typeof body.authRef === "object" && "id" in body.authRef && "version" in body.authRef && typeof body.authRef.id === "string" && typeof body.authRef.version === "string" ? { authRef: { id: body.authRef.id, version: body.authRef.version } } : {}),
|
|
93
95
|
}, { signal: controller.signal });
|
|
94
96
|
sendJson(res, 200, outcome);
|
|
@@ -11,7 +11,13 @@ function asRecord(value) {
|
|
|
11
11
|
function readString(value) {
|
|
12
12
|
return typeof value === "string" ? value : undefined;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Parse a persisted/SSE content array.
|
|
16
|
+
*
|
|
17
|
+
* Recognised blocks keep their typed shape; anything else is preserved as an
|
|
18
|
+
* `unknown` block rather than dropped, so a newer provider block type surfaces
|
|
19
|
+
* as a visible placeholder instead of vanishing from the message.
|
|
20
|
+
*/
|
|
15
21
|
export function parseAssistantContent(value) {
|
|
16
22
|
if (!Array.isArray(value))
|
|
17
23
|
return undefined;
|
|
@@ -44,9 +50,17 @@ export function parseAssistantContent(value) {
|
|
|
44
50
|
}
|
|
45
51
|
if (type === "text" || type === "output_text" || type === "") {
|
|
46
52
|
const text = readString(rec.text);
|
|
47
|
-
if (text !== undefined)
|
|
53
|
+
if (text !== undefined) {
|
|
48
54
|
blocks.push({ type: "text", text });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
49
57
|
}
|
|
58
|
+
// Unrecognised: keep it visible instead of dropping it.
|
|
59
|
+
blocks.push({
|
|
60
|
+
type: "unknown",
|
|
61
|
+
blockType: type === "" ? "unknown" : type,
|
|
62
|
+
data: item,
|
|
63
|
+
});
|
|
50
64
|
}
|
|
51
65
|
return blocks;
|
|
52
66
|
}
|
|
@@ -98,7 +112,11 @@ export function isSemanticallyEmptyAssistantCompletion(message) {
|
|
|
98
112
|
return false;
|
|
99
113
|
const blocks = extractAssistantContentBlocks(message);
|
|
100
114
|
return (!blocks.some((block) => block.type === "text" && block.text.trim() !== "") &&
|
|
101
|
-
!blocks.some((block) => block.type === "toolCall")
|
|
115
|
+
!blocks.some((block) => block.type === "toolCall") &&
|
|
116
|
+
// An unknown block is still content the provider chose to send. Treating
|
|
117
|
+
// it as empty would trigger the empty-completion recovery and replace a
|
|
118
|
+
// real response with a retry prompt.
|
|
119
|
+
!blocks.some((block) => block.type === "unknown"));
|
|
102
120
|
}
|
|
103
121
|
export function isEmptyThinkingBlock(block, options = {}) {
|
|
104
122
|
return (block.type === "thinking" &&
|
|
@@ -333,6 +333,8 @@ export function turnEventToStorePartial(event) {
|
|
|
333
333
|
case "todo_updated":
|
|
334
334
|
case "todo_cleared":
|
|
335
335
|
return { kind: event.type, data: { todos: Array.isArray(event.todos) ? event.todos : [], ...(event.toolCallId ? { toolCallId: String(event.toolCallId) } : {}) } };
|
|
336
|
+
case "workspace_changes":
|
|
337
|
+
return { kind: "workspace_changes", data: event.summary };
|
|
336
338
|
case "agent_end":
|
|
337
339
|
return {
|
|
338
340
|
kind: "agent_end",
|
|
@@ -368,6 +370,10 @@ export function turnEventToStorePartial(event) {
|
|
|
368
370
|
? { estimatedTokensAfter: event.estimatedTokensAfter }
|
|
369
371
|
: {}),
|
|
370
372
|
willRetry: Boolean(event.willRetry),
|
|
373
|
+
...(event.localFallback === true ? { localFallback: true } : {}),
|
|
374
|
+
...(typeof event.localFallbackReason === "string"
|
|
375
|
+
? { localFallbackReason: event.localFallbackReason }
|
|
376
|
+
: {}),
|
|
371
377
|
...(typeof event.errorMessage === "string"
|
|
372
378
|
? { errorMessage: event.errorMessage }
|
|
373
379
|
: {}),
|