@stigmer/runner 3.15.0 → 3.15.2-dev.20260913223433
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 -4
- package/dist/.build-fingerprint +1 -1
- package/dist/__test-utils__/execution-record-fixture.d.ts +14 -0
- package/dist/__test-utils__/execution-record-fixture.js +4 -0
- package/dist/__test-utils__/execution-record-fixture.js.map +1 -1
- package/dist/__test-utils__/file-review-projection.d.ts +40 -0
- package/dist/__test-utils__/file-review-projection.js +136 -0
- package/dist/__test-utils__/file-review-projection.js.map +1 -0
- package/dist/__test-utils__/harness-contract/types.d.ts +23 -1
- package/dist/__test-utils__/harness-contract/types.js +15 -0
- package/dist/__test-utils__/harness-contract/types.js.map +1 -1
- package/dist/__test-utils__/hermetic-activity.d.ts +44 -12
- package/dist/__test-utils__/hermetic-activity.js +52 -14
- package/dist/__test-utils__/hermetic-activity.js.map +1 -1
- package/dist/__test-utils__/model-registry-fixture.d.ts +32 -7
- package/dist/__test-utils__/model-registry-fixture.js +31 -7
- package/dist/__test-utils__/model-registry-fixture.js.map +1 -1
- package/dist/__test-utils__/turn-input-fixture.d.ts +1 -1
- package/dist/__test-utils__/turn-input-fixture.js +1 -1
- package/dist/__test-utils__/turn-input-fixture.js.map +1 -1
- package/dist/activities/call-agent.js +2 -2
- package/dist/activities/call-agent.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +45 -3
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +0 -9
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +2 -41
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -1
- package/dist/activities/execute-cursor/adapter.d.ts +7 -5
- package/dist/activities/execute-cursor/adapter.js +7 -5
- package/dist/activities/execute-cursor/adapter.js.map +1 -1
- package/dist/activities/execute-cursor/approval-policy.d.ts +5 -2
- package/dist/activities/execute-cursor/approval-policy.js +5 -2
- package/dist/activities/execute-cursor/approval-policy.js.map +1 -1
- package/dist/activities/execute-cursor/approval-state.d.ts +16 -8
- package/dist/activities/execute-cursor/approval-state.js +6 -3
- package/dist/activities/execute-cursor/approval-state.js.map +1 -1
- package/dist/activities/execute-cursor/cas-observations.d.ts +14 -2
- package/dist/activities/execute-cursor/cas-observations.js +19 -2
- package/dist/activities/execute-cursor/cas-observations.js.map +1 -1
- package/dist/activities/execute-cursor/cursor-capabilities.d.ts +8 -4
- package/dist/activities/execute-cursor/cursor-capabilities.js +21 -4
- package/dist/activities/execute-cursor/cursor-capabilities.js.map +1 -1
- package/dist/activities/execute-cursor/message-translator.d.ts +12 -20
- package/dist/activities/execute-cursor/message-translator.js +19 -32
- package/dist/activities/execute-cursor/message-translator.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +48 -58
- package/dist/activities/execute-cursor/prompt-builder.js +76 -95
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-cursor/turn-boundary.d.ts +27 -55
- package/dist/activities/execute-cursor/turn-boundary.js +30 -90
- 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 +37 -49
- package/dist/activities/execute-cursor/turn-settle.js.map +1 -1
- package/dist/activities/execute-cursor/turn-setup.d.ts +16 -24
- package/dist/activities/execute-cursor/turn-setup.js +29 -59
- package/dist/activities/execute-cursor/turn-setup.js.map +1 -1
- package/dist/activities/execute-cursor/turn-stream.d.ts +3 -8
- package/dist/activities/execute-cursor/turn-stream.js +9 -22
- package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
- package/dist/activities/execute-cursor/turn.js +5 -1
- package/dist/activities/execute-cursor/turn.js.map +1 -1
- package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.d.ts +93 -0
- package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js +348 -0
- package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.d.ts +170 -0
- package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js +225 -0
- package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.d.ts +24 -0
- package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js +41 -0
- package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.d.ts +54 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js +72 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.d.ts +187 -23
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js +238 -27
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js.map +1 -1
- package/dist/activities/execute-deep-agent/adapter.d.ts +41 -0
- package/dist/activities/execute-deep-agent/adapter.js +78 -0
- package/dist/activities/execute-deep-agent/adapter.js.map +1 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.d.ts +8 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.js +9 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.js.map +1 -1
- package/dist/activities/execute-deep-agent/deep-agent-capabilities.d.ts +31 -0
- package/dist/activities/execute-deep-agent/deep-agent-capabilities.js +40 -0
- package/dist/activities/execute-deep-agent/deep-agent-capabilities.js.map +1 -0
- package/dist/activities/execute-deep-agent/execution-state.d.ts +4 -11
- package/dist/activities/execute-deep-agent/execution-state.js +4 -12
- package/dist/activities/execute-deep-agent/execution-state.js.map +1 -1
- package/dist/activities/execute-deep-agent/hitl.d.ts +49 -47
- package/dist/activities/execute-deep-agent/hitl.js +77 -103
- package/dist/activities/execute-deep-agent/hitl.js.map +1 -1
- package/dist/activities/execute-deep-agent/prompt-builder.d.ts +51 -23
- package/dist/activities/execute-deep-agent/prompt-builder.js +115 -76
- package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/status-builder-shared.d.ts +18 -32
- package/dist/activities/execute-deep-agent/status-builder-shared.js +10 -65
- package/dist/activities/execute-deep-agent/status-builder-shared.js.map +1 -1
- package/dist/activities/execute-deep-agent/streaming-side-effects.d.ts +10 -8
- package/dist/activities/execute-deep-agent/streaming-side-effects.js +12 -14
- package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-tracker.d.ts +36 -13
- package/dist/activities/execute-deep-agent/subagent-tracker.js +76 -39
- package/dist/activities/execute-deep-agent/subagent-tracker.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +25 -28
- package/dist/activities/execute-deep-agent/subagent-transformer.js +29 -82
- package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +3 -2
- package/dist/activities/execute-deep-agent/subagent-wiring.js +2 -2
- package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -1
- package/dist/activities/execute-deep-agent/turn-settle.d.ts +42 -0
- package/dist/activities/execute-deep-agent/turn-settle.js +146 -0
- package/dist/activities/execute-deep-agent/turn-settle.js.map +1 -0
- package/dist/activities/execute-deep-agent/turn-setup.d.ts +212 -0
- package/dist/activities/execute-deep-agent/turn-setup.js +430 -0
- package/dist/activities/execute-deep-agent/turn-setup.js.map +1 -0
- package/dist/activities/execute-deep-agent/turn-stream.d.ts +97 -0
- package/dist/activities/execute-deep-agent/turn-stream.js +242 -0
- package/dist/activities/execute-deep-agent/turn-stream.js.map +1 -0
- package/dist/activities/execute-deep-agent/turn.d.ts +42 -0
- package/dist/activities/execute-deep-agent/turn.js +116 -0
- package/dist/activities/execute-deep-agent/turn.js.map +1 -0
- package/dist/activities/execute-deep-agent/v3-event-recorder.d.ts +6 -5
- package/dist/activities/execute-deep-agent/v3-event-recorder.js +6 -5
- package/dist/activities/execute-deep-agent/v3-event-recorder.js.map +1 -1
- package/dist/activities/execute-deep-agent/v3-events.d.ts +1 -1
- package/dist/activities/execute-deep-agent/v3-events.js +1 -1
- package/dist/activities/execute-deep-agent/v3-status-builder.d.ts +60 -17
- package/dist/activities/execute-deep-agent/v3-status-builder.js +72 -57
- package/dist/activities/execute-deep-agent/v3-status-builder.js.map +1 -1
- package/dist/harness/approval-decisions.d.ts +61 -0
- package/dist/harness/approval-decisions.js +102 -0
- package/dist/harness/approval-decisions.js.map +1 -0
- package/dist/harness/capabilities.d.ts +16 -5
- package/dist/harness/capabilities.js +9 -0
- package/dist/harness/capabilities.js.map +1 -1
- package/dist/harness/capture.d.ts +144 -0
- package/dist/harness/capture.js +219 -0
- package/dist/harness/capture.js.map +1 -0
- package/dist/harness/persist-chokepoint.d.ts +19 -4
- package/dist/harness/persist-chokepoint.js +17 -4
- package/dist/harness/persist-chokepoint.js.map +1 -1
- package/dist/harness/run-turn.js +115 -29
- package/dist/harness/run-turn.js.map +1 -1
- package/dist/harness/terminal-table.d.ts +40 -11
- package/dist/harness/terminal-table.js +58 -19
- package/dist/harness/terminal-table.js.map +1 -1
- package/dist/harness/turn-context.d.ts +141 -76
- package/dist/harness/turn-context.js +194 -99
- package/dist/harness/turn-context.js.map +1 -1
- package/dist/harness/types.d.ts +65 -12
- package/dist/harness/types.js +8 -2
- package/dist/harness/types.js.map +1 -1
- package/dist/harness-adapters.d.ts +12 -8
- package/dist/harness-adapters.js +17 -9
- package/dist/harness-adapters.js.map +1 -1
- package/dist/middleware/approval-gate.d.ts +1 -1
- package/dist/middleware/approval-gate.js +1 -1
- package/dist/middleware/approval-gate.js.map +1 -1
- package/dist/middleware/cost-advisory.d.ts +39 -0
- package/dist/middleware/{cost-cap.js → cost-advisory.js} +37 -55
- package/dist/middleware/cost-advisory.js.map +1 -0
- package/dist/middleware/index.d.ts +23 -12
- package/dist/middleware/index.js +26 -18
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/types.d.ts +3 -2
- package/dist/runner-manager.js +1 -5
- package/dist/runner-manager.js.map +1 -1
- package/dist/runner.js +1 -5
- package/dist/runner.js.map +1 -1
- package/dist/shared/attachment-resolver.d.ts +41 -18
- package/dist/shared/attachment-resolver.js +178 -46
- package/dist/shared/attachment-resolver.js.map +1 -1
- package/dist/shared/attachment-zip.d.ts +85 -0
- package/dist/shared/attachment-zip.js +185 -0
- package/dist/shared/attachment-zip.js.map +1 -0
- package/dist/shared/connect-backfill.js +5 -4
- package/dist/shared/connect-backfill.js.map +1 -1
- package/dist/shared/cost-guard.d.ts +3 -3
- package/dist/shared/cost-guard.js +3 -3
- package/dist/shared/execution-status-writer.d.ts +5 -5
- package/dist/shared/execution-status-writer.js +5 -5
- package/dist/shared/extract-structured-output.d.ts +8 -7
- package/dist/shared/extract-structured-output.js +8 -7
- package/dist/shared/extract-structured-output.js.map +1 -1
- package/dist/shared/filereview/cas-progress.d.ts +1 -18
- package/dist/shared/filereview/cas-progress.js +4 -0
- package/dist/shared/filereview/cas-progress.js.map +1 -1
- package/dist/shared/filereview/cas-touched.d.ts +56 -0
- package/dist/shared/filereview/cas-touched.js +63 -0
- package/dist/shared/filereview/cas-touched.js.map +1 -0
- package/dist/shared/filereview/index.d.ts +2 -1
- package/dist/shared/filereview/index.js +2 -1
- package/dist/shared/filereview/index.js.map +1 -1
- package/dist/shared/mcp-resolver.d.ts +4 -5
- package/dist/shared/mcp-resolver.js +4 -5
- package/dist/shared/mcp-resolver.js.map +1 -1
- package/dist/shared/persist-decision.d.ts +3 -4
- package/dist/shared/persist-decision.js +3 -4
- package/dist/shared/persist-decision.js.map +1 -1
- package/dist/shared/plan-mode-permissions.d.ts +2 -2
- package/dist/shared/plan-mode-permissions.js +2 -2
- package/dist/shared/plan-mode-prompt.d.ts +1 -1
- package/dist/shared/plan-mode-prompt.js +1 -1
- package/dist/shared/prompt-sections.d.ts +163 -0
- package/dist/shared/prompt-sections.js +164 -0
- package/dist/shared/prompt-sections.js.map +1 -0
- package/dist/shared/skill-resolver.d.ts +4 -2
- package/dist/shared/skill-resolver.js +4 -2
- package/dist/shared/skill-resolver.js.map +1 -1
- package/dist/shared/tool-rounds.d.ts +32 -0
- package/dist/shared/tool-rounds.js +43 -0
- package/dist/shared/tool-rounds.js.map +1 -1
- package/dist/shared/tool-row.d.ts +34 -0
- package/dist/shared/tool-row.js +52 -0
- package/dist/shared/tool-row.js.map +1 -1
- package/dist/shared/workspace/session-provision.d.ts +3 -3
- package/dist/shared/workspace/session-provision.js +3 -3
- package/dist/shared/workspace/stigmer-link.d.ts +3 -3
- package/dist/shared/workspace/stigmer-link.js +3 -3
- package/dist/shared/workspace/writeback-coordinator.d.ts +15 -22
- package/dist/shared/workspace/writeback-coordinator.js +16 -53
- package/dist/shared/workspace/writeback-coordinator.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/package.json +4 -4
- package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +1 -0
- package/src/__test-utils__/execution-record-fixture.ts +18 -2
- package/src/__test-utils__/file-review-projection.ts +156 -0
- package/src/__test-utils__/git-workspace-fixture.ts +58 -0
- package/src/__test-utils__/harness-boot-order-child.ts +7 -2
- package/src/__test-utils__/harness-contract/contract.ts +33 -20
- package/src/__test-utils__/harness-contract/recording-sink.ts +11 -1
- package/src/__test-utils__/harness-contract/runtime-contract.ts +328 -10
- package/src/__test-utils__/harness-contract/scripted-adapter.ts +38 -6
- package/src/__test-utils__/harness-contract/types.ts +27 -3
- package/src/__test-utils__/hermetic-activity.ts +52 -14
- package/src/__test-utils__/model-registry-fixture.ts +32 -7
- package/src/__test-utils__/module-specifiers.ts +24 -0
- package/src/__test-utils__/turn-input-fixture.ts +2 -2
- package/src/__tests__/harness-boot-order.test.ts +9 -2
- package/src/activities/call-agent.ts +2 -2
- package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +47 -3
- package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +2 -48
- package/src/activities/execute-cursor/__tests__/approval-decisions-agree.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +6 -1
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +52 -27
- package/src/activities/execute-cursor/__tests__/cas-observations.test.ts +25 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.everything.prompt.md +166 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.plan-mode.prompt.md +186 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.hitl.recovery.prompt.md +191 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.hitl.reinvocation.prompt.md +13 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.resumed.prefixed.prompt.md +32 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.resumed.raw.prompt.md +1 -0
- package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +1 -2
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.status.json +4 -0
- package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +24 -4
- package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +6 -5
- package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +9 -0
- package/src/activities/execute-cursor/__tests__/hitl-resume-history.test.ts +11 -8
- package/src/activities/execute-cursor/__tests__/prompt-goldens.test.ts +229 -0
- package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +3 -3
- package/src/activities/execute-cursor/__tests__/sequential-gate-resume.test.ts +2 -2
- package/src/activities/execute-cursor/__tests__/turn-boundary.test.ts +78 -234
- package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +1 -26
- package/src/activities/execute-cursor/adapter.ts +7 -5
- package/src/activities/execute-cursor/approval-policy.ts +5 -2
- package/src/activities/execute-cursor/approval-state.ts +16 -8
- package/src/activities/execute-cursor/cas-observations.ts +20 -2
- package/src/activities/execute-cursor/cursor-capabilities.ts +24 -5
- package/src/activities/execute-cursor/message-translator.ts +29 -41
- package/src/activities/execute-cursor/prompt-builder.ts +99 -157
- package/src/activities/execute-cursor/turn-boundary.ts +34 -140
- package/src/activities/execute-cursor/turn-settle.ts +37 -51
- package/src/activities/execute-cursor/turn-setup.ts +30 -70
- package/src/activities/execute-cursor/turn-stream.ts +8 -31
- package/src/activities/execute-cursor/turn.ts +5 -1
- package/src/activities/execute-deep-agent/__test-utils__/contract-subject.ts +391 -0
- package/src/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.ts +313 -0
- package/src/activities/execute-deep-agent/__test-utils__/hitl-script.ts +48 -0
- package/src/activities/execute-deep-agent/__test-utils__/scripted-model-module.ts +85 -0
- package/src/activities/execute-deep-agent/__test-utils__/scripted-model.ts +383 -36
- package/src/activities/execute-deep-agent/__tests__/adapter-graph-is-sdk-free.test.ts +76 -0
- package/src/activities/execute-deep-agent/__tests__/adapter-is-temporal-free.test.ts +47 -0
- package/src/activities/execute-deep-agent/__tests__/adapter.test.ts +80 -0
- package/src/activities/execute-deep-agent/__tests__/cas-capture-backend.test.ts +1 -1
- package/src/activities/execute-deep-agent/__tests__/execution-state-extended.test.ts +0 -2
- package/src/activities/execute-deep-agent/__tests__/execution-state.test.ts +0 -3
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.build-from-plan.prompt.md +172 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.everything.prompt.md +167 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.minimal.prompt.md +36 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.plan-mode.prompt.md +178 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.skills-below-threshold.prompt.md +158 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/file-review-capture.test.ts +210 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.status.json +74 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.status.json +104 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.status.json +78 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.status.json +138 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.status.json +68 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.status.json +154 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.status.json +116 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.status.json +69 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.status.json +67 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/plain-turn.status.json +47 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.status.json +68 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.status.json +280 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.status.json +77 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/resolution-error.status.json +18 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.status.json +99 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.status.json +109 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.status.json +76 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.text-fallback.status.json +51 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tier2.status.json +51 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tool-strategy.status.json +56 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.status.json +90 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.status.json +70 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.status.json +71 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/harness-contract.test.ts +144 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-approve-all-lease.test.ts +184 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-round-trips.test.ts +203 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-sequential-gates.test.ts +170 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/inline-artifact-across-gate.test.ts +175 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/pause-vs-shutdown.test.ts +206 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/plain-turn.test.ts +142 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/platform-stop.test.ts +126 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/recursion-limit.test.ts +139 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/resolution-error.test.ts +122 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/structured-output.test.ts +236 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-delegation.test.ts +161 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/tool-call.test.ts +157 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/workspace-lock-timeout.test.ts +152 -0
- package/src/activities/execute-deep-agent/__tests__/hitl.test.ts +50 -122
- package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +8 -6
- package/src/activities/execute-deep-agent/__tests__/plan-mode-path-normalization.test.ts +2 -2
- package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +35 -35
- package/src/activities/execute-deep-agent/__tests__/prompt-goldens.test.ts +247 -0
- package/src/activities/execute-deep-agent/__tests__/scripted-model.test.ts +329 -0
- package/src/activities/execute-deep-agent/__tests__/status-builder-shared.test.ts +1 -20
- package/src/activities/execute-deep-agent/__tests__/streaming-side-effects.test.ts +78 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-gitignored-capture.test.ts +1 -1
- package/src/activities/execute-deep-agent/__tests__/subagent-plan-mode-permissions.test.ts +2 -2
- package/src/activities/execute-deep-agent/__tests__/subagent-tracker.test.ts +57 -31
- package/src/activities/execute-deep-agent/__tests__/subagent-transformer.test.ts +19 -79
- package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +15 -15
- package/src/activities/execute-deep-agent/__tests__/summarization-verification.test.ts +1 -1
- package/src/activities/execute-deep-agent/__tests__/turn-stream.test.ts +391 -0
- package/src/activities/execute-deep-agent/__tests__/v3-status-builder.test.ts +343 -38
- package/src/activities/execute-deep-agent/__tests__/vision-input.test.ts +5 -5
- package/src/activities/execute-deep-agent/adapter.ts +94 -0
- package/src/activities/execute-deep-agent/cas-capture-observer.ts +11 -0
- package/src/activities/execute-deep-agent/deep-agent-capabilities.ts +43 -0
- package/src/activities/execute-deep-agent/execution-state.ts +4 -13
- package/src/activities/execute-deep-agent/hitl.ts +100 -123
- package/src/activities/execute-deep-agent/prompt-builder.ts +141 -115
- package/src/activities/execute-deep-agent/status-builder-shared.ts +21 -84
- package/src/activities/execute-deep-agent/streaming-side-effects.ts +13 -19
- package/src/activities/execute-deep-agent/subagent-tracker.ts +77 -42
- package/src/activities/execute-deep-agent/subagent-transformer.ts +46 -105
- package/src/activities/execute-deep-agent/subagent-wiring.ts +5 -4
- package/src/activities/execute-deep-agent/turn-settle.ts +164 -0
- package/src/activities/execute-deep-agent/turn-setup.ts +541 -0
- package/src/activities/execute-deep-agent/turn-stream.ts +313 -0
- package/src/activities/execute-deep-agent/turn.ts +131 -0
- package/src/activities/execute-deep-agent/v3-event-recorder.ts +6 -5
- package/src/activities/execute-deep-agent/v3-events.ts +1 -1
- package/src/activities/execute-deep-agent/v3-status-builder.ts +84 -63
- package/src/harness/__tests__/approval-decisions.test.ts +116 -0
- package/src/harness/__tests__/capture.test.ts +268 -0
- package/src/harness/__tests__/mount-skills.test.ts +169 -0
- package/src/harness/__tests__/persist-chokepoint.test.ts +38 -2
- package/src/harness/__tests__/run-turn-deterministic.test.ts +94 -0
- package/src/harness/__tests__/run-turn.test.ts +39 -23
- package/src/harness/__tests__/turn-attachments-vision.test.ts +80 -0
- package/src/harness/__tests__/turn-context.test.ts +73 -26
- package/src/harness/approval-decisions.ts +104 -0
- package/src/harness/capabilities.ts +16 -5
- package/src/harness/capture.ts +301 -0
- package/src/harness/persist-chokepoint.ts +24 -4
- package/src/harness/run-turn.ts +120 -29
- package/src/harness/terminal-table.ts +61 -20
- package/src/harness/turn-context.ts +208 -111
- package/src/harness/types.ts +66 -12
- package/src/harness-adapters.ts +17 -9
- package/src/middleware/__tests__/approval-gate.test.ts +1 -1
- package/src/middleware/__tests__/cost-advisory.test.ts +113 -0
- package/src/middleware/approval-gate.ts +2 -2
- package/src/middleware/{cost-cap.ts → cost-advisory.ts} +40 -70
- package/src/middleware/index.ts +29 -29
- package/src/middleware/types.ts +3 -2
- package/src/runner-manager.ts +0 -8
- package/src/runner.ts +0 -8
- package/src/shared/__tests__/attachment-naming.test.ts +6 -19
- package/src/shared/__tests__/attachment-resolver.test.ts +158 -8
- package/src/shared/__tests__/attachment-zip.test.ts +236 -0
- package/src/shared/__tests__/bedrock-adapter.test.ts +1 -1
- package/src/shared/__tests__/blueprint-resolver.test.ts +43 -0
- package/src/shared/__tests__/cost-guard.test.ts +3 -3
- package/src/shared/__tests__/prompt-sections.test.ts +167 -0
- package/src/shared/__tests__/secret-leak-scan.test.ts +2 -2
- package/src/{activities/execute-deep-agent → shared}/__tests__/stamp-flowed-rows.test.ts +33 -10
- package/src/shared/__tests__/vertex-adapter.test.ts +1 -1
- package/src/shared/attachment-resolver.ts +218 -55
- package/src/shared/attachment-zip.ts +281 -0
- package/src/shared/connect-backfill.ts +9 -11
- package/src/shared/cost-guard.ts +3 -3
- package/src/shared/execution-status-writer.ts +5 -5
- package/src/shared/extract-structured-output.ts +8 -7
- package/src/shared/filereview/__tests__/capture.test.ts +86 -4
- package/src/shared/filereview/__tests__/cas-progress.test.ts +2 -1
- package/src/shared/filereview/cas-progress.ts +5 -19
- package/src/shared/filereview/cas-touched.ts +89 -0
- package/src/shared/filereview/index.ts +4 -2
- package/src/shared/mcp-resolver.ts +4 -5
- package/src/shared/persist-decision.ts +3 -4
- package/src/shared/plan-mode-permissions.ts +2 -2
- package/src/shared/plan-mode-prompt.ts +1 -1
- package/src/shared/prompt-sections.ts +256 -0
- package/src/shared/skill-resolver.ts +4 -2
- package/src/shared/tool-rounds.ts +48 -0
- package/src/shared/tool-row.ts +61 -0
- package/src/shared/workspace/__tests__/stigmer-link.test.ts +7 -22
- package/src/shared/workspace/__tests__/writeback-coordinator.test.ts +20 -61
- package/src/shared/workspace/session-provision.ts +3 -3
- package/src/shared/workspace/stigmer-link.ts +3 -3
- package/src/shared/workspace/writeback-coordinator.ts +16 -64
- package/src/tools/index.ts +1 -1
- package/dist/activities/execute-cursor/capture-flow.d.ts +0 -142
- package/dist/activities/execute-cursor/capture-flow.js +0 -285
- package/dist/activities/execute-cursor/capture-flow.js.map +0 -1
- package/dist/activities/execute-cursor/command-provenance.d.ts +0 -48
- package/dist/activities/execute-cursor/command-provenance.js +0 -38
- package/dist/activities/execute-cursor/command-provenance.js.map +0 -1
- package/dist/activities/execute-deep-agent/attachment-injector.d.ts +0 -134
- package/dist/activities/execute-deep-agent/attachment-injector.js +0 -386
- package/dist/activities/execute-deep-agent/attachment-injector.js.map +0 -1
- package/dist/activities/execute-deep-agent/command-provenance.d.ts +0 -61
- package/dist/activities/execute-deep-agent/command-provenance.js +0 -72
- package/dist/activities/execute-deep-agent/command-provenance.js.map +0 -1
- package/dist/activities/execute-deep-agent/environment.d.ts +0 -24
- package/dist/activities/execute-deep-agent/environment.js +0 -58
- package/dist/activities/execute-deep-agent/environment.js.map +0 -1
- package/dist/activities/execute-deep-agent/event-recorder.d.ts +0 -21
- package/dist/activities/execute-deep-agent/event-recorder.js +0 -67
- package/dist/activities/execute-deep-agent/event-recorder.js.map +0 -1
- package/dist/activities/execute-deep-agent/index.d.ts +0 -15
- package/dist/activities/execute-deep-agent/index.js +0 -918
- package/dist/activities/execute-deep-agent/index.js.map +0 -1
- package/dist/activities/execute-deep-agent/mcp-gate.d.ts +0 -28
- package/dist/activities/execute-deep-agent/mcp-gate.js +0 -22
- package/dist/activities/execute-deep-agent/mcp-gate.js.map +0 -1
- package/dist/activities/execute-deep-agent/post-stream.d.ts +0 -23
- package/dist/activities/execute-deep-agent/post-stream.js +0 -71
- package/dist/activities/execute-deep-agent/post-stream.js.map +0 -1
- package/dist/activities/execute-deep-agent/setup.d.ts +0 -136
- package/dist/activities/execute-deep-agent/setup.js +0 -767
- package/dist/activities/execute-deep-agent/setup.js.map +0 -1
- package/dist/activities/execute-deep-agent/stamp-flowed-rows.d.ts +0 -36
- package/dist/activities/execute-deep-agent/stamp-flowed-rows.js +0 -56
- package/dist/activities/execute-deep-agent/stamp-flowed-rows.js.map +0 -1
- package/dist/activities/execute-deep-agent/status-builder.d.ts +0 -93
- package/dist/activities/execute-deep-agent/status-builder.js +0 -365
- package/dist/activities/execute-deep-agent/status-builder.js.map +0 -1
- package/dist/activities/execute-deep-agent/streaming-terminal.d.ts +0 -21
- package/dist/activities/execute-deep-agent/streaming-terminal.js +0 -80
- package/dist/activities/execute-deep-agent/streaming-terminal.js.map +0 -1
- package/dist/activities/execute-deep-agent/streaming-v3.d.ts +0 -13
- package/dist/activities/execute-deep-agent/streaming-v3.js +0 -174
- package/dist/activities/execute-deep-agent/streaming-v3.js.map +0 -1
- package/dist/activities/execute-deep-agent/streaming.d.ts +0 -81
- package/dist/activities/execute-deep-agent/streaming.js +0 -160
- package/dist/activities/execute-deep-agent/streaming.js.map +0 -1
- package/dist/middleware/cost-cap.d.ts +0 -22
- package/dist/middleware/cost-cap.js.map +0 -1
- package/dist/middleware/graceful-stop.d.ts +0 -17
- package/dist/middleware/graceful-stop.js +0 -63
- package/dist/middleware/graceful-stop.js.map +0 -1
- package/dist/shared/skill-writer.d.ts +0 -75
- package/dist/shared/skill-writer.js +0 -207
- package/dist/shared/skill-writer.js.map +0 -1
- package/src/activities/execute-cursor/__tests__/capture-flow.test.ts +0 -1032
- package/src/activities/execute-cursor/__tests__/command-provenance.test.ts +0 -240
- package/src/activities/execute-cursor/__tests__/progress-substrate.test.ts +0 -169
- package/src/activities/execute-cursor/capture-flow.ts +0 -379
- package/src/activities/execute-cursor/command-provenance.ts +0 -73
- package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +0 -1161
- package/src/activities/execute-deep-agent/__tests__/command-provenance.test.ts +0 -252
- package/src/activities/execute-deep-agent/__tests__/environment.test.ts +0 -108
- package/src/activities/execute-deep-agent/__tests__/event-recorder.test.ts +0 -150
- package/src/activities/execute-deep-agent/__tests__/hitl-integration.test.ts +0 -226
- package/src/activities/execute-deep-agent/__tests__/hitl-reject.test.ts +0 -318
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +0 -351
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +0 -293
- package/src/activities/execute-deep-agent/__tests__/index.test.ts +0 -99
- package/src/activities/execute-deep-agent/__tests__/mcp-gate.test.ts +0 -44
- package/src/activities/execute-deep-agent/__tests__/post-stream.test.ts +0 -112
- package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +0 -358
- package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +0 -1933
- package/src/activities/execute-deep-agent/__tests__/streaming-terminal.test.ts +0 -40
- package/src/activities/execute-deep-agent/__tests__/streaming-v3.test.ts +0 -597
- package/src/activities/execute-deep-agent/__tests__/streaming.test.ts +0 -508
- package/src/activities/execute-deep-agent/attachment-injector.ts +0 -627
- package/src/activities/execute-deep-agent/command-provenance.ts +0 -102
- package/src/activities/execute-deep-agent/environment.ts +0 -76
- package/src/activities/execute-deep-agent/event-recorder.ts +0 -95
- package/src/activities/execute-deep-agent/index.ts +0 -1072
- package/src/activities/execute-deep-agent/mcp-gate.ts +0 -37
- package/src/activities/execute-deep-agent/post-stream.ts +0 -109
- package/src/activities/execute-deep-agent/setup.ts +0 -1081
- package/src/activities/execute-deep-agent/stamp-flowed-rows.ts +0 -64
- package/src/activities/execute-deep-agent/status-builder.ts +0 -481
- package/src/activities/execute-deep-agent/streaming-terminal.ts +0 -106
- package/src/activities/execute-deep-agent/streaming-v3.ts +0 -277
- package/src/activities/execute-deep-agent/streaming.ts +0 -313
- package/src/middleware/__tests__/cost-cap.test.ts +0 -192
- package/src/middleware/__tests__/graceful-stop.test.ts +0 -105
- package/src/middleware/graceful-stop.ts +0 -86
- package/src/shared/__tests__/skill-writer.test.ts +0 -372
- package/src/shared/skill-writer.ts +0 -266
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime's file-review capture — apply-then-review for every harness,
|
|
3
|
+
* written once: the baseline pinned before the engine runs, the mid-run
|
|
4
|
+
* progress the chokepoint refreshes on every write, the candidate captured
|
|
5
|
+
* after the engine's turn, the DD-28 approved-command provenance, the flowed
|
|
6
|
+
* transcript rows stamped with the change set, and the one question the
|
|
7
|
+
* outcome table asks afterwards: is a review pending?
|
|
8
|
+
*
|
|
9
|
+
* ONE CAPTURE, ONE MOMENT, ONE OWNER
|
|
10
|
+
* ----------------------------------
|
|
11
|
+
* A turn's reviewable change is a property of the TREE, not of the engine:
|
|
12
|
+
* whatever sits on the working tree when the engine's turn is over is what
|
|
13
|
+
* the user reviews, whoever wrote it — the engine, a sub-agent, a recovery
|
|
14
|
+
* retry, a stdio MCP server the engine spawned. So the runtime pins the
|
|
15
|
+
* baseline as its LAST act before `adapter.runTurn` (after its own writes
|
|
16
|
+
* into the tree — the reconcile, the skill and attachment mounts — so they
|
|
17
|
+
* cancel out of the diff) and captures ONCE after `runTurn` returns, over
|
|
18
|
+
* the whole turn. Anything written into the tree after the pin is the
|
|
19
|
+
* turn's change. An adapter needs neither the baseline nor the change-set
|
|
20
|
+
* id and never learns whether a review is pending; the one fact it holds
|
|
21
|
+
* that the runtime cannot read is what its engine observed touching
|
|
22
|
+
* CAS-owned paths (`TurnSink.bindCasObservations`).
|
|
23
|
+
*
|
|
24
|
+
* Until S3 M4 both adapters carried this whole act (Cursor in its
|
|
25
|
+
* `turn-boundary.ts` between the stream and `run.wait()`, the deep-agent in
|
|
26
|
+
* its `turn-settle.ts`), each with its own evidence source and its own
|
|
27
|
+
* scoping rules for the provenance and the stamp. The two rules here are the
|
|
28
|
+
* one reading both engines already produce:
|
|
29
|
+
*
|
|
30
|
+
* - PROVENANCE (DD-28, `shared/filereview/command-provenance.ts` is the
|
|
31
|
+
* rule; this is its two inputs). "This turn's commands" are the top-level
|
|
32
|
+
* rows whose id had not SETTLED before the engine ran — never a message
|
|
33
|
+
* position, because on BOTH engines an approved command executes on the
|
|
34
|
+
* row the runtime seeded for it (the deep-agent's builder and Cursor's
|
|
35
|
+
* translator both reconcile the re-attempt onto the seeded WAITING row),
|
|
36
|
+
* at its prior position; a positional scope misses it (F-M4-P3: Cursor's
|
|
37
|
+
* did, so its auto-keep never qualified a gated-then-approved command).
|
|
38
|
+
* "Executed" is a COMPLETED row. "Consented" is the row's own
|
|
39
|
+
* server-authored `approval_action` — the seeded row keeps its id and its
|
|
40
|
+
* verdict when it executes on resume, so the executed command IS its
|
|
41
|
+
* consent row. Any sub-agent activity fails closed (DD-28 D1).
|
|
42
|
+
* - THE STAMP (`shared/tool-row.ts` `stampFlowedFileEditRows`). A write or
|
|
43
|
+
* delete row created this turn that reached COMPLETED flowed onto the
|
|
44
|
+
* tree and is badged with the change set; a WAITING (denied, gated) or
|
|
45
|
+
* FAILED row did not and is not. The row's own status is the evidence,
|
|
46
|
+
* not a ledger of denial tokens.
|
|
47
|
+
*
|
|
48
|
+
* WHAT IS NOT HERE
|
|
49
|
+
* ----------------
|
|
50
|
+
* The substrate and the ledger authoring (`shared/filereview/capture.ts`,
|
|
51
|
+
* `cas-touched.ts`, `progress.ts`); the resume-time reconcile
|
|
52
|
+
* (`turn-context.ts` `reconcileReinvocation`, already the runtime's since
|
|
53
|
+
* S2); the outcome matrix that turns "a review is pending" into a phase
|
|
54
|
+
* (`run-turn.ts`, through `terminal-table.ts` `awaitingReviewArm`).
|
|
55
|
+
*
|
|
56
|
+
* TWO GAPS THIS MODULE DOES NOT CLOSE (recorded for S5, S3 M4 F-M4-P-gaps)
|
|
57
|
+
* ----------------------------------------------------------------------
|
|
58
|
+
* A turn that ends `interrupted` is not captured (a stop fired; the tree may
|
|
59
|
+
* be mid-edit). So a platform STOP returns COMPLETED with unreviewed edits
|
|
60
|
+
* on the tree, and a pause or worker shutdown reinvokes the same turn, whose
|
|
61
|
+
* new pin absorbs the pre-pause edits into its baseline and authors a second
|
|
62
|
+
* BASELINE for the same change set. Both predate the lift on both harnesses.
|
|
63
|
+
*/
|
|
64
|
+
import type { AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
65
|
+
import type { TurnCommandProvenance } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
|
|
66
|
+
import type { ArtifactStorage } from "../shared/artifact-storage.js";
|
|
67
|
+
import { type CasTouchedReader } from "../shared/filereview/cas-touched.js";
|
|
68
|
+
import { type ProgressCaptureState, type ProgressSubstrate } from "../shared/filereview/progress.js";
|
|
69
|
+
import type { FileReviewIdentity } from "./capabilities.js";
|
|
70
|
+
import type { TurnWorkspace } from "./types.js";
|
|
71
|
+
/** The mid-run progress the chokepoint refreshes on every write: the substrate and the floor it throttles by. */
|
|
72
|
+
export interface TurnProgress {
|
|
73
|
+
readonly changeSetId: string;
|
|
74
|
+
readonly substrate: ProgressSubstrate;
|
|
75
|
+
readonly state: ProgressCaptureState;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* One turn's capture as the runtime holds it between the pin and the
|
|
79
|
+
* boundary — a `runTurn` closure value beside the usage accumulator and the
|
|
80
|
+
* watchdog, on neither `TurnInput` (the adapter needs none of it) nor the
|
|
81
|
+
* frame (nothing here is a resource to release). Absent outside capture
|
|
82
|
+
* mode.
|
|
83
|
+
*/
|
|
84
|
+
export interface TurnCapture {
|
|
85
|
+
readonly changeSetId: string;
|
|
86
|
+
/** The pre-turn tree on a git work tree; `""` on a non-git one (the CAS manifest is the baseline there). */
|
|
87
|
+
readonly baselineTree: string;
|
|
88
|
+
readonly progress: TurnProgress;
|
|
89
|
+
/** Top-level rows already settled before the engine ran: the complement is "this turn's" (the provenance scope). */
|
|
90
|
+
readonly priorSettledToolCallIds: ReadonlySet<string>;
|
|
91
|
+
/** Sub-agent rows present before the engine ran: the stamp's scope, and any growth fails provenance closed. */
|
|
92
|
+
readonly priorSubAgentToolCallIds: ReadonlySet<string>;
|
|
93
|
+
/**
|
|
94
|
+
* What the engine observed touching CAS-owned paths, once the adapter has
|
|
95
|
+
* bound it (`TurnSink.bindCasObservations`); read at each progress capture
|
|
96
|
+
* and at the boundary. Unbound reads as nothing observed: git-only capture.
|
|
97
|
+
*/
|
|
98
|
+
casObservations: CasTouchedReader | undefined;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Turn start, in capture mode: snapshot the pre-turn ids, pin the pre-turn
|
|
102
|
+
* tree behind the baseline ref and author BASELINE_CAPTURED under the
|
|
103
|
+
* harness's identity (the event rides the next persist), and build the
|
|
104
|
+
* progress substrate for this workspace shape — the git slice over the
|
|
105
|
+
* baseline and the harness's excluded paths, the CAS slice over whatever
|
|
106
|
+
* observations the adapter later binds (a delegating reader, since the bind
|
|
107
|
+
* happens inside `runTurn`), hybrid when both apply. The CAS slice exists
|
|
108
|
+
* only when artifact storage does: without it a gitignored write is
|
|
109
|
+
* deny-gated by the harness (`captureIgnored`), never captured, and the
|
|
110
|
+
* ledger could not store its blobs anyway.
|
|
111
|
+
*
|
|
112
|
+
* Returns `undefined` outside capture mode: nothing to pin, nothing to
|
|
113
|
+
* capture, the classic deny-gate governs writes.
|
|
114
|
+
*/
|
|
115
|
+
export declare function pinCaptureBaseline(args: {
|
|
116
|
+
readonly status: AgentExecutionStatus;
|
|
117
|
+
readonly executionId: string;
|
|
118
|
+
readonly workspace: TurnWorkspace;
|
|
119
|
+
readonly fileReview: FileReviewIdentity;
|
|
120
|
+
readonly artifactStorage: ArtifactStorage | undefined;
|
|
121
|
+
}): Promise<TurnCapture | undefined>;
|
|
122
|
+
/**
|
|
123
|
+
* Turn end: compose the CAS captures from the bound observations, derive the
|
|
124
|
+
* approved-command provenance, author CANDIDATE_CAPTURED (the seam authors
|
|
125
|
+
* nothing for a turn that changed nothing), and — iff a candidate exists —
|
|
126
|
+
* stamp the flowed rows. The working tree is LEFT applied: the user reviews
|
|
127
|
+
* the real change, and a reject snaps files back on the resume
|
|
128
|
+
* (`reconcileReinvocation`). Returns whether a review is now pending.
|
|
129
|
+
*/
|
|
130
|
+
export declare function captureCandidate(args: {
|
|
131
|
+
readonly status: AgentExecutionStatus;
|
|
132
|
+
readonly executionId: string;
|
|
133
|
+
readonly workspace: TurnWorkspace;
|
|
134
|
+
readonly fileReview: FileReviewIdentity;
|
|
135
|
+
readonly artifactStorage: ArtifactStorage | undefined;
|
|
136
|
+
readonly capture: TurnCapture;
|
|
137
|
+
/** `spec.auto_approve_all`, the one whole-run bypass: qualifies every executed command as consented (DD-28). */
|
|
138
|
+
readonly globalBypass: boolean;
|
|
139
|
+
}): Promise<boolean>;
|
|
140
|
+
/**
|
|
141
|
+
* The runtime's two inputs to the shared DD-28 rule (see the header). Pure
|
|
142
|
+
* over the status and the pre-turn snapshots; exported for its own tests.
|
|
143
|
+
*/
|
|
144
|
+
export declare function deriveCommandProvenance(status: AgentExecutionStatus, capture: Pick<TurnCapture, "priorSettledToolCallIds" | "priorSubAgentToolCallIds">, globalBypass: boolean): TurnCommandProvenance | undefined;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime's file-review capture — apply-then-review for every harness,
|
|
3
|
+
* written once: the baseline pinned before the engine runs, the mid-run
|
|
4
|
+
* progress the chokepoint refreshes on every write, the candidate captured
|
|
5
|
+
* after the engine's turn, the DD-28 approved-command provenance, the flowed
|
|
6
|
+
* transcript rows stamped with the change set, and the one question the
|
|
7
|
+
* outcome table asks afterwards: is a review pending?
|
|
8
|
+
*
|
|
9
|
+
* ONE CAPTURE, ONE MOMENT, ONE OWNER
|
|
10
|
+
* ----------------------------------
|
|
11
|
+
* A turn's reviewable change is a property of the TREE, not of the engine:
|
|
12
|
+
* whatever sits on the working tree when the engine's turn is over is what
|
|
13
|
+
* the user reviews, whoever wrote it — the engine, a sub-agent, a recovery
|
|
14
|
+
* retry, a stdio MCP server the engine spawned. So the runtime pins the
|
|
15
|
+
* baseline as its LAST act before `adapter.runTurn` (after its own writes
|
|
16
|
+
* into the tree — the reconcile, the skill and attachment mounts — so they
|
|
17
|
+
* cancel out of the diff) and captures ONCE after `runTurn` returns, over
|
|
18
|
+
* the whole turn. Anything written into the tree after the pin is the
|
|
19
|
+
* turn's change. An adapter needs neither the baseline nor the change-set
|
|
20
|
+
* id and never learns whether a review is pending; the one fact it holds
|
|
21
|
+
* that the runtime cannot read is what its engine observed touching
|
|
22
|
+
* CAS-owned paths (`TurnSink.bindCasObservations`).
|
|
23
|
+
*
|
|
24
|
+
* Until S3 M4 both adapters carried this whole act (Cursor in its
|
|
25
|
+
* `turn-boundary.ts` between the stream and `run.wait()`, the deep-agent in
|
|
26
|
+
* its `turn-settle.ts`), each with its own evidence source and its own
|
|
27
|
+
* scoping rules for the provenance and the stamp. The two rules here are the
|
|
28
|
+
* one reading both engines already produce:
|
|
29
|
+
*
|
|
30
|
+
* - PROVENANCE (DD-28, `shared/filereview/command-provenance.ts` is the
|
|
31
|
+
* rule; this is its two inputs). "This turn's commands" are the top-level
|
|
32
|
+
* rows whose id had not SETTLED before the engine ran — never a message
|
|
33
|
+
* position, because on BOTH engines an approved command executes on the
|
|
34
|
+
* row the runtime seeded for it (the deep-agent's builder and Cursor's
|
|
35
|
+
* translator both reconcile the re-attempt onto the seeded WAITING row),
|
|
36
|
+
* at its prior position; a positional scope misses it (F-M4-P3: Cursor's
|
|
37
|
+
* did, so its auto-keep never qualified a gated-then-approved command).
|
|
38
|
+
* "Executed" is a COMPLETED row. "Consented" is the row's own
|
|
39
|
+
* server-authored `approval_action` — the seeded row keeps its id and its
|
|
40
|
+
* verdict when it executes on resume, so the executed command IS its
|
|
41
|
+
* consent row. Any sub-agent activity fails closed (DD-28 D1).
|
|
42
|
+
* - THE STAMP (`shared/tool-row.ts` `stampFlowedFileEditRows`). A write or
|
|
43
|
+
* delete row created this turn that reached COMPLETED flowed onto the
|
|
44
|
+
* tree and is badged with the change set; a WAITING (denied, gated) or
|
|
45
|
+
* FAILED row did not and is not. The row's own status is the evidence,
|
|
46
|
+
* not a ledger of denial tokens.
|
|
47
|
+
*
|
|
48
|
+
* WHAT IS NOT HERE
|
|
49
|
+
* ----------------
|
|
50
|
+
* The substrate and the ledger authoring (`shared/filereview/capture.ts`,
|
|
51
|
+
* `cas-touched.ts`, `progress.ts`); the resume-time reconcile
|
|
52
|
+
* (`turn-context.ts` `reconcileReinvocation`, already the runtime's since
|
|
53
|
+
* S2); the outcome matrix that turns "a review is pending" into a phase
|
|
54
|
+
* (`run-turn.ts`, through `terminal-table.ts` `awaitingReviewArm`).
|
|
55
|
+
*
|
|
56
|
+
* TWO GAPS THIS MODULE DOES NOT CLOSE (recorded for S5, S3 M4 F-M4-P-gaps)
|
|
57
|
+
* ----------------------------------------------------------------------
|
|
58
|
+
* A turn that ends `interrupted` is not captured (a stop fired; the tree may
|
|
59
|
+
* be mid-edit). So a platform STOP returns COMPLETED with unreviewed edits
|
|
60
|
+
* on the tree, and a pause or worker shutdown reinvokes the same turn, whose
|
|
61
|
+
* new pin absorbs the pre-pause edits into its baseline and authors a second
|
|
62
|
+
* BASELINE for the same change set. Both predate the lift on both harnesses.
|
|
63
|
+
*/
|
|
64
|
+
import { ApprovalAction, FileCaptureClass, ToolCallStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
65
|
+
import { captureBaselineToLedger, captureCandidateToLedger } from "../shared/filereview/capture.js";
|
|
66
|
+
import { createCasProgressSubstrate } from "../shared/filereview/cas-progress.js";
|
|
67
|
+
import { buildCasTurnCaptures } from "../shared/filereview/cas-touched.js";
|
|
68
|
+
import { qualifyTurnCommandProvenance } from "../shared/filereview/command-provenance.js";
|
|
69
|
+
import { hasCandidateCaptured } from "../shared/filereview/events.js";
|
|
70
|
+
import { createGitProgressSubstrate, createHybridProgressSubstrate, newProgressCaptureState, } from "../shared/filereview/progress.js";
|
|
71
|
+
import { collectSettledToolCallIds, collectSubAgentToolCallIds, stampFlowedFileEditRows, stampFlowedSubAgentFileEditRows } from "../shared/tool-row.js";
|
|
72
|
+
const NOTHING_OBSERVED = { before: new Map(), blockedSecretPaths: new Set() };
|
|
73
|
+
/**
|
|
74
|
+
* Turn start, in capture mode: snapshot the pre-turn ids, pin the pre-turn
|
|
75
|
+
* tree behind the baseline ref and author BASELINE_CAPTURED under the
|
|
76
|
+
* harness's identity (the event rides the next persist), and build the
|
|
77
|
+
* progress substrate for this workspace shape — the git slice over the
|
|
78
|
+
* baseline and the harness's excluded paths, the CAS slice over whatever
|
|
79
|
+
* observations the adapter later binds (a delegating reader, since the bind
|
|
80
|
+
* happens inside `runTurn`), hybrid when both apply. The CAS slice exists
|
|
81
|
+
* only when artifact storage does: without it a gitignored write is
|
|
82
|
+
* deny-gated by the harness (`captureIgnored`), never captured, and the
|
|
83
|
+
* ledger could not store its blobs anyway.
|
|
84
|
+
*
|
|
85
|
+
* Returns `undefined` outside capture mode: nothing to pin, nothing to
|
|
86
|
+
* capture, the classic deny-gate governs writes.
|
|
87
|
+
*/
|
|
88
|
+
export async function pinCaptureBaseline(args) {
|
|
89
|
+
const { status, executionId, workspace, fileReview, artifactStorage } = args;
|
|
90
|
+
if (!workspace.captureMode)
|
|
91
|
+
return undefined;
|
|
92
|
+
const { primaryDir, gitWorkspace, changeSetId } = workspace;
|
|
93
|
+
const priorSettledToolCallIds = collectSettledToolCallIds(status.messages);
|
|
94
|
+
const priorSubAgentToolCallIds = collectSubAgentToolCallIds(status.subAgentExecutions);
|
|
95
|
+
const baselineTree = await captureBaselineToLedger({
|
|
96
|
+
status,
|
|
97
|
+
gitRoot: primaryDir,
|
|
98
|
+
executionId,
|
|
99
|
+
changeSetId,
|
|
100
|
+
harnessId: fileReview.harnessId,
|
|
101
|
+
excludePaths: fileReview.excludePaths,
|
|
102
|
+
gitWorkspace,
|
|
103
|
+
});
|
|
104
|
+
const capture = {
|
|
105
|
+
changeSetId,
|
|
106
|
+
baselineTree,
|
|
107
|
+
progress: {
|
|
108
|
+
changeSetId,
|
|
109
|
+
state: newProgressCaptureState(),
|
|
110
|
+
substrate: buildProgressSubstrate({
|
|
111
|
+
executionId,
|
|
112
|
+
workspace,
|
|
113
|
+
baselineTree,
|
|
114
|
+
excludePaths: fileReview.excludePaths,
|
|
115
|
+
casSlice: artifactStorage !== undefined,
|
|
116
|
+
// Delegates to whatever the adapter binds later; `capture` is
|
|
117
|
+
// assigned before any capture() can run.
|
|
118
|
+
readObservations: () => capture.casObservations?.() ?? NOTHING_OBSERVED,
|
|
119
|
+
}),
|
|
120
|
+
},
|
|
121
|
+
priorSettledToolCallIds,
|
|
122
|
+
priorSubAgentToolCallIds,
|
|
123
|
+
casObservations: undefined,
|
|
124
|
+
};
|
|
125
|
+
return capture;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The progress substrate for this workspace shape (DD-32 / DD-33): a git
|
|
129
|
+
* tree diffs its tracked paths by `--numstat` against the baseline; the CAS
|
|
130
|
+
* slice reads the engine's observations for the gitignored (git tree) or
|
|
131
|
+
* every (non-git) path; a git tree with storage composes both. The truth
|
|
132
|
+
* table is `deriveCaptureMode`'s: capture mode holds only for a git tree or
|
|
133
|
+
* a workspace with storage, so the fourth cell is unreachable and says so.
|
|
134
|
+
*/
|
|
135
|
+
function buildProgressSubstrate(args) {
|
|
136
|
+
const { executionId, workspace, baselineTree, excludePaths, casSlice, readObservations } = args;
|
|
137
|
+
const git = workspace.gitWorkspace
|
|
138
|
+
? createGitProgressSubstrate({ workspaceRoot: workspace.primaryDir, executionId, baselineTree, excludePaths })
|
|
139
|
+
: undefined;
|
|
140
|
+
const cas = casSlice ? createCasProgressSubstrate({ workspaceRoot: workspace.primaryDir, read: readObservations }) : undefined;
|
|
141
|
+
if (git && cas)
|
|
142
|
+
return createHybridProgressSubstrate(git, cas);
|
|
143
|
+
const one = git ?? cas;
|
|
144
|
+
if (!one)
|
|
145
|
+
throw new Error(`capture: capture mode on a non-git tree without storage (execution=${executionId}); deriveCaptureMode forbids this`);
|
|
146
|
+
return one;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Turn end: compose the CAS captures from the bound observations, derive the
|
|
150
|
+
* approved-command provenance, author CANDIDATE_CAPTURED (the seam authors
|
|
151
|
+
* nothing for a turn that changed nothing), and — iff a candidate exists —
|
|
152
|
+
* stamp the flowed rows. The working tree is LEFT applied: the user reviews
|
|
153
|
+
* the real change, and a reject snaps files back on the resume
|
|
154
|
+
* (`reconcileReinvocation`). Returns whether a review is now pending.
|
|
155
|
+
*/
|
|
156
|
+
export async function captureCandidate(args) {
|
|
157
|
+
const { status, executionId, workspace, fileReview, artifactStorage, capture, globalBypass } = args;
|
|
158
|
+
const { primaryDir, gitWorkspace } = workspace;
|
|
159
|
+
const { changeSetId } = capture;
|
|
160
|
+
const casCaptureClass = gitWorkspace ? FileCaptureClass.GIT_IGNORED_CAPTURED : FileCaptureClass.NON_GIT_CAS;
|
|
161
|
+
const observed = artifactStorage && capture.casObservations ? await capture.casObservations() : NOTHING_OBSERVED;
|
|
162
|
+
const { casCaptures, unreviewablePaths } = await buildCasTurnCaptures(observed, primaryDir, casCaptureClass);
|
|
163
|
+
const commandProvenance = deriveCommandProvenance(status, capture, globalBypass);
|
|
164
|
+
if (commandProvenance) {
|
|
165
|
+
console.log(`capture: turn qualifies for approved-command auto-keep ` +
|
|
166
|
+
`(consent rows: ${commandProvenance.consentToolCallIds.join(",") || "(auto_approve_all)"}); ` +
|
|
167
|
+
`attaching provenance to candidate (execution=${executionId})`);
|
|
168
|
+
}
|
|
169
|
+
await captureCandidateToLedger({
|
|
170
|
+
status,
|
|
171
|
+
gitRoot: primaryDir,
|
|
172
|
+
executionId,
|
|
173
|
+
changeSetId,
|
|
174
|
+
baselineTree: capture.baselineTree,
|
|
175
|
+
harnessId: fileReview.harnessId,
|
|
176
|
+
excludePaths: fileReview.excludePaths,
|
|
177
|
+
casCaptures,
|
|
178
|
+
storage: artifactStorage,
|
|
179
|
+
unreviewablePaths,
|
|
180
|
+
unreviewableCaptureClass: casCaptureClass,
|
|
181
|
+
gitWorkspace,
|
|
182
|
+
commandProvenance,
|
|
183
|
+
});
|
|
184
|
+
const pending = hasCandidateCaptured(status, changeSetId);
|
|
185
|
+
if (pending) {
|
|
186
|
+
// A row must never reference a change set that does not exist, so the
|
|
187
|
+
// stamp is gated on the authored candidate.
|
|
188
|
+
stampFlowedFileEditRows(status.messages, changeSetId, { flowed: isCompletedRow });
|
|
189
|
+
stampFlowedSubAgentFileEditRows(status.subAgentExecutions, changeSetId, capture.priorSubAgentToolCallIds, isCompletedRow);
|
|
190
|
+
console.log(`capture: change set ${changeSetId} authored to the file_review ledger; working tree left applied for review (execution=${executionId})`);
|
|
191
|
+
}
|
|
192
|
+
return pending;
|
|
193
|
+
}
|
|
194
|
+
/** The row's own evidence that its effect landed on the tree. */
|
|
195
|
+
function isCompletedRow(tc) {
|
|
196
|
+
return tc.status === ToolCallStatus.TOOL_CALL_COMPLETED;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The runtime's two inputs to the shared DD-28 rule (see the header). Pure
|
|
200
|
+
* over the status and the pre-turn snapshots; exported for its own tests.
|
|
201
|
+
*/
|
|
202
|
+
export function deriveCommandProvenance(status, capture, globalBypass) {
|
|
203
|
+
// DD-28 D1: any sub-agent activity this turn disqualifies — a sub-agent
|
|
204
|
+
// that ran contributes at least one row id absent from the pre-turn set,
|
|
205
|
+
// and its writes fold into this change set without a consented command.
|
|
206
|
+
for (const id of collectSubAgentToolCallIds(status.subAgentExecutions)) {
|
|
207
|
+
if (!capture.priorSubAgentToolCallIds.has(id))
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
const turnToolCalls = status.messages.flatMap((m) => m.toolCalls).filter((tc) => !capture.priorSettledToolCallIds.has(tc.id));
|
|
211
|
+
return qualifyTurnCommandProvenance({
|
|
212
|
+
turnToolCalls,
|
|
213
|
+
messages: status.messages,
|
|
214
|
+
isExecutedCommand: isCompletedRow,
|
|
215
|
+
resolveDirectConsent: (tc) => tc.approvalAction === ApprovalAction.APPROVE || tc.approvalAction === ApprovalAction.APPROVE_ALL ? tc.id : undefined,
|
|
216
|
+
globalBypass,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/harness/capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAMhI,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAkD,MAAM,qCAAqC,CAAC;AAC3H,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB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|
@@ -10,13 +10,21 @@
|
|
|
10
10
|
* any built-in write row targeting a secret-like path, top-level and
|
|
11
11
|
* sub-agent. The single airtight choke point for a deny-gate harness and
|
|
12
12
|
* the only guarantee under `auto_approve_all`. Idempotent.
|
|
13
|
-
* 2. `
|
|
13
|
+
* 2. `file_change_progress` is refreshed from the turn's capture (the "N
|
|
14
|
+
* files changed so far" strip, DD-32) when the turn is in capture mode:
|
|
15
|
+
* the tree is read at most once per floor interval and only re-attached
|
|
16
|
+
* when it moved (`shared/filereview/progress.ts`), so a write that
|
|
17
|
+
* changed nothing on disk carries the snapshot it already had. Before
|
|
18
|
+
* S3 M4 each adapter's stream loop did this before its own persists; the
|
|
19
|
+
* runtime owns the capture now, so the display field it derives is
|
|
20
|
+
* refreshed where every other runtime-owned field is — here.
|
|
21
|
+
* 3. `streaming_usage` is refreshed from the accumulator when it has turns,
|
|
14
22
|
* so the summary the UI shows is the one the write carries.
|
|
15
|
-
*
|
|
23
|
+
* 4. `persistStatus` (`shared/status.ts`): tool-output offload, the
|
|
16
24
|
* aggregate size cap, transient retry, oversize recovery. Never rejects.
|
|
17
|
-
*
|
|
25
|
+
* 5. A Temporal heartbeat, so a long streaming turn's liveness is proven by
|
|
18
26
|
* the writes it makes (Q-S2-10).
|
|
19
|
-
*
|
|
27
|
+
* 6. The control plane's answer: STOP becomes the runtime's platform-stop
|
|
20
28
|
* cause on the stop controller, which aborts the adapter's signal.
|
|
21
29
|
*
|
|
22
30
|
* Single-flight with coalescing: an adapter's `requestPersist()` while a
|
|
@@ -35,6 +43,7 @@
|
|
|
35
43
|
import type { AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
36
44
|
import type { StigmerClient } from "../client/stigmer-client.js";
|
|
37
45
|
import type { ToolOutputOffloadContext } from "../shared/status-offload.js";
|
|
46
|
+
import type { TurnProgress } from "./capture.js";
|
|
38
47
|
import type { UsageAccumulator } from "./usage-accumulator.js";
|
|
39
48
|
export interface PersistChokepointDeps {
|
|
40
49
|
readonly client: StigmerClient;
|
|
@@ -48,6 +57,12 @@ export interface PersistChokepointDeps {
|
|
|
48
57
|
* and is `undefined` for a write made before then (no usage yet anyway).
|
|
49
58
|
*/
|
|
50
59
|
readonly usage: () => UsageAccumulator | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* The turn's mid-run progress, read at WRITE time for the same reason as
|
|
62
|
+
* `usage`: it exists only once the runtime has pinned the capture baseline,
|
|
63
|
+
* after resolution, and is `undefined` outside capture mode.
|
|
64
|
+
*/
|
|
65
|
+
readonly progress: () => TurnProgress | undefined;
|
|
51
66
|
/** The Temporal heartbeat, pulsed after each write. */
|
|
52
67
|
readonly heartbeat: () => void;
|
|
53
68
|
/** The control plane answered STOP to this write. */
|
|
@@ -10,13 +10,21 @@
|
|
|
10
10
|
* any built-in write row targeting a secret-like path, top-level and
|
|
11
11
|
* sub-agent. The single airtight choke point for a deny-gate harness and
|
|
12
12
|
* the only guarantee under `auto_approve_all`. Idempotent.
|
|
13
|
-
* 2. `
|
|
13
|
+
* 2. `file_change_progress` is refreshed from the turn's capture (the "N
|
|
14
|
+
* files changed so far" strip, DD-32) when the turn is in capture mode:
|
|
15
|
+
* the tree is read at most once per floor interval and only re-attached
|
|
16
|
+
* when it moved (`shared/filereview/progress.ts`), so a write that
|
|
17
|
+
* changed nothing on disk carries the snapshot it already had. Before
|
|
18
|
+
* S3 M4 each adapter's stream loop did this before its own persists; the
|
|
19
|
+
* runtime owns the capture now, so the display field it derives is
|
|
20
|
+
* refreshed where every other runtime-owned field is — here.
|
|
21
|
+
* 3. `streaming_usage` is refreshed from the accumulator when it has turns,
|
|
14
22
|
* so the summary the UI shows is the one the write carries.
|
|
15
|
-
*
|
|
23
|
+
* 4. `persistStatus` (`shared/status.ts`): tool-output offload, the
|
|
16
24
|
* aggregate size cap, transient retry, oversize recovery. Never rejects.
|
|
17
|
-
*
|
|
25
|
+
* 5. A Temporal heartbeat, so a long streaming turn's liveness is proven by
|
|
18
26
|
* the writes it makes (Q-S2-10).
|
|
19
|
-
*
|
|
27
|
+
* 6. The control plane's answer: STOP becomes the runtime's platform-stop
|
|
20
28
|
* cause on the stop controller, which aborts the adapter's signal.
|
|
21
29
|
*
|
|
22
30
|
* Single-flight with coalescing: an adapter's `requestPersist()` while a
|
|
@@ -35,6 +43,7 @@
|
|
|
35
43
|
import { create } from "@bufbuild/protobuf";
|
|
36
44
|
import { ExecutionControlSignal } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
37
45
|
import { StreamingUsageSummarySchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/usage_pb";
|
|
46
|
+
import { captureFileChangeProgress } from "../shared/filereview/progress.js";
|
|
38
47
|
import { persistStatus } from "../shared/status.js";
|
|
39
48
|
import { withholdSecretContentFromMessages } from "../shared/tool-row.js";
|
|
40
49
|
export class PersistChokepoint {
|
|
@@ -74,6 +83,10 @@ export class PersistChokepoint {
|
|
|
74
83
|
async write() {
|
|
75
84
|
const { client, executionId, status, offload, heartbeat } = this.deps;
|
|
76
85
|
withholdSecretContentFromMessages(status.messages, status.subAgentExecutions);
|
|
86
|
+
const progress = this.deps.progress();
|
|
87
|
+
if (progress) {
|
|
88
|
+
await captureFileChangeProgress({ status, changeSetId: progress.changeSetId, substrate: progress.substrate, state: progress.state });
|
|
89
|
+
}
|
|
77
90
|
const usage = this.deps.usage();
|
|
78
91
|
if (usage?.hasTurns) {
|
|
79
92
|
status.streamingUsage = create(StreamingUsageSummarySchema, usage.snapshot());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist-chokepoint.js","sourceRoot":"","sources":["../../src/harness/persist-chokepoint.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"persist-chokepoint.js","sourceRoot":"","sources":["../../src/harness/persist-chokepoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,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