@stigmer/runner 3.0.9-dev.20260615153829 → 3.1.0
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/dist/.build-fingerprint +1 -1
- package/dist/__test-utils__/approval-contract/types.d.ts +174 -0
- package/dist/__test-utils__/approval-contract/types.js +24 -0
- package/dist/__test-utils__/approval-contract/types.js.map +1 -0
- package/dist/activities/call-agent-status.d.ts +19 -1
- package/dist/activities/call-agent-status.js +64 -5
- package/dist/activities/call-agent-status.js.map +1 -1
- package/dist/activities/call-llm.js +19 -53
- package/dist/activities/call-llm.js.map +1 -1
- package/dist/activities/classify-tool-approvals.d.ts +24 -0
- package/dist/activities/classify-tool-approvals.js +69 -17
- package/dist/activities/classify-tool-approvals.js.map +1 -1
- package/dist/activities/discover-mcp-server.d.ts +7 -0
- package/dist/activities/discover-mcp-server.js +11 -1
- package/dist/activities/discover-mcp-server.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +140 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +130 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.d.ts +18 -0
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +123 -0
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -0
- package/dist/activities/execute-cursor/approval-policy.d.ts +17 -61
- package/dist/activities/execute-cursor/approval-policy.js +8 -120
- package/dist/activities/execute-cursor/approval-policy.js.map +1 -1
- package/dist/activities/execute-cursor/approval-state.d.ts +219 -9
- package/dist/activities/execute-cursor/approval-state.js +233 -17
- package/dist/activities/execute-cursor/approval-state.js.map +1 -1
- package/dist/activities/execute-cursor/capture-flow.d.ts +127 -0
- package/dist/activities/execute-cursor/capture-flow.js +234 -0
- package/dist/activities/execute-cursor/capture-flow.js.map +1 -0
- package/dist/activities/execute-cursor/cas-observations.d.ts +96 -0
- package/dist/activities/execute-cursor/cas-observations.js +184 -0
- package/dist/activities/execute-cursor/cas-observations.js.map +1 -0
- package/dist/activities/execute-cursor/command-provenance.d.ts +62 -0
- package/dist/activities/execute-cursor/command-provenance.js +128 -0
- package/dist/activities/execute-cursor/command-provenance.js.map +1 -0
- package/dist/activities/execute-cursor/exact-apply.d.ts +110 -0
- package/dist/activities/execute-cursor/exact-apply.js +204 -0
- package/dist/activities/execute-cursor/exact-apply.js.map +1 -0
- package/dist/activities/execute-cursor/hook-script.d.ts +53 -24
- package/dist/activities/execute-cursor/hook-script.js +310 -47
- package/dist/activities/execute-cursor/hook-script.js.map +1 -1
- package/dist/activities/execute-cursor/index.d.ts +8 -1
- package/dist/activities/execute-cursor/index.js +500 -64
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-cursor/message-translator.d.ts +258 -11
- package/dist/activities/execute-cursor/message-translator.js +836 -90
- package/dist/activities/execute-cursor/message-translator.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +20 -23
- package/dist/activities/execute-cursor/prompt-builder.js +74 -15
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-cursor/workspace-setup.d.ts +17 -0
- package/dist/activities/execute-cursor/workspace-setup.js +212 -33
- package/dist/activities/execute-cursor/workspace-setup.js.map +1 -1
- package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.d.ts +19 -0
- package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.js +143 -0
- package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.d.ts +88 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js +81 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js.map +1 -0
- package/dist/activities/execute-deep-agent/approval-file-change.d.ts +47 -0
- package/dist/activities/execute-deep-agent/approval-file-change.js +68 -0
- package/dist/activities/execute-deep-agent/approval-file-change.js.map +1 -0
- package/dist/activities/execute-deep-agent/attachment-injector.d.ts +8 -1
- package/dist/activities/execute-deep-agent/attachment-injector.js +7 -7
- package/dist/activities/execute-deep-agent/attachment-injector.js.map +1 -1
- package/dist/activities/execute-deep-agent/cas-capture-backend.d.ts +42 -0
- package/dist/activities/execute-deep-agent/cas-capture-backend.js +47 -0
- package/dist/activities/execute-deep-agent/cas-capture-backend.js.map +1 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.d.ts +79 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.js +112 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.js.map +1 -0
- package/dist/activities/execute-deep-agent/hitl.d.ts +16 -3
- package/dist/activities/execute-deep-agent/hitl.js +11 -3
- package/dist/activities/execute-deep-agent/hitl.js.map +1 -1
- package/dist/activities/execute-deep-agent/index.d.ts +2 -1
- package/dist/activities/execute-deep-agent/index.js +393 -33
- package/dist/activities/execute-deep-agent/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/inline-publisher.d.ts +7 -1
- package/dist/activities/execute-deep-agent/inline-publisher.js +23 -2
- package/dist/activities/execute-deep-agent/inline-publisher.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.d.ts +53 -2
- package/dist/activities/execute-deep-agent/setup.js +149 -92
- package/dist/activities/execute-deep-agent/setup.js.map +1 -1
- package/dist/activities/execute-deep-agent/stamp-flowed-rows.d.ts +36 -0
- package/dist/activities/execute-deep-agent/stamp-flowed-rows.js +56 -0
- package/dist/activities/execute-deep-agent/stamp-flowed-rows.js.map +1 -0
- package/dist/activities/execute-deep-agent/status-builder-shared.d.ts +34 -1
- package/dist/activities/execute-deep-agent/status-builder-shared.js +26 -25
- package/dist/activities/execute-deep-agent/status-builder-shared.js.map +1 -1
- package/dist/activities/execute-deep-agent/status-builder.d.ts +17 -5
- package/dist/activities/execute-deep-agent/status-builder.js +44 -3
- package/dist/activities/execute-deep-agent/status-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/streaming-side-effects.js +2 -19
- package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -1
- package/dist/activities/execute-deep-agent/streaming.js +3 -15
- package/dist/activities/execute-deep-agent/streaming.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +25 -7
- package/dist/activities/execute-deep-agent/subagent-transformer.js +23 -7
- package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +30 -3
- package/dist/activities/execute-deep-agent/subagent-wiring.js +29 -3
- package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -1
- package/dist/activities/execute-deep-agent/v3-status-builder.js +32 -2
- package/dist/activities/execute-deep-agent/v3-status-builder.js.map +1 -1
- package/dist/claimcheck/payload-codec.js +9 -5
- package/dist/claimcheck/payload-codec.js.map +1 -1
- package/dist/client/stigmer-client.d.ts +2 -0
- package/dist/client/stigmer-client.js +2 -0
- package/dist/client/stigmer-client.js.map +1 -1
- package/dist/middleware/approval-gate.d.ts +85 -4
- package/dist/middleware/approval-gate.js +165 -38
- package/dist/middleware/approval-gate.js.map +1 -1
- package/dist/middleware/types.d.ts +2 -5
- package/dist/shared/activity-input.d.ts +43 -0
- package/dist/shared/activity-input.js +17 -0
- package/dist/shared/activity-input.js.map +1 -0
- package/dist/shared/approval-canonicalize.d.ts +19 -0
- package/dist/shared/approval-canonicalize.js +119 -0
- package/dist/shared/approval-canonicalize.js.map +1 -0
- package/dist/shared/approval-fingerprint.d.ts +106 -0
- package/dist/shared/approval-fingerprint.js +113 -0
- package/dist/shared/approval-fingerprint.js.map +1 -0
- package/dist/shared/approval-policy.d.ts +182 -12
- package/dist/shared/approval-policy.js +213 -27
- package/dist/shared/approval-policy.js.map +1 -1
- package/dist/shared/args-preview.d.ts +52 -0
- package/dist/shared/args-preview.js +93 -0
- package/dist/shared/args-preview.js.map +1 -0
- package/dist/shared/artifact-storage.d.ts +19 -1
- package/dist/shared/artifact-storage.js +48 -11
- package/dist/shared/artifact-storage.js.map +1 -1
- package/dist/shared/file-change.d.ts +44 -0
- package/dist/shared/file-change.js +57 -0
- package/dist/shared/file-change.js.map +1 -0
- package/dist/shared/file-tools.d.ts +107 -0
- package/dist/shared/file-tools.js +168 -0
- package/dist/shared/file-tools.js.map +1 -0
- package/dist/shared/filereview/capture.d.ts +202 -0
- package/dist/shared/filereview/capture.js +498 -0
- package/dist/shared/filereview/capture.js.map +1 -0
- package/dist/shared/filereview/cas-substrate.d.ts +190 -0
- package/dist/shared/filereview/cas-substrate.js +284 -0
- package/dist/shared/filereview/cas-substrate.js.map +1 -0
- package/dist/shared/filereview/digest.d.ts +40 -0
- package/dist/shared/filereview/digest.js +66 -0
- package/dist/shared/filereview/digest.js.map +1 -0
- package/dist/shared/filereview/events.d.ts +170 -0
- package/dist/shared/filereview/events.js +298 -0
- package/dist/shared/filereview/events.js.map +1 -0
- package/dist/shared/filereview/git-substrate.d.ts +175 -0
- package/dist/shared/filereview/git-substrate.js +439 -0
- package/dist/shared/filereview/git-substrate.js.map +1 -0
- package/dist/shared/filereview/index.d.ts +11 -0
- package/dist/shared/filereview/index.js +12 -0
- package/dist/shared/filereview/index.js.map +1 -0
- package/dist/shared/filereview/secret-paths.d.ts +63 -0
- package/dist/shared/filereview/secret-paths.js +105 -0
- package/dist/shared/filereview/secret-paths.js.map +1 -0
- package/dist/shared/fingerprint-secret.d.ts +26 -0
- package/dist/shared/fingerprint-secret.js +47 -0
- package/dist/shared/fingerprint-secret.js.map +1 -0
- package/dist/shared/model-client.d.ts +51 -0
- package/dist/shared/model-client.js +77 -0
- package/dist/shared/model-client.js.map +1 -0
- package/dist/shared/plan-artifact.js +0 -2
- package/dist/shared/plan-artifact.js.map +1 -1
- package/dist/shared/status-offload.d.ts +83 -9
- package/dist/shared/status-offload.js +399 -79
- package/dist/shared/status-offload.js.map +1 -1
- package/dist/shared/status.js +14 -1
- package/dist/shared/status.js.map +1 -1
- package/dist/shared/tool-kind.d.ts +19 -0
- package/dist/shared/tool-kind.js +13 -0
- package/dist/shared/tool-kind.js.map +1 -1
- package/dist/shared/tool-row.d.ts +88 -0
- package/dist/shared/tool-row.js +127 -0
- package/dist/shared/tool-row.js.map +1 -0
- package/dist/shared/workspace/platform-dir.d.ts +25 -0
- package/dist/shared/workspace/platform-dir.js +38 -2
- package/dist/shared/workspace/platform-dir.js.map +1 -1
- package/dist/workflows/call-agent-orchestrator.js +56 -7
- package/dist/workflows/call-agent-orchestrator.js.map +1 -1
- package/dist/workflows/connect-mcp-server.d.ts +50 -0
- package/dist/workflows/connect-mcp-server.js +136 -15
- package/dist/workflows/connect-mcp-server.js.map +1 -1
- package/dist/workflows/types.d.ts +8 -0
- package/package.json +2 -2
- package/src/__test-utils__/approval-contract/contract.ts +224 -0
- package/src/__test-utils__/approval-contract/types.ts +179 -0
- package/src/__test-utils__/fake-artifact-storage.ts +72 -0
- package/src/__tests__/approval-gateway-contract.test.ts +29 -0
- package/src/__tests__/claimcheck-codec.test.ts +16 -53
- package/src/__tests__/golden-e2e.test.ts +2 -0
- package/src/__tests__/runner-token-coordinator.test.ts +3 -3
- package/src/activities/__tests__/call-agent-status.test.ts +135 -0
- package/src/activities/__tests__/call-llm.test.ts +1 -1
- package/src/activities/__tests__/classify-tool-approvals.test.ts +208 -1
- package/src/activities/__tests__/discover-mcp-server.test.ts +30 -0
- package/src/activities/__tests__/workflow-event-activities.test.ts +2 -1
- package/src/activities/call-agent-status.ts +74 -4
- package/src/activities/call-llm.ts +18 -63
- package/src/activities/classify-tool-approvals.ts +101 -19
- package/src/activities/discover-mcp-server.ts +29 -1
- package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +216 -0
- package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +148 -0
- package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +41 -9
- package/src/activities/execute-cursor/__tests__/approval-state.test.ts +292 -0
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +68 -1
- package/src/activities/execute-cursor/__tests__/capture-flow.test.ts +1005 -0
- package/src/activities/execute-cursor/__tests__/cas-observations.test.ts +187 -0
- package/src/activities/execute-cursor/__tests__/coarse-fingerprint.test.ts +97 -0
- package/src/activities/execute-cursor/__tests__/command-provenance.test.ts +240 -0
- package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +203 -0
- package/src/activities/execute-cursor/__tests__/exact-apply.test.ts +375 -0
- package/src/activities/execute-cursor/__tests__/hitl-ledger.test.ts +1294 -24
- package/src/activities/execute-cursor/__tests__/hitl-resume-history.test.ts +446 -0
- package/src/activities/execute-cursor/__tests__/hook-script.test.ts +384 -110
- package/src/activities/execute-cursor/__tests__/message-translator.test.ts +171 -25
- package/src/activities/execute-cursor/__tests__/sequential-gate-resume.test.ts +189 -0
- package/src/activities/execute-cursor/__tests__/tool-result-image.test.ts +44 -23
- package/src/activities/execute-cursor/__tests__/workspace-setup.test.ts +190 -10
- package/src/activities/execute-cursor/approval-policy.ts +28 -159
- package/src/activities/execute-cursor/approval-state.ts +366 -18
- package/src/activities/execute-cursor/capture-flow.ts +323 -0
- package/src/activities/execute-cursor/cas-observations.ts +204 -0
- package/src/activities/execute-cursor/command-provenance.ts +168 -0
- package/src/activities/execute-cursor/exact-apply.ts +253 -0
- package/src/activities/execute-cursor/hook-script.ts +317 -51
- package/src/activities/execute-cursor/index.ts +575 -67
- package/src/activities/execute-cursor/message-translator.ts +963 -89
- package/src/activities/execute-cursor/prompt-builder.ts +80 -14
- package/src/activities/execute-cursor/workspace-setup.ts +257 -42
- package/src/activities/execute-deep-agent/__test-utils__/gateway-substrate.ts +180 -0
- package/src/activities/execute-deep-agent/__test-utils__/scripted-model.ts +134 -0
- package/src/activities/execute-deep-agent/__tests__/approval-file-change.test.ts +84 -0
- package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +11 -24
- package/src/activities/execute-deep-agent/__tests__/cas-capture-backend.test.ts +64 -0
- package/src/activities/execute-deep-agent/__tests__/cas-capture-observer.test.ts +163 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-integration.test.ts +8 -5
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +342 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +284 -0
- package/src/activities/execute-deep-agent/__tests__/hitl.test.ts +14 -36
- package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +31 -13
- package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +349 -0
- package/src/activities/execute-deep-agent/__tests__/stamp-flowed-rows.test.ts +119 -0
- package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +91 -10
- package/src/activities/execute-deep-agent/__tests__/streaming-v3.test.ts +9 -9
- package/src/activities/execute-deep-agent/__tests__/subagent-approval-propagation.test.ts +160 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-gitignored-capture.test.ts +213 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-transformer.test.ts +3 -6
- package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +84 -1
- package/src/activities/execute-deep-agent/__tests__/v3-status-builder.test.ts +4 -1
- package/src/activities/execute-deep-agent/approval-file-change.ts +80 -0
- package/src/activities/execute-deep-agent/attachment-injector.ts +20 -11
- package/src/activities/execute-deep-agent/cas-capture-backend.ts +66 -0
- package/src/activities/execute-deep-agent/cas-capture-observer.ts +125 -0
- package/src/activities/execute-deep-agent/hitl.ts +23 -7
- package/src/activities/execute-deep-agent/index.ts +463 -40
- package/src/activities/execute-deep-agent/inline-publisher.ts +27 -4
- package/src/activities/execute-deep-agent/setup.ts +223 -125
- package/src/activities/execute-deep-agent/stamp-flowed-rows.ts +64 -0
- package/src/activities/execute-deep-agent/status-builder-shared.ts +62 -23
- package/src/activities/execute-deep-agent/status-builder.ts +63 -8
- package/src/activities/execute-deep-agent/streaming-side-effects.ts +2 -16
- package/src/activities/execute-deep-agent/streaming.ts +3 -13
- package/src/activities/execute-deep-agent/subagent-transformer.ts +53 -13
- package/src/activities/execute-deep-agent/subagent-wiring.ts +50 -3
- package/src/activities/execute-deep-agent/v3-status-builder.ts +36 -2
- package/src/claimcheck/payload-codec.ts +8 -8
- package/src/client/stigmer-client.ts +9 -1
- package/src/middleware/__tests__/approval-gate.test.ts +488 -4
- package/src/middleware/approval-gate.ts +247 -38
- package/src/middleware/types.ts +5 -5
- package/src/shared/__tests__/activity-input.test.ts +78 -0
- package/src/shared/__tests__/approval-canonicalize.test.ts +106 -0
- package/src/shared/__tests__/approval-fingerprint.test.ts +115 -0
- package/src/shared/__tests__/approval-policy.test.ts +274 -40
- package/src/shared/__tests__/args-preview.test.ts +78 -0
- package/src/shared/__tests__/artifact-storage-extended.test.ts +62 -10
- package/src/shared/__tests__/artifact-storage.test.ts +123 -11
- package/src/shared/__tests__/file-change.test.ts +85 -0
- package/src/shared/__tests__/file-tools.test.ts +90 -0
- package/src/shared/__tests__/fingerprint-secret.test.ts +51 -0
- package/src/shared/__tests__/lease-scope-corpus.test.ts +56 -0
- package/src/shared/__tests__/model-client.test.ts +162 -0
- package/src/shared/__tests__/plan-artifact.test.ts +11 -26
- package/src/shared/__tests__/policy-source-corpus.test.ts +58 -0
- package/src/shared/__tests__/status-offload.test.ts +573 -16
- package/src/shared/__tests__/status.test.ts +4 -5
- package/src/shared/__tests__/tool-kind.test.ts +24 -1
- package/src/shared/__tests__/tool-row.test.ts +221 -0
- package/src/shared/activity-input.ts +57 -0
- package/src/shared/approval-canonicalize.ts +159 -0
- package/src/shared/approval-fingerprint.ts +148 -0
- package/src/shared/approval-policy.ts +303 -27
- package/src/shared/args-preview.ts +98 -0
- package/src/shared/artifact-storage.ts +62 -11
- package/src/shared/checkpointer/__tests__/http-saver.test.ts +1 -2
- package/src/shared/file-change.ts +64 -0
- package/src/shared/file-tools.ts +169 -0
- package/src/shared/filereview/__tests__/capture.test.ts +856 -0
- package/src/shared/filereview/__tests__/cas-substrate.test.ts +404 -0
- package/src/shared/filereview/__tests__/digest.test.ts +100 -0
- package/src/shared/filereview/__tests__/events.test.ts +245 -0
- package/src/shared/filereview/__tests__/git-substrate.test.ts +362 -0
- package/src/shared/filereview/__tests__/proxy-reconcile.test.ts +286 -0
- package/src/shared/filereview/__tests__/secret-paths.test.ts +121 -0
- package/src/shared/filereview/capture.ts +727 -0
- package/src/shared/filereview/cas-substrate.ts +401 -0
- package/src/shared/filereview/digest.ts +83 -0
- package/src/shared/filereview/events.ts +449 -0
- package/src/shared/filereview/git-substrate.ts +555 -0
- package/src/shared/filereview/index.ts +60 -0
- package/src/shared/filereview/secret-paths.ts +121 -0
- package/src/shared/fingerprint-secret.ts +53 -0
- package/src/shared/model-client.ts +122 -0
- package/src/shared/plan-artifact.ts +0 -2
- package/src/shared/status-offload.ts +433 -77
- package/src/shared/status.ts +13 -0
- package/src/shared/tool-kind.ts +33 -0
- package/src/shared/tool-row.ts +135 -0
- package/src/shared/workspace/platform-dir.ts +41 -2
- package/src/workflow-engine/__tests__/golden-execution.test.ts +35 -18
- package/src/workflow-engine/__tests__/tasks/try.test.ts +1 -1
- package/src/workflows/__tests__/connect-mcp-server.test.ts +304 -29
- package/src/workflows/call-agent-orchestrator.ts +53 -6
- package/src/workflows/connect-mcp-server.ts +179 -24
- package/src/workflows/types.ts +8 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runner-held master secret for HITL approval fingerprints (Phase 2).
|
|
3
|
+
*
|
|
4
|
+
* The per-execution fingerprint key is derived from this secret + `execution_id`
|
|
5
|
+
* (see {@link file://./approval-fingerprint.ts} `deriveExecutionFingerprintKey`).
|
|
6
|
+
* Source precedence:
|
|
7
|
+
*
|
|
8
|
+
* 1. `STIGMER_RUNNER_HITL_SECRET` env var (UTF-8), when set — the only way to get
|
|
9
|
+
* a key that is STABLE across runner processes/replicas. Required once a lease
|
|
10
|
+
* becomes a cross-process bearer token (Phase 7); optional today.
|
|
11
|
+
* 2. A per-process random secret generated once at first use — sufficient for
|
|
12
|
+
* Phase 2 because the fingerprint is recompute-and-compare WITHIN one runner
|
|
13
|
+
* process for a given execution: the deep-agent gateway runs in-process, and
|
|
14
|
+
* the Cursor key is written to and read from the per-session state file by the
|
|
15
|
+
* same process. A process restart re-keys, which can only *re-ask* a pending
|
|
16
|
+
* approval (fail-safe), never silently mis-authorize.
|
|
17
|
+
*
|
|
18
|
+
* The secret is never logged. The value is memoized so the per-process fallback
|
|
19
|
+
* stays stable for the lifetime of the process.
|
|
20
|
+
*/
|
|
21
|
+
import { type BinaryLike } from "node:crypto";
|
|
22
|
+
/**
|
|
23
|
+
* Return the runner's HITL master secret (env-configured, else a stable
|
|
24
|
+
* per-process random fallback). Memoized.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getRunnerHitlMasterSecret(): BinaryLike;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runner-held master secret for HITL approval fingerprints (Phase 2).
|
|
3
|
+
*
|
|
4
|
+
* The per-execution fingerprint key is derived from this secret + `execution_id`
|
|
5
|
+
* (see {@link file://./approval-fingerprint.ts} `deriveExecutionFingerprintKey`).
|
|
6
|
+
* Source precedence:
|
|
7
|
+
*
|
|
8
|
+
* 1. `STIGMER_RUNNER_HITL_SECRET` env var (UTF-8), when set — the only way to get
|
|
9
|
+
* a key that is STABLE across runner processes/replicas. Required once a lease
|
|
10
|
+
* becomes a cross-process bearer token (Phase 7); optional today.
|
|
11
|
+
* 2. A per-process random secret generated once at first use — sufficient for
|
|
12
|
+
* Phase 2 because the fingerprint is recompute-and-compare WITHIN one runner
|
|
13
|
+
* process for a given execution: the deep-agent gateway runs in-process, and
|
|
14
|
+
* the Cursor key is written to and read from the per-session state file by the
|
|
15
|
+
* same process. A process restart re-keys, which can only *re-ask* a pending
|
|
16
|
+
* approval (fail-safe), never silently mis-authorize.
|
|
17
|
+
*
|
|
18
|
+
* The secret is never logged. The value is memoized so the per-process fallback
|
|
19
|
+
* stays stable for the lifetime of the process.
|
|
20
|
+
*/
|
|
21
|
+
import { randomBytes } from "node:crypto";
|
|
22
|
+
const ENV_VAR = "STIGMER_RUNNER_HITL_SECRET";
|
|
23
|
+
let cached;
|
|
24
|
+
let warned = false;
|
|
25
|
+
/**
|
|
26
|
+
* Return the runner's HITL master secret (env-configured, else a stable
|
|
27
|
+
* per-process random fallback). Memoized.
|
|
28
|
+
*/
|
|
29
|
+
export function getRunnerHitlMasterSecret() {
|
|
30
|
+
if (cached)
|
|
31
|
+
return cached;
|
|
32
|
+
const fromEnv = process.env[ENV_VAR];
|
|
33
|
+
if (fromEnv && fromEnv.length > 0) {
|
|
34
|
+
cached = Buffer.from(fromEnv, "utf-8");
|
|
35
|
+
return cached;
|
|
36
|
+
}
|
|
37
|
+
cached = randomBytes(32);
|
|
38
|
+
if (!warned) {
|
|
39
|
+
warned = true;
|
|
40
|
+
console.warn(`[hitl-gateway] ${ENV_VAR} is not set; using a per-process random ` +
|
|
41
|
+
"fingerprint secret. Fingerprints are stable within this process only — " +
|
|
42
|
+
`set ${ENV_VAR} for a key stable across runner restarts/replicas ` +
|
|
43
|
+
"(required in Phase 7).");
|
|
44
|
+
}
|
|
45
|
+
return cached;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=fingerprint-secret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint-secret.js","sourceRoot":"","sources":["../../src/shared/fingerprint-secret.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAmB,MAAM,aAAa,CAAC;AAE3D,MAAM,OAAO,GAAG,4BAA4B,CAAC;AAE7C,IAAI,MAA0B,CAAC;AAC/B,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB;;;GAGG;AACH,MAAM,UAAU,yBAAyB;IACvC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;IACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAI,CAAC;QACd,OAAO,CAAC,IAAI,CACV,kBAAkB,OAAO,0CAA0C;YACnE,yEAAyE;YACzE,OAAO,OAAO,oDAAoD;YAClE,wBAAwB,CACzB,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single construction point for LangChain chat models in the runner.
|
|
3
|
+
*
|
|
4
|
+
* This is the only place that translates a Stigmer registry model ID
|
|
5
|
+
* (dot-notation, e.g. "claude-haiku-4.5") into the provider's API model ID
|
|
6
|
+
* (e.g. "claude-haiku-4-5-20251001") before a client is built — so no
|
|
7
|
+
* activity can bypass the translation and 404 the provider.
|
|
8
|
+
*
|
|
9
|
+
* Layering: `llm-proxy.ts` stays pure routing utilities (no LangChain
|
|
10
|
+
* dependency); this module is the LangChain-aware layer above it that owns
|
|
11
|
+
* the resolve -> infer-provider -> strip-prefix -> proxy-wire -> construct
|
|
12
|
+
* sequence that used to be copy-pasted across every LLM activity.
|
|
13
|
+
*/
|
|
14
|
+
import type { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
15
|
+
import { type LlmProvider } from "./llm-proxy.js";
|
|
16
|
+
export interface BuildChatModelOptions {
|
|
17
|
+
/** Registry id ("claude-haiku-4.5"), "provider:model", or a provider API id. */
|
|
18
|
+
readonly modelName: string;
|
|
19
|
+
/** When set, requests route through the Stigmer proxy at the provider path. */
|
|
20
|
+
readonly proxyEndpoint?: string;
|
|
21
|
+
readonly stigmerToken?: string;
|
|
22
|
+
/** Scope headers for proxy FGA/billing attribution. */
|
|
23
|
+
readonly headerScope?: {
|
|
24
|
+
executionId?: string;
|
|
25
|
+
mcpServerId?: string;
|
|
26
|
+
workflowExecutionId?: string;
|
|
27
|
+
};
|
|
28
|
+
/** Defaults to 0. */
|
|
29
|
+
readonly temperature?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Pass-through only; intentionally no default. Anthropic requires a value,
|
|
32
|
+
* but callers differ (setup omits it, call-llm uses 4096), so the default
|
|
33
|
+
* stays the caller's decision to avoid silently changing behavior.
|
|
34
|
+
*/
|
|
35
|
+
readonly maxTokens?: number;
|
|
36
|
+
readonly timeoutMs?: number;
|
|
37
|
+
readonly maxRetries?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface BuiltChatModel {
|
|
40
|
+
readonly model: BaseChatModel;
|
|
41
|
+
readonly provider: LlmProvider;
|
|
42
|
+
/** The resolved id actually handed to the provider. */
|
|
43
|
+
readonly apiModelId: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build a configured chat model, resolving the registry id to a provider API
|
|
47
|
+
* id first. The resolution MUST precede provider inference and prefix
|
|
48
|
+
* stripping — that ordering is the invariant each per-site copy kept dropping,
|
|
49
|
+
* surfacing as `404 model: claude-haiku-4.5` at the provider.
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildChatModel(opts: BuildChatModelOptions): Promise<BuiltChatModel>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single construction point for LangChain chat models in the runner.
|
|
3
|
+
*
|
|
4
|
+
* This is the only place that translates a Stigmer registry model ID
|
|
5
|
+
* (dot-notation, e.g. "claude-haiku-4.5") into the provider's API model ID
|
|
6
|
+
* (e.g. "claude-haiku-4-5-20251001") before a client is built — so no
|
|
7
|
+
* activity can bypass the translation and 404 the provider.
|
|
8
|
+
*
|
|
9
|
+
* Layering: `llm-proxy.ts` stays pure routing utilities (no LangChain
|
|
10
|
+
* dependency); this module is the LangChain-aware layer above it that owns
|
|
11
|
+
* the resolve -> infer-provider -> strip-prefix -> proxy-wire -> construct
|
|
12
|
+
* sequence that used to be copy-pasted across every LLM activity.
|
|
13
|
+
*/
|
|
14
|
+
import { ChatAnthropic } from "@langchain/anthropic";
|
|
15
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
16
|
+
import { inferProvider, stripProviderPrefix, resolveProxyBaseUrl, buildProxyHeaders, } from "./llm-proxy.js";
|
|
17
|
+
import { resolveToApiModelId } from "./model-registry.js";
|
|
18
|
+
/**
|
|
19
|
+
* Build a configured chat model, resolving the registry id to a provider API
|
|
20
|
+
* id first. The resolution MUST precede provider inference and prefix
|
|
21
|
+
* stripping — that ordering is the invariant each per-site copy kept dropping,
|
|
22
|
+
* surfacing as `404 model: claude-haiku-4.5` at the provider.
|
|
23
|
+
*/
|
|
24
|
+
export async function buildChatModel(opts) {
|
|
25
|
+
const resolved = await resolveToApiModelId(opts.modelName);
|
|
26
|
+
const provider = inferProvider(resolved);
|
|
27
|
+
const apiModelId = stripProviderPrefix(resolved);
|
|
28
|
+
const baseUrl = opts.proxyEndpoint
|
|
29
|
+
? resolveProxyBaseUrl(opts.proxyEndpoint, provider)
|
|
30
|
+
: undefined;
|
|
31
|
+
const headers = opts.proxyEndpoint && opts.stigmerToken
|
|
32
|
+
? buildProxyHeaders(opts.stigmerToken, opts.headerScope ?? {})
|
|
33
|
+
: undefined;
|
|
34
|
+
// Proxy mode authenticates with the Stigmer token; direct mode falls back to
|
|
35
|
+
// the provider's own env-var key.
|
|
36
|
+
const apiKey = opts.proxyEndpoint
|
|
37
|
+
? (opts.stigmerToken ?? "proxy-managed")
|
|
38
|
+
: provider === "openai"
|
|
39
|
+
? (process.env.OPENAI_API_KEY ?? "")
|
|
40
|
+
: (process.env.ANTHROPIC_API_KEY ?? "");
|
|
41
|
+
const common = {
|
|
42
|
+
temperature: opts.temperature ?? 0,
|
|
43
|
+
apiKey,
|
|
44
|
+
...(opts.maxTokens ? { maxTokens: opts.maxTokens } : {}),
|
|
45
|
+
...(opts.timeoutMs ? { maxRetries: opts.maxRetries ?? 0, timeout: opts.timeoutMs } : {}),
|
|
46
|
+
};
|
|
47
|
+
// The two SDKs name the transport-override block differently (OpenAI:
|
|
48
|
+
// `configuration`, Anthropic: `clientOptions`) — encapsulating that here is
|
|
49
|
+
// the whole point, since the shape mismatch is where bugs used to hide.
|
|
50
|
+
const model = provider === "openai"
|
|
51
|
+
? new ChatOpenAI({
|
|
52
|
+
model: apiModelId,
|
|
53
|
+
...common,
|
|
54
|
+
...(baseUrl || headers
|
|
55
|
+
? {
|
|
56
|
+
configuration: {
|
|
57
|
+
...(baseUrl ? { baseURL: baseUrl } : {}),
|
|
58
|
+
...(headers ? { defaultHeaders: headers } : {}),
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
: {}),
|
|
62
|
+
})
|
|
63
|
+
: new ChatAnthropic({
|
|
64
|
+
model: apiModelId,
|
|
65
|
+
...common,
|
|
66
|
+
...(baseUrl || headers
|
|
67
|
+
? {
|
|
68
|
+
clientOptions: {
|
|
69
|
+
...(baseUrl ? { baseURL: baseUrl } : {}),
|
|
70
|
+
...(headers ? { defaultHeaders: headers } : {}),
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
: {}),
|
|
74
|
+
});
|
|
75
|
+
return { model, provider, apiModelId };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=model-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-client.js","sourceRoot":"","sources":["../../src/shared/model-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBA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AI,CAAC,UAAU,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzF,CAAC;IAEF,sEAAsE;IACtE,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,KAAK,GAAkB,QAAQ,KAAK,QAAQ;QAChD,CAAC,CAAC,IAAI,UAAU,CAAC;YACb,KAAK,EAAE,UAAU;YACjB,GAAG,MAAM;YACT,GAAG,CAAC,OAAO,IAAI,OAAO;gBACpB,CAAC,CAAC;oBACE,aAAa,EAAE;wBACb,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wBACxC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAChD;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;QACJ,CAAC,CAAC,IAAI,aAAa,CAAC;YAChB,KAAK,EAAE,UAAU;YACjB,GAAG,MAAM;YACT,GAAG,CAAC,OAAO,IAAI,OAAO;gBACpB,CAAC,CAAC;oBACE,aAAa,EAAE;wBACb,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wBACxC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAChD;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAC;IAEP,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -69,14 +69,12 @@ export async function publishPlanArtifact(opts) {
|
|
|
69
69
|
const contentHash = createHash("sha256").update(content).digest("hex");
|
|
70
70
|
const storageKey = `artifacts/${executionId}/${PLAN_ARTIFACT_NAME}`;
|
|
71
71
|
await artifactStorage.upload(storageKey, content, "text/markdown");
|
|
72
|
-
const downloadUrl = await artifactStorage.getDownloadUrl(storageKey);
|
|
73
72
|
const artifact = create(ExecutionArtifactSchema, {
|
|
74
73
|
name: PLAN_ARTIFACT_NAME,
|
|
75
74
|
sandboxPath: PLAN_ARTIFACT_SANDBOX_PATH,
|
|
76
75
|
kind: ExecutionArtifactKind.FILE,
|
|
77
76
|
sizeBytes: BigInt(content.length),
|
|
78
77
|
storageKey,
|
|
79
|
-
downloadUrl,
|
|
80
78
|
createdAt: utcTimestamp(),
|
|
81
79
|
contentHash,
|
|
82
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-artifact.js","sourceRoot":"","sources":["../../src/shared/plan-artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kEAAkE,CAAC;AAC3G,OAAO,EACL,qBAAqB,EACrB,WAAW,GACZ,MAAM,8DAA8D,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAEnE;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA4B;IAC/D,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,GAA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AC,uBAAuB,EAAE;YAC/C,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,0BAA0B;YACvC,IAAI,EAAE,qBAAqB,CAAC,IAAI;YAChC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YACjC,UAAU;YACV,SAAS,EAAE,YAAY,EAAE;YACzB,WAAW;SACZ,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC;QACrF,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,CAAC,GAAG,CACT,6BAA6B,WAAW,gBAAgB,kBAAkB,GAAG;YAC7E,IAAI,OAAO,CAAC,MAAM,gBAAgB,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAC9D,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,6BAA6B,WAAW,KAAK;YAC7C,uCAAuC,GAAG,EAAE,CAC7C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Tool outputs (an MCP screenshot's base64 image, a giant accessibility-tree
|
|
5
5
|
* dump, a multi-MB shell log, a huge file write) are stored inline in
|
|
6
|
-
* `ToolCall.result`/`args_preview`, which live in `status.messages`
|
|
7
|
-
*
|
|
6
|
+
* `ToolCall.result`/`args_preview`, which live in `status.messages` AND in
|
|
7
|
+
* each `status.sub_agent_executions[].messages` (a delegated tool call's
|
|
8
|
+
* result is just as unbounded), and are re-serialized whole on every
|
|
9
|
+
* `persistStatus` -> `updateStatus` gRPC call.
|
|
8
10
|
* Left unchecked, a single large result pushes the message past the server's
|
|
9
11
|
* 4 MiB gRPC receive cap; the call fails with `resource_exhausted`, progress
|
|
10
12
|
* stops persisting, and the live UI freezes mid-execution.
|
|
@@ -20,12 +22,22 @@
|
|
|
20
22
|
* Idempotent and content-hash-deduped so the throttled, repeated persists
|
|
21
23
|
* (and result re-inflation by mergeToolCallEvent) upload each blob once.
|
|
22
24
|
*
|
|
23
|
-
* 2.
|
|
25
|
+
* 2. offloadCandidateChangesToFit — an aggregate, storage-backed step for the
|
|
26
|
+
* file-review ledger: if the status still exceeds the soft cap after (1),
|
|
27
|
+
* it offloads the largest still-inline captured before/after bodies to
|
|
28
|
+
* retrievable refs (biggest-first) until it fits, so a captured file stays
|
|
29
|
+
* REVIEWABLE (the UI lazily fetches the ref) instead of being dropped. The
|
|
30
|
+
* persisted body is a display projection — reconcile sources bytes from the
|
|
31
|
+
* git refs / CAS manifest, never this body — so this is correctness-neutral.
|
|
32
|
+
*
|
|
33
|
+
* 3. enforceStatusSizeLimit — an aggregate, type-agnostic backstop that runs
|
|
24
34
|
* even when no artifact storage is available: if the encoded status still
|
|
25
35
|
* exceeds a soft cap (comfortably under 4 MiB), it elides the largest
|
|
26
|
-
* remaining inline fields in place until the payload fits.
|
|
36
|
+
* remaining inline fields in place until the payload fits. For file-review
|
|
37
|
+
* bodies this is the LAST resort (no storage, or (2) could not free enough):
|
|
38
|
+
* the body is dropped and the file marked SIZE_ELIDED / incomplete.
|
|
27
39
|
*
|
|
28
|
-
*
|
|
40
|
+
* All operate ONLY on what is persisted/streamed; the agent's working context
|
|
29
41
|
* is managed by the harness/SDK separately, so reasoning is unaffected.
|
|
30
42
|
*/
|
|
31
43
|
import type { AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
@@ -37,6 +49,13 @@ import type { ArtifactStorage } from "./artifact-storage.js";
|
|
|
37
49
|
* even a handful of large-but-sub-threshold results cannot aggregate past it.
|
|
38
50
|
*/
|
|
39
51
|
export declare const INLINE_TOOL_OUTPUT_MAX_BYTES: number;
|
|
52
|
+
/**
|
|
53
|
+
* A single FileChange before/after body larger than this is offloaded to
|
|
54
|
+
* artifact storage. Smaller than the 256 KiB tool-output cap because a file
|
|
55
|
+
* change can carry two bodies (before + after) per change and several changes
|
|
56
|
+
* per tool call, so the aggregate would otherwise climb quickly.
|
|
57
|
+
*/
|
|
58
|
+
export declare const INLINE_FILE_CONTENT_MAX_BYTES: number;
|
|
40
59
|
/** Head of an offloaded text result kept inline for an at-a-glance preview. */
|
|
41
60
|
export declare const TEXT_PREVIEW_HEAD_CHARS = 4000;
|
|
42
61
|
/**
|
|
@@ -49,21 +68,44 @@ export declare const STATUS_PAYLOAD_SOFT_LIMIT_BYTES: number;
|
|
|
49
68
|
* large, to maximize the chance the retry succeeds.
|
|
50
69
|
*/
|
|
51
70
|
export declare const STATUS_PAYLOAD_HARD_LIMIT_BYTES: number;
|
|
71
|
+
/**
|
|
72
|
+
* Marker left in place of an aggregate-elided inline field. Exported so the
|
|
73
|
+
* resume-time exact-apply resolver can recognize (and refuse to write) an elided
|
|
74
|
+
* body rather than corrupting a file with the marker text — the lossy elision is
|
|
75
|
+
* the one case where the exact approved bytes are unrecoverable and exact-apply
|
|
76
|
+
* must fall back. The two sides cannot drift because they share this constant.
|
|
77
|
+
*/
|
|
78
|
+
export declare const ELISION_MARKER = "[output elided to keep status under the size limit]";
|
|
52
79
|
export interface ToolOutputOffloadContext {
|
|
53
80
|
readonly artifactStorage: ArtifactStorage;
|
|
54
81
|
readonly executionId: string;
|
|
55
82
|
/** Override the per-result byte threshold (tests use a small value). */
|
|
56
83
|
readonly maxInlineBytes?: number;
|
|
84
|
+
/** Override the per-file-content-body byte threshold (tests use a small value). */
|
|
85
|
+
readonly maxInlineFileBytes?: number;
|
|
57
86
|
}
|
|
58
87
|
interface ImagePayload {
|
|
59
88
|
readonly base64: string;
|
|
60
89
|
readonly mimeType: string;
|
|
61
90
|
}
|
|
62
91
|
/**
|
|
63
|
-
* Best-effort extraction of an inline
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
92
|
+
* Best-effort extraction of an inline image from a tool result string.
|
|
93
|
+
*
|
|
94
|
+
* An MCP tool that returns an image (e.g. a computer-use screenshot) must be
|
|
95
|
+
* lifted into a renderable `ToolCallOutputRef`; otherwise it persists as text
|
|
96
|
+
* and the UI shows raw JSON / "view full output" instead of the picture. The
|
|
97
|
+
* image can arrive in many wrappers depending on the harness and whether the
|
|
98
|
+
* result was pre-serialized, so detection looks for an UNAMBIGUOUS image signal
|
|
99
|
+
* rather than a fixed envelope position:
|
|
100
|
+
*
|
|
101
|
+
* 1. a `data:image/*;base64,...` URL anywhere in the string, then
|
|
102
|
+
* 2. a recognized image block at any depth of a JSON result
|
|
103
|
+
* (see {@link imageFromBlock}).
|
|
104
|
+
*
|
|
105
|
+
* Returns null for non-image or unparseable results so the caller falls back to
|
|
106
|
+
* text offload. It deliberately does NOT treat a bare base64 string with no
|
|
107
|
+
* image marker as an image — that would misclassify legitimate large text
|
|
108
|
+
* (logs, base64-encoded files) as pictures.
|
|
67
109
|
*/
|
|
68
110
|
export declare function detectImagePayload(result: string): ImagePayload | null;
|
|
69
111
|
/**
|
|
@@ -71,8 +113,40 @@ export declare function detectImagePayload(result: string): ImagePayload | null;
|
|
|
71
113
|
* replacing the inline value with a short head + ToolCallOutputRef. Per-tool
|
|
72
114
|
* failures fall back to an inline truncation (a bounded result beats a failed
|
|
73
115
|
* persist) and never throw, so a storage hiccup cannot fail the execution.
|
|
116
|
+
*
|
|
117
|
+
* File-review before/after bodies (on the CANDIDATE_CAPTURED ledger events) are
|
|
118
|
+
* offloaded in the same pass — a tool can produce a small result yet a large
|
|
119
|
+
* captured diff. A file-review offload failure is non-fatal — the body stays
|
|
120
|
+
* inline and the aggregate backstop (enforceStatusSizeLimit) drops it if needed.
|
|
74
121
|
*/
|
|
75
122
|
export declare function offloadOversizedToolOutputs(status: AgentExecutionStatus, ctx: ToolOutputOffloadContext): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Aggregate-budget offload of file-review candidate bodies (async, storage-backed).
|
|
125
|
+
*
|
|
126
|
+
* The per-item pass ({@link offloadOversizedToolOutputs}) only offloads a body
|
|
127
|
+
* over {@link INLINE_FILE_CONTENT_MAX_BYTES}; many mid-sized captured files (each
|
|
128
|
+
* under that per-file cap) can still sum the whole status past the soft limit.
|
|
129
|
+
* Rather than let the storage-less backstop ({@link enforceStatusSizeLimit}) DROP
|
|
130
|
+
* those bodies — which sets `diff_complete=false` and blocks approval, turning a
|
|
131
|
+
* reviewable change discard-only — this step offloads the largest still-inline
|
|
132
|
+
* captured bodies to retrievable refs (biggest-first) until the status fits. The
|
|
133
|
+
* review UI then lazily fetches each ref via getArtifactContent exactly as it
|
|
134
|
+
* already does for a >128 KiB file, and the change stays reviewable
|
|
135
|
+
* (`diff_complete` is untouched, so the set rollup is unchanged).
|
|
136
|
+
*
|
|
137
|
+
* Correctness: the persisted before/after body is a DISPLAY projection —
|
|
138
|
+
* reconcile sources the approved bytes from the pinned git refs / CAS manifest
|
|
139
|
+
* and verifies them against the enforcement digests (`before_sha256`/
|
|
140
|
+
* `after_sha256`), never this body (see {@link ../filereview/capture.js}). So
|
|
141
|
+
* converting a body to a ref (or, in the backstop, dropping it) cannot change
|
|
142
|
+
* what is applied on approval.
|
|
143
|
+
*
|
|
144
|
+
* Non-fatal per side: a storage failure leaves that body inline for the backstop
|
|
145
|
+
* to drop. Returns true if any body was offloaded. Called only for a status that
|
|
146
|
+
* actually carries file-review events (the caller guards on that), and a no-op
|
|
147
|
+
* (single encode) when the status already fits.
|
|
148
|
+
*/
|
|
149
|
+
export declare function offloadCandidateChangesToFit(status: AgentExecutionStatus, ctx: ToolOutputOffloadContext, softLimitBytes?: number): Promise<boolean>;
|
|
76
150
|
/**
|
|
77
151
|
* Aggregate, type-agnostic backstop. If the encoded status exceeds
|
|
78
152
|
* `softLimitBytes`, elide the largest inline tool fields (and, as a last
|