@stigmer/runner 3.14.1 → 3.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-fingerprint +1 -1
- package/dist/__test-utils__/execution-record-fixture.d.ts +47 -0
- package/dist/__test-utils__/execution-record-fixture.js +68 -0
- package/dist/__test-utils__/execution-record-fixture.js.map +1 -0
- package/dist/__test-utils__/harness-contract/types.d.ts +166 -0
- package/dist/__test-utils__/harness-contract/types.js +49 -0
- package/dist/__test-utils__/harness-contract/types.js.map +1 -0
- package/dist/__test-utils__/hermetic-activity.d.ts +28 -5
- package/dist/__test-utils__/hermetic-activity.js +23 -7
- package/dist/__test-utils__/hermetic-activity.js.map +1 -1
- package/dist/__test-utils__/mock-workspace.d.ts +15 -0
- package/dist/__test-utils__/mock-workspace.js +21 -0
- package/dist/__test-utils__/mock-workspace.js.map +1 -0
- package/dist/__test-utils__/model-registry-fixture.d.ts +56 -0
- package/dist/__test-utils__/model-registry-fixture.js +66 -0
- package/dist/__test-utils__/model-registry-fixture.js.map +1 -0
- package/dist/__test-utils__/turn-input-fixture.d.ts +60 -0
- package/dist/__test-utils__/turn-input-fixture.js +118 -0
- package/dist/__test-utils__/turn-input-fixture.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.d.ts +107 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +344 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +20 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +58 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +2 -32
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +38 -62
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +47 -121
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +17 -1
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +27 -4
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +52 -11
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +66 -7
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -1
- package/dist/activities/execute-cursor/adapter.d.ts +55 -0
- package/dist/activities/execute-cursor/adapter.js +119 -0
- package/dist/activities/execute-cursor/adapter.js.map +1 -0
- package/dist/activities/execute-cursor/approval-state.d.ts +2 -2
- package/dist/activities/execute-cursor/approval-state.js.map +1 -1
- package/dist/activities/execute-cursor/capture-flow.d.ts +15 -30
- package/dist/activities/execute-cursor/capture-flow.js +17 -26
- package/dist/activities/execute-cursor/capture-flow.js.map +1 -1
- package/dist/activities/execute-cursor/cursor-capabilities.d.ts +23 -0
- package/dist/activities/execute-cursor/cursor-capabilities.js +33 -0
- package/dist/activities/execute-cursor/cursor-capabilities.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-mcp-config.d.ts +2 -2
- package/dist/activities/execute-cursor/cursor-mcp-config.js.map +1 -1
- package/dist/activities/execute-cursor/fetch-interceptor.d.ts +15 -25
- package/dist/activities/execute-cursor/fetch-interceptor.js +39 -33
- package/dist/activities/execute-cursor/fetch-interceptor.js.map +1 -1
- package/dist/activities/execute-cursor/http2-interceptor.d.ts +21 -17
- package/dist/activities/execute-cursor/http2-interceptor.js +38 -31
- package/dist/activities/execute-cursor/http2-interceptor.js.map +1 -1
- package/dist/activities/execute-cursor/message-translator.d.ts +28 -19
- package/dist/activities/execute-cursor/message-translator.js +76 -27
- package/dist/activities/execute-cursor/message-translator.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +180 -11
- package/dist/activities/execute-cursor/prompt-builder.js +171 -0
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-cursor/rejection-capture.d.ts +3 -6
- package/dist/activities/execute-cursor/rejection-capture.js +5 -7
- package/dist/activities/execute-cursor/rejection-capture.js.map +1 -1
- package/dist/activities/execute-cursor/session-lifecycle.d.ts +1 -4
- package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -1
- package/dist/activities/execute-cursor/turn-boundary.d.ts +1 -1
- package/dist/activities/execute-cursor/turn-settle.d.ts +49 -0
- package/dist/activities/execute-cursor/turn-settle.js +507 -0
- package/dist/activities/execute-cursor/turn-settle.js.map +1 -0
- package/dist/activities/execute-cursor/turn-setup.d.ts +173 -0
- package/dist/activities/execute-cursor/turn-setup.js +496 -0
- package/dist/activities/execute-cursor/turn-setup.js.map +1 -0
- package/dist/activities/execute-cursor/turn-stream.d.ts +41 -71
- package/dist/activities/execute-cursor/turn-stream.js +70 -135
- package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
- package/dist/activities/execute-cursor/turn.d.ts +43 -0
- package/dist/activities/execute-cursor/turn.js +222 -0
- package/dist/activities/execute-cursor/turn.js.map +1 -0
- package/dist/activities/execute-cursor/usage-pricing.d.ts +38 -0
- package/dist/activities/execute-cursor/usage-pricing.js +50 -0
- package/dist/activities/execute-cursor/usage-pricing.js.map +1 -0
- package/dist/activities/execute-deep-agent/approval-file-change.d.ts +1 -1
- package/dist/activities/execute-deep-agent/approval-file-change.js +1 -1
- package/dist/activities/execute-deep-agent/environment.js +1 -1
- package/dist/activities/execute-deep-agent/environment.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.js +3 -2
- package/dist/activities/execute-deep-agent/setup.js.map +1 -1
- package/dist/activities/hydrate-workflow-execution.js +1 -1
- package/dist/activities/hydrate-workflow-execution.js.map +1 -1
- package/dist/config.d.ts +15 -0
- package/dist/config.js.map +1 -1
- package/dist/harness/capabilities.d.ts +16 -0
- package/dist/harness/capabilities.js +1 -0
- package/dist/harness/capabilities.js.map +1 -1
- package/dist/harness/persist-chokepoint.d.ts +74 -0
- package/dist/harness/persist-chokepoint.js +88 -0
- package/dist/harness/persist-chokepoint.js.map +1 -0
- package/dist/harness/registry.d.ts +44 -5
- package/dist/harness/registry.js +61 -5
- package/dist/harness/registry.js.map +1 -1
- package/dist/harness/run-turn.d.ts +53 -0
- package/dist/harness/run-turn.js +528 -0
- package/dist/harness/run-turn.js.map +1 -0
- package/dist/harness/stop-controller.d.ts +50 -0
- package/dist/harness/stop-controller.js +62 -0
- package/dist/harness/stop-controller.js.map +1 -0
- package/dist/harness/terminal-table.d.ts +141 -0
- package/dist/harness/terminal-table.js +239 -0
- package/dist/harness/terminal-table.js.map +1 -0
- package/dist/harness/turn-context.d.ts +523 -0
- package/dist/harness/turn-context.js +739 -0
- package/dist/harness/turn-context.js.map +1 -0
- package/dist/harness/types.d.ts +232 -52
- package/dist/harness/types.js +17 -8
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/usage-accumulator.d.ts +68 -0
- package/dist/harness/usage-accumulator.js +101 -0
- package/dist/harness/usage-accumulator.js.map +1 -0
- package/dist/harness-adapters.d.ts +27 -0
- package/dist/harness-adapters.js +28 -0
- package/dist/harness-adapters.js.map +1 -0
- package/dist/main.js.map +1 -1
- package/dist/runner-manager.js +64 -48
- package/dist/runner-manager.js.map +1 -1
- package/dist/runner.d.ts +5 -4
- package/dist/runner.js +65 -64
- package/dist/runner.js.map +1 -1
- package/dist/shared/approval-policy.d.ts +1 -1
- package/dist/shared/approval-policy.js.map +1 -1
- package/dist/{activities/execute-cursor → shared}/attachment-resolver.d.ts +2 -2
- package/dist/{activities/execute-cursor → shared}/attachment-resolver.js +5 -5
- package/dist/shared/attachment-resolver.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/blueprint-resolver.d.ts +7 -5
- package/dist/{activities/execute-cursor → shared}/blueprint-resolver.js +3 -63
- package/dist/shared/blueprint-resolver.js.map +1 -0
- package/dist/shared/channel-attachment.d.ts +1 -1
- package/dist/shared/channel-attachment.js.map +1 -1
- package/dist/{activities/execute-cursor → shared}/cost-guard.d.ts +5 -1
- package/dist/{activities/execute-cursor → shared}/cost-guard.js +5 -1
- package/dist/shared/cost-guard.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/env-resolver.d.ts +1 -1
- package/dist/shared/env-resolver.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/exact-apply.d.ts +1 -1
- package/dist/{activities/execute-cursor → shared}/exact-apply.js +6 -6
- package/dist/shared/exact-apply.js.map +1 -0
- package/dist/shared/execution-context.d.ts +35 -0
- package/dist/shared/execution-context.js +38 -0
- package/dist/shared/execution-context.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/extract-structured-output.d.ts +5 -2
- package/dist/{activities/execute-cursor → shared}/extract-structured-output.js +9 -6
- package/dist/shared/extract-structured-output.js.map +1 -0
- package/dist/shared/filereview/capture.d.ts +1 -1
- package/dist/shared/filereview/capture.js +1 -1
- package/dist/shared/heartbeat.d.ts +13 -11
- package/dist/shared/heartbeat.js +14 -29
- package/dist/shared/heartbeat.js.map +1 -1
- package/dist/{activities/execute-cursor → shared}/persist-decision.d.ts +5 -2
- package/dist/{activities/execute-cursor → shared}/persist-decision.js +4 -1
- package/dist/shared/persist-decision.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/skill-resolver.d.ts +16 -3
- package/dist/{activities/execute-cursor → shared}/skill-resolver.js +12 -4
- package/dist/shared/skill-resolver.js.map +1 -0
- package/dist/shared/subagent-rows.d.ts +21 -0
- package/dist/shared/subagent-rows.js +34 -0
- package/dist/shared/subagent-rows.js.map +1 -0
- package/dist/shared/worker-shutdown.d.ts +43 -16
- package/dist/shared/worker-shutdown.js +28 -13
- package/dist/shared/worker-shutdown.js.map +1 -1
- package/dist/shared/workspace/platform-dir.d.ts +1 -1
- package/dist/shared/workspace/platform-dir.js +1 -1
- package/dist/shared/workspace/session-provision.d.ts +54 -0
- package/dist/{activities/execute-cursor/workspace-provision.js → shared/workspace/session-provision.js} +15 -12
- package/dist/shared/workspace/session-provision.js.map +1 -0
- package/package.json +4 -4
- package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +110 -14
- package/src/__test-utils__/execution-record-fixture.ts +104 -0
- package/src/__test-utils__/harness-boot-order-child.ts +58 -0
- package/src/__test-utils__/harness-contract/contract.ts +128 -83
- package/src/__test-utils__/harness-contract/recording-sink.ts +15 -4
- package/src/__test-utils__/harness-contract/runtime-contract.ts +666 -0
- package/src/__test-utils__/harness-contract/scripted-adapter.ts +92 -32
- package/src/__test-utils__/harness-contract/types.ts +85 -9
- package/src/__test-utils__/hermetic-activity.ts +33 -8
- package/src/__test-utils__/model-registry-fixture.ts +72 -0
- package/src/__test-utils__/module-specifiers.ts +82 -0
- package/src/__test-utils__/turn-input-fixture.ts +155 -0
- package/src/__tests__/harness-boot-order.test.ts +77 -0
- package/src/__tests__/harness-contract.test.ts +7 -5
- package/src/__tests__/runner-manager.test.ts +18 -0
- package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +102 -0
- package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +396 -0
- package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +66 -0
- package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +2 -43
- package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +65 -145
- package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +30 -4
- package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +96 -8
- package/src/activities/execute-cursor/__tests__/adapter-is-temporal-free.test.ts +45 -0
- package/src/activities/execute-cursor/__tests__/approval-decisions-agree.test.ts +90 -0
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +7 -8
- package/src/activities/execute-cursor/__tests__/capture-flow.test.ts +28 -1
- package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +64 -6
- package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.status.json +53 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.status.json +1 -6
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.status.json +56 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.status.json +48 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.status.json +18 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.status.json +36 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.status.json +37 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.status.json +38 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.status.json +59 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.status.json +79 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.status.json +2 -7
- package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +170 -0
- package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +22 -18
- package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +286 -0
- package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +332 -0
- package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +193 -0
- package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +185 -0
- package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +151 -0
- package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +65 -35
- package/src/activities/execute-cursor/__tests__/message-translator.test.ts +0 -40
- package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +171 -0
- package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +118 -243
- package/src/activities/execute-cursor/__tests__/usage-pricing.test.ts +84 -0
- package/src/activities/execute-cursor/adapter.ts +138 -0
- package/src/activities/execute-cursor/approval-state.ts +2 -2
- package/src/activities/execute-cursor/capture-flow.ts +18 -41
- package/src/activities/execute-cursor/cursor-capabilities.ts +35 -0
- package/src/activities/execute-cursor/cursor-mcp-config.ts +2 -2
- package/src/activities/execute-cursor/fetch-interceptor.ts +48 -45
- package/src/activities/execute-cursor/http2-interceptor.ts +47 -34
- package/src/activities/execute-cursor/message-translator.ts +90 -45
- package/src/activities/execute-cursor/prompt-builder.ts +327 -12
- package/src/activities/execute-cursor/rejection-capture.ts +5 -12
- package/src/activities/execute-cursor/session-lifecycle.ts +1 -5
- package/src/activities/execute-cursor/turn-boundary.ts +1 -1
- package/src/activities/execute-cursor/turn-settle.ts +601 -0
- package/src/activities/execute-cursor/turn-setup.ts +645 -0
- package/src/activities/execute-cursor/turn-stream.ts +84 -210
- package/src/activities/execute-cursor/turn.ts +240 -0
- package/src/activities/execute-cursor/usage-pricing.ts +67 -0
- package/src/activities/execute-deep-agent/approval-file-change.ts +1 -1
- package/src/activities/execute-deep-agent/environment.ts +1 -1
- package/src/activities/execute-deep-agent/setup.ts +3 -2
- package/src/activities/hydrate-workflow-execution.ts +1 -1
- package/src/config.ts +13 -0
- package/src/harness/__tests__/import-direction.test.ts +168 -0
- package/src/harness/__tests__/persist-chokepoint.test.ts +146 -0
- package/src/harness/__tests__/registry.test.ts +1 -0
- package/src/harness/__tests__/run-turn.test.ts +165 -0
- package/src/harness/__tests__/stop-controller.test.ts +49 -0
- package/src/harness/__tests__/turn-context.test.ts +178 -0
- package/src/harness/__tests__/usage-accumulator.test.ts +83 -0
- package/src/harness/capabilities.ts +17 -0
- package/src/harness/persist-chokepoint.ts +112 -0
- package/src/harness/registry.ts +79 -5
- package/src/harness/run-turn.ts +618 -0
- package/src/harness/stop-controller.ts +83 -0
- package/src/harness/terminal-table.ts +276 -0
- package/src/harness/turn-context.ts +1028 -0
- package/src/harness/types.ts +248 -53
- package/src/harness/usage-accumulator.ts +122 -0
- package/src/harness-adapters.ts +30 -0
- package/src/main.ts +1 -1
- package/src/runner-manager.ts +68 -61
- package/src/runner.ts +67 -78
- package/src/shared/__tests__/attachment-naming.test.ts +1 -1
- package/src/{activities/execute-cursor → shared}/__tests__/attachment-resolver.test.ts +6 -4
- package/src/{activities/execute-cursor → shared}/__tests__/cost-guard.test.ts +2 -1
- package/src/{activities/execute-cursor → shared}/__tests__/exact-apply.test.ts +3 -3
- package/src/{activities/execute-cursor → shared}/__tests__/extract-structured-output.test.ts +8 -8
- package/src/{activities/execute-cursor → shared}/__tests__/persist-decision.test.ts +4 -2
- package/src/{activities/execute-cursor → shared}/__tests__/skill-resolver.test.ts +1 -1
- package/src/shared/__tests__/subagent-rows.test.ts +34 -0
- package/src/shared/__tests__/worker-shutdown.test.ts +44 -39
- package/src/shared/approval-policy.ts +1 -1
- package/src/{activities/execute-cursor → shared}/attachment-resolver.ts +6 -6
- package/src/{activities/execute-cursor → shared}/blueprint-resolver.ts +7 -78
- package/src/shared/channel-attachment.ts +1 -1
- package/src/{activities/execute-cursor → shared}/cost-guard.ts +5 -1
- package/src/{activities/execute-cursor → shared}/env-resolver.ts +1 -1
- package/src/{activities/execute-cursor → shared}/exact-apply.ts +7 -7
- package/src/shared/execution-context.ts +45 -0
- package/src/{activities/execute-cursor → shared}/extract-structured-output.ts +10 -7
- package/src/shared/filereview/capture.ts +1 -1
- package/src/shared/heartbeat.ts +13 -33
- package/src/{activities/execute-cursor → shared}/persist-decision.ts +5 -2
- package/src/{activities/execute-cursor → shared}/skill-resolver.ts +20 -6
- package/src/shared/subagent-rows.ts +39 -0
- package/src/shared/worker-shutdown.ts +55 -25
- package/src/{activities/execute-cursor/__tests__/workspace-provision.test.ts → shared/workspace/__tests__/session-provision.test.ts} +25 -28
- package/src/shared/workspace/platform-dir.ts +1 -1
- package/src/{activities/execute-cursor/workspace-provision.ts → shared/workspace/session-provision.ts} +29 -16
- package/dist/activities/execute-cursor/attachment-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/blueprint-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/cost-guard.js.map +0 -1
- package/dist/activities/execute-cursor/env-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/exact-apply.js.map +0 -1
- package/dist/activities/execute-cursor/extract-structured-output.js.map +0 -1
- package/dist/activities/execute-cursor/index.d.ts +0 -209
- package/dist/activities/execute-cursor/index.js +0 -2345
- package/dist/activities/execute-cursor/index.js.map +0 -1
- package/dist/activities/execute-cursor/persist-decision.js.map +0 -1
- package/dist/activities/execute-cursor/skill-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/usage-accumulator.d.ts +0 -89
- package/dist/activities/execute-cursor/usage-accumulator.js +0 -121
- package/dist/activities/execute-cursor/usage-accumulator.js.map +0 -1
- package/dist/activities/execute-cursor/workspace-provision.d.ts +0 -42
- package/dist/activities/execute-cursor/workspace-provision.js.map +0 -1
- package/src/activities/execute-cursor/__tests__/usage-accumulator.test.ts +0 -164
- package/src/activities/execute-cursor/index.ts +0 -2876
- package/src/activities/execute-cursor/usage-accumulator.ts +0 -169
- /package/dist/{activities/execute-cursor → shared}/env-resolver.js +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one way a turn is told to stop, and the runtime's record of why.
|
|
3
|
+
*
|
|
4
|
+
* The adapter contract gives an engine ONE signal (`TurnSink.stopSignal`) for
|
|
5
|
+
* every cause of stopping and forbids it to branch on the cause; the runtime
|
|
6
|
+
* keeps the cause here, as evidence its terminal table reads after the
|
|
7
|
+
* adapter settles `interrupted`. Four producers abort the signal: the stall
|
|
8
|
+
* watchdog, the usage accumulator's cost cap, the persist chokepoint's
|
|
9
|
+
* platform STOP, and Temporal's own cancellation (a pause, a worker
|
|
10
|
+
* shutdown, a heartbeat timeout — told apart later from the signal's reason,
|
|
11
|
+
* `shared/worker-shutdown.ts`). The first cause wins the abort; every cause
|
|
12
|
+
* is recorded, because the table's precedence (stall over cost cap over
|
|
13
|
+
* cancellation over platform stop) is decided at settlement, not at abort.
|
|
14
|
+
*
|
|
15
|
+
* Nothing here is engine-specific and nothing here persists; the Cursor
|
|
16
|
+
* orchestrator kept the same facts as flags on its stream state
|
|
17
|
+
* (`turn-stream.ts` `TurnStreamState`, before S2 M3 moved them out).
|
|
18
|
+
*/
|
|
19
|
+
export class StopController {
|
|
20
|
+
controller = new AbortController();
|
|
21
|
+
stall;
|
|
22
|
+
costCapExceeded = false;
|
|
23
|
+
platformStop = false;
|
|
24
|
+
cancellation = false;
|
|
25
|
+
/** The adapter's `stopSignal`. Its `reason` is the first cause's kind, a diagnostic only. */
|
|
26
|
+
get signal() {
|
|
27
|
+
return this.controller.signal;
|
|
28
|
+
}
|
|
29
|
+
get evidence() {
|
|
30
|
+
return {
|
|
31
|
+
stall: this.stall,
|
|
32
|
+
costCapExceeded: this.costCapExceeded,
|
|
33
|
+
platformStop: this.platformStop,
|
|
34
|
+
cancellation: this.cancellation,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Record a cause and abort the signal (idempotent per cause; the signal aborts once). */
|
|
38
|
+
stop(cause) {
|
|
39
|
+
switch (cause.kind) {
|
|
40
|
+
case "stall":
|
|
41
|
+
this.stall ??= cause.error;
|
|
42
|
+
break;
|
|
43
|
+
case "cost-cap":
|
|
44
|
+
this.costCapExceeded = true;
|
|
45
|
+
break;
|
|
46
|
+
case "platform-stop":
|
|
47
|
+
this.platformStop = true;
|
|
48
|
+
break;
|
|
49
|
+
case "cancellation":
|
|
50
|
+
this.cancellation = true;
|
|
51
|
+
break;
|
|
52
|
+
default: {
|
|
53
|
+
const exhaustive = cause;
|
|
54
|
+
throw new Error(`StopController: unknown stop cause ${JSON.stringify(exhaustive)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!this.controller.signal.aborted) {
|
|
58
|
+
this.controller.abort(cause.kind);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=stop-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop-controller.js","sourceRoot":"","sources":["../../src/harness/stop-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAoBH,MAAM,OAAO,cAAc;IACR,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IAC5C,KAAK,CAAgC;IACrC,eAAe,GAAG,KAAK,CAAC;IACxB,YAAY,GAAG,KAAK,CAAC;IACrB,YAAY,GAAG,KAAK,CAAC;IAE7B,6FAA6F;IAC7F,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAChC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;IACJ,CAAC;IAED,0FAA0F;IAC1F,IAAI,CAAC,KAAgB;QACnB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,OAAO;gBACV,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC;gBAC3B,MAAM;YACR,KAAK,UAAU;gBACb,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;gBAC5B,MAAM;YACR,KAAK,eAAe;gBAClB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;gBACzB,MAAM;YACR,KAAK,cAAc;gBACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;gBACzB,MAAM;YACR,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,UAAU,GAAU,KAAK,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACtF,CAAC;QACH,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The terminal table: every way a turn ends, as data — the phase it writes,
|
|
3
|
+
* the `error` it sets, the system rows it appends, whether it stamps
|
|
4
|
+
* `completedAt`, and whether the activity RETURNS the slim status or THROWS
|
|
5
|
+
* a `CancelledFailure` — with one function that applies an arm to a status.
|
|
6
|
+
*
|
|
7
|
+
* Why data and not one function per arm: the copy is the user-facing
|
|
8
|
+
* contract of the runner (the hermetic goldens pin every string below byte
|
|
9
|
+
* for byte, `activities/execute-cursor/__tests__/hermetic/`), and a table a
|
|
10
|
+
* reader can scan is how that contract stays reviewable. The native
|
|
11
|
+
* harness's `execute-deep-agent/streaming-terminal.ts` keeps one function
|
|
12
|
+
* per arm; S3 aligns the two (P-1's copy alignment) with both in view.
|
|
13
|
+
*
|
|
14
|
+
* The throw-vs-return rule, unchanged from the orchestrator it replaces:
|
|
15
|
+
* - RETURN when a Temporal retry would only repeat the outcome — a stall
|
|
16
|
+
* would wedge again, an exhausted budget would burn again, a platform
|
|
17
|
+
* stop is the platform's decision, a failed engine would fail the same
|
|
18
|
+
* prompt the same way, a completed turn is complete.
|
|
19
|
+
* - THROW `CancelledFailure` when the workflow must see the activity as
|
|
20
|
+
* cancelled — the orchestrator's pause, the runner's own drain, and an
|
|
21
|
+
* infrastructure cancel it delivered — with the message the control
|
|
22
|
+
* planes recognise.
|
|
23
|
+
*
|
|
24
|
+
* An arm's rows are appended exactly once, by `applyTerminalArm`, and an arm
|
|
25
|
+
* is persisted exactly once, by `run-turn.ts`'s `settleWith` — the one
|
|
26
|
+
* writer of a terminal. The orchestrator this table replaced appended the
|
|
27
|
+
* three THROW arms' rows twice (its throw fell into its own catch, which
|
|
28
|
+
* wrote the copy again); S2 reproduced that on purpose so the goldens could
|
|
29
|
+
* pin the wire byte for byte, and the PR after S2 removed it with a reviewed
|
|
30
|
+
* golden regeneration (stigmer#1054, Q-S2-4).
|
|
31
|
+
*/
|
|
32
|
+
import type { AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
33
|
+
import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
34
|
+
import { type StallTimeoutError } from "../shared/stall-watchdog.js";
|
|
35
|
+
import type { WorkspaceLockTimeoutError } from "../shared/workspace/workspace-lock.js";
|
|
36
|
+
import type { FailureSurface } from "./types.js";
|
|
37
|
+
/** How the activity ends after the arm is written and persisted. */
|
|
38
|
+
export type TerminalDisposition = {
|
|
39
|
+
readonly kind: "return";
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "throw";
|
|
42
|
+
readonly message: string;
|
|
43
|
+
};
|
|
44
|
+
/** One arm of the table: what to write, and how to end. */
|
|
45
|
+
export interface TerminalArm {
|
|
46
|
+
readonly phase: ExecutionPhase;
|
|
47
|
+
/** `status.error`; absent leaves it as it is (a pause is not an error). */
|
|
48
|
+
readonly error?: string;
|
|
49
|
+
/** System rows appended in order, each exactly once. */
|
|
50
|
+
readonly rows: readonly string[];
|
|
51
|
+
/** Stamp `completedAt`; a paused turn is not complete. */
|
|
52
|
+
readonly completes: boolean;
|
|
53
|
+
readonly disposition: TerminalDisposition;
|
|
54
|
+
}
|
|
55
|
+
/** The fixed strings of the table, in one place. Every one is pinned by a golden or a hermetic assertion. */
|
|
56
|
+
export declare const TERMINAL_COPY: {
|
|
57
|
+
readonly pause: {
|
|
58
|
+
readonly row: "Execution paused by user. Use resume to continue.";
|
|
59
|
+
readonly throwMessage: "Activity paused by orchestrator";
|
|
60
|
+
readonly throwMessageAfterError: "Activity paused by orchestrator (error during pause)";
|
|
61
|
+
};
|
|
62
|
+
readonly workerShutdown: {
|
|
63
|
+
readonly error: "Execution interrupted: runner worker was shut down. Retry or resume.";
|
|
64
|
+
readonly row: "Execution interrupted: the runner worker was shut down while the agent was still running. You can retry or resume.";
|
|
65
|
+
readonly throwMessage: "Activity cancelled (worker shutdown, not user pause)";
|
|
66
|
+
};
|
|
67
|
+
readonly infrastructureCancel: {
|
|
68
|
+
readonly error: "Execution interrupted: agent was unresponsive (heartbeat timeout). Retry or resume.";
|
|
69
|
+
readonly row: "Execution interrupted: the agent was unresponsive for too long. You can retry or resume.";
|
|
70
|
+
readonly throwMessage: "Activity cancelled (heartbeat timeout, not user pause)";
|
|
71
|
+
readonly throwMessageAfterError: "Activity cancelled (infrastructure, not user pause)";
|
|
72
|
+
};
|
|
73
|
+
readonly platformStop: {
|
|
74
|
+
readonly row: "Execution stopped by the platform.";
|
|
75
|
+
};
|
|
76
|
+
readonly rejectedByUser: {
|
|
77
|
+
readonly error: "Execution rejected by user";
|
|
78
|
+
readonly row: "Execution was rejected by the user during tool approval.";
|
|
79
|
+
};
|
|
80
|
+
readonly fileReview: {
|
|
81
|
+
readonly applyFailedPrefix: "Some approved file changes could not be applied because the file changed after review: ";
|
|
82
|
+
readonly discardedPrefix: "Some proposed file changes were discarded by the user and were not applied: ";
|
|
83
|
+
};
|
|
84
|
+
readonly internalFailure: {
|
|
85
|
+
readonly row: "Internal system error occurred. Please contact support if this issue persists.";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** The watchdog cancelled a turn that made no progress. RETURN: an identical prompt would wedge again. */
|
|
89
|
+
export declare function stallArm(error: StallTimeoutError): TerminalArm;
|
|
90
|
+
/**
|
|
91
|
+
* The cost cap stopped the turn. TERMINATED, not FAILED: the platform
|
|
92
|
+
* deliberately stopped the run, work is checkpointed, and the conversation
|
|
93
|
+
* continues on the next message (the recursion-limit precedent in
|
|
94
|
+
* `execute-deep-agent/streaming-terminal.ts`). RETURN: a retry would burn
|
|
95
|
+
* the same budget again.
|
|
96
|
+
*/
|
|
97
|
+
export declare function costCapArm(maxCostUsd: number, estimatedCostUsd: number): TerminalArm;
|
|
98
|
+
/** The runner is draining. Not a user pause: FAILED with the shutdown copy, thrown as cancelled. */
|
|
99
|
+
export declare function workerShutdownArm(): TerminalArm;
|
|
100
|
+
/** The orchestrator paused the execution. Not an error, not complete; thrown as cancelled. */
|
|
101
|
+
export declare function pauseArm(): TerminalArm;
|
|
102
|
+
/** Temporal cancelled for its own reason (a heartbeat timeout). FAILED with the unresponsive copy, thrown as cancelled. */
|
|
103
|
+
export declare function infrastructureCancelArm(): TerminalArm;
|
|
104
|
+
/** The control plane answered STOP. A clean COMPLETED early exit. */
|
|
105
|
+
export declare function platformStopArm(): TerminalArm;
|
|
106
|
+
/** Another turn held the primary tree past the lock timeout. RETURN: a retry would queue behind the same holder. */
|
|
107
|
+
export declare function workspaceLockTimeoutArm(error: WorkspaceLockTimeoutError): TerminalArm;
|
|
108
|
+
/** An adjudicated irreversible action (shell / MCP) was REJECTed. */
|
|
109
|
+
export declare function rejectedByUserArm(): TerminalArm;
|
|
110
|
+
/**
|
|
111
|
+
* A pure file-review resume: the agent already finished its turn during
|
|
112
|
+
* capture, so keeping or discarding a change never re-prompts it
|
|
113
|
+
* (Cursor-like); the reconcile is the whole act and the execution is
|
|
114
|
+
* complete. A failed reconcile (what-you-approve-is-what-applies could not
|
|
115
|
+
* be honored) tells the human; a discard tells the human which files were
|
|
116
|
+
* reverted — the agent's native context still believes those edits stuck,
|
|
117
|
+
* and any edit it makes from that belief is re-surfaced next turn (the
|
|
118
|
+
* structural safety net; design-decisions/capture-reject-next-turn-resync-not-built.md).
|
|
119
|
+
*/
|
|
120
|
+
export declare function fileReviewResolvedArm(settlement: {
|
|
121
|
+
readonly failed: boolean;
|
|
122
|
+
readonly failureDetail: string;
|
|
123
|
+
readonly discardedPaths: readonly string[];
|
|
124
|
+
}): TerminalArm;
|
|
125
|
+
/**
|
|
126
|
+
* The adapter settled `failed`. The surface picks the copy (the three shapes
|
|
127
|
+
* the Cursor orchestrator wrote, `types.ts` `FailureSurface`); `message` is
|
|
128
|
+
* the adapter's user-facing sentence and becomes `status.error` whole.
|
|
129
|
+
*/
|
|
130
|
+
export declare function failedArm(message: string, surface: FailureSurface): TerminalArm;
|
|
131
|
+
/**
|
|
132
|
+
* An error the runtime caught itself, outside any adapter (a resolution
|
|
133
|
+
* phase, the epilogue): the boilerplate row and the described error as the
|
|
134
|
+
* details, with `status.error` carrying the `Execution failed:` prefix the
|
|
135
|
+
* orchestrator's generic arm always wrote (`describeExecutionError` supplies
|
|
136
|
+
* the two parts). The one arm whose `error` and details row differ, kept as
|
|
137
|
+
* it was because the resolution-error golden pins both.
|
|
138
|
+
*/
|
|
139
|
+
export declare function unexpectedErrorArm(errorType: string, errorMessage: string): TerminalArm;
|
|
140
|
+
/** Write an arm onto the status: phase, error, completion stamp, rows. The caller persists and disposes. */
|
|
141
|
+
export declare function applyTerminalArm(status: AgentExecutionStatus, arm: TerminalArm): void;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The terminal table: every way a turn ends, as data — the phase it writes,
|
|
3
|
+
* the `error` it sets, the system rows it appends, whether it stamps
|
|
4
|
+
* `completedAt`, and whether the activity RETURNS the slim status or THROWS
|
|
5
|
+
* a `CancelledFailure` — with one function that applies an arm to a status.
|
|
6
|
+
*
|
|
7
|
+
* Why data and not one function per arm: the copy is the user-facing
|
|
8
|
+
* contract of the runner (the hermetic goldens pin every string below byte
|
|
9
|
+
* for byte, `activities/execute-cursor/__tests__/hermetic/`), and a table a
|
|
10
|
+
* reader can scan is how that contract stays reviewable. The native
|
|
11
|
+
* harness's `execute-deep-agent/streaming-terminal.ts` keeps one function
|
|
12
|
+
* per arm; S3 aligns the two (P-1's copy alignment) with both in view.
|
|
13
|
+
*
|
|
14
|
+
* The throw-vs-return rule, unchanged from the orchestrator it replaces:
|
|
15
|
+
* - RETURN when a Temporal retry would only repeat the outcome — a stall
|
|
16
|
+
* would wedge again, an exhausted budget would burn again, a platform
|
|
17
|
+
* stop is the platform's decision, a failed engine would fail the same
|
|
18
|
+
* prompt the same way, a completed turn is complete.
|
|
19
|
+
* - THROW `CancelledFailure` when the workflow must see the activity as
|
|
20
|
+
* cancelled — the orchestrator's pause, the runner's own drain, and an
|
|
21
|
+
* infrastructure cancel it delivered — with the message the control
|
|
22
|
+
* planes recognise.
|
|
23
|
+
*
|
|
24
|
+
* An arm's rows are appended exactly once, by `applyTerminalArm`, and an arm
|
|
25
|
+
* is persisted exactly once, by `run-turn.ts`'s `settleWith` — the one
|
|
26
|
+
* writer of a terminal. The orchestrator this table replaced appended the
|
|
27
|
+
* three THROW arms' rows twice (its throw fell into its own catch, which
|
|
28
|
+
* wrote the copy again); S2 reproduced that on purpose so the goldens could
|
|
29
|
+
* pin the wire byte for byte, and the PR after S2 removed it with a reviewed
|
|
30
|
+
* golden regeneration (stigmer#1054, Q-S2-4).
|
|
31
|
+
*/
|
|
32
|
+
import { create } from "@bufbuild/protobuf";
|
|
33
|
+
import { AgentMessageSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
|
|
34
|
+
import { ExecutionPhase, MessageType } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
35
|
+
import { COST_LIMIT_USER_COPY, formatCostLimitError } from "../shared/cost-guard.js";
|
|
36
|
+
import { formatStallFailure } from "../shared/stall-watchdog.js";
|
|
37
|
+
import { utcTimestamp } from "../shared/status.js";
|
|
38
|
+
const RETURN = { kind: "return" };
|
|
39
|
+
/** The fixed strings of the table, in one place. Every one is pinned by a golden or a hermetic assertion. */
|
|
40
|
+
export const TERMINAL_COPY = {
|
|
41
|
+
pause: {
|
|
42
|
+
row: "Execution paused by user. Use resume to continue.",
|
|
43
|
+
throwMessage: "Activity paused by orchestrator",
|
|
44
|
+
throwMessageAfterError: "Activity paused by orchestrator (error during pause)",
|
|
45
|
+
},
|
|
46
|
+
workerShutdown: {
|
|
47
|
+
error: "Execution interrupted: runner worker was shut down. Retry or resume.",
|
|
48
|
+
row: "Execution interrupted: the runner worker was shut down while the agent was still running. You can retry or resume.",
|
|
49
|
+
throwMessage: "Activity cancelled (worker shutdown, not user pause)",
|
|
50
|
+
},
|
|
51
|
+
infrastructureCancel: {
|
|
52
|
+
error: "Execution interrupted: agent was unresponsive (heartbeat timeout). Retry or resume.",
|
|
53
|
+
row: "Execution interrupted: the agent was unresponsive for too long. You can retry or resume.",
|
|
54
|
+
throwMessage: "Activity cancelled (heartbeat timeout, not user pause)",
|
|
55
|
+
throwMessageAfterError: "Activity cancelled (infrastructure, not user pause)",
|
|
56
|
+
},
|
|
57
|
+
platformStop: {
|
|
58
|
+
row: "Execution stopped by the platform.",
|
|
59
|
+
},
|
|
60
|
+
rejectedByUser: {
|
|
61
|
+
error: "Execution rejected by user",
|
|
62
|
+
row: "Execution was rejected by the user during tool approval.",
|
|
63
|
+
},
|
|
64
|
+
fileReview: {
|
|
65
|
+
applyFailedPrefix: "Some approved file changes could not be applied because the file changed after review: ",
|
|
66
|
+
discardedPrefix: "Some proposed file changes were discarded by the user and were not applied: ",
|
|
67
|
+
},
|
|
68
|
+
internalFailure: {
|
|
69
|
+
row: "Internal system error occurred. Please contact support if this issue persists.",
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
// ── The arms ────────────────────────────────────────────────────────────────
|
|
73
|
+
/** The watchdog cancelled a turn that made no progress. RETURN: an identical prompt would wedge again. */
|
|
74
|
+
export function stallArm(error) {
|
|
75
|
+
return {
|
|
76
|
+
phase: ExecutionPhase.EXECUTION_FAILED,
|
|
77
|
+
error: formatStallFailure(error),
|
|
78
|
+
rows: [
|
|
79
|
+
`Execution failed: the agent made no progress for too long and was stopped (${error.message}). You can retry or resume.`,
|
|
80
|
+
],
|
|
81
|
+
completes: true,
|
|
82
|
+
disposition: RETURN,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The cost cap stopped the turn. TERMINATED, not FAILED: the platform
|
|
87
|
+
* deliberately stopped the run, work is checkpointed, and the conversation
|
|
88
|
+
* continues on the next message (the recursion-limit precedent in
|
|
89
|
+
* `execute-deep-agent/streaming-terminal.ts`). RETURN: a retry would burn
|
|
90
|
+
* the same budget again.
|
|
91
|
+
*/
|
|
92
|
+
export function costCapArm(maxCostUsd, estimatedCostUsd) {
|
|
93
|
+
return {
|
|
94
|
+
phase: ExecutionPhase.EXECUTION_TERMINATED,
|
|
95
|
+
error: formatCostLimitError(maxCostUsd, estimatedCostUsd),
|
|
96
|
+
rows: [COST_LIMIT_USER_COPY],
|
|
97
|
+
completes: true,
|
|
98
|
+
disposition: RETURN,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** The runner is draining. Not a user pause: FAILED with the shutdown copy, thrown as cancelled. */
|
|
102
|
+
export function workerShutdownArm() {
|
|
103
|
+
return {
|
|
104
|
+
phase: ExecutionPhase.EXECUTION_FAILED,
|
|
105
|
+
error: TERMINAL_COPY.workerShutdown.error,
|
|
106
|
+
rows: [TERMINAL_COPY.workerShutdown.row],
|
|
107
|
+
completes: true,
|
|
108
|
+
disposition: { kind: "throw", message: TERMINAL_COPY.workerShutdown.throwMessage },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** The orchestrator paused the execution. Not an error, not complete; thrown as cancelled. */
|
|
112
|
+
export function pauseArm() {
|
|
113
|
+
return {
|
|
114
|
+
phase: ExecutionPhase.EXECUTION_PAUSED,
|
|
115
|
+
rows: [TERMINAL_COPY.pause.row],
|
|
116
|
+
completes: false,
|
|
117
|
+
disposition: { kind: "throw", message: TERMINAL_COPY.pause.throwMessage },
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** Temporal cancelled for its own reason (a heartbeat timeout). FAILED with the unresponsive copy, thrown as cancelled. */
|
|
121
|
+
export function infrastructureCancelArm() {
|
|
122
|
+
return {
|
|
123
|
+
phase: ExecutionPhase.EXECUTION_FAILED,
|
|
124
|
+
error: TERMINAL_COPY.infrastructureCancel.error,
|
|
125
|
+
rows: [TERMINAL_COPY.infrastructureCancel.row],
|
|
126
|
+
completes: true,
|
|
127
|
+
disposition: { kind: "throw", message: TERMINAL_COPY.infrastructureCancel.throwMessage },
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** The control plane answered STOP. A clean COMPLETED early exit. */
|
|
131
|
+
export function platformStopArm() {
|
|
132
|
+
return {
|
|
133
|
+
phase: ExecutionPhase.EXECUTION_COMPLETED,
|
|
134
|
+
rows: [TERMINAL_COPY.platformStop.row],
|
|
135
|
+
completes: true,
|
|
136
|
+
disposition: RETURN,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/** Another turn held the primary tree past the lock timeout. RETURN: a retry would queue behind the same holder. */
|
|
140
|
+
export function workspaceLockTimeoutArm(error) {
|
|
141
|
+
return {
|
|
142
|
+
phase: ExecutionPhase.EXECUTION_FAILED,
|
|
143
|
+
error: error.message,
|
|
144
|
+
rows: [`Execution failed: ${error.message}`],
|
|
145
|
+
completes: true,
|
|
146
|
+
disposition: RETURN,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** An adjudicated irreversible action (shell / MCP) was REJECTed. */
|
|
150
|
+
export function rejectedByUserArm() {
|
|
151
|
+
return {
|
|
152
|
+
phase: ExecutionPhase.EXECUTION_FAILED,
|
|
153
|
+
error: TERMINAL_COPY.rejectedByUser.error,
|
|
154
|
+
rows: [TERMINAL_COPY.rejectedByUser.row],
|
|
155
|
+
completes: true,
|
|
156
|
+
disposition: RETURN,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* A pure file-review resume: the agent already finished its turn during
|
|
161
|
+
* capture, so keeping or discarding a change never re-prompts it
|
|
162
|
+
* (Cursor-like); the reconcile is the whole act and the execution is
|
|
163
|
+
* complete. A failed reconcile (what-you-approve-is-what-applies could not
|
|
164
|
+
* be honored) tells the human; a discard tells the human which files were
|
|
165
|
+
* reverted — the agent's native context still believes those edits stuck,
|
|
166
|
+
* and any edit it makes from that belief is re-surfaced next turn (the
|
|
167
|
+
* structural safety net; design-decisions/capture-reject-next-turn-resync-not-built.md).
|
|
168
|
+
*/
|
|
169
|
+
export function fileReviewResolvedArm(settlement) {
|
|
170
|
+
const rows = [];
|
|
171
|
+
if (settlement.failed) {
|
|
172
|
+
rows.push(`${TERMINAL_COPY.fileReview.applyFailedPrefix}${settlement.failureDetail}.`);
|
|
173
|
+
}
|
|
174
|
+
else if (settlement.discardedPaths.length > 0) {
|
|
175
|
+
rows.push(`${TERMINAL_COPY.fileReview.discardedPrefix}${settlement.discardedPaths.join(", ")}.`);
|
|
176
|
+
}
|
|
177
|
+
return { phase: ExecutionPhase.EXECUTION_COMPLETED, rows, completes: true, disposition: RETURN };
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The adapter settled `failed`. The surface picks the copy (the three shapes
|
|
181
|
+
* the Cursor orchestrator wrote, `types.ts` `FailureSurface`); `message` is
|
|
182
|
+
* the adapter's user-facing sentence and becomes `status.error` whole.
|
|
183
|
+
*/
|
|
184
|
+
export function failedArm(message, surface) {
|
|
185
|
+
const rows = (() => {
|
|
186
|
+
switch (surface) {
|
|
187
|
+
case "engine":
|
|
188
|
+
return [];
|
|
189
|
+
case "actionable":
|
|
190
|
+
return [`Execution failed: ${message}`];
|
|
191
|
+
case "internal":
|
|
192
|
+
return [TERMINAL_COPY.internalFailure.row, `Error details: ${message}`];
|
|
193
|
+
default: {
|
|
194
|
+
const exhaustive = surface;
|
|
195
|
+
throw new Error(`terminal table: unknown failure surface ${String(exhaustive)}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
})();
|
|
199
|
+
return { phase: ExecutionPhase.EXECUTION_FAILED, error: message, rows, completes: true, disposition: RETURN };
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* An error the runtime caught itself, outside any adapter (a resolution
|
|
203
|
+
* phase, the epilogue): the boilerplate row and the described error as the
|
|
204
|
+
* details, with `status.error` carrying the `Execution failed:` prefix the
|
|
205
|
+
* orchestrator's generic arm always wrote (`describeExecutionError` supplies
|
|
206
|
+
* the two parts). The one arm whose `error` and details row differ, kept as
|
|
207
|
+
* it was because the resolution-error golden pins both.
|
|
208
|
+
*/
|
|
209
|
+
export function unexpectedErrorArm(errorType, errorMessage) {
|
|
210
|
+
const described = `[${errorType}] ${errorMessage}`;
|
|
211
|
+
return {
|
|
212
|
+
phase: ExecutionPhase.EXECUTION_FAILED,
|
|
213
|
+
error: `Execution failed: ${described}`,
|
|
214
|
+
rows: [TERMINAL_COPY.internalFailure.row, `Error details: ${described}`],
|
|
215
|
+
completes: true,
|
|
216
|
+
disposition: RETURN,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
// ── Applying an arm ─────────────────────────────────────────────────────────
|
|
220
|
+
/**
|
|
221
|
+
* Append system rows, each with its own timestamp, in order. Module-private
|
|
222
|
+
* on purpose: rows reach a status only through `applyTerminalArm`, so no
|
|
223
|
+
* caller can append an arm's copy a second time (the shape of stigmer#1054).
|
|
224
|
+
*/
|
|
225
|
+
function appendSystemRows(status, rows) {
|
|
226
|
+
for (const content of rows) {
|
|
227
|
+
status.messages.push(create(AgentMessageSchema, { type: MessageType.MESSAGE_SYSTEM, content, timestamp: utcTimestamp() }));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/** Write an arm onto the status: phase, error, completion stamp, rows. The caller persists and disposes. */
|
|
231
|
+
export function applyTerminalArm(status, arm) {
|
|
232
|
+
status.phase = arm.phase;
|
|
233
|
+
if (arm.error !== undefined)
|
|
234
|
+
status.error = arm.error;
|
|
235
|
+
if (arm.completes)
|
|
236
|
+
status.completedAt = utcTimestamp();
|
|
237
|
+
appendSystemRows(status, arm.rows);
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=terminal-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-table.js","sourceRoot":"","sources":["../../src/harness/terminal-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iEAAiE,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAE3G,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAA0B,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAmBnD,MAAM,MAAM,GAAwB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAEvD,6GAA6G;AAC7G,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE;QACL,GAAG,EAAE,mDAAmD;QACxD,YAAY,EAAE,iCAAiC;QAC/C,sBAAsB,EAAE,sDAAsD;KAC/E;IACD,cAAc,EAAE;QACd,KAAK,EAAE,sEAAsE;QAC7E,GAAG,EAAE,oHAAoH;QACzH,YAAY,EAAE,sDAAsD;KACrE;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,qFAAqF;QAC5F,GAAG,EAAE,0FAA0F;QAC/F,YAAY,EAAE,wDAAwD;QACtE,sBAAsB,EAAE,qDAAqD;KAC9E;IACD,YAAY,EAAE;QACZ,GAAG,EAAE,oCAAoC;KAC1C;IACD,cAAc,EAAE;QACd,KAAK,EAAE,4BAA4B;QACnC,GAAG,EAAE,0DAA0D;KAChE;IACD,UAAU,EAAE;QACV,iBAAiB,EAAE,yFAAyF;QAC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