@stigmer/runner 3.15.3-dev.20260914100347 → 3.15.3-dev.20260916211208
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/README.md +1 -0
- package/dist/.build-fingerprint +1 -1
- package/dist/__test-utils__/approval-contract/types.d.ts +1 -1
- package/dist/__test-utils__/hermetic-activity.d.ts +61 -7
- package/dist/__test-utils__/hermetic-activity.js +100 -9
- package/dist/__test-utils__/hermetic-activity.js.map +1 -1
- package/dist/__test-utils__/model-registry-fixture.d.ts +22 -3
- package/dist/__test-utils__/model-registry-fixture.js +22 -7
- package/dist/__test-utils__/model-registry-fixture.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.d.ts +2 -2
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +14 -11
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/fold.d.ts +61 -0
- package/dist/activities/execute-cursor/__test-utils__/fold.js +94 -0
- package/dist/activities/execute-cursor/__test-utils__/fold.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +1 -1
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +52 -14
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +46 -12
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +21 -28
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +27 -11
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +70 -26
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +82 -32
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -1
- package/dist/activities/execute-cursor/adapter.d.ts +8 -7
- package/dist/activities/execute-cursor/adapter.js +13 -9
- package/dist/activities/execute-cursor/adapter.js.map +1 -1
- package/dist/activities/execute-cursor/approval-policy.d.ts +10 -10
- package/dist/activities/execute-cursor/approval-policy.js +12 -23
- package/dist/activities/execute-cursor/approval-policy.js.map +1 -1
- package/dist/activities/execute-cursor/approval-state.d.ts +35 -1
- package/dist/activities/execute-cursor/approval-state.js +65 -0
- package/dist/activities/execute-cursor/approval-state.js.map +1 -1
- package/dist/activities/execute-cursor/{message-translator.d.ts → boundary-rows.d.ts} +45 -341
- package/dist/activities/execute-cursor/boundary-rows.js +1018 -0
- package/dist/activities/execute-cursor/boundary-rows.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-capabilities.d.ts +1 -1
- package/dist/activities/execute-cursor/cursor-capabilities.js +1 -1
- package/dist/activities/execute-cursor/cursor-event-recorder.d.ts +33 -14
- package/dist/activities/execute-cursor/cursor-event-recorder.js +43 -21
- package/dist/activities/execute-cursor/cursor-event-recorder.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +3 -3
- package/dist/activities/execute-cursor/prompt-builder.js +4 -4
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-cursor/sdk-warmup.d.ts +15 -6
- package/dist/activities/execute-cursor/sdk-warmup.js +15 -6
- package/dist/activities/execute-cursor/sdk-warmup.js.map +1 -1
- package/dist/activities/execute-cursor/service-tier.js +1 -2
- package/dist/activities/execute-cursor/service-tier.js.map +1 -1
- package/dist/activities/execute-cursor/session-lifecycle.d.ts +38 -59
- package/dist/activities/execute-cursor/session-lifecycle.js +59 -96
- package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -1
- package/dist/activities/execute-cursor/session-store.d.ts +100 -0
- package/dist/activities/execute-cursor/session-store.js +157 -0
- package/dist/activities/execute-cursor/session-store.js.map +1 -0
- package/dist/activities/execute-cursor/sub-agent-steps.d.ts +79 -0
- package/dist/activities/execute-cursor/sub-agent-steps.js +180 -0
- package/dist/activities/execute-cursor/sub-agent-steps.js.map +1 -0
- package/dist/activities/execute-cursor/tool-result.d.ts +49 -0
- package/dist/activities/execute-cursor/tool-result.js +130 -0
- package/dist/activities/execute-cursor/tool-result.js.map +1 -0
- package/dist/activities/execute-cursor/translator.d.ts +178 -0
- package/dist/activities/execute-cursor/translator.js +485 -0
- package/dist/activities/execute-cursor/translator.js.map +1 -0
- package/dist/activities/execute-cursor/turn-boundary.d.ts +15 -5
- package/dist/activities/execute-cursor/turn-boundary.js +10 -14
- package/dist/activities/execute-cursor/turn-boundary.js.map +1 -1
- package/dist/activities/execute-cursor/turn-settle.d.ts +11 -7
- package/dist/activities/execute-cursor/turn-settle.js +47 -34
- package/dist/activities/execute-cursor/turn-settle.js.map +1 -1
- package/dist/activities/execute-cursor/turn-setup.d.ts +2 -2
- package/dist/activities/execute-cursor/turn-setup.js +5 -5
- package/dist/activities/execute-cursor/turn-setup.js.map +1 -1
- package/dist/activities/execute-cursor/turn-stream.d.ts +23 -14
- package/dist/activities/execute-cursor/turn-stream.js +41 -28
- package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
- package/dist/activities/execute-cursor/turn.d.ts +4 -4
- package/dist/activities/execute-cursor/turn.js +5 -5
- package/dist/activities/execute-cursor/usage-pricing.d.ts +2 -2
- package/dist/activities/execute-cursor/usage-pricing.js +2 -2
- package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.d.ts +2 -2
- package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js +2 -2
- package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.d.ts +16 -11
- package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js +22 -10
- package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js.map +1 -1
- package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js +1 -1
- package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js.map +1 -1
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.d.ts +2 -3
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js +2 -3
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js.map +1 -1
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.d.ts +12 -3
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js +18 -4
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js.map +1 -1
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.d.ts +10 -1
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js +24 -11
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js.map +1 -1
- package/dist/activities/execute-deep-agent/adapter.d.ts +1 -1
- package/dist/activities/execute-deep-agent/adapter.js +1 -1
- package/dist/activities/execute-deep-agent/approval-file-change.d.ts +19 -19
- package/dist/activities/execute-deep-agent/approval-file-change.js +16 -15
- package/dist/activities/execute-deep-agent/approval-file-change.js.map +1 -1
- package/dist/activities/execute-deep-agent/deep-agent-capabilities.d.ts +2 -2
- package/dist/activities/execute-deep-agent/deep-agent-capabilities.js +2 -2
- package/dist/activities/execute-deep-agent/hitl.d.ts +2 -2
- package/dist/activities/execute-deep-agent/hitl.js +2 -2
- package/dist/activities/execute-deep-agent/inline-publisher.d.ts +13 -3
- package/dist/activities/execute-deep-agent/inline-publisher.js +3 -3
- package/dist/activities/execute-deep-agent/inline-publisher.js.map +1 -1
- package/dist/activities/execute-deep-agent/prompt-builder.d.ts +3 -3
- package/dist/activities/execute-deep-agent/prompt-builder.js +6 -7
- package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/streaming-side-effects.d.ts +16 -8
- package/dist/activities/execute-deep-agent/streaming-side-effects.js +20 -33
- package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +3 -3
- package/dist/activities/execute-deep-agent/subagent-transformer.js +1 -1
- package/dist/activities/execute-deep-agent/translator.d.ts +134 -0
- package/dist/activities/execute-deep-agent/translator.js +418 -0
- package/dist/activities/execute-deep-agent/translator.js.map +1 -0
- package/dist/activities/execute-deep-agent/turn-settle.d.ts +13 -7
- package/dist/activities/execute-deep-agent/turn-settle.js +34 -45
- package/dist/activities/execute-deep-agent/turn-settle.js.map +1 -1
- package/dist/activities/execute-deep-agent/turn-setup.d.ts +8 -8
- package/dist/activities/execute-deep-agent/turn-setup.js +7 -7
- package/dist/activities/execute-deep-agent/turn-stream.d.ts +13 -10
- package/dist/activities/execute-deep-agent/turn-stream.js +44 -41
- package/dist/activities/execute-deep-agent/turn-stream.js.map +1 -1
- package/dist/activities/execute-deep-agent/turn.d.ts +3 -3
- package/dist/activities/execute-deep-agent/turn.js +3 -3
- package/dist/config.d.ts +2 -2
- package/dist/harness/approval-decisions.d.ts +1 -1
- package/dist/harness/approval-decisions.js +1 -1
- package/dist/harness/capabilities.d.ts +21 -11
- package/dist/harness/capabilities.js +2 -2
- package/dist/harness/capture.d.ts +4 -4
- package/dist/harness/capture.js +4 -4
- package/dist/harness/persist-chokepoint.d.ts +3 -3
- package/dist/harness/persist-chokepoint.js +3 -3
- package/dist/harness/registry.d.ts +2 -2
- package/dist/harness/registry.js +2 -2
- package/dist/harness/run-turn.d.ts +6 -4
- package/dist/harness/run-turn.js +31 -9
- package/dist/harness/run-turn.js.map +1 -1
- package/dist/harness/stop-controller.d.ts +1 -1
- package/dist/harness/stop-controller.js +1 -1
- package/dist/harness/terminal-table.d.ts +7 -7
- package/dist/harness/terminal-table.js +7 -7
- package/dist/harness/transcript/builder.d.ts +182 -0
- package/dist/harness/transcript/builder.js +693 -0
- package/dist/harness/transcript/builder.js.map +1 -0
- package/dist/harness/transcript/events.d.ts +218 -0
- package/dist/harness/transcript/events.js +50 -0
- package/dist/harness/transcript/events.js.map +1 -0
- package/dist/harness/transcript/state.d.ts +110 -0
- package/dist/harness/transcript/state.js +148 -0
- package/dist/harness/transcript/state.js.map +1 -0
- package/dist/harness/turn-context.d.ts +54 -38
- package/dist/harness/turn-context.js +42 -43
- package/dist/harness/turn-context.js.map +1 -1
- package/dist/harness/types.d.ts +63 -22
- package/dist/harness/types.js +12 -11
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/usage-accumulator.d.ts +2 -2
- package/dist/harness/usage-accumulator.js +2 -2
- package/dist/harness-adapters.d.ts +5 -4
- package/dist/harness-adapters.js +5 -4
- package/dist/harness-adapters.js.map +1 -1
- package/dist/middleware/approval-gate.d.ts +6 -0
- package/dist/middleware/approval-gate.js +7 -57
- package/dist/middleware/approval-gate.js.map +1 -1
- package/dist/middleware/cost-advisory.d.ts +3 -3
- package/dist/middleware/cost-advisory.js +3 -3
- package/dist/middleware/index.d.ts +1 -1
- package/dist/middleware/index.js +1 -1
- package/dist/runner-manager.js +1 -1
- package/dist/runner-manager.js.map +1 -1
- package/dist/shared/approval-policy.d.ts +53 -0
- package/dist/shared/approval-policy.js +76 -0
- package/dist/shared/approval-policy.js.map +1 -1
- package/dist/shared/args-preview.d.ts +45 -22
- package/dist/shared/args-preview.js +51 -41
- package/dist/shared/args-preview.js.map +1 -1
- package/dist/shared/attachment-resolver.d.ts +4 -4
- package/dist/shared/attachment-resolver.js +4 -4
- package/dist/shared/attachment-vision.d.ts +2 -1
- package/dist/shared/attachment-vision.js.map +1 -1
- package/dist/shared/attachment-zip.d.ts +2 -2
- package/dist/shared/attachment-zip.js +2 -2
- package/dist/shared/cost-guard.d.ts +2 -2
- package/dist/shared/cost-guard.js +2 -2
- package/dist/shared/exact-apply.d.ts +1 -1
- package/dist/shared/exact-apply.js +1 -1
- package/dist/shared/execution-context.d.ts +2 -2
- package/dist/shared/execution-context.js +2 -2
- package/dist/shared/extract-structured-output.d.ts +2 -2
- package/dist/shared/extract-structured-output.js +2 -2
- package/dist/shared/filereview/cas-touched.d.ts +2 -2
- package/dist/shared/filereview/cas-touched.js +2 -2
- package/dist/shared/heartbeat.d.ts +1 -1
- package/dist/shared/heartbeat.js +1 -1
- package/dist/shared/llm-backend.d.ts +0 -4
- package/dist/shared/llm-backend.js +0 -4
- package/dist/shared/llm-backend.js.map +1 -1
- package/dist/shared/model-error.d.ts +1 -2
- package/dist/shared/model-error.js +1 -2
- package/dist/shared/model-error.js.map +1 -1
- package/dist/shared/persist-decision.d.ts +18 -24
- package/dist/shared/persist-decision.js +19 -11
- package/dist/shared/persist-decision.js.map +1 -1
- package/dist/shared/prompt-sections.d.ts +4 -4
- package/dist/shared/prompt-sections.js +4 -4
- package/dist/shared/skill-resolver.d.ts +3 -3
- package/dist/shared/skill-resolver.js +3 -3
- package/dist/shared/status-offload.d.ts +1 -1
- package/dist/shared/status-offload.js +2 -2
- package/dist/shared/status-offload.js.map +1 -1
- package/dist/shared/streaming-scheduler.d.ts +2 -7
- package/dist/shared/streaming-scheduler.js +6 -14
- package/dist/shared/streaming-scheduler.js.map +1 -1
- package/dist/shared/subagent-rows.d.ts +2 -2
- package/dist/shared/subagent-rows.js +2 -2
- package/dist/shared/todos.d.ts +3 -3
- package/dist/shared/todos.js +3 -3
- package/dist/shared/tool-row.d.ts +19 -1
- package/dist/shared/tool-row.js +36 -2
- package/dist/shared/tool-row.js.map +1 -1
- package/dist/shared/worker-shutdown.d.ts +1 -1
- package/dist/shared/worker-shutdown.js +1 -1
- package/dist/shared/workspace/session-provision.d.ts +1 -1
- package/dist/shared/workspace/session-provision.js +1 -1
- package/dist/shared/workspace/sources/empty.d.ts +1 -1
- package/dist/shared/workspace/sources/empty.js +1 -2
- package/dist/shared/workspace/sources/empty.js.map +1 -1
- package/dist/shared/workspace/sources/git.js +4 -4
- package/dist/shared/workspace/sources/git.js.map +1 -1
- package/dist/shared/workspace/sources/local-path.js +6 -6
- package/dist/shared/workspace/sources/local-path.js.map +1 -1
- package/dist/shared/workspace/stigmer-link.d.ts +1 -1
- package/dist/shared/workspace/stigmer-link.js +1 -1
- package/dist/shared/workspace/types.d.ts +2 -5
- package/dist/shared/workspace/types.js +0 -6
- package/dist/shared/workspace/types.js.map +1 -1
- package/dist/shared/workspace/writeback-coordinator.d.ts +17 -4
- package/dist/shared/workspace/writeback-coordinator.js +7 -9
- package/dist/shared/workspace/writeback-coordinator.js.map +1 -1
- package/package.json +5 -5
- package/src/__test-utils__/__tests__/execution-record-barrier.test.ts +70 -0
- package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +35 -1
- package/src/__test-utils__/approval-contract/contract.ts +1 -1
- package/src/__test-utils__/approval-contract/types.ts +1 -1
- package/src/__test-utils__/harness-boot-order-child.ts +1 -1
- package/src/__test-utils__/harness-contract/contract.ts +8 -8
- package/src/__test-utils__/harness-contract/recording-sink.ts +11 -1
- package/src/__test-utils__/harness-contract/runtime-contract.ts +52 -16
- package/src/__test-utils__/harness-contract/scripted-adapter.ts +47 -43
- package/src/__test-utils__/hermetic-activity.ts +113 -9
- package/src/__test-utils__/model-registry-fixture.ts +31 -7
- package/src/__test-utils__/module-specifiers.ts +32 -3
- package/src/__tests__/harness-boot-order.test.ts +1 -1
- package/src/__tests__/harness-contract.test.ts +1 -1
- package/src/__tests__/runner-manager.test.ts +1 -1
- package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +32 -8
- package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +12 -10
- package/src/activities/execute-cursor/__test-utils__/fold.ts +116 -0
- package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +1 -1
- package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +72 -19
- package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +35 -29
- package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +94 -38
- package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +2 -1
- package/src/activities/execute-cursor/__tests__/approval-state.test.ts +14 -21
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +3 -3
- package/src/activities/execute-cursor/__tests__/coarse-fingerprint.test.ts +2 -1
- package/src/activities/execute-cursor/__tests__/cursor-baseurl-routing.test.ts +10 -8
- package/src/activities/execute-cursor/__tests__/cursor-event-recorder.test.ts +142 -0
- package/src/activities/execute-cursor/__tests__/cursor-fetch-interceptor-bypass.test.ts +24 -12
- package/src/activities/execute-cursor/__tests__/cursor-generate-image-live.test.ts +7 -2
- package/src/activities/execute-cursor/__tests__/cursor-hook-protocol-live.test.ts +163 -0
- package/src/activities/execute-cursor/__tests__/cursor-sdk-auth-smoke.test.ts +23 -20
- package/src/activities/execute-cursor/__tests__/cursor-transcript-live.test.ts +298 -0
- package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +4 -2
- package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +5 -2
- package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +5 -2
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/mcp-tool-call.status.json +71 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-task-note.status.json +73 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.error-delta.status.json +78 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.output-first.status.json +72 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.status.json +72 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sub-agent-delegation.status.json +109 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/thinking-turn.status.json +78 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/todo-write.status.json +119 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-error.status.json +68 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-only-step.status.json +67 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.status.json +1 -1
- package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +10 -7
- package/src/activities/execute-cursor/__tests__/hermetic/mcp-tool-call.test.ts +146 -0
- package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +8 -5
- package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +6 -2
- package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +4 -1
- package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +6 -2
- package/src/activities/execute-cursor/__tests__/hermetic/sdk-task-note.test.ts +122 -0
- package/src/activities/execute-cursor/__tests__/hermetic/shell-output-delta.test.ts +276 -0
- package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +12 -9
- package/src/activities/execute-cursor/__tests__/hermetic/sub-agent-delegation.test.ts +196 -0
- package/src/activities/execute-cursor/__tests__/hermetic/thinking-turn.test.ts +145 -0
- package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +4 -1
- package/src/activities/execute-cursor/__tests__/hermetic/todo-write.test.ts +165 -0
- package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +7 -4
- package/src/activities/execute-cursor/__tests__/hermetic/tool-error.test.ts +138 -0
- package/src/activities/execute-cursor/__tests__/hermetic/tool-only-step.test.ts +130 -0
- package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +17 -2
- package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +5 -2
- package/src/activities/execute-cursor/__tests__/hitl-ledger.test.ts +43 -60
- package/src/activities/execute-cursor/__tests__/hitl-resume-history.test.ts +23 -28
- package/src/activities/execute-cursor/__tests__/hook-script.test.ts +2 -1
- package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/prompt-goldens.test.ts +5 -5
- package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +11 -13
- package/src/activities/execute-cursor/__tests__/sequential-gate-resume.test.ts +8 -11
- package/src/activities/execute-cursor/__tests__/session-lifecycle.test.ts +86 -58
- package/src/activities/execute-cursor/__tests__/session-store.test.ts +220 -0
- package/src/activities/execute-cursor/__tests__/tool-result-image.test.ts +8 -22
- package/src/activities/execute-cursor/__tests__/translator.test.ts +594 -0
- package/src/activities/execute-cursor/__tests__/turn-boundary.test.ts +8 -5
- package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +87 -63
- package/src/activities/execute-cursor/adapter.ts +13 -9
- package/src/activities/execute-cursor/approval-policy.ts +12 -24
- package/src/activities/execute-cursor/approval-state.ts +66 -1
- package/src/activities/execute-cursor/boundary-rows.ts +1132 -0
- package/src/activities/execute-cursor/cursor-capabilities.ts +1 -1
- package/src/activities/execute-cursor/cursor-event-recorder.ts +57 -28
- package/src/activities/execute-cursor/fetch-interceptor.ts +1 -1
- package/src/activities/execute-cursor/http2-interceptor.ts +1 -1
- package/src/activities/execute-cursor/prompt-builder.ts +6 -6
- package/src/activities/execute-cursor/sdk-warmup.ts +15 -6
- package/src/activities/execute-cursor/service-tier.ts +1 -2
- package/src/activities/execute-cursor/session-lifecycle.ts +63 -109
- package/src/activities/execute-cursor/session-store.ts +187 -0
- package/src/activities/execute-cursor/sub-agent-steps.ts +188 -0
- package/src/activities/execute-cursor/tool-result.ts +128 -0
- package/src/activities/execute-cursor/translator.ts +541 -0
- package/src/activities/execute-cursor/turn-boundary.ts +21 -14
- package/src/activities/execute-cursor/turn-settle.ts +46 -34
- package/src/activities/execute-cursor/turn-setup.ts +5 -5
- package/src/activities/execute-cursor/turn-stream.ts +49 -46
- package/src/activities/execute-cursor/turn.ts +5 -5
- package/src/activities/execute-cursor/usage-pricing.ts +2 -2
- package/src/activities/execute-deep-agent/__test-utils__/contract-subject.ts +2 -2
- package/src/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.ts +23 -11
- package/src/activities/execute-deep-agent/__test-utils__/hitl-script.ts +1 -1
- package/src/activities/execute-deep-agent/__test-utils__/scripted-model-module.ts +2 -3
- package/src/activities/execute-deep-agent/__test-utils__/scripted-model.ts +25 -4
- package/src/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.ts +25 -11
- package/src/activities/execute-deep-agent/__tests__/adapter-graph-is-sdk-free.test.ts +1 -1
- package/src/activities/execute-deep-agent/__tests__/adapter-is-temporal-free.test.ts +1 -1
- package/src/activities/execute-deep-agent/__tests__/approval-file-change.test.ts +6 -17
- package/src/activities/execute-deep-agent/__tests__/hermetic/file-review-capture.test.ts +25 -8
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.status.json +2 -7
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.status.json +4 -14
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.status.json +1 -5
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.status.json +4 -7
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.status.json +1 -5
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.status.json +2 -9
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.status.json +2 -9
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.status.json +1 -4
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.status.json +1 -4
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.status.json +1 -4
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.status.json +109 -76
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.status.json +1 -5
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.status.json +2 -10
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.status.json +2 -10
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.status.json +1 -5
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.status.json +3 -6
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.status.json +1 -4
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.status.json +1 -4
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/write-todos.status.json +92 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/harness-contract.test.ts +3 -3
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-approve-all-lease.test.ts +9 -5
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-round-trips.test.ts +3 -3
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-sequential-gates.test.ts +3 -3
- package/src/activities/execute-deep-agent/__tests__/hermetic/inline-artifact-across-gate.test.ts +7 -6
- package/src/activities/execute-deep-agent/__tests__/hermetic/pause-vs-shutdown.test.ts +10 -11
- package/src/activities/execute-deep-agent/__tests__/hermetic/plain-turn.test.ts +4 -4
- package/src/activities/execute-deep-agent/__tests__/hermetic/platform-stop.test.ts +9 -8
- package/src/activities/execute-deep-agent/__tests__/hermetic/recursion-limit.test.ts +21 -13
- package/src/activities/execute-deep-agent/__tests__/hermetic/resolution-error.test.ts +2 -2
- package/src/activities/execute-deep-agent/__tests__/hermetic/structured-output.test.ts +7 -7
- package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-delegation.test.ts +28 -12
- package/src/activities/execute-deep-agent/__tests__/hermetic/tool-call.test.ts +21 -21
- package/src/activities/execute-deep-agent/__tests__/hermetic/workspace-lock-timeout.test.ts +5 -5
- package/src/activities/execute-deep-agent/__tests__/hermetic/write-todos.test.ts +160 -0
- package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +35 -30
- package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +3 -4
- package/src/activities/execute-deep-agent/__tests__/prompt-goldens.test.ts +12 -10
- package/src/activities/execute-deep-agent/__tests__/scripted-model.test.ts +13 -3
- package/src/activities/execute-deep-agent/__tests__/streaming-side-effects.test.ts +26 -18
- package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +1 -1
- package/src/activities/execute-deep-agent/__tests__/{subagent-tracker.test.ts → translator-subagents.test.ts} +76 -57
- package/src/activities/execute-deep-agent/__tests__/{v3-status-builder.test.ts → translator-through-builder.test.ts} +213 -299
- package/src/activities/execute-deep-agent/__tests__/translator.test.ts +505 -0
- package/src/activities/execute-deep-agent/__tests__/turn-stream.test.ts +11 -29
- package/src/activities/execute-deep-agent/adapter.ts +1 -1
- package/src/activities/execute-deep-agent/approval-file-change.ts +20 -22
- package/src/activities/execute-deep-agent/deep-agent-capabilities.ts +2 -2
- package/src/activities/execute-deep-agent/hitl.ts +2 -2
- package/src/activities/execute-deep-agent/inline-publisher.ts +16 -5
- package/src/activities/execute-deep-agent/prompt-builder.ts +6 -7
- package/src/activities/execute-deep-agent/streaming-side-effects.ts +22 -31
- package/src/activities/execute-deep-agent/subagent-transformer.ts +3 -3
- package/src/activities/execute-deep-agent/translator.ts +463 -0
- package/src/activities/execute-deep-agent/turn-settle.ts +35 -43
- package/src/activities/execute-deep-agent/turn-setup.ts +8 -8
- package/src/activities/execute-deep-agent/turn-stream.ts +53 -51
- package/src/activities/execute-deep-agent/turn.ts +3 -3
- package/src/config.ts +2 -2
- package/src/harness/README.md +335 -0
- package/src/harness/__tests__/approval-decisions.test.ts +2 -2
- package/src/harness/__tests__/capture.test.ts +3 -3
- package/src/harness/__tests__/import-direction.test.ts +3 -2
- package/src/harness/__tests__/mount-skills.test.ts +4 -1
- package/src/harness/__tests__/readme-index.test.ts +339 -0
- package/src/harness/__tests__/run-turn.test.ts +131 -6
- package/src/harness/__tests__/transcript-is-engine-free.test.ts +83 -0
- package/src/harness/__tests__/transcript-writers.test.ts +191 -0
- package/src/harness/__tests__/turn-attachments-vision.test.ts +5 -2
- package/src/harness/__tests__/turn-context.test.ts +5 -5
- package/src/harness/approval-decisions.ts +1 -1
- package/src/harness/capabilities.ts +21 -11
- package/src/harness/capture.ts +4 -4
- package/src/harness/persist-chokepoint.ts +3 -3
- package/src/harness/registry.ts +2 -2
- package/src/harness/run-turn.ts +33 -9
- package/src/harness/stop-controller.ts +1 -1
- package/src/harness/terminal-table.ts +7 -7
- package/src/harness/transcript/__tests__/builder.test.ts +975 -0
- package/src/harness/transcript/__tests__/state.test.ts +143 -0
- package/src/harness/transcript/builder.ts +755 -0
- package/src/harness/transcript/events.ts +262 -0
- package/src/harness/transcript/state.ts +167 -0
- package/src/harness/turn-context.ts +61 -46
- package/src/harness/types.ts +64 -22
- package/src/harness/usage-accumulator.ts +2 -2
- package/src/harness-adapters.ts +5 -4
- package/src/middleware/__tests__/cost-advisory.test.ts +2 -2
- package/src/middleware/approval-gate.ts +7 -74
- package/src/middleware/cost-advisory.ts +3 -3
- package/src/middleware/index.ts +1 -1
- package/src/runner-manager.ts +1 -1
- package/src/shared/__tests__/approval-policy.test.ts +45 -0
- package/src/shared/__tests__/args-preview.test.ts +40 -20
- package/src/shared/__tests__/attachment-naming.test.ts +1 -1
- package/src/shared/__tests__/attachment-resolver.test.ts +5 -5
- package/src/shared/__tests__/attachment-zip.test.ts +1 -1
- package/src/shared/__tests__/blueprint-resolver.test.ts +1 -1
- package/src/shared/__tests__/cost-guard.test.ts +1 -1
- package/src/shared/__tests__/exact-apply.test.ts +2 -1
- package/src/shared/__tests__/persist-decision.test.ts +19 -33
- package/src/shared/__tests__/prompt-sections.test.ts +1 -1
- package/src/shared/__tests__/stamp-flowed-rows.test.ts +1 -1
- package/src/shared/__tests__/status-offload.test.ts +1 -1
- package/src/shared/__tests__/streaming-scheduler.test.ts +8 -9
- package/src/shared/__tests__/todos.test.ts +1 -1
- package/src/shared/__tests__/tool-row.test.ts +1 -1
- package/src/shared/approval-policy.ts +95 -0
- package/src/shared/args-preview.ts +51 -42
- package/src/shared/attachment-resolver.ts +4 -4
- package/src/shared/attachment-vision.ts +2 -1
- package/src/shared/attachment-zip.ts +2 -2
- package/src/shared/cost-guard.ts +2 -2
- package/src/shared/exact-apply.ts +1 -1
- package/src/shared/execution-context.ts +2 -2
- package/src/shared/extract-structured-output.ts +2 -2
- package/src/shared/filereview/__tests__/capture.test.ts +9 -5
- package/src/shared/filereview/__tests__/git-substrate.test.ts +4 -1
- package/src/shared/filereview/__tests__/proxy-reconcile.test.ts +3 -3
- package/src/shared/filereview/cas-touched.ts +2 -2
- package/src/shared/heartbeat.ts +1 -1
- package/src/shared/llm-backend.ts +0 -4
- package/src/shared/model-error.ts +1 -2
- package/src/shared/persist-decision.ts +19 -28
- package/src/shared/prompt-sections.ts +4 -4
- package/src/shared/skill-resolver.ts +3 -3
- package/src/shared/status-offload.ts +2 -2
- package/src/shared/streaming-scheduler.ts +8 -13
- package/src/shared/subagent-rows.ts +2 -2
- package/src/shared/todos.ts +3 -3
- package/src/shared/tool-row.ts +38 -2
- package/src/shared/worker-shutdown.ts +1 -1
- package/src/shared/workspace/__tests__/git-source.test.ts +3 -3
- package/src/shared/workspace/__tests__/provisioner.test.ts +5 -5
- package/src/shared/workspace/__tests__/session-provision.test.ts +2 -2
- package/src/shared/workspace/__tests__/writeback-coordinator.integration.test.ts +8 -9
- package/src/shared/workspace/__tests__/writeback-coordinator.test.ts +25 -25
- package/src/shared/workspace/provisioner.ts +1 -1
- package/src/shared/workspace/session-provision.ts +1 -1
- package/src/shared/workspace/sources/empty.ts +2 -2
- package/src/shared/workspace/sources/git.ts +3 -4
- package/src/shared/workspace/sources/local-path.ts +5 -6
- package/src/shared/workspace/stigmer-link.ts +1 -1
- package/src/shared/workspace/types.ts +2 -5
- package/src/shared/workspace/writeback-coordinator.ts +23 -12
- package/dist/activities/execute-cursor/delta-enricher.d.ts +0 -87
- package/dist/activities/execute-cursor/delta-enricher.js +0 -265
- package/dist/activities/execute-cursor/delta-enricher.js.map +0 -1
- package/dist/activities/execute-cursor/message-translator.js +0 -2040
- package/dist/activities/execute-cursor/message-translator.js.map +0 -1
- package/dist/activities/execute-cursor/todo-tracker.d.ts +0 -40
- package/dist/activities/execute-cursor/todo-tracker.js +0 -80
- package/dist/activities/execute-cursor/todo-tracker.js.map +0 -1
- package/dist/activities/execute-deep-agent/execution-state.d.ts +0 -54
- package/dist/activities/execute-deep-agent/execution-state.js +0 -68
- package/dist/activities/execute-deep-agent/execution-state.js.map +0 -1
- package/dist/activities/execute-deep-agent/status-builder-shared.d.ts +0 -65
- package/dist/activities/execute-deep-agent/status-builder-shared.js +0 -90
- package/dist/activities/execute-deep-agent/status-builder-shared.js.map +0 -1
- package/dist/activities/execute-deep-agent/subagent-tracker.d.ts +0 -113
- package/dist/activities/execute-deep-agent/subagent-tracker.js +0 -400
- package/dist/activities/execute-deep-agent/subagent-tracker.js.map +0 -1
- package/dist/activities/execute-deep-agent/v3-events.d.ts +0 -102
- package/dist/activities/execute-deep-agent/v3-events.js +0 -35
- package/dist/activities/execute-deep-agent/v3-events.js.map +0 -1
- package/dist/activities/execute-deep-agent/v3-protocol-normalizer.d.ts +0 -15
- package/dist/activities/execute-deep-agent/v3-protocol-normalizer.js +0 -235
- package/dist/activities/execute-deep-agent/v3-protocol-normalizer.js.map +0 -1
- package/dist/activities/execute-deep-agent/v3-status-builder.d.ts +0 -111
- package/dist/activities/execute-deep-agent/v3-status-builder.js +0 -457
- package/dist/activities/execute-deep-agent/v3-status-builder.js.map +0 -1
- package/dist/shared/execution-status-writer.d.ts +0 -31
- package/dist/shared/execution-status-writer.js +0 -43
- package/dist/shared/execution-status-writer.js.map +0 -1
- package/src/activities/execute-cursor/__tests__/delta-enricher.test.ts +0 -310
- package/src/activities/execute-cursor/__tests__/message-translator.test.ts +0 -1033
- package/src/activities/execute-cursor/__tests__/todo-tracker.test.ts +0 -498
- package/src/activities/execute-cursor/delta-enricher.ts +0 -307
- package/src/activities/execute-cursor/message-translator.ts +0 -2319
- package/src/activities/execute-cursor/todo-tracker.ts +0 -91
- package/src/activities/execute-deep-agent/__tests__/execution-state-extended.test.ts +0 -148
- package/src/activities/execute-deep-agent/__tests__/execution-state.test.ts +0 -154
- package/src/activities/execute-deep-agent/__tests__/status-builder-shared.test.ts +0 -47
- package/src/activities/execute-deep-agent/__tests__/v3-protocol-normalizer.test.ts +0 -324
- package/src/activities/execute-deep-agent/execution-state.ts +0 -78
- package/src/activities/execute-deep-agent/status-builder-shared.ts +0 -142
- package/src/activities/execute-deep-agent/subagent-tracker.ts +0 -479
- package/src/activities/execute-deep-agent/v3-events.ts +0 -153
- package/src/activities/execute-deep-agent/v3-protocol-normalizer.ts +0 -264
- package/src/activities/execute-deep-agent/v3-status-builder.ts +0 -565
- package/src/shared/execution-status-writer.ts +0 -56
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TranscriptEvent — the canonical event the transcript builder folds: what
|
|
3
|
+
* every harness's translator emits and `TranscriptBuilder` consumes to build
|
|
4
|
+
* the transcript half of the AgentExecutionStatus proto.
|
|
5
|
+
*
|
|
6
|
+
* A runner-internal contract (not persisted, not exposed to clients). It was
|
|
7
|
+
* born in the native adapter as `StigmerRunEvent`, the normalized form of
|
|
8
|
+
* LangGraph's v3 protocol, and promoted here on 2026-09-14 (#1097) because
|
|
9
|
+
* its own header already called it the thing that isolates the builder from
|
|
10
|
+
* the engine — the same move #1070 and #1096 made for the turn runtime. #1097
|
|
11
|
+
* cut it engine-neutral one rule at a time:
|
|
12
|
+
*
|
|
13
|
+
* - Every member the builder never folded left — `usage`, `lifecycle`,
|
|
14
|
+
* `provider`, and the `seq`/`node`/`messageId`/`reason` fields no handler
|
|
15
|
+
* read. Usage is a LOOP concern: the native loop reads it off the wire
|
|
16
|
+
* (`usageOf`) and prices it into `TurnSink.reportUsage`; the Cursor loop
|
|
17
|
+
* reads its own from the SDK's `turn-ended` delta. A transcript fact is
|
|
18
|
+
* what a row or a message carries; usage is neither.
|
|
19
|
+
* - `tool_finished` carries `result: string`; the engine's output
|
|
20
|
+
* envelope is the translator's to render.
|
|
21
|
+
* - `tool_started` carries the attribution (`mcpServerSlug`), the
|
|
22
|
+
* provenance and — where the harness runs a gated call before its
|
|
23
|
+
* boundary parks it — the gate's word. The translator resolves them from
|
|
24
|
+
* the harness's policy state; the builder writes what it is told and
|
|
25
|
+
* decides nothing about approval.
|
|
26
|
+
* - Scope is `subAgentId?` — the only scope either harness has is
|
|
27
|
+
* "the root, or one sub-agent by the id its row carries" — and the
|
|
28
|
+
* translator says when a sub-agent opens and closes
|
|
29
|
+
* (`sub_agent_started/finished/failed`). LangGraph's namespace grammar
|
|
30
|
+
* (`tools:<uuid>|model_request:<uuid>`), the `task` tool's name and its
|
|
31
|
+
* depth rule are the native translator's alone now.
|
|
32
|
+
* - `approval_proposed`, the one post-stream fact both harnesses
|
|
33
|
+
* produce, and `system_note`, a harness's line in its own voice. The
|
|
34
|
+
* union is complete: a Cursor translator emits it and writes
|
|
35
|
+
* nothing else.
|
|
36
|
+
*
|
|
37
|
+
* The rule the union keeps: a member carries an identity and the
|
|
38
|
+
* fact the builder cannot read elsewhere, nothing else. Every engine fact
|
|
39
|
+
* reaches the builder as a translator's output.
|
|
40
|
+
*
|
|
41
|
+
* ID conventions:
|
|
42
|
+
* - `runId` — the identity of ONE streamed assistant message (LangGraph's
|
|
43
|
+
* LLM-call run id on native; a translator-minted segment id on Cursor);
|
|
44
|
+
* shared across that message's events
|
|
45
|
+
* - `callId` — provider tool call ID (e.g. `toolu_...`); keys ToolCall records
|
|
46
|
+
* - `subAgentId` — the sub-agent row's id, which on both harnesses is the
|
|
47
|
+
* `task` tool call's id
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
import type { PolicySource } from "../../shared/approval-policy.js";
|
|
51
|
+
|
|
52
|
+
// ── Scope ─────────────────────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Which transcript a fact belongs to: the root's, or a sub-agent's by the id
|
|
56
|
+
* its row carries. Absent = root. The builder keeps one set of handlers and
|
|
57
|
+
* looks the scope's transcript up by this id; how a harness knows which
|
|
58
|
+
* sub-agent an event belongs to (LangGraph's namespace prefix, Cursor's
|
|
59
|
+
* `conversationSteps`) is the translator's knowledge.
|
|
60
|
+
*/
|
|
61
|
+
interface Scoped {
|
|
62
|
+
readonly subAgentId?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── Message Events ────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
export interface MessageStartEvent extends Scoped {
|
|
68
|
+
readonly kind: "message_start";
|
|
69
|
+
readonly runId: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface TextDeltaEvent extends Scoped {
|
|
73
|
+
readonly kind: "text_delta";
|
|
74
|
+
readonly runId: string;
|
|
75
|
+
readonly text: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ReasoningDeltaEvent extends Scoped {
|
|
79
|
+
readonly kind: "reasoning_delta";
|
|
80
|
+
readonly runId: string;
|
|
81
|
+
readonly text: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface MessageFinishEvent extends Scoped {
|
|
85
|
+
readonly kind: "message_finish";
|
|
86
|
+
readonly runId: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ── Tool Events ───────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The translator's word that a call is GATED — the fields the row carries,
|
|
93
|
+
* never a decision the builder makes (#1097, 2026-09-14). A gated call that
|
|
94
|
+
* has STARTED is running until the
|
|
95
|
+
* harness's boundary parks it through `approval_proposed`: that is Cursor's
|
|
96
|
+
* shape (the SDK runs the tool; the deny-and-retry boundary parks it after
|
|
97
|
+
* the stream). Native never emits this member — LangGraph's `interrupt()`
|
|
98
|
+
* fires before the tool handler runs, so a held call never produces a
|
|
99
|
+
* `tool_started` at all, and the arrival of one IS the engine's word that
|
|
100
|
+
* the call was authorized (capture mode let it flow, a lease or policy
|
|
101
|
+
* cleared it, or the user approved it). Native's gate fact reaches the
|
|
102
|
+
* transcript through `approval_proposed` from the post-stream seed. So a
|
|
103
|
+
* row is never WAITING at creation on either harness; the plan's `parked:
|
|
104
|
+
* true` arm had no producer and was dropped.
|
|
105
|
+
*/
|
|
106
|
+
export interface GateAnswer {
|
|
107
|
+
/** The approval card's message, placeholders already resolved. */
|
|
108
|
+
readonly message: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ToolStartedEvent extends Scoped {
|
|
112
|
+
readonly kind: "tool_started";
|
|
113
|
+
readonly callId: string;
|
|
114
|
+
readonly name: string;
|
|
115
|
+
readonly input: Record<string, unknown>;
|
|
116
|
+
/** The MCP server this tool belongs to, `""` for a built-in — resolved by the translator (attribution is engine knowledge). */
|
|
117
|
+
readonly mcpServerSlug: string;
|
|
118
|
+
/**
|
|
119
|
+
* Which policy layer governs this call, for the row's authorization
|
|
120
|
+
* provenance; absent where the harness cannot attribute it (sub-agent rows
|
|
121
|
+
* on both harnesses today, #1133) or no layer governs it.
|
|
122
|
+
*/
|
|
123
|
+
readonly provenance?: PolicySource;
|
|
124
|
+
readonly gate?: GateAnswer;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface ToolArgDeltaEvent extends Scoped {
|
|
128
|
+
readonly kind: "tool_arg_delta";
|
|
129
|
+
readonly callId: string;
|
|
130
|
+
readonly argsChunk: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface ToolOutputDeltaEvent extends Scoped {
|
|
134
|
+
readonly kind: "tool_output_delta";
|
|
135
|
+
readonly callId: string;
|
|
136
|
+
readonly delta: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A fact the harness observed at one instant and delivers at another. The
|
|
141
|
+
* builder is the transcript's one clock — every row stamp is `utcTimestamp()`
|
|
142
|
+
* at apply — except here: a Cursor completion arrives first on the SDK's
|
|
143
|
+
* delta channel, and the translator must QUEUE it for the loop to apply after
|
|
144
|
+
* the current stream event (a delta applied mid-persist would land on a row
|
|
145
|
+
* the offload is replacing). Without the observed
|
|
146
|
+
* instant the row's `completedAt` would be the fold's moment, one stream
|
|
147
|
+
* event late — seconds late while the model narrates — and the tool's
|
|
148
|
+
* duration in the console would lie (fixed 2026-09-15, #1097). Absent
|
|
149
|
+
* means "now": native, and every fact a translator emits as it sees it,
|
|
150
|
+
* never set it.
|
|
151
|
+
*/
|
|
152
|
+
interface Observed {
|
|
153
|
+
readonly observedAt?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface ToolFinishedEvent extends Scoped, Observed {
|
|
157
|
+
readonly kind: "tool_finished";
|
|
158
|
+
readonly callId: string;
|
|
159
|
+
/**
|
|
160
|
+
* The result as the row carries it — already a string. Rendering the
|
|
161
|
+
* engine's output (LangChain's ToolMessage envelope, Cursor's result
|
|
162
|
+
* object) is the translator's; the builder stores what it is handed and
|
|
163
|
+
* the persist chokepoint bounds it.
|
|
164
|
+
*/
|
|
165
|
+
readonly result: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface ToolErrorEvent extends Scoped, Observed {
|
|
169
|
+
readonly kind: "tool_error";
|
|
170
|
+
readonly callId: string;
|
|
171
|
+
readonly message: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ── Sub-Agent Events ──────────────────────────────────────────────
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A sub-agent opens: the builder creates its row (keyed by `subAgentId`) and
|
|
178
|
+
* a transcript of its own that later events scoped to it fold into. Emitted
|
|
179
|
+
* by the translator BEFORE the delegating tool's own `tool_started`, so the
|
|
180
|
+
* row exists when the parent's `task` row is created. For a sub-agent the
|
|
181
|
+
* builder already knows (a seeded row re-announced by a replayed engine)
|
|
182
|
+
* this is a no-op — the row is never duplicated.
|
|
183
|
+
*/
|
|
184
|
+
export interface SubAgentStartedEvent {
|
|
185
|
+
readonly kind: "sub_agent_started";
|
|
186
|
+
readonly subAgentId: string;
|
|
187
|
+
/** The sub-agent's declared name (deepagents' `subagent_type`; Cursor's `task` name). */
|
|
188
|
+
readonly name: string;
|
|
189
|
+
/** What it was asked to do, as the card's title and as its input. */
|
|
190
|
+
readonly subject: string;
|
|
191
|
+
readonly input: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface SubAgentFinishedEvent {
|
|
195
|
+
readonly kind: "sub_agent_finished";
|
|
196
|
+
readonly subAgentId: string;
|
|
197
|
+
/** The sub-agent's final output as the row carries it — the same string the delegating tool's `tool_finished` carries. */
|
|
198
|
+
readonly output?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface SubAgentFailedEvent {
|
|
202
|
+
readonly kind: "sub_agent_failed";
|
|
203
|
+
readonly subAgentId: string;
|
|
204
|
+
readonly error: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ── Post-Stream Facts ─────────────────────────────────────────────
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A call the harness's boundary parked for approval AFTER the stream — the
|
|
211
|
+
* one post-stream fact both harnesses produce: native's
|
|
212
|
+
* `seedPendingInterrupts` reads the graph checkpoint's un-resumed interrupts
|
|
213
|
+
* (a held call never streamed a `tool_started`, so no row exists yet);
|
|
214
|
+
* Cursor's denial overlay re-proposes a call the hook denied (a row exists,
|
|
215
|
+
* `error`ed). An UPSERT: a known `callId` REOPENS its row — WAITING, the
|
|
216
|
+
* outcome fields cleared, `approvalRequestedAt` stamped once; an unknown one
|
|
217
|
+
* gets a WAITING row on the scope's current AI message, the text that
|
|
218
|
+
* proposed it (the message-boundary rule). Either way the builder reports
|
|
219
|
+
* {@link awaitingApproval}. The one place a row is ever WAITING.
|
|
220
|
+
*/
|
|
221
|
+
export interface ApprovalProposedEvent extends Scoped {
|
|
222
|
+
readonly kind: "approval_proposed";
|
|
223
|
+
readonly callId: string;
|
|
224
|
+
readonly name: string;
|
|
225
|
+
readonly mcpServerSlug: string;
|
|
226
|
+
/** The proposed arguments, redacted by the harness — the card renders the change from them; absent when the harness could not correlate them. */
|
|
227
|
+
readonly args?: Record<string, unknown>;
|
|
228
|
+
/** The approval card's message, placeholders already resolved. */
|
|
229
|
+
readonly message: string;
|
|
230
|
+
readonly provenance?: PolicySource;
|
|
231
|
+
/** Cursor's content identity for a same-identity re-proposal (`approvalContentDigest`); native has none. */
|
|
232
|
+
readonly contentDigest?: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* A line the harness adds to the transcript in its own voice — Cursor's
|
|
237
|
+
* `task` SDK event (a status line about the run), the boundary's
|
|
238
|
+
* unresolved-disclosure row. A SYSTEM message in the scope, never
|
|
239
|
+
* an AI one, so it neither hosts tool rows nor moves the message boundary.
|
|
240
|
+
*/
|
|
241
|
+
export interface SystemNoteEvent extends Scoped {
|
|
242
|
+
readonly kind: "system_note";
|
|
243
|
+
readonly text: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ── Union ─────────────────────────────────────────────────────────
|
|
247
|
+
|
|
248
|
+
export type TranscriptEvent =
|
|
249
|
+
| MessageStartEvent
|
|
250
|
+
| TextDeltaEvent
|
|
251
|
+
| ReasoningDeltaEvent
|
|
252
|
+
| MessageFinishEvent
|
|
253
|
+
| ToolStartedEvent
|
|
254
|
+
| ToolArgDeltaEvent
|
|
255
|
+
| ToolOutputDeltaEvent
|
|
256
|
+
| ToolFinishedEvent
|
|
257
|
+
| ToolErrorEvent
|
|
258
|
+
| SubAgentStartedEvent
|
|
259
|
+
| SubAgentFinishedEvent
|
|
260
|
+
| SubAgentFailedEvent
|
|
261
|
+
| ApprovalProposedEvent
|
|
262
|
+
| SystemNoteEvent;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TranscriptState — the AgentExecutionStatus proto `TranscriptBuilder` is
|
|
3
|
+
* building into, held as one {@link Transcript} per scope: the root's over
|
|
4
|
+
* `status.messages`, and one per sub-agent over its row's `messages`.
|
|
5
|
+
*
|
|
6
|
+
* Indexes, not copies: every map value is the live proto object (a ToolCall
|
|
7
|
+
* inside a message's repeated field, an AgentMessage inside a `messages`
|
|
8
|
+
* array), so a mutation through the index IS the mutation of the proto, and
|
|
9
|
+
* nothing here can drift from what is persisted. The arrays themselves are
|
|
10
|
+
* the status's own, pushed into and never replaced, so every wrapper of the
|
|
11
|
+
* status (the runtime's persist chokepoint, the settle modules that amend
|
|
12
|
+
* rows by identity) keeps seeing every row. A reinvocation's prior rows
|
|
13
|
+
* arrive through {@link TranscriptState.seed} — the turn runtime's
|
|
14
|
+
* `seedFromPersistedStatus` hands them here — so they are indexed by the
|
|
15
|
+
* same routine that indexes a status handed to the constructor.
|
|
16
|
+
*
|
|
17
|
+
* One shape for every scope (since #1097): until then the root's indexes
|
|
18
|
+
* lived here keyed by LangGraph namespace and the
|
|
19
|
+
* sub-agents' in a second module with its own copies of the same maps and
|
|
20
|
+
* handlers (`subagent-tracker.ts`, deleted in #1097). Scope is `subAgentId?`
|
|
21
|
+
* now and the namespace key collapsed — the tracker already resolved every
|
|
22
|
+
* local namespace to `""` — so a transcript's "current AI message" and
|
|
23
|
+
* "last run" are single values.
|
|
24
|
+
*
|
|
25
|
+
* The name says what it holds — the transcript's bookkeeping, not the
|
|
26
|
+
* execution's state, which is the turn runtime's (`harness/turn-context.ts`);
|
|
27
|
+
* it was `ExecutionState` in the native adapter (renamed in #1097).
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import type { AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
31
|
+
import { MessageType } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
32
|
+
import type { AgentMessage, ToolCall } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
|
|
33
|
+
import type { SubAgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/subagent_pb";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One scope's transcript: the `messages[]` it folds into (by reference) and
|
|
37
|
+
* the live indexes over it. Seeded rows are indexed at construction so a
|
|
38
|
+
* re-emitted event reconciles onto the existing row instead of duplicating
|
|
39
|
+
* it (the durable-checkpoint resume; the memory-checkpointer replay).
|
|
40
|
+
*/
|
|
41
|
+
export class Transcript {
|
|
42
|
+
/** tool_call_id → the live ToolCall inside one of this transcript's messages. */
|
|
43
|
+
readonly toolCalls = new Map<string, ToolCall>();
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* runId → the AgentMessage that run streams into (a THINKING row under
|
|
47
|
+
* its own key), so two runs' tokens never interleave.
|
|
48
|
+
*/
|
|
49
|
+
readonly messagesByRun = new Map<string, AgentMessage>();
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The AI message a tool row attaches to — the latest message with text in
|
|
53
|
+
* this scope. Over a seeded transcript it starts as the seed's
|
|
54
|
+
* last AI message: the message that proposed a call is still the
|
|
55
|
+
* one that proposed it across a turn boundary, which is also Cursor's
|
|
56
|
+
* shape (`findOrCreateLastAiMessage`).
|
|
57
|
+
*/
|
|
58
|
+
currentAiMessage: AgentMessage | undefined;
|
|
59
|
+
|
|
60
|
+
/** The latest LLM run in this scope, for closing the previous message's streaming flag when a new run starts. */
|
|
61
|
+
lastRunId: string | undefined;
|
|
62
|
+
|
|
63
|
+
/** Progressive tool-call argument JSON, accumulated per callId until it parses. */
|
|
64
|
+
readonly argBuffers = new Map<string, string>();
|
|
65
|
+
|
|
66
|
+
constructor(readonly messages: AgentMessage[]) {
|
|
67
|
+
for (const message of messages) this.index(message);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Take a message that is already on (or is being appended to) this
|
|
72
|
+
* transcript into the indexes: every row by id, and the message as the
|
|
73
|
+
* current AI message when it is one — the seed's last AI message is the
|
|
74
|
+
* one a resumed turn's first row joins. The one routine behind
|
|
75
|
+
* both ways rows arrive before the stream — the status as handed to the
|
|
76
|
+
* constructor, and the runtime's seed of a reinvocation's prior rows
|
|
77
|
+
* ({@link TranscriptState.seed}) — so neither can index differently.
|
|
78
|
+
*/
|
|
79
|
+
index(message: AgentMessage): void {
|
|
80
|
+
for (const tc of message.toolCalls) {
|
|
81
|
+
if (tc.id) this.toolCalls.set(tc.id, tc);
|
|
82
|
+
}
|
|
83
|
+
if (message.type === MessageType.MESSAGE_AI) this.currentAiMessage = message;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The transcript half of a persisted status: what a reinvocation seeds through the builder. */
|
|
88
|
+
export type TranscriptSeed = Pick<AgentExecutionStatus, "messages" | "subAgentExecutions" | "artifacts" | "workspaceWriteBacks" | "todos">;
|
|
89
|
+
|
|
90
|
+
/** A sub-agent's row and the transcript folded into it. */
|
|
91
|
+
export interface SubAgentScope {
|
|
92
|
+
readonly row: SubAgentExecution;
|
|
93
|
+
readonly transcript: Transcript;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export class TranscriptState {
|
|
97
|
+
/** The protobuf projection being built. */
|
|
98
|
+
readonly proto: AgentExecutionStatus;
|
|
99
|
+
|
|
100
|
+
/** The root transcript, over `proto.messages`. */
|
|
101
|
+
readonly root: Transcript;
|
|
102
|
+
|
|
103
|
+
private readonly subAgentsById = new Map<string, SubAgentScope>();
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Indexes the status as handed: the root's messages and every seeded
|
|
107
|
+
* sub-agent row (a reinvocation's seed carries prior turns' rows, whose
|
|
108
|
+
* events may be re-driven).
|
|
109
|
+
*/
|
|
110
|
+
constructor(proto: AgentExecutionStatus) {
|
|
111
|
+
this.proto = proto;
|
|
112
|
+
this.root = new Transcript(proto.messages);
|
|
113
|
+
for (const row of proto.subAgentExecutions) {
|
|
114
|
+
this.subAgentsById.set(row.id, { row, transcript: new Transcript(row.messages) });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The transcript an event folds into: the root's for no `subAgentId`, a sub-agent's for a known one, `undefined` for an unknown one. */
|
|
119
|
+
scope(subAgentId: string | undefined): Transcript | undefined {
|
|
120
|
+
if (subAgentId === undefined) return this.root;
|
|
121
|
+
return this.subAgentsById.get(subAgentId)?.transcript;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
subAgent(subAgentId: string): SubAgentScope | undefined {
|
|
125
|
+
return this.subAgentsById.get(subAgentId);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Push a new sub-agent row onto the status and open its transcript. The caller checks the id is new. */
|
|
129
|
+
openSubAgent(row: SubAgentExecution): SubAgentScope {
|
|
130
|
+
this.proto.subAgentExecutions.push(row);
|
|
131
|
+
const scope = { row, transcript: new Transcript(row.messages) };
|
|
132
|
+
this.subAgentsById.set(row.id, scope);
|
|
133
|
+
return scope;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Append a persisted transcript's rows to the status AND index them — the
|
|
138
|
+
* runtime's seed of a reinvocation (`harness/turn-context.ts`
|
|
139
|
+
* `seedFromPersistedStatus` says why every collection is seeded: the
|
|
140
|
+
* server replaces each list wholesale, so a resumed turn's write must be a
|
|
141
|
+
* superset). Every collection is pushed into, never reassigned, so the
|
|
142
|
+
* status's arrays stay the ones every wrapper of the status holds. A
|
|
143
|
+
* sub-agent row already known by id is skipped (a seed is applied once).
|
|
144
|
+
* The rows arrive through the same {@link Transcript.index} the
|
|
145
|
+
* constructor uses, so a builder that seeds after it is born indexes
|
|
146
|
+
* exactly as one born over the seeded status would.
|
|
147
|
+
*/
|
|
148
|
+
seed(persisted: TranscriptSeed): void {
|
|
149
|
+
for (const message of persisted.messages) {
|
|
150
|
+
this.proto.messages.push(message);
|
|
151
|
+
this.root.index(message);
|
|
152
|
+
}
|
|
153
|
+
for (const row of persisted.subAgentExecutions) {
|
|
154
|
+
if (this.subAgentsById.has(row.id)) continue;
|
|
155
|
+
this.openSubAgent(row);
|
|
156
|
+
}
|
|
157
|
+
this.proto.artifacts.push(...persisted.artifacts);
|
|
158
|
+
this.proto.workspaceWriteBacks.push(...persisted.workspaceWriteBacks);
|
|
159
|
+
for (const [id, todo] of Object.entries(persisted.todos)) this.proto.todos[id] = todo;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Every transcript, the root's first — for the rules that sweep them all (`finalize`). */
|
|
163
|
+
*transcripts(): IterableIterator<Transcript> {
|
|
164
|
+
yield this.root;
|
|
165
|
+
for (const { transcript } of this.subAgentsById.values()) yield transcript;
|
|
166
|
+
}
|
|
167
|
+
}
|