@tea-agent/loop-agent 0.51.0 → 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 +123 -5
- 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
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-scoped compaction limits for the Console's Pi runtime.
|
|
3
|
+
*
|
|
4
|
+
* Stored outside any repo, beside the other cross-project preferences:
|
|
5
|
+
* `<appDataRoot>/settings/pi-compaction.json`.
|
|
6
|
+
*
|
|
7
|
+
* Why this exists: a self-hosted gateway can accept far less input than the
|
|
8
|
+
* model's declared `contextWindow`. The old model exposed that as an absolute
|
|
9
|
+
* "gateway limit", which silently stops working the moment the conversation
|
|
10
|
+
* moves to a model with a different window. The policy now follows DSH: a
|
|
11
|
+
* window fraction plus headroom, both relative to the window, so one setting
|
|
12
|
+
* stays correct across models.
|
|
13
|
+
*
|
|
14
|
+
* Environment variables remain supported and take precedence, so an operator
|
|
15
|
+
* can override without touching saved settings (see `resolveCompactionSettings`).
|
|
16
|
+
*/
|
|
17
|
+
import { readFile, rename, writeFile } from "node:fs/promises";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { ensureSecureDir } from "../../infrastructure/console/app-data.js";
|
|
20
|
+
import { DEFAULT_HEADROOM_TOKENS, DEFAULT_RETAIN_RATIO, DEFAULT_THRESHOLD_RATIO, } from "../../shared/pi-context-pressure/compaction-policy.js";
|
|
21
|
+
export const PI_COMPACTION_SETTINGS_SCHEMA_VERSION = 1;
|
|
22
|
+
export class PiCompactionSettingsError extends Error {
|
|
23
|
+
code;
|
|
24
|
+
status;
|
|
25
|
+
constructor(code, message, status = 400) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.status = status;
|
|
29
|
+
this.name = "PiCompactionSettingsError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Bounds mirror the environment parser so the two sources cannot disagree. */
|
|
33
|
+
export const THRESHOLD_RATIO_MIN = 0.05;
|
|
34
|
+
export const THRESHOLD_RATIO_MAX = 1;
|
|
35
|
+
export const HEADROOM_MIN = 0;
|
|
36
|
+
export const HEADROOM_MAX = 10_000_000;
|
|
37
|
+
export const RETAIN_RATIO_MIN = 0.01;
|
|
38
|
+
export const RETAIN_RATIO_MAX = 0.99;
|
|
39
|
+
/**
|
|
40
|
+
* Keys accepted from a saved file.
|
|
41
|
+
*
|
|
42
|
+
* The previous schema stored `gatewayInputLimitTokens` and `keepRecentTokens`.
|
|
43
|
+
* Those are dropped on read rather than migrated: an absolute gateway ceiling
|
|
44
|
+
* cannot be converted into a relative headroom, and a retained-token count is
|
|
45
|
+
* now derived from the window. Ignoring them means an upgraded install lands on
|
|
46
|
+
* the DSH defaults instead of on a silently wrong value.
|
|
47
|
+
*/
|
|
48
|
+
const LEGACY_KEYS = new Set(["gatewayInputLimitTokens", "keepRecentTokens"]);
|
|
49
|
+
const CURRENT_KEYS = ["thresholdRatio", "headroomTokens", "retainRatio"];
|
|
50
|
+
function isRecord(value) {
|
|
51
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
52
|
+
}
|
|
53
|
+
function boundedNumber(value, label, min, max) {
|
|
54
|
+
if (value === undefined || value === null)
|
|
55
|
+
return undefined;
|
|
56
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
57
|
+
throw new PiCompactionSettingsError("INVALID_INPUT", `${label}必须是数字`);
|
|
58
|
+
}
|
|
59
|
+
if (value < min || value > max) {
|
|
60
|
+
throw new PiCompactionSettingsError("INVALID_INPUT", `${label}必须在 ${min} 到 ${max} 之间(收到 ${value})`);
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
export function parsePiCompactionSettings(value) {
|
|
65
|
+
if (value === undefined || value === null)
|
|
66
|
+
return {};
|
|
67
|
+
if (!isRecord(value)) {
|
|
68
|
+
throw new PiCompactionSettingsError("INVALID_INPUT", "压缩设置格式无效");
|
|
69
|
+
}
|
|
70
|
+
const unknownKeys = Object.keys(value).filter((key) => !LEGACY_KEYS.has(key) && !CURRENT_KEYS.includes(key));
|
|
71
|
+
if (unknownKeys.length > 0) {
|
|
72
|
+
throw new PiCompactionSettingsError("INVALID_INPUT", `压缩设置包含无效字段:${unknownKeys.join(", ")}`);
|
|
73
|
+
}
|
|
74
|
+
const thresholdRatio = boundedNumber(value.thresholdRatio, "窗口比例", THRESHOLD_RATIO_MIN, THRESHOLD_RATIO_MAX);
|
|
75
|
+
const headroomTokens = boundedNumber(value.headroomTokens, "额外余量", HEADROOM_MIN, HEADROOM_MAX);
|
|
76
|
+
const retainRatio = boundedNumber(value.retainRatio, "保留比例", RETAIN_RATIO_MIN, RETAIN_RATIO_MAX);
|
|
77
|
+
if (thresholdRatio !== undefined &&
|
|
78
|
+
retainRatio !== undefined &&
|
|
79
|
+
retainRatio >= thresholdRatio) {
|
|
80
|
+
// DSH rejects this outright: retaining as much as we compact leaves the
|
|
81
|
+
// summary covering nothing.
|
|
82
|
+
throw new PiCompactionSettingsError("INVALID_INPUT", "保留比例必须小于窗口比例");
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
...(thresholdRatio === undefined ? {} : { thresholdRatio }),
|
|
86
|
+
...(headroomTokens === undefined ? {} : { headroomTokens }),
|
|
87
|
+
...(retainRatio === undefined ? {} : { retainRatio }),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Saved settings win over the environment only when the environment is absent:
|
|
92
|
+
* an operator's exported variable is an explicit override for this process,
|
|
93
|
+
* while the saved file is the durable preference.
|
|
94
|
+
*/
|
|
95
|
+
export function resolveCompactionSettings(input) {
|
|
96
|
+
const env = input.env ?? process.env;
|
|
97
|
+
const saved = input.saved ?? {};
|
|
98
|
+
const readEnv = (name) => {
|
|
99
|
+
const raw = env[name]?.trim();
|
|
100
|
+
if (!raw)
|
|
101
|
+
return undefined;
|
|
102
|
+
const parsed = Number(raw);
|
|
103
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
104
|
+
};
|
|
105
|
+
const thresholdFromEnv = readEnv("HARNESS_COMPACTION_THRESHOLD_RATIO");
|
|
106
|
+
const headroomFromEnv = readEnv("HARNESS_COMPACTION_HEADROOM_TOKENS");
|
|
107
|
+
const retainFromEnv = readEnv("HARNESS_COMPACTION_RETAIN_RATIO");
|
|
108
|
+
return {
|
|
109
|
+
thresholdRatio: thresholdFromEnv ?? saved.thresholdRatio,
|
|
110
|
+
headroomTokens: headroomFromEnv ?? saved.headroomTokens,
|
|
111
|
+
retainRatio: retainFromEnv ?? saved.retainRatio,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** Effective values with DSH defaults applied, for display. */
|
|
115
|
+
export function effectiveCompactionSettings(settings) {
|
|
116
|
+
return {
|
|
117
|
+
thresholdRatio: settings.thresholdRatio ?? DEFAULT_THRESHOLD_RATIO,
|
|
118
|
+
headroomTokens: settings.headroomTokens ?? DEFAULT_HEADROOM_TOKENS,
|
|
119
|
+
retainRatio: settings.retainRatio ?? DEFAULT_RETAIN_RATIO,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function settingsFile(appDataRoot) {
|
|
123
|
+
return path.join(appDataRoot, "settings", "pi-compaction.json");
|
|
124
|
+
}
|
|
125
|
+
async function readStored(file) {
|
|
126
|
+
let raw;
|
|
127
|
+
try {
|
|
128
|
+
raw = await readFile(file, "utf8");
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return {
|
|
132
|
+
schemaVersion: PI_COMPACTION_SETTINGS_SCHEMA_VERSION,
|
|
133
|
+
revision: 0,
|
|
134
|
+
updatedAt: new Date(0).toISOString(),
|
|
135
|
+
settings: {},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
const parsed = JSON.parse(raw);
|
|
140
|
+
if (!isRecord(parsed) ||
|
|
141
|
+
parsed.schemaVersion !== PI_COMPACTION_SETTINGS_SCHEMA_VERSION ||
|
|
142
|
+
!Number.isSafeInteger(parsed.revision) ||
|
|
143
|
+
parsed.revision < 0) {
|
|
144
|
+
throw new Error("invalid schema");
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
schemaVersion: PI_COMPACTION_SETTINGS_SCHEMA_VERSION,
|
|
148
|
+
revision: parsed.revision,
|
|
149
|
+
updatedAt: typeof parsed.updatedAt === "string"
|
|
150
|
+
? parsed.updatedAt
|
|
151
|
+
: new Date(0).toISOString(),
|
|
152
|
+
settings: parsePiCompactionSettings(parsed.settings),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
// A file written by the previous schema is readable: its keys are parsed
|
|
157
|
+
// and dropped. Only a genuinely broken file is an error.
|
|
158
|
+
if (error instanceof PiCompactionSettingsError)
|
|
159
|
+
throw error;
|
|
160
|
+
throw new PiCompactionSettingsError("SETTINGS_UNREADABLE", "无法读取压缩设置,请检查程序数据目录中的 settings/pi-compaction.json", 503);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function writeAtomic(file, content) {
|
|
164
|
+
await ensureSecureDir(path.dirname(file));
|
|
165
|
+
const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
166
|
+
await writeFile(temporary, content, { encoding: "utf8", mode: 0o600 });
|
|
167
|
+
await rename(temporary, file);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* One persisted preference per Console data root.
|
|
171
|
+
*
|
|
172
|
+
* Reads are uncached on purpose: the runtime asks once per session start, and a
|
|
173
|
+
* stale cache would silently keep a corrected setting from applying.
|
|
174
|
+
*/
|
|
175
|
+
export async function createPiCompactionSettings(appDataRoot) {
|
|
176
|
+
const file = settingsFile(appDataRoot);
|
|
177
|
+
const view = (stored) => {
|
|
178
|
+
const effective = resolveCompactionSettings({ saved: stored.settings });
|
|
179
|
+
const resolved = effectiveCompactionSettings(effective);
|
|
180
|
+
return {
|
|
181
|
+
ok: true,
|
|
182
|
+
revision: stored.revision,
|
|
183
|
+
settings: stored.settings,
|
|
184
|
+
effective: resolved,
|
|
185
|
+
envOverrides: {
|
|
186
|
+
thresholdRatio: effective.thresholdRatio !== stored.settings.thresholdRatio,
|
|
187
|
+
headroomTokens: effective.headroomTokens !== stored.settings.headroomTokens,
|
|
188
|
+
retainRatio: effective.retainRatio !== stored.settings.retainRatio,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
return {
|
|
193
|
+
async read() {
|
|
194
|
+
return view(await readStored(file));
|
|
195
|
+
},
|
|
196
|
+
async current() {
|
|
197
|
+
return (await readStored(file)).settings;
|
|
198
|
+
},
|
|
199
|
+
async save(input) {
|
|
200
|
+
if (!isRecord(input) ||
|
|
201
|
+
!Number.isSafeInteger(input.expectedRevision) ||
|
|
202
|
+
input.expectedRevision < 0) {
|
|
203
|
+
throw new PiCompactionSettingsError("INVALID_INPUT", "保存需要有效的设置和版本号");
|
|
204
|
+
}
|
|
205
|
+
const settings = parsePiCompactionSettings(input.settings);
|
|
206
|
+
const current = await readStored(file);
|
|
207
|
+
if (current.revision !== input.expectedRevision) {
|
|
208
|
+
throw new PiCompactionSettingsError("REVISION_CONFLICT", "压缩设置已在其他页面更新,请重新加载后再保存", 409);
|
|
209
|
+
}
|
|
210
|
+
const next = {
|
|
211
|
+
schemaVersion: PI_COMPACTION_SETTINGS_SCHEMA_VERSION,
|
|
212
|
+
revision: current.revision + 1,
|
|
213
|
+
updatedAt: new Date().toISOString(),
|
|
214
|
+
settings,
|
|
215
|
+
};
|
|
216
|
+
await writeAtomic(file, `${JSON.stringify(next, null, 2)}\n`);
|
|
217
|
+
return { ok: true, revision: next.revision, settings };
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
}
|
|
@@ -1032,7 +1032,7 @@ async function handleListOperations(_req, res, ctx) {
|
|
|
1032
1032
|
ops: operations.map((op) => ({ ...op, workspaceId: ctx.workspace?.workspaceId })),
|
|
1033
1033
|
});
|
|
1034
1034
|
}
|
|
1035
|
-
async function handleOperationEvents(req, res, ctx, operationId) {
|
|
1035
|
+
export async function handleOperationEvents(req, res, ctx, operationId) {
|
|
1036
1036
|
if (!ctx.operator) {
|
|
1037
1037
|
sendJson(res, 503, {
|
|
1038
1038
|
ok: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createVersionCheck } from "./version-check.js";
|
|
2
2
|
import { createVersionNotes } from "./version-notes.js";
|
|
3
3
|
import { createNetworkProxySettings, NetworkProxyError } from "./network-proxy-settings.js";
|
|
4
|
+
import { createPiCompactionSettings, PiCompactionSettingsError, } from "./pi-compaction-settings.js";
|
|
4
5
|
import { createNpmUpdateClient } from "../../shared/update/npm-client.js";
|
|
5
6
|
import { AutomationStore } from "../scheduler/automation-store.js";
|
|
6
7
|
import { AutomationRuntime } from "./automation-runtime.js";
|
|
@@ -21,7 +22,7 @@ import { matchRepoHtmlPreviewRoute } from "./chat/repo-browser.js";
|
|
|
21
22
|
import { acceptConsoleUpdateAndInit } from "./operator-actions.js";
|
|
22
23
|
import { createOperationEventStore, } from "./operation-sse.js";
|
|
23
24
|
import { OperationStore, reconcileConsoleRestartOutcome, } from "../../infrastructure/console/operation-store.js";
|
|
24
|
-
import { createWorkspaceReadinessCache, handleConsoleHealthRequest, handleWorkspaceRoutes, sendJson, serveConsoleStatic, } from "./routes.js";
|
|
25
|
+
import { createWorkspaceReadinessCache, handleConsoleHealthRequest, handleWorkspaceRoutes, sendJson, serveConsoleStatic, handleOperationEvents, } from "./routes.js";
|
|
25
26
|
import { evaluateMutationGate, issueBootCapabilityToken, injectConfirmationTokenScript, } from "./security.js";
|
|
26
27
|
import { resolvePackageRootFromConsole } from "./sibling-controller.js";
|
|
27
28
|
import { isDagRerunPromptOverrideEnabled } from "../../shared/dag-prompt-override.js";
|
|
@@ -195,7 +196,9 @@ export async function createConsoleServer(options) {
|
|
|
195
196
|
...bootstrapAppData,
|
|
196
197
|
operations: path.join(bootstrapAppData.root, "program", "operations"),
|
|
197
198
|
});
|
|
198
|
-
const programEvents = createOperationEventStore(
|
|
199
|
+
const programEvents = createOperationEventStore({
|
|
200
|
+
persistenceDir: path.join(bootstrapAppData.root, "program", "operations", "events"),
|
|
201
|
+
});
|
|
199
202
|
let restartOutcomeTimer;
|
|
200
203
|
if (!options.skipReconcile)
|
|
201
204
|
await programOperations.reconcileOnBoot();
|
|
@@ -555,6 +558,83 @@ export async function createConsoleServer(options) {
|
|
|
555
558
|
}
|
|
556
559
|
if (pathname.startsWith("/api/operator/v1/") ||
|
|
557
560
|
pathname.startsWith("/api/session/")) {
|
|
561
|
+
// P0-A: Dedicated workspace tasks/subagents API routes (not process-level registry).
|
|
562
|
+
//
|
|
563
|
+
// Job termination rides the same namespace: a background job is a row in
|
|
564
|
+
// this surface, and the reader terminates it from the row — DSH's drawer
|
|
565
|
+
// does exactly that with `jobs.kill(ownerSessionId, jobId)`.
|
|
566
|
+
//
|
|
567
|
+
// Three shapes, matched SEPARATELY: a single alternation with a catch-all
|
|
568
|
+
// `([^/]+)` segment swallows "jobs" and the job path never resolves.
|
|
569
|
+
let workspaceSubagentMatch = null;
|
|
570
|
+
let subagentAction;
|
|
571
|
+
let stopAgentId;
|
|
572
|
+
let jobStopId;
|
|
573
|
+
const jobStopMatch = pathname.match(/^\/api\/operator\/v1\/workspaces\/([^/]+)\/subagents\/jobs\/([^/]+)\/stop$/);
|
|
574
|
+
const agentStopMatch = pathname.match(/^\/api\/operator\/v1\/workspaces\/([^/]+)\/subagents\/([^/]+)\/stop$/);
|
|
575
|
+
const listMatch = pathname.match(/^\/api\/operator\/v1\/workspaces\/([^/]+)\/subagents(?:\/(events))?$/);
|
|
576
|
+
if (jobStopMatch) {
|
|
577
|
+
jobStopId = decodeURIComponent(jobStopMatch[2]);
|
|
578
|
+
workspaceSubagentMatch = jobStopMatch;
|
|
579
|
+
}
|
|
580
|
+
else if (agentStopMatch) {
|
|
581
|
+
stopAgentId = decodeURIComponent(agentStopMatch[2]);
|
|
582
|
+
workspaceSubagentMatch = agentStopMatch;
|
|
583
|
+
}
|
|
584
|
+
else if (listMatch) {
|
|
585
|
+
subagentAction = listMatch[2];
|
|
586
|
+
workspaceSubagentMatch = listMatch;
|
|
587
|
+
}
|
|
588
|
+
if (workspaceSubagentMatch) {
|
|
589
|
+
const targetWorkspaceId = decodeURIComponent(workspaceSubagentMatch[1]);
|
|
590
|
+
if (method === "POST" && (stopAgentId || jobStopId)) {
|
|
591
|
+
const { evaluateMutationGate } = await import("./security.js");
|
|
592
|
+
const failure = evaluateMutationGate(req, {
|
|
593
|
+
cookieName: bootToken.cookieName,
|
|
594
|
+
bootToken: bootToken.value,
|
|
595
|
+
confirmationToken: bootToken.confirmationToken,
|
|
596
|
+
consoleOrigin: getConsoleOrigin(),
|
|
597
|
+
allowNonLoopbackAccess: !loopbackBind,
|
|
598
|
+
});
|
|
599
|
+
if (failure) {
|
|
600
|
+
sendJson(res, failure.status, {
|
|
601
|
+
ok: false,
|
|
602
|
+
error: { code: failure.code, message: failure.message },
|
|
603
|
+
});
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
const resolution = await resolveContext(targetWorkspaceId);
|
|
608
|
+
if (!resolution.ok) {
|
|
609
|
+
sendJson(res, resolution.status, {
|
|
610
|
+
ok: false,
|
|
611
|
+
error: { code: resolution.code, message: resolution.message },
|
|
612
|
+
});
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
const { handleListChatSubagentTasks, handleChatSubagentLive, handleStopWorkspaceSubagent, handleStopWorkspaceJob, } = await import("./chat/routes.js");
|
|
616
|
+
if (method === "GET" && !subagentAction) {
|
|
617
|
+
await handleListChatSubagentTasks(req, res, resolution.context.chatRouteDeps, targetWorkspaceId);
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
if (method === "GET" && subagentAction === "events") {
|
|
621
|
+
await handleChatSubagentLive(req, res, resolution.context.chatRouteDeps, targetWorkspaceId);
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
if (method === "POST" && jobStopId) {
|
|
625
|
+
await handleStopWorkspaceJob(req, res, resolution.context.chatRouteDeps, jobStopId);
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
if (method === "POST" && stopAgentId) {
|
|
629
|
+
await handleStopWorkspaceSubagent(req, res, resolution.context.chatRouteDeps, stopAgentId);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
sendJson(res, 404, {
|
|
633
|
+
ok: false,
|
|
634
|
+
error: { code: "NOT_FOUND", message: `unknown workspace subagents route: ${pathname}` },
|
|
635
|
+
});
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
558
638
|
// Workspace Registry routes are process-level (no workspaceId).
|
|
559
639
|
if (pathname === "/api/operator/v1/workspaces" ||
|
|
560
640
|
pathname.startsWith("/api/operator/v1/workspaces/")) {
|
|
@@ -631,7 +711,11 @@ export async function createConsoleServer(options) {
|
|
|
631
711
|
// (显式 ?workspaceId=),不属于 chat 的 pi/* 前缀面;
|
|
632
712
|
// 交给 handleOperatorDispatch。
|
|
633
713
|
pathname !== "/api/operator/v1/pi/credentials" &&
|
|
634
|
-
pathname !== "/api/operator/v1/pi/providers"
|
|
714
|
+
pathname !== "/api/operator/v1/pi/providers" &&
|
|
715
|
+
// 压缩设置是用户级全局偏好(网关上限属于部署而非工作区),
|
|
716
|
+
// 没有 workspaceId 可传;留在 chat 分发里会被
|
|
717
|
+
// WORKSPACE_REQUIRED 拒绝,永远到不了下面的 handler。
|
|
718
|
+
pathname !== "/api/operator/v1/pi/compaction-settings") {
|
|
635
719
|
await handleChatDispatch(req, res, pathname, url, method);
|
|
636
720
|
return;
|
|
637
721
|
}
|
|
@@ -944,6 +1028,59 @@ export async function createConsoleServer(options) {
|
|
|
944
1028
|
await dispatchChat(req, res, resolution.context.chatRouteDeps, pathname, resolution.context.workspaceId);
|
|
945
1029
|
}
|
|
946
1030
|
async function handleOperatorDispatch(req, res, pathname, url, method) {
|
|
1031
|
+
if (pathname === "/api/operator/v1/pi/compaction-settings") {
|
|
1032
|
+
// Gateway limit and retained tail live with the other
|
|
1033
|
+
// cross-project preferences; no-store keeps a corrected limit
|
|
1034
|
+
// from being served stale after a save.
|
|
1035
|
+
res.setHeader("Cache-Control", "no-store");
|
|
1036
|
+
try {
|
|
1037
|
+
const store = await createPiCompactionSettings(bootstrapAppData.root);
|
|
1038
|
+
if (method === "GET") {
|
|
1039
|
+
sendJson(res, 200, await store.read());
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
if (method !== "PUT") {
|
|
1043
|
+
sendJson(res, 405, {
|
|
1044
|
+
ok: false,
|
|
1045
|
+
error: { code: "METHOD_NOT_ALLOWED", message: "method not allowed" },
|
|
1046
|
+
});
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
const failure = evaluateMutationGate(req, {
|
|
1050
|
+
cookieName: bootToken.cookieName,
|
|
1051
|
+
bootToken: bootToken.value,
|
|
1052
|
+
confirmationToken: bootToken.confirmationToken,
|
|
1053
|
+
consoleOrigin: getConsoleOrigin(),
|
|
1054
|
+
allowNonLoopbackAccess: !loopbackBind,
|
|
1055
|
+
});
|
|
1056
|
+
if (failure) {
|
|
1057
|
+
sendJson(res, failure.status, { ok: false, error: failure });
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
const body = await readBodyOnce(req, 16_384);
|
|
1061
|
+
if (!body.ok) {
|
|
1062
|
+
sendJson(res, body.status, {
|
|
1063
|
+
ok: false,
|
|
1064
|
+
error: { code: body.code, message: body.message },
|
|
1065
|
+
});
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
sendJson(res, 200, await store.save(body.value));
|
|
1069
|
+
}
|
|
1070
|
+
catch (error) {
|
|
1071
|
+
const known = error instanceof PiCompactionSettingsError;
|
|
1072
|
+
sendJson(res, known ? error.status : 503, {
|
|
1073
|
+
ok: false,
|
|
1074
|
+
error: {
|
|
1075
|
+
code: known ? error.code : "COMPACTION_SETTINGS_FAILED",
|
|
1076
|
+
message: known
|
|
1077
|
+
? error.message
|
|
1078
|
+
: "压缩设置未能保存,请检查程序数据目录后重试",
|
|
1079
|
+
},
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
947
1084
|
if (pathname === "/api/operator/v1/network-proxy") {
|
|
948
1085
|
res.setHeader("Cache-Control", "no-store");
|
|
949
1086
|
try {
|
|
@@ -1033,7 +1170,8 @@ export async function createConsoleServer(options) {
|
|
|
1033
1170
|
}
|
|
1034
1171
|
const params = record.actionParams ?? {};
|
|
1035
1172
|
if (!params || typeof params !== "object" || Array.isArray(params) ||
|
|
1036
|
-
Object.keys(params).some(key => key !== "channel") ||
|
|
1173
|
+
Object.keys(params).some(key => key !== "channel" && key !== "acknowledgeInterruption") ||
|
|
1174
|
+
(params.acknowledgeInterruption !== undefined && typeof params.acknowledgeInterruption !== "boolean") ||
|
|
1037
1175
|
typeof record.clientRequestId !== "string" || !record.clientRequestId.trim()) {
|
|
1038
1176
|
sendJson(res, 400, { ok: false, error: { code: "INVALID_INPUT", message: "clientRequestId and valid update parameters are required" } });
|
|
1039
1177
|
return;
|
|
@@ -1046,7 +1184,7 @@ export async function createConsoleServer(options) {
|
|
|
1046
1184
|
const result = await acceptConsoleUpdateAndInit({
|
|
1047
1185
|
operations: programOperations, events: programEvents,
|
|
1048
1186
|
consoleUpdateExecutor: sharedConsoleUpdateExecutor,
|
|
1049
|
-
}, record.clientRequestId, channel);
|
|
1187
|
+
}, record.clientRequestId, channel, params.acknowledgeInterruption === true);
|
|
1050
1188
|
sendJson(res, result.status, result.body);
|
|
1051
1189
|
return;
|
|
1052
1190
|
}
|
|
@@ -1057,9 +1195,13 @@ export async function createConsoleServer(options) {
|
|
|
1057
1195
|
return;
|
|
1058
1196
|
}
|
|
1059
1197
|
const opMatch = pathname.match(/^\/api\/operator\/v1\/operations\/([^/]+)(?:\/(events))?$/);
|
|
1060
|
-
if (method === "GET" && opMatch
|
|
1198
|
+
if (method === "GET" && opMatch) {
|
|
1061
1199
|
const operation = await programOperations.get(decodeURIComponent(opMatch[1]));
|
|
1062
1200
|
if (operation) {
|
|
1201
|
+
if (opMatch[2]) {
|
|
1202
|
+
await handleOperationEvents(req, res, { operator: { operations: programOperations, events: programEvents } }, operation.operationId);
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1063
1205
|
sendJson(res, 200, { ok: true, operation });
|
|
1064
1206
|
return;
|
|
1065
1207
|
}
|