@tea-agent/loop-agent 0.52.0-next.1 → 0.52.0-next.3
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 +67 -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 +114 -2
- package/dist/commands/init.js +79 -12
- package/dist/shared/operator/capabilities.js +0 -122
- package/dist/shared/update/npm-client.js +14 -3
- package/dist/task/config-types.js +5 -10
- package/dist/task/read-model.js +0 -4
- package/dist/task/runtime.js +0 -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/chat-event-projection.js +2 -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/pi-runtime/custom-tools/apiworkbench-tools.js +65 -3
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +4 -0
- package/dist/worker/console/chat/pi-runtime.js +274 -94
- 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 +295 -25
- package/dist/worker/console/chat/subagents/jobs.js +115 -4
- package/dist/worker/console/chat/terminal-sessions.js +36 -2
- package/dist/worker/console/chat/tool-exposure-catalog.js +1 -1
- package/dist/worker/console/chat/tool-preview.js +22 -0
- package/dist/worker/console/chat/turn-process.js +52 -0
- package/dist/worker/console/chat/vcp-prompt.js +14 -9
- package/dist/worker/console/chat/workspace-changes.js +137 -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/routes.js +1 -1
- package/dist/worker/console/server.js +89 -5
- package/dist/worker/console/static/assets/FilePreviewDocx-ybM3ZqSl.js +9 -0
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-CM5ocMUs.js +1 -0
- package/dist/worker/console/static/assets/{arc-Bkf_oc0_.js → arc-CDapwdTN.js} +1 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-Ogy4GOqS.js +36 -0
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-D62uVvbI.js → blockDiagram-VBNYF7ZC-DsiaOIgU.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-Iq0Y8Afx.js → c4Diagram-5PPSVZJV-B84hhgSe.js} +1 -1
- package/dist/worker/console/static/assets/channel-BCVzSVXD.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D1TxRE3k.js → chunk-2GRJ4B5K-SPqOhMla.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-BE-DHkAO.js → chunk-2Q5K7J3B-BL0Q4ZV3.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-t0iYO8Cc.js → chunk-5RXB4S5H-CJpOcFAh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-Clo2nExi.js → chunk-5VM5RSS4-DQC6vqVW.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-C7bSpo-3.js → chunk-6Q2QTUOP-D4dq_L0l.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DorZaymh.js → chunk-GF5L2VYU-DVNZmiVo.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Ch_4HvyJ.js → chunk-JWPE2WC7-B1yOfAhr.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-yaSoFe-3.js → chunk-KBJHAD2P-BEPc1N6N.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-QpjaXecS.js → chunk-RYQCIY6F-Da_-gMwh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-B3t6cycg.js → chunk-XXDRQBXY-C75eW9DT.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BRlRsJR0.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BRlRsJR0.js +1 -0
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-C4Gn7eYB.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--CBwVt18.js +62 -0
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BK0ua9V8.js → dagre-VZM6K2ZE-B8dBxboB.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-t9-HP13j.js → diagram-7IWD3JNH-hKtlE0w-.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-L5Sg9jMD.js → diagram-B4RE2ZJO-BKirx0F3.js} +1 -1
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-bkx-oUrD.js +24 -0
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-D7sFtSjr.js +24 -0
- package/dist/worker/console/static/assets/diagram-UB23O5K3-BPjzGBV_.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-DODv-GbM.js +1 -0
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CNOuj3BO.js → erDiagram-JOGREHBK-DbfVp5uI.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-h_Cyayai.js → flowDiagram-UKHOOZJN-BHWWThbx.js} +1 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-SWY_8oU3.js +292 -0
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-CJdhHY-i.js +106 -0
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-CLC4mTWX.js +2 -0
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DAdf5lHp.js → ishikawaDiagram-WSZJBQD7-CiJDWOmX.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BQbGtg66.js → journeyDiagram-NVQOT4AX-eIQfMD0f.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CetLubYc.js → kanban-definition-27J2QSJJ-3d6r1cG7.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DLZOjaVz.js → linear-BjbmxxDk.js} +1 -1
- package/dist/worker/console/static/assets/main-B9ZnQejR.css +1 -0
- package/dist/worker/console/static/assets/main-D4knTr0R.js +644 -0
- package/dist/worker/console/static/assets/{mermaid.core-B_xZl_gM.js → mermaid.core-CD2GFYrr.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Dzo3dzp0.js → mindmap-definition-FAOFIHXS-D0ORXhx-.js} +1 -1
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-BqNbcp7_.js +1 -0
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Cp3YrVzQ.js → pieDiagram-7S7Q4E2Y-CGO0Y13N.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-4tI5mUgW.js → quadrantDiagram-CIZ2JOQS-vH4fdvTV.js} +1 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-B_sbmiFS.js +1 -0
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DY-0JqdT.js → requirementDiagram-LRYGKXZP-DbHtPigL.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DuJIzRKC.js → sankeyDiagram-W5VNT64P-BcqNS0Ko.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BTbVJ85l.js → sequenceDiagram-SI44F4Z6-5Zf3xJfg.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-BPPh1uLw.js → sheet-workbook-Bvq6WFll.js} +2 -2
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-BoO7GXeG.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-3suojNXT.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Bq6cg1c9.js +1 -0
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-B5CyFSLq.js +2 -0
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-VvJzDuB_.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-GR6lxokn.js → timeline-definition-Z64GVDOM-BuZ_HcXz.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DEkwyzsF.js → vennDiagram-T6HMQDX7-CJ_IDS7Q.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-W5jnvEJ3.js → wardleyDiagram-T6FBY63Y-BpKLb-Su.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-cqsloioo.js → xychartDiagram-ELKLHX3M-Mdo6gaIk.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/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/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/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/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/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 +5 -3
- package/resource-catalog.v1.json +6 -6
- 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
package/dist/commands/init.js
CHANGED
|
@@ -3,6 +3,7 @@ import { access, copyFile, lstat, mkdir, readdir, readFile, realpath, rename, rm
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { isDeepStrictEqual } from "node:util";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { normalizedAcceptedHarnessHash } from "./init-accepted-merge.js";
|
|
6
7
|
import { GITIGNORE_BLOCK_END, GITIGNORE_BLOCK_START, buildManagedGitignoreBlock, extractGitignoreManagedBlock, mergeGitignoreManagedBlock, } from "../shared/gitignore-managed-block.js";
|
|
7
8
|
import { isInitRuntimeActive, } from "../shared/runtime-activity.js";
|
|
8
9
|
import { loadHarnessManifest } from "../governance/harness.js";
|
|
@@ -1657,16 +1658,8 @@ async function buildCurrentSurfaceState(input) {
|
|
|
1657
1658
|
};
|
|
1658
1659
|
}
|
|
1659
1660
|
/** Follow only exact controller normalization edges, never infer acceptance
|
|
1660
|
-
* from shape equality. Persisted edges recover an interrupted surface refresh.
|
|
1661
|
-
|
|
1662
|
-
let current = acceptedHash;
|
|
1663
|
-
for (const action of actions) {
|
|
1664
|
-
if (action.path === "harness.json" && action.type === "reconcile-harness-structure" &&
|
|
1665
|
-
action.beforeSha256 === current && action.afterSha256)
|
|
1666
|
-
current = action.afterSha256;
|
|
1667
|
-
}
|
|
1668
|
-
return current;
|
|
1669
|
-
}
|
|
1661
|
+
* from shape equality. Persisted edges recover an interrupted surface refresh.
|
|
1662
|
+
* See `init-accepted-merge.ts` for the rewrite-action set and its history. */
|
|
1670
1663
|
async function writeInitSurfaceState(input) {
|
|
1671
1664
|
const state = await buildCurrentSurfaceState(input);
|
|
1672
1665
|
state.dispositions = [
|
|
@@ -2752,7 +2745,59 @@ function actionForMissing(pathName, state) {
|
|
|
2752
2745
|
reason: "managed block file is missing or stale",
|
|
2753
2746
|
};
|
|
2754
2747
|
}
|
|
2755
|
-
|
|
2748
|
+
/**
|
|
2749
|
+
* Fields that carry verification authority.
|
|
2750
|
+
*
|
|
2751
|
+
* The controller preserves these from the project during reconciliation
|
|
2752
|
+
* (`buildHarness` keeps `existing.verification` etc.), so a merge that
|
|
2753
|
+
* rewrites them does not just change configuration — it changes which
|
|
2754
|
+
* checks gate the project. Callers need to know this before editing.
|
|
2755
|
+
*/
|
|
2756
|
+
const HARNESS_AUTHORITY_LOCKED_FIELDS = [
|
|
2757
|
+
"verification",
|
|
2758
|
+
"workflowPolicy",
|
|
2759
|
+
"executors",
|
|
2760
|
+
];
|
|
2761
|
+
/**
|
|
2762
|
+
* Compare two JSON documents and report the differing key paths.
|
|
2763
|
+
*
|
|
2764
|
+
* Values are never emitted: the caller only needs to know *which* paths to
|
|
2765
|
+
* reconcile. Arrays compare as whole values because element-wise paths are
|
|
2766
|
+
* noisy for configuration and rarely actionable.
|
|
2767
|
+
*
|
|
2768
|
+
* Exported so the key-path diff can be tested directly; a wrong diff misleads
|
|
2769
|
+
* the merge more than no diff at all.
|
|
2770
|
+
*/
|
|
2771
|
+
export function diffJsonKeyPaths(current, desired) {
|
|
2772
|
+
const added = [];
|
|
2773
|
+
const removed = [];
|
|
2774
|
+
const changed = [];
|
|
2775
|
+
const walk = (left, right, prefix) => {
|
|
2776
|
+
const leftIsRecord = isRecord(left);
|
|
2777
|
+
const rightIsRecord = isRecord(right);
|
|
2778
|
+
if (leftIsRecord && rightIsRecord) {
|
|
2779
|
+
for (const key of new Set([...Object.keys(left), ...Object.keys(right)])) {
|
|
2780
|
+
const nextPrefix = prefix ? `${prefix}.${key}` : key;
|
|
2781
|
+
const inLeft = Object.hasOwn(left, key);
|
|
2782
|
+
const inRight = Object.hasOwn(right, key);
|
|
2783
|
+
if (!inLeft && inRight)
|
|
2784
|
+
added.push(nextPrefix);
|
|
2785
|
+
else if (inLeft && !inRight)
|
|
2786
|
+
removed.push(nextPrefix);
|
|
2787
|
+
else
|
|
2788
|
+
walk(left[key], right[key], nextPrefix);
|
|
2789
|
+
}
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
if (leftIsRecord !== rightIsRecord || !isDeepStrictEqual(left, right)) {
|
|
2793
|
+
if (prefix)
|
|
2794
|
+
changed.push(prefix);
|
|
2795
|
+
}
|
|
2796
|
+
};
|
|
2797
|
+
walk(current, desired, "");
|
|
2798
|
+
return { added: added.sort(), removed: removed.sort(), changed: changed.sort() };
|
|
2799
|
+
}
|
|
2800
|
+
function modelMergeTaskFor(pathName, state, allPaths, recordedState, desiredPatch) {
|
|
2756
2801
|
return {
|
|
2757
2802
|
taskId: `init-merge-${sha256Text(pathName).slice(0, 12)}`,
|
|
2758
2803
|
path: pathName,
|
|
@@ -2774,12 +2819,25 @@ function modelMergeTaskFor(pathName, state, allPaths, recordedState) {
|
|
|
2774
2819
|
verification: [
|
|
2775
2820
|
`git diff --check -- ${pathName}`,
|
|
2776
2821
|
],
|
|
2822
|
+
// A merge task that only says "complete this task" leaves the caller to
|
|
2823
|
+
// rediscover the authority rules. That is a fact the controller already
|
|
2824
|
+
// holds, so state it in a slot call sites do not overwrite.
|
|
2825
|
+
...(pathName === "harness.json"
|
|
2826
|
+
? {
|
|
2827
|
+
authorityLockedFields: [...HARNESS_AUTHORITY_LOCKED_FIELDS],
|
|
2828
|
+
mergeGuidance: [
|
|
2829
|
+
`Keep the project values of these authority fields: ${HARNESS_AUTHORITY_LOCKED_FIELDS.join(", ")}.`,
|
|
2830
|
+
"`.harness/init-surface.json` is rewritten by the controller after a successful merge; do not edit it by hand.",
|
|
2831
|
+
],
|
|
2832
|
+
}
|
|
2833
|
+
: {}),
|
|
2777
2834
|
evidence: {
|
|
2778
2835
|
baseSha256: recordedState?.files[pathName]?.currentSha256,
|
|
2779
2836
|
currentSha256: state?.currentSha256,
|
|
2780
2837
|
desiredSha256: state?.sourceSha256,
|
|
2781
2838
|
sourceAnchorSha256: state?.sourceAnchorSha256,
|
|
2782
2839
|
},
|
|
2840
|
+
...(desiredPatch ? { desiredPatch } : {}),
|
|
2783
2841
|
};
|
|
2784
2842
|
}
|
|
2785
2843
|
function recommendedNextFor(report) {
|
|
@@ -3056,7 +3114,16 @@ export async function checkInitUpdate(input) {
|
|
|
3056
3114
|
}
|
|
3057
3115
|
else if (modelMigration.kind === "ambiguous") {
|
|
3058
3116
|
const state = currentState.files["harness.json"];
|
|
3059
|
-
|
|
3117
|
+
// The desired structure is computable here, so the caller does
|
|
3118
|
+
// not have to infer which key paths differ.
|
|
3119
|
+
const template = await readJsonIfExists(path.join(assetRoot, "harness.json"));
|
|
3120
|
+
const desiredStructure = buildHarness({
|
|
3121
|
+
existing: harness,
|
|
3122
|
+
template,
|
|
3123
|
+
projectName,
|
|
3124
|
+
governanceRoot,
|
|
3125
|
+
});
|
|
3126
|
+
const mergeTask = modelMergeTaskFor("harness.json", state, allPaths, recordedState, diffJsonKeyPaths(harness, desiredStructure));
|
|
3060
3127
|
mergeTask.reason = `legacy model configuration requires a human/model merge: ${modelMigration.reason}`;
|
|
3061
3128
|
mergeTask.mergeRules = [
|
|
3062
3129
|
"Preserve every existing harness.json field unless the user explicitly approves its migration.",
|
|
@@ -149,19 +149,6 @@ const OFFICIAL_ACTIONS = [
|
|
|
149
149
|
"human-gated-required",
|
|
150
150
|
],
|
|
151
151
|
["dagInitHybrid", "loop-agent dag init-hybrid", "mutation", "advanced"],
|
|
152
|
-
["dagWorkflowPlan", "loop-agent dag workflow-plan", "read", "advanced"],
|
|
153
|
-
[
|
|
154
|
-
"dagWorkflowValidate",
|
|
155
|
-
"loop-agent dag workflow-validate",
|
|
156
|
-
"read",
|
|
157
|
-
"advanced",
|
|
158
|
-
],
|
|
159
|
-
[
|
|
160
|
-
"dagWorkflowCompile",
|
|
161
|
-
"loop-agent dag workflow-compile",
|
|
162
|
-
"mutation",
|
|
163
|
-
"advanced",
|
|
164
|
-
],
|
|
165
152
|
["planList", "loop-agent plan list", "read", "model-callable"],
|
|
166
153
|
["planCreate", "loop-agent plan create", "mutation", "model-callable"],
|
|
167
154
|
["planComplete", "loop-agent plan complete", "mutation", "model-callable"],
|
|
@@ -190,7 +177,6 @@ const OFFICIAL_ACTIONS = [
|
|
|
190
177
|
"model-callable",
|
|
191
178
|
],
|
|
192
179
|
["piReuseBenchmark", "loop-agent pi-reuse-benchmark", "read", "advanced"],
|
|
193
|
-
["loopBenchmark", "loop-agent loop-benchmark", "read", "advanced"],
|
|
194
180
|
[
|
|
195
181
|
"knowledgeCurate",
|
|
196
182
|
"loop-agent knowledge curate",
|
|
@@ -222,18 +208,6 @@ const OFFICIAL_ACTIONS = [
|
|
|
222
208
|
"mutation",
|
|
223
209
|
"advanced",
|
|
224
210
|
],
|
|
225
|
-
...["init", "status", "run", "record-round", "add-signal", "closeout"].map((leaf) => [
|
|
226
|
-
`loop${leaf.replace(/(^|-)(.)/g, (_m, _d, c) => c.toUpperCase())}`,
|
|
227
|
-
`loop-agent loop ${leaf}`,
|
|
228
|
-
leaf === "status" ? "read" : "mutation",
|
|
229
|
-
"advanced",
|
|
230
|
-
]),
|
|
231
|
-
...["list", "inspect", "save", "run", "diff", "replay"].map((leaf) => [
|
|
232
|
-
`workflow${leaf[0].toUpperCase()}${leaf.slice(1)}`,
|
|
233
|
-
`loop-agent workflow ${leaf}`,
|
|
234
|
-
["list", "inspect", "diff"].includes(leaf) ? "read" : "mutation",
|
|
235
|
-
"advanced",
|
|
236
|
-
]),
|
|
237
211
|
[
|
|
238
212
|
"workerFeatureReview",
|
|
239
213
|
"agent-worker feature review",
|
|
@@ -2000,12 +1974,6 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
|
|
|
2000
1974
|
action: "piReuseBenchmark",
|
|
2001
1975
|
source: "loop-agent",
|
|
2002
1976
|
},
|
|
2003
|
-
{
|
|
2004
|
-
command: "loop-agent loop-benchmark",
|
|
2005
|
-
coverage: "advanced",
|
|
2006
|
-
action: "loopBenchmark",
|
|
2007
|
-
source: "loop-agent",
|
|
2008
|
-
},
|
|
2009
1977
|
{
|
|
2010
1978
|
command: "loop-agent dag execute",
|
|
2011
1979
|
coverage: "model-callable",
|
|
@@ -2373,24 +2341,6 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
|
|
|
2373
2341
|
action: "dagValidate",
|
|
2374
2342
|
source: "loop-agent",
|
|
2375
2343
|
},
|
|
2376
|
-
{
|
|
2377
|
-
command: "loop-agent dag workflow-plan",
|
|
2378
|
-
coverage: "advanced",
|
|
2379
|
-
action: "dagWorkflowPlan",
|
|
2380
|
-
source: "loop-agent",
|
|
2381
|
-
},
|
|
2382
|
-
{
|
|
2383
|
-
command: "loop-agent dag workflow-validate",
|
|
2384
|
-
coverage: "advanced",
|
|
2385
|
-
action: "dagWorkflowValidate",
|
|
2386
|
-
source: "loop-agent",
|
|
2387
|
-
},
|
|
2388
|
-
{
|
|
2389
|
-
command: "loop-agent dag workflow-compile",
|
|
2390
|
-
coverage: "advanced",
|
|
2391
|
-
action: "dagWorkflowCompile",
|
|
2392
|
-
source: "loop-agent",
|
|
2393
|
-
},
|
|
2394
2344
|
{
|
|
2395
2345
|
command: "loop-agent dag approve",
|
|
2396
2346
|
coverage: "human-gated-required",
|
|
@@ -2492,78 +2442,6 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
|
|
|
2492
2442
|
source: "loop-agent",
|
|
2493
2443
|
exclusionReason: "Artifact revision staging consumes a human-selected local file and remains on dedicated Console/CLI mutation gates.",
|
|
2494
2444
|
},
|
|
2495
|
-
{
|
|
2496
|
-
command: "loop-agent workflow list",
|
|
2497
|
-
coverage: "advanced",
|
|
2498
|
-
action: "workflowList",
|
|
2499
|
-
source: "loop-agent",
|
|
2500
|
-
},
|
|
2501
|
-
{
|
|
2502
|
-
command: "loop-agent workflow inspect",
|
|
2503
|
-
coverage: "advanced",
|
|
2504
|
-
action: "workflowInspect",
|
|
2505
|
-
source: "loop-agent",
|
|
2506
|
-
},
|
|
2507
|
-
{
|
|
2508
|
-
command: "loop-agent workflow save",
|
|
2509
|
-
coverage: "advanced",
|
|
2510
|
-
action: "workflowSave",
|
|
2511
|
-
source: "loop-agent",
|
|
2512
|
-
},
|
|
2513
|
-
{
|
|
2514
|
-
command: "loop-agent workflow run",
|
|
2515
|
-
coverage: "advanced",
|
|
2516
|
-
action: "workflowRun",
|
|
2517
|
-
source: "loop-agent",
|
|
2518
|
-
},
|
|
2519
|
-
{
|
|
2520
|
-
command: "loop-agent workflow diff",
|
|
2521
|
-
coverage: "advanced",
|
|
2522
|
-
action: "workflowDiff",
|
|
2523
|
-
source: "loop-agent",
|
|
2524
|
-
},
|
|
2525
|
-
{
|
|
2526
|
-
command: "loop-agent workflow replay",
|
|
2527
|
-
coverage: "advanced",
|
|
2528
|
-
action: "workflowReplay",
|
|
2529
|
-
source: "loop-agent",
|
|
2530
|
-
},
|
|
2531
|
-
{
|
|
2532
|
-
command: "loop-agent loop init",
|
|
2533
|
-
coverage: "advanced",
|
|
2534
|
-
action: "loopInit",
|
|
2535
|
-
source: "loop-agent",
|
|
2536
|
-
},
|
|
2537
|
-
{
|
|
2538
|
-
command: "loop-agent loop status",
|
|
2539
|
-
coverage: "advanced",
|
|
2540
|
-
action: "loopStatus",
|
|
2541
|
-
source: "loop-agent",
|
|
2542
|
-
},
|
|
2543
|
-
{
|
|
2544
|
-
command: "loop-agent loop run",
|
|
2545
|
-
coverage: "advanced",
|
|
2546
|
-
action: "loopRun",
|
|
2547
|
-
source: "loop-agent",
|
|
2548
|
-
},
|
|
2549
|
-
{
|
|
2550
|
-
command: "loop-agent loop record-round",
|
|
2551
|
-
coverage: "advanced",
|
|
2552
|
-
action: "loopRecordRound",
|
|
2553
|
-
source: "loop-agent",
|
|
2554
|
-
},
|
|
2555
|
-
{
|
|
2556
|
-
command: "loop-agent loop add-signal",
|
|
2557
|
-
coverage: "advanced",
|
|
2558
|
-
action: "loopAddSignal",
|
|
2559
|
-
source: "loop-agent",
|
|
2560
|
-
},
|
|
2561
|
-
{
|
|
2562
|
-
command: "loop-agent loop closeout",
|
|
2563
|
-
coverage: "advanced",
|
|
2564
|
-
action: "loopCloseout",
|
|
2565
|
-
source: "loop-agent",
|
|
2566
|
-
},
|
|
2567
2445
|
{
|
|
2568
2446
|
command: "loop-agent dag decision inspect",
|
|
2569
2447
|
coverage: "model-callable",
|
|
@@ -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/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
|
@@ -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);
|
|
@@ -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",
|
|
@@ -856,6 +856,8 @@ export function createChatEventStore(options) {
|
|
|
856
856
|
/** B5-1: sessions whose latest `message_update` appends are still waiting
|
|
857
857
|
* for the next persist (debounced; structural events / turn changes flush). */
|
|
858
858
|
const pendingPersists = new Map();
|
|
859
|
+
/** P2-A: lightweight in-memory projection checkpoints. */
|
|
860
|
+
const checkpoints = new Map();
|
|
859
861
|
function persistedPath(sessionId) {
|
|
860
862
|
return persistenceDir
|
|
861
863
|
? path.join(persistenceDir, `${safeSessionId(sessionId)}.json`)
|
|
@@ -1390,14 +1392,41 @@ export function createChatEventStore(options) {
|
|
|
1390
1392
|
epoch(sessionId) {
|
|
1391
1393
|
return ringFor(sessionId).epoch;
|
|
1392
1394
|
},
|
|
1395
|
+
minSeq(sessionId) {
|
|
1396
|
+
return ringFor(sessionId).minSeq;
|
|
1397
|
+
},
|
|
1393
1398
|
latestSeq(sessionId) {
|
|
1394
1399
|
return ringFor(sessionId).nextSeq - 1;
|
|
1395
1400
|
},
|
|
1396
|
-
snapshot(sessionId) {
|
|
1401
|
+
snapshot(sessionId, options) {
|
|
1397
1402
|
const ring = rings.get(sessionId) ?? loadRing(sessionId);
|
|
1398
1403
|
if (ring)
|
|
1399
1404
|
rings.set(sessionId, ring);
|
|
1400
|
-
|
|
1405
|
+
if (!ring)
|
|
1406
|
+
return [];
|
|
1407
|
+
if (options?.afterSeq !== undefined) {
|
|
1408
|
+
return ring.events.filter((event) => event.seq > options.afterSeq);
|
|
1409
|
+
}
|
|
1410
|
+
return ring.events.slice();
|
|
1411
|
+
},
|
|
1412
|
+
getCheckpoint(sessionId) {
|
|
1413
|
+
const cp = checkpoints.get(sessionId);
|
|
1414
|
+
if (!cp)
|
|
1415
|
+
return undefined;
|
|
1416
|
+
const ring = rings.get(sessionId) ?? loadRing(sessionId);
|
|
1417
|
+
if (!ring)
|
|
1418
|
+
return undefined;
|
|
1419
|
+
if (cp.eventEpoch !== ring.epoch || (ring.events.length > 0 && cp.asOfSeq < ring.minSeq)) {
|
|
1420
|
+
checkpoints.delete(sessionId);
|
|
1421
|
+
return undefined;
|
|
1422
|
+
}
|
|
1423
|
+
return cp;
|
|
1424
|
+
},
|
|
1425
|
+
setCheckpoint(sessionId, checkpoint) {
|
|
1426
|
+
checkpoints.set(sessionId, checkpoint);
|
|
1427
|
+
},
|
|
1428
|
+
invalidateCheckpoint(sessionId) {
|
|
1429
|
+
checkpoints.delete(sessionId);
|
|
1401
1430
|
},
|
|
1402
1431
|
goalHistory(sessionId) {
|
|
1403
1432
|
const ring = ringFor(sessionId);
|
|
@@ -1436,6 +1465,7 @@ export function createChatEventStore(options) {
|
|
|
1436
1465
|
rings.delete(sessionId);
|
|
1437
1466
|
turnCounts.delete(sessionId);
|
|
1438
1467
|
subscribers.delete(sessionId);
|
|
1468
|
+
checkpoints.delete(sessionId);
|
|
1439
1469
|
// B5-1: drop any debounced (not yet written) updates with the ring itself —
|
|
1440
1470
|
// the file is being deleted, so flushing first would only resurrect it.
|
|
1441
1471
|
pendingPersists.delete(sessionId);
|
|
@@ -23,6 +23,7 @@ function validSource(value) {
|
|
|
23
23
|
file: ["kind", "workspaceId", "path", "version", "versionScope", "view", "anchor", "startLine", "endLine", "sheet", "cellRange"],
|
|
24
24
|
diff: ["kind", "workspaceId", "path", "side", "comparison", "version", "startLine", "endLine"],
|
|
25
25
|
terminal: ["kind", "workspaceId", "terminalSessionId", "ownerSessionId", "shell", "anchor"],
|
|
26
|
+
api: ["kind", "workspaceId", "method", "url", "status", "elapsedMs", "anchor"],
|
|
26
27
|
};
|
|
27
28
|
const allowed = typeof s.kind === "string" ? keys[s.kind] : undefined;
|
|
28
29
|
if (!allowed || Object.keys(s).some((key) => !allowed.includes(key)))
|
|
@@ -53,6 +54,9 @@ function validSource(value) {
|
|
|
53
54
|
&& validLine(s.startLine) && validLine(s.endLine) && s.endLine >= s.startLine;
|
|
54
55
|
case "terminal":
|
|
55
56
|
return boundedString(s.terminalSessionId) && boundedString(s.ownerSessionId) && boundedString(s.shell) && boundedString(s.anchor);
|
|
57
|
+
case "api":
|
|
58
|
+
return typeof s.method === "string" && /^[A-Za-z]{1,16}$/.test(s.method) && boundedString(s.url, 2_048) && typeof s.status === "number" && Number.isFinite(s.status)
|
|
59
|
+
&& typeof s.elapsedMs === "number" && Number.isFinite(s.elapsedMs) && s.elapsedMs >= 0 && boundedString(s.anchor);
|
|
56
60
|
default: return false;
|
|
57
61
|
}
|
|
58
62
|
}
|
|
@@ -7,6 +7,7 @@ import { parseAssertions } from "../../api-workbench-assertions.js";
|
|
|
7
7
|
* api_send send one sandboxed HTTP request (env {{key}} substitution)
|
|
8
8
|
* api_environments list environments; upsert baseUrl + key=value variables
|
|
9
9
|
* api_history list / clear recent send history
|
|
10
|
+
* api_debug one-shot debugging brief (endpoints + env + history)
|
|
10
11
|
*
|
|
11
12
|
* Envelope: success { ok: true, ... } / failure { ok: false, error: { code, message } }
|
|
12
13
|
* with stable APIWB_* error codes. Sends use the same validation,
|
|
@@ -15,8 +16,9 @@ import { parseAssertions } from "../../api-workbench-assertions.js";
|
|
|
15
16
|
import { scanSpecsSnapshot, parseQueryParams, ApiWorkbenchCoreError, } from "../../api-workbench-core.js";
|
|
16
17
|
const APIWB_TOOLS_DESCRIPTION = "API workbench: scan repo OpenAPI/Swagger specs and static code routes (api_scan), " +
|
|
17
18
|
"send one sandboxed HTTP request with environment {{key}} substitution (api_send), " +
|
|
18
|
-
"list/upsert environment prefixes + variables (api_environments),
|
|
19
|
-
"
|
|
19
|
+
"list/upsert environment prefixes + variables (api_environments), review send history (api_history), " +
|
|
20
|
+
"and pull a one-shot debugging brief (api_debug). " +
|
|
21
|
+
"Use api_scan or api_debug before guessing endpoints; environments carry non-secret key=value variables. Never submit credential values through tool arguments.";
|
|
20
22
|
export async function buildApiWorkbenchTools(options) {
|
|
21
23
|
const [{ Type }, { defineTool }] = await Promise.all([
|
|
22
24
|
import("typebox"),
|
|
@@ -130,6 +132,66 @@ export async function buildApiWorkbenchTools(options) {
|
|
|
130
132
|
}, { signal }));
|
|
131
133
|
},
|
|
132
134
|
}),
|
|
135
|
+
defineTool({
|
|
136
|
+
name: "api_debug",
|
|
137
|
+
label: "API debug brief",
|
|
138
|
+
description: "One-shot debugging brief: compact endpoint inventory, environments, credentials (metadata only), recent send history, and a debugging playbook. Read this BEFORE sending requests when unsure which endpoint/parameter to use; then use api_send to replay and iterate.",
|
|
139
|
+
parameters: Type.Object({
|
|
140
|
+
query: Type.Optional(Type.String({ maxLength: 120, description: "Case-insensitive substring filter for endpoint paths" })),
|
|
141
|
+
}, { additionalProperties: false }),
|
|
142
|
+
async execute(_id, params) {
|
|
143
|
+
return run("APIWB_DEBUG_FAILED", async () => {
|
|
144
|
+
const snapshot = await scanSpecsSnapshot(opts.repoRoot);
|
|
145
|
+
const needle = params.query?.trim().toLowerCase();
|
|
146
|
+
const endpoints = [];
|
|
147
|
+
for (const spec of snapshot.specs) {
|
|
148
|
+
for (const endpoint of spec.endpoints ?? []) {
|
|
149
|
+
const path = endpoint.path ?? "";
|
|
150
|
+
if (needle && !path.toLowerCase().includes(needle))
|
|
151
|
+
continue;
|
|
152
|
+
endpoints.push({
|
|
153
|
+
method: endpoint.method ?? "",
|
|
154
|
+
path,
|
|
155
|
+
...(endpoint.summary ? { summary: endpoint.summary } : {}),
|
|
156
|
+
required: (endpoint.parameters ?? [])
|
|
157
|
+
.filter((p) => p && typeof p === "object" && p.required === true && p.in !== "body")
|
|
158
|
+
.map((p) => String(p.name ?? ""))
|
|
159
|
+
.filter(Boolean),
|
|
160
|
+
});
|
|
161
|
+
if (endpoints.length >= 80)
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (endpoints.length >= 80)
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
const env = await opts.apiWorkbench.readEnvironmentState();
|
|
168
|
+
const credentials = (await opts.apiWorkbench.auth.list()).credentials.map((c) => ({
|
|
169
|
+
id: c.id,
|
|
170
|
+
name: c.name,
|
|
171
|
+
origin: c.origin,
|
|
172
|
+
configured: c.configured,
|
|
173
|
+
}));
|
|
174
|
+
const history = opts.apiWorkbench.listWorkbenchHistory().slice(0, 10).map((h) => ({
|
|
175
|
+
method: h.method,
|
|
176
|
+
url: h.url,
|
|
177
|
+
status: h.status,
|
|
178
|
+
elapsedMs: h.elapsedMs,
|
|
179
|
+
at: h.at,
|
|
180
|
+
}));
|
|
181
|
+
return {
|
|
182
|
+
ok: true,
|
|
183
|
+
stats: snapshot.stats,
|
|
184
|
+
endpoints,
|
|
185
|
+
environments: env,
|
|
186
|
+
credentials,
|
|
187
|
+
history,
|
|
188
|
+
playbook: "1) api_scan/api_debug to inventory endpoints; 2) pick endpoint + environment ({{key}} substitution); " +
|
|
189
|
+
"3) api_send with responseFields to extract only needed fields; 4) on failure read authDiagnosis/error code, " +
|
|
190
|
+
"fix one variable at a time and resend; 5) confirm with assertions; 6) save recurring flows with api_collections.",
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
}),
|
|
133
195
|
defineTool({
|
|
134
196
|
name: "api_environments",
|
|
135
197
|
label: "API environments",
|
|
@@ -183,7 +245,7 @@ export async function buildApiWorkbenchTools(options) {
|
|
|
183
245
|
const capability = defineTool({
|
|
184
246
|
name: "apiCapabilities",
|
|
185
247
|
label: "API capabilities",
|
|
186
|
-
description: "Directory for the API workbench. Does not send a request, change an environment, or run a collection. Returns the family, a summary, how to discover tools, the
|
|
248
|
+
description: "Directory for the API workbench. Does not send a request, change an environment, or run a collection. Returns the family, a summary, how to discover tools, the six tool names, and whether they have side effects.",
|
|
187
249
|
parameters: Type.Object({ target: Type.Optional(Type.String({ maxLength: 80 })) }, { additionalProperties: false }),
|
|
188
250
|
async execute(_id, params) {
|
|
189
251
|
const result = discover(params.target);
|
|
@@ -127,6 +127,10 @@ function guardModelRuntimeCosts(value) {
|
|
|
127
127
|
* absent at module load (discovered lazily by pi-readiness instead).
|
|
128
128
|
*/
|
|
129
129
|
export function createDefaultPiSdkBindings() {
|
|
130
|
+
// Warm the ESM module graph while the user is still on the empty UI. The
|
|
131
|
+
// first create otherwise pays the cold SDK import before it can answer 201.
|
|
132
|
+
// A missing SDK still fails lazily on first use, not at bindings creation.
|
|
133
|
+
void loadSdk().catch(() => undefined);
|
|
130
134
|
const consoleServices = new WeakSet();
|
|
131
135
|
return {
|
|
132
136
|
getAgentDir: async () => {
|