@stigmer/runner 3.15.3-dev.20260914121148 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- 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 +2 -2
- 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 +47 -12
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +41 -10
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +15 -6
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +17 -4
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -1
- package/dist/activities/execute-cursor/adapter.d.ts +4 -4
- package/dist/activities/execute-cursor/adapter.js +4 -4
- 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/service-tier.js +1 -2
- package/dist/activities/execute-cursor/service-tier.js.map +1 -1
- 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/activities/generate-session-subject.d.ts +25 -4
- package/dist/activities/generate-session-subject.js +17 -7
- package/dist/activities/generate-session-subject.js.map +1 -1
- package/dist/client/stigmer-client.d.ts +17 -6
- package/dist/client/stigmer-client.js +47 -14
- package/dist/client/stigmer-client.js.map +1 -1
- package/dist/config.d.ts +6 -3
- package/dist/config.js +4 -1
- package/dist/config.js.map +1 -1
- 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/interceptors/run-credential-activity.d.ts +28 -0
- package/dist/interceptors/run-credential-activity.js +56 -0
- package/dist/interceptors/run-credential-activity.js.map +1 -0
- 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 +10 -4
- package/dist/runner-manager.js.map +1 -1
- package/dist/shared/activity-input.d.ts +9 -0
- package/dist/shared/activity-input.js +17 -0
- package/dist/shared/activity-input.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-zip.d.ts +2 -2
- package/dist/shared/attachment-zip.js +2 -2
- package/dist/shared/channel-attachment.d.ts +8 -5
- package/dist/shared/channel-attachment.js +10 -6
- package/dist/shared/channel-attachment.js.map +1 -1
- 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/filereview/progress.d.ts +13 -0
- package/dist/shared/filereview/progress.js +13 -0
- package/dist/shared/filereview/progress.js.map +1 -1
- 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/memory-attachment.d.ts +16 -9
- package/dist/shared/memory-attachment.js +18 -10
- package/dist/shared/memory-attachment.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/run-credential-store.d.ts +32 -0
- package/dist/shared/run-credential-store.js +39 -0
- package/dist/shared/run-credential-store.js.map +1 -0
- package/dist/shared/run-credential.d.ts +61 -0
- package/dist/shared/run-credential.js +68 -0
- package/dist/shared/run-credential.js.map +1 -0
- 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/synthesized-attachment.d.ts +30 -3
- package/dist/shared/synthesized-attachment.js +26 -0
- package/dist/shared/synthesized-attachment.js.map +1 -1
- 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/dist/worker.js +10 -3
- package/dist/worker.js.map +1 -1
- package/dist/workflow-source.d.ts +10 -0
- package/dist/workflow-source.js +12 -0
- package/dist/workflow-source.js.map +1 -1
- package/dist/workflows/execute-from-execution.d.ts +15 -0
- package/dist/workflows/execute-from-execution.js +11 -0
- package/dist/workflows/execute-from-execution.js.map +1 -1
- package/dist/workflows/index.d.ts +5 -3
- package/dist/workflows/index.js +5 -3
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/interceptors/run-credential.d.ts +34 -0
- package/dist/workflows/interceptors/run-credential.js +71 -0
- package/dist/workflows/interceptors/run-credential.js.map +1 -0
- package/package.json +4 -4
- 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__/run-credential-e2e.test.ts +233 -0
- package/src/__tests__/run-credential-registration.test.ts +80 -0
- package/src/__tests__/runner-manager.test.ts +1 -1
- package/src/activities/__tests__/generate-session-subject-wire.test.ts +119 -0
- package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +1 -1
- package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +2 -2
- 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 +67 -17
- package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +19 -5
- 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-event-recorder.test.ts +142 -0
- package/src/activities/execute-cursor/__tests__/cursor-fetch-interceptor-bypass.test.ts +19 -8
- package/src/activities/execute-cursor/__tests__/cursor-sdk-auth-smoke.test.ts +10 -8
- 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 +1 -1
- package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +1 -1
- 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 +7 -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 +5 -5
- package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +2 -1
- package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +2 -1
- 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 +8 -8
- 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 +1 -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 +3 -3
- 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 +13 -1
- package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +2 -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__/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 +4 -4
- 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/service-tier.ts +1 -2
- 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/activities/generate-session-subject.ts +29 -4
- package/src/client/__tests__/stigmer-client.test.ts +92 -0
- package/src/client/stigmer-client.ts +48 -14
- package/src/config.ts +6 -3
- 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/interceptors/__tests__/run-credential-activity.test.ts +133 -0
- package/src/interceptors/run-credential-activity.ts +67 -0
- 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 +14 -4
- 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__/channel-attachment.test.ts +12 -0
- package/src/shared/__tests__/cost-guard.test.ts +1 -1
- package/src/shared/__tests__/exact-apply.test.ts +2 -1
- package/src/shared/__tests__/memory-attachment.test.ts +17 -0
- package/src/shared/__tests__/persist-decision.test.ts +19 -33
- package/src/shared/__tests__/prompt-sections.test.ts +1 -1
- package/src/shared/__tests__/run-credential.test.ts +111 -0
- 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/activity-input.ts +21 -0
- 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-zip.ts +2 -2
- package/src/shared/channel-attachment.ts +14 -6
- 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/filereview/progress.ts +13 -0
- package/src/shared/heartbeat.ts +1 -1
- package/src/shared/llm-backend.ts +0 -4
- package/src/shared/memory-attachment.ts +22 -10
- 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/run-credential-store.ts +45 -0
- package/src/shared/run-credential.ts +70 -0
- 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/synthesized-attachment.ts +38 -3
- 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/src/worker.ts +15 -3
- package/src/workflow-source.ts +15 -0
- package/src/workflows/__tests__/run-credential-interceptor.test.ts +178 -0
- package/src/workflows/execute-from-execution.ts +17 -0
- package/src/workflows/index.ts +5 -3
- package/src/workflows/interceptors/run-credential.ts +101 -0
- 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,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pins who may CREATE a transcript row: an `AgentMessage`, a `ToolCall` or a
|
|
3
|
+
* `SubAgentExecution` on the execution status. Two writers, and no third:
|
|
4
|
+
*
|
|
5
|
+
* - `src/harness/transcript/` — the one transcript builder, which every
|
|
6
|
+
* harness folds its engine's events through (`TurnSink.transcript`);
|
|
7
|
+
* - `src/harness/terminal-table.ts` — the runtime's terminal system rows
|
|
8
|
+
* (the pause copy, the failure copy), which are not transcript facts of
|
|
9
|
+
* any engine and never were.
|
|
10
|
+
*
|
|
11
|
+
* Why it matters (#1097's founding promise): the promise that a
|
|
12
|
+
* third harness is "a translator and nothing else" holds only while there
|
|
13
|
+
* is exactly one place a row comes from. A module that builds a row itself
|
|
14
|
+
* — an adapter pushing an AI message with a WAITING call, a settle
|
|
15
|
+
* synthesizing a SYSTEM line — is a second copy of the folding rule, and
|
|
16
|
+
* the two copies drift (the memo counted three such copies before this
|
|
17
|
+
* entry). The rule is about CREATION. Amending a row a builder created —
|
|
18
|
+
* flipping a WAITING row SKIPPED, stamping a change-set id, marking a
|
|
19
|
+
* sub-agent CANCELLED, the Cursor boundary's identity-based collapses — is
|
|
20
|
+
* legitimate, and the modules that do it are named in `TurnSink`'s header;
|
|
21
|
+
* a fence over them would be a list, not a rule.
|
|
22
|
+
*
|
|
23
|
+
* A reinvocation's prior rows are not an exception: the runtime seeds them
|
|
24
|
+
* THROUGH the builder (`TranscriptBuilder.seed`, from `turn-context.ts`
|
|
25
|
+
* `seedFromPersistedStatus`), so the seed indexes what it appends and this
|
|
26
|
+
* list stays at two. (For one commit the seed pushed rows itself and was
|
|
27
|
+
* the third name here.)
|
|
28
|
+
*
|
|
29
|
+
* The rule is read off the TypeScript syntax tree, as the import fences are
|
|
30
|
+
* (`import-direction.test.ts`): a schema named in a header comment, or a
|
|
31
|
+
* `.messages.push(` in prose, cannot trip it; a row built through any of the
|
|
32
|
+
* three schemas, or an array push onto `messages` / `subAgentExecutions`
|
|
33
|
+
* wherever the array is reached from, cannot slip past it.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import { describe, it, expect } from "vitest";
|
|
37
|
+
import { join, relative, sep } from "node:path";
|
|
38
|
+
import { fileURLToPath } from "node:url";
|
|
39
|
+
import ts from "typescript";
|
|
40
|
+
|
|
41
|
+
import { readSource, typeScriptFilesUnder } from "../../__test-utils__/module-specifiers.js";
|
|
42
|
+
|
|
43
|
+
const SRC_ROOT = fileURLToPath(new URL("../../", import.meta.url));
|
|
44
|
+
|
|
45
|
+
/** The proto schemas a transcript row is created through; naming one is creating one. */
|
|
46
|
+
const ROW_SCHEMAS: ReadonlySet<string> = new Set(["AgentMessageSchema", "ToolCallSchema", "SubAgentExecutionSchema"]);
|
|
47
|
+
|
|
48
|
+
/** The status arrays a created row is pushed onto. */
|
|
49
|
+
const ROW_ARRAYS: ReadonlySet<string> = new Set(["messages", "subAgentExecutions"]);
|
|
50
|
+
|
|
51
|
+
/** The modules allowed to create rows, relative to `src/`: a directory (every file under it) or a file. */
|
|
52
|
+
const ALLOWED_CREATORS: readonly string[] = [
|
|
53
|
+
join("harness", "transcript") + sep,
|
|
54
|
+
join("harness", "terminal-table.ts"),
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
/** Every row-creating construct in `source`, in source order: `names <Schema>` or `pushes onto .<array>`. */
|
|
58
|
+
export function transcriptRowWrites(fileName: string, source: string): string[] {
|
|
59
|
+
const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, /* setParentNodes */ false);
|
|
60
|
+
const writes: string[] = [];
|
|
61
|
+
const visit = (node: ts.Node): void => {
|
|
62
|
+
if (ts.isIdentifier(node) && ROW_SCHEMAS.has(node.text)) {
|
|
63
|
+
const write = `names ${node.text}`;
|
|
64
|
+
if (!writes.includes(write)) writes.push(write);
|
|
65
|
+
} else if (
|
|
66
|
+
ts.isCallExpression(node) &&
|
|
67
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
68
|
+
node.expression.name.text === "push" &&
|
|
69
|
+
ts.isPropertyAccessExpression(node.expression.expression) &&
|
|
70
|
+
ROW_ARRAYS.has(node.expression.expression.name.text)
|
|
71
|
+
) {
|
|
72
|
+
const write = `pushes onto .${node.expression.expression.name.text}`;
|
|
73
|
+
if (!writes.includes(write)) writes.push(write);
|
|
74
|
+
}
|
|
75
|
+
ts.forEachChild(node, visit);
|
|
76
|
+
};
|
|
77
|
+
visit(sourceFile);
|
|
78
|
+
return writes;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function isAllowedCreator(relativeFile: string): boolean {
|
|
82
|
+
return ALLOWED_CREATORS.some((allowed) => (allowed.endsWith(sep) ? relativeFile.startsWith(allowed) : relativeFile === allowed));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface Offence {
|
|
86
|
+
readonly file: string;
|
|
87
|
+
readonly writes: readonly string[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface Sweep {
|
|
91
|
+
readonly visited: string[];
|
|
92
|
+
readonly creators: string[];
|
|
93
|
+
readonly offences: Offence[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Production modules only: tests and test utilities build rows freely (fixtures, goldens' drivers). */
|
|
97
|
+
function sweep(): Sweep {
|
|
98
|
+
const visited: string[] = [];
|
|
99
|
+
const creators: string[] = [];
|
|
100
|
+
const offences: Offence[] = [];
|
|
101
|
+
for (const file of typeScriptFilesUnder(SRC_ROOT, new Set(["__tests__", "__test-utils__"]))) {
|
|
102
|
+
const relativeFile = relative(SRC_ROOT, file);
|
|
103
|
+
visited.push(relativeFile);
|
|
104
|
+
const writes = transcriptRowWrites(file, readSource(file));
|
|
105
|
+
if (writes.length === 0) continue;
|
|
106
|
+
creators.push(relativeFile);
|
|
107
|
+
if (!isAllowedCreator(relativeFile)) offences.push({ file: relativeFile, writes });
|
|
108
|
+
}
|
|
109
|
+
return { visited, creators, offences };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function describeOffences(offences: readonly Offence[]): string {
|
|
113
|
+
return offences.map((o) => ` ${o.file}: ${o.writes.join(", ")}`).join("\n");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
describe("transcriptRowWrites (the checker itself)", () => {
|
|
117
|
+
const file = join(SRC_ROOT, "activities", "some-harness", "settle.ts");
|
|
118
|
+
|
|
119
|
+
it.each([
|
|
120
|
+
["a message built through its schema", 'const m = create(AgentMessageSchema, { content: "x" });', "names AgentMessageSchema"],
|
|
121
|
+
["a tool call built through its schema", "const tc = create(ToolCallSchema, { id });", "names ToolCallSchema"],
|
|
122
|
+
["a sub-agent row built through its schema", "const row = create(SubAgentExecutionSchema, { id });", "names SubAgentExecutionSchema"],
|
|
123
|
+
["a schema merely imported", 'import { AgentMessageSchema } from "@stigmer/protos/x_pb";', "names AgentMessageSchema"],
|
|
124
|
+
["a push onto the root transcript", "status.messages.push(msg);", "pushes onto .messages"],
|
|
125
|
+
["a push onto a nested transcript", "scope.row.messages.push(msg);", "pushes onto .messages"],
|
|
126
|
+
["a spread push", "sink.status.messages.push(...seed.messages);", "pushes onto .messages"],
|
|
127
|
+
["a push onto the sub-agent rows", "this.proto.subAgentExecutions.push(row);", "pushes onto .subAgentExecutions"],
|
|
128
|
+
])("flags %s", (_label, source, expected) => {
|
|
129
|
+
expect(transcriptRowWrites(file, source)).toEqual([expected]);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it.each([
|
|
133
|
+
["a schema named in a comment", "// built through AgentMessageSchema elsewhere\nconst x = 1;"],
|
|
134
|
+
["a push described in a comment", "// the builder does status.messages.push(msg)\nconst x = 1;"],
|
|
135
|
+
["a schema named in a string", 'const hint = "AgentMessageSchema";'],
|
|
136
|
+
["a read of the transcript", "const last = status.messages.at(-1);"],
|
|
137
|
+
["a push onto an unrelated array", "status.artifacts.push(artifact);"],
|
|
138
|
+
["a push onto a bare `messages` local", "messages.push(m);"],
|
|
139
|
+
["the message TYPE, not its schema", 'import type { AgentMessage } from "@stigmer/protos/x_pb";'],
|
|
140
|
+
["an in-place amendment of a row", "row.status = ToolCallStatus.TOOL_CALL_SKIPPED;"],
|
|
141
|
+
])("does not flag %s", (_label, source) => {
|
|
142
|
+
expect(transcriptRowWrites(file, source)).toEqual([]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("names each construct once, in source order", () => {
|
|
146
|
+
const source = [
|
|
147
|
+
"const a = create(AgentMessageSchema, {});",
|
|
148
|
+
"const b = create(ToolCallSchema, {});",
|
|
149
|
+
"const c = create(AgentMessageSchema, {});",
|
|
150
|
+
"a.toolCalls.push(b); status.messages.push(a); status.messages.push(c);",
|
|
151
|
+
].join("\n");
|
|
152
|
+
expect(transcriptRowWrites(file, source)).toEqual(["names AgentMessageSchema", "names ToolCallSchema", "pushes onto .messages"]);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe("only the transcript builder and the terminal table create transcript rows", () => {
|
|
157
|
+
const result = sweep();
|
|
158
|
+
|
|
159
|
+
it("inspected production modules across src/ and skipped the test trees (the walk is rooted where it claims)", () => {
|
|
160
|
+
expect(result.visited).toEqual(
|
|
161
|
+
expect.arrayContaining([
|
|
162
|
+
join("harness", "run-turn.ts"),
|
|
163
|
+
join("harness", "transcript", "builder.ts"),
|
|
164
|
+
join("activities", "execute-cursor", "boundary-rows.ts"),
|
|
165
|
+
join("activities", "execute-deep-agent", "hitl.ts"),
|
|
166
|
+
join("shared", "exact-apply.ts"),
|
|
167
|
+
]),
|
|
168
|
+
);
|
|
169
|
+
expect(
|
|
170
|
+
result.visited.some((f) => f.includes(`${sep}__tests__${sep}`) || f.includes(`${sep}__test-utils__${sep}`)),
|
|
171
|
+
"the production sweep must skip the test trees",
|
|
172
|
+
).toBe(false);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("found the allowed creators (the checker sees the rows it exists to see)", () => {
|
|
176
|
+
expect(result.creators).toEqual(
|
|
177
|
+
expect.arrayContaining([
|
|
178
|
+
join("harness", "transcript", "builder.ts"),
|
|
179
|
+
join("harness", "transcript", "state.ts"),
|
|
180
|
+
join("harness", "terminal-table.ts"),
|
|
181
|
+
]),
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("finds no creator outside the allow-list", () => {
|
|
186
|
+
expect(
|
|
187
|
+
result.offences,
|
|
188
|
+
`a transcript row is created through TurnSink.transcript, never built in place:\n${describeOffences(result.offences)}`,
|
|
189
|
+
).toEqual([]);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pins which model the attachment phase asks the registry about when it
|
|
3
3
|
* sizes the vision budget (`turn-context.ts` `resolveTurnAttachments`): the
|
|
4
4
|
* model the execution named, or the registry's default when it named none —
|
|
5
|
-
* the model the native harness will build in that case. Before
|
|
5
|
+
* the model the native harness will build in that case. Before #1096 the
|
|
6
6
|
* phase asked about the raw executionConfig name, so an execution with no
|
|
7
7
|
* model named asked about `""` (always "unknown", read as sighted) while the
|
|
8
8
|
* native orchestrator asked about the resolved default (its `setup.ts`,
|
|
@@ -29,14 +29,17 @@ import { DEEP_AGENT_VISION_PROFILE } from "../../shared/attachment-vision.js";
|
|
|
29
29
|
import { TimingRecorder } from "../../shared/cold-start-timing.js";
|
|
30
30
|
import { mockStigmerClient } from "../../__test-utils__/mock-client.js";
|
|
31
31
|
import { testConfig } from "../../__test-utils__/config-fixture.js";
|
|
32
|
+
import { TranscriptBuilder } from "../transcript/builder.js";
|
|
32
33
|
import { resolveTurnAttachments, type ResolutionDeps } from "../turn-context.js";
|
|
33
34
|
|
|
34
35
|
function deps(): ResolutionDeps {
|
|
36
|
+
const status = create(AgentExecutionStatusSchema, {});
|
|
35
37
|
return {
|
|
36
38
|
input: { executionId: "aex_1", threadId: "", turnSeq: 0 },
|
|
37
39
|
client: mockStigmerClient(),
|
|
38
40
|
config: testConfig(),
|
|
39
|
-
status
|
|
41
|
+
status,
|
|
42
|
+
transcript: new TranscriptBuilder("aex_1", status),
|
|
40
43
|
artifactStorage: undefined,
|
|
41
44
|
timing: new TimingRecorder(),
|
|
42
45
|
signal: new AbortController().signal,
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
* (`activities/execute-cursor/__tests__/approval-state.test.ts`), because
|
|
15
15
|
* `src/harness/` never imports `src/activities/`, tests included.
|
|
16
16
|
* - `decideReinvocation`: the three ways a resume proceeds (any decision
|
|
17
|
-
* runs the agent — REJECT included since
|
|
17
|
+
* runs the agent — REJECT included since #1096 —, a clean file-review
|
|
18
18
|
* resume completes, a failed or partially discarded one completes with
|
|
19
19
|
* its facts carried).
|
|
20
20
|
* - `regeneratesApprovedWrites`: which pause primitives make the runner pin
|
|
21
21
|
* an approved whole-file write's bytes itself (the engine re-runs the
|
|
22
22
|
* model) and which never do (the engine applies the exact args it paused
|
|
23
|
-
* on).
|
|
23
|
+
* on).
|
|
24
24
|
*
|
|
25
25
|
* The phases that fetch and provision are exercised end to end by the
|
|
26
26
|
* hermetic goldens (`activities/execute-cursor/__tests__/hermetic/`), which
|
|
@@ -163,10 +163,10 @@ describe("decideReinvocation", () => {
|
|
|
163
163
|
expect(decideReinvocation(facts())).toBeUndefined();
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
it("a REJECT runs the agent like any other decision — the run continues without the tool (stigmer#197
|
|
167
|
-
// Until
|
|
166
|
+
it("a REJECT runs the agent like any other decision — the run continues without the tool (stigmer#197)", () => {
|
|
167
|
+
// Until #1096 this returned `{ kind: "rejected-by-user" }` and the runtime
|
|
168
168
|
// FAILED the execution before any engine ran, contradicting the proto, the
|
|
169
|
-
// conformance suite and the native harness
|
|
169
|
+
// conformance suite and the native harness.
|
|
170
170
|
const decisions = new Map([
|
|
171
171
|
["tc-1", ApprovalAction.APPROVE],
|
|
172
172
|
["tc-2", ApprovalAction.REJECT],
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*
|
|
35
35
|
* This is the contract as of stigmer#197: REJECT denies the tool and the run
|
|
36
36
|
* CONTINUES; it never fails the execution. The native harness proved it
|
|
37
|
-
* (`hitl.ts` `reconcileNonExecutingDecisions`, moved here
|
|
37
|
+
* (`hitl.ts` `reconcileNonExecutingDecisions`, moved here in #1096) and the
|
|
38
38
|
* conformance suite (`agentexecution-approval.conformance.test.ts`) is its
|
|
39
39
|
* arbiter for both harnesses.
|
|
40
40
|
*/
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* the Cursor builder renders the session's first user message), and the
|
|
16
16
|
* shared prompt glue (`shared/prompt-sections.ts`) is written so that
|
|
17
17
|
* placement stays each adapter's. The runtime would branch on it only if it
|
|
18
|
-
* ever composed prompts itself —
|
|
19
|
-
* that exists
|
|
18
|
+
* ever composed prompts itself — an open unification question (#1135), not a
|
|
19
|
+
* phase that exists.
|
|
20
20
|
*
|
|
21
21
|
* The matrix the contract was designed against (2026-09; Claude and Codex are
|
|
22
22
|
* the surveyed SDKs, not built harnesses):
|
|
@@ -53,12 +53,22 @@ import type { VisionProfile } from "../shared/attachment-vision.js";
|
|
|
53
53
|
* - `deny-and-retry`: an out-of-process hook denies the tool, the adapter
|
|
54
54
|
* records the denial, cancels the run, and re-runs with grants on the next
|
|
55
55
|
* invocation.
|
|
56
|
-
* - `callback`: an in-process callback decides per tool
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
56
|
+
* - `callback`: an in-process callback decides per tool. The intended shape
|
|
57
|
+
* is the `interrupt` one seen from the runtime: the turn still ends
|
|
58
|
+
* `awaiting_approval` and reinvokes, and the adapter answers the callback
|
|
59
|
+
* with "deny, stop" and resumes with the decisions.
|
|
60
|
+
* - `none`: the engine offers no gate. The intended shape is that the
|
|
61
|
+
* runtime confines such a harness to capture-only work (a read-only
|
|
62
|
+
* sandbox) so a gated action never reaches the engine.
|
|
63
|
+
*
|
|
64
|
+
* Two of the four are built and two are reserved. `interrupt` (native) and
|
|
65
|
+
* `deny-and-retry` (Cursor) each have a real adapter and the contract kit
|
|
66
|
+
* runs under both. `callback` and `none` come from the 2026-09 survey of the
|
|
67
|
+
* Claude and Codex SDKs: the type carries them so an adapter can declare
|
|
68
|
+
* them, but no adapter does, and the runtime reads `pausePrimitive` in one
|
|
69
|
+
* place only (`turn-context.ts` `regeneratesApprovedWrites`, which returns
|
|
70
|
+
* false for `none`). The capture-only confinement for `none` is design
|
|
71
|
+
* still to be done before the first gate-less harness lands.
|
|
62
72
|
*/
|
|
63
73
|
export type PausePrimitive = "interrupt" | "deny-and-retry" | "callback" | "none";
|
|
64
74
|
|
|
@@ -78,9 +88,9 @@ export type StateIdSource = "deterministic" | "engine-minted";
|
|
|
78
88
|
* workspace-relative paths the harness writes into the repo that a turn's
|
|
79
89
|
* diff must never show (Cursor's transient `.cursor/hooks.json`). Declared
|
|
80
90
|
* once per adapter, read by `harness/capture.ts` (the pin, the progress
|
|
81
|
-
* slice, the candidate) and `turn-context.ts` (the reconcile).
|
|
82
|
-
* as an argument, homed here
|
|
83
|
-
* reader
|
|
91
|
+
* slice, the candidate) and `turn-context.ts` (the reconcile). First passed
|
|
92
|
+
* as an argument, then homed here as a capability (#1070); the capture joined
|
|
93
|
+
* the reconcile as a reader in #1096.
|
|
84
94
|
*/
|
|
85
95
|
export interface FileReviewIdentity {
|
|
86
96
|
readonly harnessId: string;
|
package/src/harness/capture.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* that the runtime cannot read is what its engine observed touching
|
|
22
22
|
* CAS-owned paths (`TurnSink.bindCasObservations`).
|
|
23
23
|
*
|
|
24
|
-
* Until
|
|
24
|
+
* Until #1096 both adapters carried this whole act (Cursor in its
|
|
25
25
|
* `turn-boundary.ts` between the stream and `run.wait()`, the deep-agent in
|
|
26
26
|
* its `turn-settle.ts`), each with its own evidence source and its own
|
|
27
27
|
* scoping rules for the provenance and the stamp. The two rules here are the
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* position, because on BOTH engines an approved command executes on the
|
|
34
34
|
* row the runtime seeded for it (the deep-agent's builder and Cursor's
|
|
35
35
|
* translator both reconcile the re-attempt onto the seeded WAITING row),
|
|
36
|
-
* at its prior position; a positional scope misses it (
|
|
36
|
+
* at its prior position; a positional scope misses it (Cursor's
|
|
37
37
|
* did, so its auto-keep never qualified a gated-then-approved command).
|
|
38
38
|
* "Executed" is a COMPLETED row. "Consented" is the row's own
|
|
39
39
|
* server-authored `approval_action` — the seeded row keeps its id and its
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
* The substrate and the ledger authoring (`shared/filereview/capture.ts`,
|
|
51
51
|
* `cas-touched.ts`, `progress.ts`); the resume-time reconcile
|
|
52
52
|
* (`turn-context.ts` `reconcileReinvocation`, already the runtime's since
|
|
53
|
-
*
|
|
53
|
+
* #1070); the outcome matrix that turns "a review is pending" into a phase
|
|
54
54
|
* (`run-turn.ts`, through `terminal-table.ts` `awaitingReviewArm`).
|
|
55
55
|
*
|
|
56
|
-
* TWO GAPS THIS MODULE DOES NOT CLOSE (recorded
|
|
56
|
+
* TWO GAPS THIS MODULE DOES NOT CLOSE (recorded as #1115)
|
|
57
57
|
* ----------------------------------------------------------------------
|
|
58
58
|
* A turn that ends `interrupted` is not captured (a stop fired; the tree may
|
|
59
59
|
* be mid-edit). So a platform STOP returns COMPLETED with unreviewed edits
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* the tree is read at most once per floor interval and only re-attached
|
|
16
16
|
* when it moved (`shared/filereview/progress.ts`), so a write that
|
|
17
17
|
* changed nothing on disk carries the snapshot it already had. Before
|
|
18
|
-
*
|
|
18
|
+
* #1096 each adapter's stream loop did this before its own persists; the
|
|
19
19
|
* runtime owns the capture now, so the display field it derives is
|
|
20
20
|
* refreshed where every other runtime-owned field is — here.
|
|
21
21
|
* 3. `streaming_usage` is refreshed from the accumulator when it has turns,
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* 4. `persistStatus` (`shared/status.ts`): tool-output offload, the
|
|
24
24
|
* aggregate size cap, transient retry, oversize recovery. Never rejects.
|
|
25
25
|
* 5. A Temporal heartbeat, so a long streaming turn's liveness is proven by
|
|
26
|
-
* the writes it makes
|
|
26
|
+
* the writes it makes.
|
|
27
27
|
* 6. The control plane's answer: STOP becomes the runtime's platform-stop
|
|
28
28
|
* cause on the stop controller, which aborts the adapter's signal.
|
|
29
29
|
*
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* and resolves when that follow-up has. The promise it returns therefore
|
|
35
35
|
* always means "the state as of my request is on the control plane", which
|
|
36
36
|
* is what lets the Cursor loop await it and see a STOP before it pulls the
|
|
37
|
-
* next event, exactly as its own inline persist did
|
|
37
|
+
* next event, exactly as its own inline persist did.
|
|
38
38
|
*
|
|
39
39
|
* The runtime's terminal writes use the same path (`write()`), so the
|
|
40
40
|
* secret backstop and the usage summary ride the final status too, as they
|
package/src/harness/registry.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* dials the control plane, and `shutdownHarnesses` runs them in reverse so
|
|
11
11
|
* what was set up last is torn down first.
|
|
12
12
|
*
|
|
13
|
-
* Error posture
|
|
13
|
+
* Error posture (fixed in #1064):
|
|
14
14
|
* - Boot validates the whole table BEFORE booting anything (a duplicate name
|
|
15
15
|
* is a configuration defect, and a half-booted worker is the worst state to
|
|
16
16
|
* discover it in), then fails fast at the first adapter that rejects. A
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* turn runtime (`run-turn.ts`). The table of real rows is NOT here: it lives
|
|
24
24
|
* at the source root (`src/harness-adapters.ts`), because a row imports its
|
|
25
25
|
* adapter from `activities/` and nothing under `src/harness/` may
|
|
26
|
-
* (`__tests__/import-direction.test.ts
|
|
26
|
+
* (`__tests__/import-direction.test.ts`). The registry knows rows,
|
|
27
27
|
* never which adapters exist.
|
|
28
28
|
*
|
|
29
29
|
* `HarnessName` lives here and not in `types.ts` on purpose: the wire
|
package/src/harness/run-turn.ts
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* every harness, with the engine behind the adapter contract (`types.ts`).
|
|
4
4
|
*
|
|
5
5
|
* What runs here and nowhere else: the activity's identity and its
|
|
6
|
-
* execution-scoped context; the status
|
|
6
|
+
* execution-scoped context; the status, the one transcript builder over it
|
|
7
|
+
* (born with the status, seeded by the reinvocation phase, handed to the
|
|
8
|
+
* adapter as `sink.transcript`, finalized once the adapter returns) and the
|
|
9
|
+
* single persist chokepoint;
|
|
7
10
|
* the periodic heartbeat; the stop controller and its four producers (the
|
|
8
11
|
* stall watchdog, the cost cap, the platform STOP, Temporal's cancellation);
|
|
9
12
|
* the resolution phases (`turn-context.ts`) composed into the `TurnInput`;
|
|
@@ -24,9 +27,8 @@
|
|
|
24
27
|
* registry row, not a branch.
|
|
25
28
|
*
|
|
26
29
|
* Extracted from `activities/execute-cursor/index.ts` `executeCursorInner`
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* ruling). Its twelve resolution phases came out at M2; what came out here is
|
|
30
|
+
* in #1070, whose body carries the reasoning behind each phase. Its twelve
|
|
31
|
+
* resolution phases came out first; what came out here is
|
|
30
32
|
* everything between them and after the engine: the seventeen hermetic
|
|
31
33
|
* goldens under `execute-cursor/__tests__/hermetic/` pin the result byte
|
|
32
34
|
* for byte, and `__tests__/run-turn.test.ts` proves the table against the
|
|
@@ -81,6 +83,7 @@ import {
|
|
|
81
83
|
workspaceLockTimeoutArm,
|
|
82
84
|
type TerminalArm,
|
|
83
85
|
} from "./terminal-table.js";
|
|
86
|
+
import { TranscriptBuilder } from "./transcript/builder.js";
|
|
84
87
|
import { resolveTurnContext, type ResolutionDeps, type TurnFrame, type TurnSettlement } from "./turn-context.js";
|
|
85
88
|
import type { HarnessAdapter, TurnInput, TurnSink } from "./types.js";
|
|
86
89
|
import { UsageAccumulator } from "./usage-accumulator.js";
|
|
@@ -148,6 +151,15 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
148
151
|
startedAt: utcTimestamp(),
|
|
149
152
|
});
|
|
150
153
|
|
|
154
|
+
// The one transcript builder of this turn, born with the status and before
|
|
155
|
+
// any phase, so it exists for everything that writes a row or an output
|
|
156
|
+
// onto the status: the write-back coordinator (phase 2c), the seed of a
|
|
157
|
+
// reinvocation's prior rows (phase 3, through `seed()`, which indexes them
|
|
158
|
+
// as it appends), the adapter (`sink.transcript`), and the epilogue. One
|
|
159
|
+
// constructor call per turn; a second builder over the same status would
|
|
160
|
+
// index the same rows twice.
|
|
161
|
+
const transcript = new TranscriptBuilder(executionId, status);
|
|
162
|
+
|
|
151
163
|
// Cold-start timeline of this turn's setup: one mark after each phase, the
|
|
152
164
|
// adapter's own segments marked through the sink, emitted by the adapter
|
|
153
165
|
// once its engine is resolved (an early return skips it — partial setups
|
|
@@ -254,7 +266,7 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
254
266
|
);
|
|
255
267
|
// The execution completes here, so its answer rides the slim as it
|
|
256
268
|
// does from `completeTurn`: the seed carried the transcript and any
|
|
257
|
-
// structured output the paused turn resolved
|
|
269
|
+
// structured output the paused turn resolved.
|
|
258
270
|
return { kind: "return", value: completionSlim(lastAssistantText()) };
|
|
259
271
|
}
|
|
260
272
|
default: {
|
|
@@ -274,7 +286,7 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
274
286
|
// The stall watchdog: the periodic heartbeat proves the process is alive,
|
|
275
287
|
// not that the engine is progressing; if the engine wedges, nothing
|
|
276
288
|
// arrives and the turn would hang forever. Armed for the adapter's whole
|
|
277
|
-
// stretch
|
|
289
|
+
// stretch and reset by every `recordActivity`; on stall the
|
|
278
290
|
// signal aborts, the adapter cancels its run, and the table reports the
|
|
279
291
|
// stall with the last detail the adapter named.
|
|
280
292
|
watchdog = startStallWatchdog(config.cursorStreamStallTimeoutMs, (idleMs) => {
|
|
@@ -288,6 +300,7 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
288
300
|
|
|
289
301
|
const sink: TurnSink = {
|
|
290
302
|
status,
|
|
303
|
+
transcript,
|
|
291
304
|
stopSignal: stop.signal,
|
|
292
305
|
setupTiming,
|
|
293
306
|
requestPersist: () => chokepoint.request(),
|
|
@@ -343,6 +356,16 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
343
356
|
armedWatchdog.stop();
|
|
344
357
|
heartbeatPhase = "epilogue";
|
|
345
358
|
|
|
359
|
+
// The stream is over, however it ended: nothing on the transcript is
|
|
360
|
+
// still streaming. Here and not only in the adapters' settles, because
|
|
361
|
+
// this is the one place that sees every path — a turn that failed before
|
|
362
|
+
// its settle, or ended on a thrown budget, used to persist its last
|
|
363
|
+
// message with the flag on, a spinner the console never stopped (the
|
|
364
|
+
// kit's settled-transcript fact caught it on both real adapters).
|
|
365
|
+
// Idempotent: an adapter that persists on the settled rows mid-settle
|
|
366
|
+
// finalizes first, as the Cursor harness does before `run.wait()`.
|
|
367
|
+
transcript.finalize();
|
|
368
|
+
|
|
346
369
|
// The capture boundary, ONCE, over whatever the whole turn left on the
|
|
347
370
|
// tree — unless a stop fired mid-turn (`interrupted`: the tree may be
|
|
348
371
|
// mid-edit and the pause or drain reinvokes this same turn). Before the
|
|
@@ -381,7 +404,7 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
381
404
|
// approval or file-review signal and reinvokes.
|
|
382
405
|
return settleWith(awaitingApprovalArm());
|
|
383
406
|
case "tool_call_limit": {
|
|
384
|
-
// A review wins over the terminal
|
|
407
|
+
// A review wins over the terminal: the limit's copy rides
|
|
385
408
|
// the transcript and the reinvocation's reconcile completes the turn.
|
|
386
409
|
const settledLimit = await settleWith(reviewPending ? awaitingReviewArm(toolCallLimitArm()) : toolCallLimitArm());
|
|
387
410
|
console.log(`${activityName} terminated (tool-call limit): execution=${executionId}${reviewPending ? ", review pending" : ""}`);
|
|
@@ -459,7 +482,7 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
459
482
|
/**
|
|
460
483
|
* The engine finished AND left a reviewable change: the structured output
|
|
461
484
|
* is resolved now, before the WAITING persist, so the resume that
|
|
462
|
-
* reconciles the review completes with it
|
|
485
|
+
* reconciles the review completes with it; then
|
|
463
486
|
* the review pause. Nothing else of the completion epilogue runs here —
|
|
464
487
|
* the plan artifact and the write-back belong to the settlement that
|
|
465
488
|
* actually completes the execution.
|
|
@@ -530,7 +553,7 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
530
553
|
* unless the adapter already did (the deep-agent's `structuredResponse`):
|
|
531
554
|
* extracted from the final text through the tiers below. Runs where the
|
|
532
555
|
* engine has FINISHED speaking — a completed turn, and a completed turn
|
|
533
|
-
* the runtime pauses for file review (
|
|
556
|
+
* the runtime pauses for file review (the pure-reconcile
|
|
534
557
|
* COMPLETED then carries it, on every harness).
|
|
535
558
|
*/
|
|
536
559
|
async function resolveStructuredOutput(turn: TurnInput, finalText: string | undefined): Promise<void> {
|
|
@@ -663,6 +686,7 @@ async function runTurn(deps: TurnRuntimeDeps, input: NormalizedActivityInput): P
|
|
|
663
686
|
client,
|
|
664
687
|
config,
|
|
665
688
|
status,
|
|
689
|
+
transcript,
|
|
666
690
|
artifactStorage,
|
|
667
691
|
timing: setupTiming,
|
|
668
692
|
signal: cancellationSignal,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Nothing here is engine-specific and nothing here persists; the Cursor
|
|
16
16
|
* orchestrator kept the same facts as flags on its stream state
|
|
17
|
-
* (`turn-stream.ts` `TurnStreamState`, before
|
|
17
|
+
* (`turn-stream.ts` `TurnStreamState`, before #1070 moved them out).
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { StallTimeoutError } from "../shared/stall-watchdog.js";
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* for byte, `activities/execute-cursor/__tests__/hermetic/`), and a table a
|
|
10
10
|
* reader can scan is how that contract stays reviewable. The native
|
|
11
11
|
* harness once kept one function per arm (`streaming-terminal.ts`, retired
|
|
12
|
-
*
|
|
12
|
+
* in #1096); since #1096 both harnesses' turns end through this one table.
|
|
13
13
|
*
|
|
14
14
|
* The throw-vs-return rule, unchanged from the orchestrator it replaces:
|
|
15
15
|
* - RETURN when a Temporal retry would only repeat the outcome — a stall
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
* is persisted exactly once, by `run-turn.ts`'s `settleWith` — the one
|
|
26
26
|
* writer of a terminal. The orchestrator this table replaced appended the
|
|
27
27
|
* three THROW arms' rows twice (its throw fell into its own catch, which
|
|
28
|
-
* wrote the copy again);
|
|
29
|
-
* pin the wire byte for byte, and the PR after
|
|
30
|
-
* golden regeneration (stigmer#1054
|
|
28
|
+
* wrote the copy again); #1070 reproduced that on purpose so the goldens could
|
|
29
|
+
* pin the wire byte for byte, and the PR after it removed it with a reviewed
|
|
30
|
+
* golden regeneration (stigmer#1054).
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
import { create } from "@bufbuild/protobuf";
|
|
@@ -174,7 +174,7 @@ export function infrastructureCancelArm(): TerminalArm {
|
|
|
174
174
|
* The engine proposed at least one gated side effect and stopped: the
|
|
175
175
|
* WAITING_APPROVAL rows are already on the transcript. Not an error, not
|
|
176
176
|
* complete, no copy; RETURN to the workflow, which waits for the approval
|
|
177
|
-
* signal and reinvokes with the decisions. Until
|
|
177
|
+
* signal and reinvokes with the decisions. Until #1096 this was an inline
|
|
178
178
|
* phase flip in `run-turn.ts`; it is an arm because every way an activity
|
|
179
179
|
* ends belongs in this one table.
|
|
180
180
|
*/
|
|
@@ -193,11 +193,11 @@ export function awaitingApprovalArm(): TerminalArm {
|
|
|
193
193
|
* tool-call-limit copy; an `engine`-surface failure has none), never its
|
|
194
194
|
* phase, its `error` or its completion stamp, and the resume's reconcile
|
|
195
195
|
* settles the execution COMPLETED as every pure file-review resume does
|
|
196
|
-
* (`fileReviewResolvedArm`). Until
|
|
196
|
+
* (`fileReviewResolvedArm`). Until #1096 only the Cursor harness behaved so,
|
|
197
197
|
* and only because its boundary ran before it consulted its engine's
|
|
198
198
|
* result; the deep-agent wrote FAILED with the edits applied and unreviewed.
|
|
199
199
|
* Stated cost: the cloud's `status.error` prefix match for a tool-call limit
|
|
200
|
-
* does not fire when that limit left edits
|
|
200
|
+
* does not fire when that limit left edits.
|
|
201
201
|
*/
|
|
202
202
|
export function awaitingReviewArm(deferred?: TerminalArm): TerminalArm {
|
|
203
203
|
return {
|