@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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The native deep-agent harness as a `HarnessContractSubject` — the REAL
|
|
3
|
+
* `createDeepAgentAdapter()` driven through the harness contract kit, with
|
|
4
|
+
* the kit's engine-neutral scenario vocabulary translated onto the
|
|
5
|
+
* `ScriptedModel` double that every native hermetic golden already runs on.
|
|
6
|
+
*
|
|
7
|
+
* The sibling of `execute-cursor/__test-utils__/contract-subject.ts` (the
|
|
8
|
+
* mold) and of `gateway-substrate.ts` (the native side of the approval
|
|
9
|
+
* contract kit): the kit owns the invariants and the runtime stand-in, this
|
|
10
|
+
* module owns the ENGINE — what the model will do on its next call — and
|
|
11
|
+
* reports what really happened. The adapter under test is the production
|
|
12
|
+
* one, untouched; the model client is the one module doubled
|
|
13
|
+
* (`scripted-model-module.ts`, S3 M0 ruling Q-M0-1), and the tools the model
|
|
14
|
+
* calls are deepagents' real built-ins over the real gate.
|
|
15
|
+
*
|
|
16
|
+
* ── The engine is per execution, and its memory is the conversation ────────
|
|
17
|
+
* One `ScriptedModel` per execution, minted at the first `arrange` and handed
|
|
18
|
+
* out by the double for every build production requests under that
|
|
19
|
+
* execution's `headerScope.executionId` — the attribution header the proxy
|
|
20
|
+
* already carries, so concurrent executions each reach their own engine
|
|
21
|
+
* through an id nothing was added to send. The kit arranges a turn as a
|
|
22
|
+
* PLAN, and on every model call the engine plays the first step the
|
|
23
|
+
* conversation does not yet show: a `propose` or `read` whose tool-call id
|
|
24
|
+
* already has a `ToolMessage` anywhere on the thread (executed, or the
|
|
25
|
+
* gate's denial) is done; a `say` already spoken in THIS turn's segment
|
|
26
|
+
* (after the last human message) is done; `usage` folds into the turn's
|
|
27
|
+
* first model call only. Nothing is remembered on the subject: the sqlite
|
|
28
|
+
* checkpoint IS the engine's memory, which is why the same plan is right on
|
|
29
|
+
* a `Command(resume)` (the tool result is in the transcript before the model
|
|
30
|
+
* is asked) and on a later turn of the same thread (an approved-and-run call
|
|
31
|
+
* is not proposed again — Cursor's "obedient model" of Q-M4-4, derived
|
|
32
|
+
* instead of stored).
|
|
33
|
+
*
|
|
34
|
+
* ── The translation, one rule per word ──────────────────────────────────────
|
|
35
|
+
* - `say(text)` → the turn's text. A second `say` before any tool step
|
|
36
|
+
* inserts an ungated `think` call as the step boundary:
|
|
37
|
+
* a LangGraph agent cannot speak twice without acting
|
|
38
|
+
* (only the cost-cap arm's `[say, usage, say]` needs it).
|
|
39
|
+
* - `propose(id, a)` → ONE gated built-in whose execution is counted by a
|
|
40
|
+
* REAL side effect the subject reads back:
|
|
41
|
+
* `write r` → `edit_file` appending `id` as a line to a
|
|
42
|
+
* ledger the subject seeded at the path the backend
|
|
43
|
+
* resolves `r` to (`resolveWorkspacePath`, the virtual
|
|
44
|
+
* root). FILE_EDIT and FILE_WRITE are one `write`
|
|
45
|
+
* category by design (`tool-kind.ts`); unlike
|
|
46
|
+
* `write_file`, which refuses an existing path and so
|
|
47
|
+
* leaves no trace of a second execution, an edit
|
|
48
|
+
* counts EVERY execution.
|
|
49
|
+
* `shell r` → `execute` appending `id` to the session's
|
|
50
|
+
* shell ledger, `r` riding as a trailing comment.
|
|
51
|
+
* `delete` and `mcp` are refused as test bugs: no kit
|
|
52
|
+
* invariant asks for them here.
|
|
53
|
+
* `executionCount(id)` is the number of ledger lines
|
|
54
|
+
* equal to `id` — the safety-critical observable, read
|
|
55
|
+
* off disk, independent of anything the adapter wrote.
|
|
56
|
+
* - `read(id, path)` → `read_file` of a file the subject seeds; the ungated
|
|
57
|
+
* tool call every harness flushes a persist on.
|
|
58
|
+
* - `usage(delta)` → the model turn's `usage_metadata` (the cache buckets
|
|
59
|
+
* under `input_token_details`); consecutive deltas sum,
|
|
60
|
+
* the kit judges sums.
|
|
61
|
+
* - `hang` → the turn parks on the run's abort signal after its
|
|
62
|
+
* chunks (`ScriptedTurn.ends`); the park resolves
|
|
63
|
+
* `whenHanging()`. Never a timer.
|
|
64
|
+
* - `fail(msg, s)` → the turn throws `msg` after its chunks. `engine` and
|
|
65
|
+
* `internal` are one act here: the native adapter has
|
|
66
|
+
* ONE failure surface (`turn.ts` classifies every
|
|
67
|
+
* escaped error `internal`); `actionable` is refused.
|
|
68
|
+
* - `limit` → a `think` call under a fresh id on every model call,
|
|
69
|
+
* until the graph's recursion limit stops the run.
|
|
70
|
+
* - `cancelled` → refused: this harness has no engine-side cancel (the
|
|
71
|
+
* runtime arm is declared off for it).
|
|
72
|
+
*/
|
|
73
|
+
import { type BaseMessage } from "@langchain/core/messages";
|
|
74
|
+
import type { HarnessAdapter } from "../../../harness/types.js";
|
|
75
|
+
import type { HarnessContractSubject } from "../../../__test-utils__/harness-contract/types.js";
|
|
76
|
+
import type { HermeticEnvironment } from "../../../__test-utils__/hermetic-activity.js";
|
|
77
|
+
import { ScriptedModel } from "./scripted-model.js";
|
|
78
|
+
export interface DeepAgentContractSubject extends HarnessContractSubject {
|
|
79
|
+
readonly adapter: HarnessAdapter;
|
|
80
|
+
/** The engine minted for an execution, once the kit has arranged a turn for it. */
|
|
81
|
+
engineFor(executionId: string): ScriptedModel | undefined;
|
|
82
|
+
/** The conversation the engine was last asked with, for the subject file's observations of what the graph shows the model. */
|
|
83
|
+
lastTranscriptOf(executionId: string): readonly BaseMessage[] | undefined;
|
|
84
|
+
/** The session's workspace directory, as the runtime's provisioner resolves it and as this subject seeds it. */
|
|
85
|
+
workspaceDirOf(sessionId: string): string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Build the subject over one hermetic environment (the temp `HOME` the sqlite
|
|
89
|
+
* checkpoints land under, the temp workspace root). The environment is the
|
|
90
|
+
* caller's to create before and dispose after; the model-client double is
|
|
91
|
+
* bound for the module here, so a file holds one subject.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createDeepAgentContractSubject(env: HermeticEnvironment): DeepAgentContractSubject;
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The native deep-agent harness as a `HarnessContractSubject` — the REAL
|
|
3
|
+
* `createDeepAgentAdapter()` driven through the harness contract kit, with
|
|
4
|
+
* the kit's engine-neutral scenario vocabulary translated onto the
|
|
5
|
+
* `ScriptedModel` double that every native hermetic golden already runs on.
|
|
6
|
+
*
|
|
7
|
+
* The sibling of `execute-cursor/__test-utils__/contract-subject.ts` (the
|
|
8
|
+
* mold) and of `gateway-substrate.ts` (the native side of the approval
|
|
9
|
+
* contract kit): the kit owns the invariants and the runtime stand-in, this
|
|
10
|
+
* module owns the ENGINE — what the model will do on its next call — and
|
|
11
|
+
* reports what really happened. The adapter under test is the production
|
|
12
|
+
* one, untouched; the model client is the one module doubled
|
|
13
|
+
* (`scripted-model-module.ts`, S3 M0 ruling Q-M0-1), and the tools the model
|
|
14
|
+
* calls are deepagents' real built-ins over the real gate.
|
|
15
|
+
*
|
|
16
|
+
* ── The engine is per execution, and its memory is the conversation ────────
|
|
17
|
+
* One `ScriptedModel` per execution, minted at the first `arrange` and handed
|
|
18
|
+
* out by the double for every build production requests under that
|
|
19
|
+
* execution's `headerScope.executionId` — the attribution header the proxy
|
|
20
|
+
* already carries, so concurrent executions each reach their own engine
|
|
21
|
+
* through an id nothing was added to send. The kit arranges a turn as a
|
|
22
|
+
* PLAN, and on every model call the engine plays the first step the
|
|
23
|
+
* conversation does not yet show: a `propose` or `read` whose tool-call id
|
|
24
|
+
* already has a `ToolMessage` anywhere on the thread (executed, or the
|
|
25
|
+
* gate's denial) is done; a `say` already spoken in THIS turn's segment
|
|
26
|
+
* (after the last human message) is done; `usage` folds into the turn's
|
|
27
|
+
* first model call only. Nothing is remembered on the subject: the sqlite
|
|
28
|
+
* checkpoint IS the engine's memory, which is why the same plan is right on
|
|
29
|
+
* a `Command(resume)` (the tool result is in the transcript before the model
|
|
30
|
+
* is asked) and on a later turn of the same thread (an approved-and-run call
|
|
31
|
+
* is not proposed again — Cursor's "obedient model" of Q-M4-4, derived
|
|
32
|
+
* instead of stored).
|
|
33
|
+
*
|
|
34
|
+
* ── The translation, one rule per word ──────────────────────────────────────
|
|
35
|
+
* - `say(text)` → the turn's text. A second `say` before any tool step
|
|
36
|
+
* inserts an ungated `think` call as the step boundary:
|
|
37
|
+
* a LangGraph agent cannot speak twice without acting
|
|
38
|
+
* (only the cost-cap arm's `[say, usage, say]` needs it).
|
|
39
|
+
* - `propose(id, a)` → ONE gated built-in whose execution is counted by a
|
|
40
|
+
* REAL side effect the subject reads back:
|
|
41
|
+
* `write r` → `edit_file` appending `id` as a line to a
|
|
42
|
+
* ledger the subject seeded at the path the backend
|
|
43
|
+
* resolves `r` to (`resolveWorkspacePath`, the virtual
|
|
44
|
+
* root). FILE_EDIT and FILE_WRITE are one `write`
|
|
45
|
+
* category by design (`tool-kind.ts`); unlike
|
|
46
|
+
* `write_file`, which refuses an existing path and so
|
|
47
|
+
* leaves no trace of a second execution, an edit
|
|
48
|
+
* counts EVERY execution.
|
|
49
|
+
* `shell r` → `execute` appending `id` to the session's
|
|
50
|
+
* shell ledger, `r` riding as a trailing comment.
|
|
51
|
+
* `delete` and `mcp` are refused as test bugs: no kit
|
|
52
|
+
* invariant asks for them here.
|
|
53
|
+
* `executionCount(id)` is the number of ledger lines
|
|
54
|
+
* equal to `id` — the safety-critical observable, read
|
|
55
|
+
* off disk, independent of anything the adapter wrote.
|
|
56
|
+
* - `read(id, path)` → `read_file` of a file the subject seeds; the ungated
|
|
57
|
+
* tool call every harness flushes a persist on.
|
|
58
|
+
* - `usage(delta)` → the model turn's `usage_metadata` (the cache buckets
|
|
59
|
+
* under `input_token_details`); consecutive deltas sum,
|
|
60
|
+
* the kit judges sums.
|
|
61
|
+
* - `hang` → the turn parks on the run's abort signal after its
|
|
62
|
+
* chunks (`ScriptedTurn.ends`); the park resolves
|
|
63
|
+
* `whenHanging()`. Never a timer.
|
|
64
|
+
* - `fail(msg, s)` → the turn throws `msg` after its chunks. `engine` and
|
|
65
|
+
* `internal` are one act here: the native adapter has
|
|
66
|
+
* ONE failure surface (`turn.ts` classifies every
|
|
67
|
+
* escaped error `internal`); `actionable` is refused.
|
|
68
|
+
* - `limit` → a `think` call under a fresh id on every model call,
|
|
69
|
+
* until the graph's recursion limit stops the run.
|
|
70
|
+
* - `cancelled` → refused: this harness has no engine-side cancel (the
|
|
71
|
+
* runtime arm is declared off for it).
|
|
72
|
+
*/
|
|
73
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
74
|
+
import { dirname, join } from "node:path";
|
|
75
|
+
import { isAIMessage, isHumanMessage, isToolMessage } from "@langchain/core/messages";
|
|
76
|
+
import { resolveWorkspacePath } from "../../../shared/file-change.js";
|
|
77
|
+
import { createDeepAgentAdapter } from "../adapter.js";
|
|
78
|
+
import { hermeticDeepAgentConfig } from "./hermetic-deep-agent.js";
|
|
79
|
+
import { ScriptedModel } from "./scripted-model.js";
|
|
80
|
+
import { bindScriptedModel } from "./scripted-model-module.js";
|
|
81
|
+
/** The user's message every kit turn asks; the prompt builder needs one and the kit has none to give. */
|
|
82
|
+
const KIT_USER_MESSAGE = "Do what the scenario says.";
|
|
83
|
+
/** The one line a write ledger starts with; every execution appends its id under it, so the edit's anchor stays unique. */
|
|
84
|
+
const WRITE_LEDGER_MARK = "KIT-LEDGER";
|
|
85
|
+
/** What a seeded `read` target contains; the content is never asserted, the completed row is. */
|
|
86
|
+
const READ_FILE_CONTENT = "seeded by the harness contract kit\n";
|
|
87
|
+
/**
|
|
88
|
+
* Build the subject over one hermetic environment (the temp `HOME` the sqlite
|
|
89
|
+
* checkpoints land under, the temp workspace root). The environment is the
|
|
90
|
+
* caller's to create before and dispose after; the model-client double is
|
|
91
|
+
* bound for the module here, so a file holds one subject.
|
|
92
|
+
*/
|
|
93
|
+
export function createDeepAgentContractSubject(env) {
|
|
94
|
+
return new DeepAgentSubject(env);
|
|
95
|
+
}
|
|
96
|
+
class DeepAgentSubject {
|
|
97
|
+
env;
|
|
98
|
+
name = "deep-agent";
|
|
99
|
+
harness = "deep-agent";
|
|
100
|
+
adapter;
|
|
101
|
+
config;
|
|
102
|
+
engines = new Map();
|
|
103
|
+
arranged = new Map();
|
|
104
|
+
lastTranscripts = new Map();
|
|
105
|
+
ledgers = new Map();
|
|
106
|
+
hangWaiters = [];
|
|
107
|
+
mintCounter = 0;
|
|
108
|
+
constructor(env) {
|
|
109
|
+
this.env = env;
|
|
110
|
+
this.config = hermeticDeepAgentConfig(env, "sqlite");
|
|
111
|
+
this.adapter = createDeepAgentAdapter();
|
|
112
|
+
bindScriptedModel((opts) => {
|
|
113
|
+
const executionId = opts.headerScope?.executionId;
|
|
114
|
+
const engine = executionId ? this.engines.get(executionId) : undefined;
|
|
115
|
+
if (!engine) {
|
|
116
|
+
throw new Error(`${this.name}: buildChatModel asked for execution '${executionId ?? "<none>"}' but no turn was arranged for it (kit bug)`);
|
|
117
|
+
}
|
|
118
|
+
return engine;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// ── HarnessContractSubject ────────────────────────────────────────────────
|
|
122
|
+
arrange(turn, view) {
|
|
123
|
+
// A word this subject cannot translate is refused HERE, as a test bug:
|
|
124
|
+
// refused at play time it would surface as an engine failure and read as
|
|
125
|
+
// the adapter's behaviour.
|
|
126
|
+
for (const step of turn)
|
|
127
|
+
this.refuseUnproducible(step);
|
|
128
|
+
mkdirSync(this.workspaceDirOf(view.sessionId), { recursive: true });
|
|
129
|
+
for (const step of turn)
|
|
130
|
+
this.seedFor(step, view);
|
|
131
|
+
this.arranged.set(view.executionId, { steps: turn, view });
|
|
132
|
+
if (!this.engines.has(view.executionId))
|
|
133
|
+
this.engines.set(view.executionId, this.mintEngine(view.executionId));
|
|
134
|
+
}
|
|
135
|
+
inputOverrides(view) {
|
|
136
|
+
// No model is named: the adapter resolves the registry's featured native
|
|
137
|
+
// model, which is the fixture's — the production "no model named" path.
|
|
138
|
+
return { workspaceDir: this.workspaceDirOf(view.sessionId), message: KIT_USER_MESSAGE };
|
|
139
|
+
}
|
|
140
|
+
whenHanging() {
|
|
141
|
+
return new Promise((resolve) => this.hangWaiters.push(resolve));
|
|
142
|
+
}
|
|
143
|
+
executionCount(toolCallId) {
|
|
144
|
+
const ledger = this.ledgers.get(toolCallId);
|
|
145
|
+
if (!ledger || !existsSync(ledger.file))
|
|
146
|
+
return 0;
|
|
147
|
+
return readFileSync(ledger.file, "utf8")
|
|
148
|
+
.split("\n")
|
|
149
|
+
.filter((line) => line === toolCallId).length;
|
|
150
|
+
}
|
|
151
|
+
// ── The subject file's observations ──────────────────────────────────────
|
|
152
|
+
engineFor(executionId) {
|
|
153
|
+
return this.engines.get(executionId);
|
|
154
|
+
}
|
|
155
|
+
lastTranscriptOf(executionId) {
|
|
156
|
+
return this.lastTranscripts.get(executionId);
|
|
157
|
+
}
|
|
158
|
+
/** The directory the runtime's provisioner gives a session with no workspace entries (`session-root.ts`). */
|
|
159
|
+
workspaceDirOf(sessionId) {
|
|
160
|
+
return join(this.env.workspaceRootDir, "sessions", sessionId);
|
|
161
|
+
}
|
|
162
|
+
// ── The engine ────────────────────────────────────────────────────────────
|
|
163
|
+
mintEngine(executionId) {
|
|
164
|
+
return new ScriptedModel(() => (transcript) => this.play(executionId, transcript), [], {
|
|
165
|
+
onPark: () => {
|
|
166
|
+
for (const waiter of this.hangWaiters.splice(0))
|
|
167
|
+
waiter();
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/** The words this subject has no honest translation for (see the header); each is a kit-file bug, named. */
|
|
172
|
+
refuseUnproducible(step) {
|
|
173
|
+
switch (step.kind) {
|
|
174
|
+
case "propose":
|
|
175
|
+
if (step.action.kind !== "write" && step.action.kind !== "shell") {
|
|
176
|
+
throw new Error(`${this.name}: propose(${step.action.kind}) is not translated by this subject (no kit invariant asks for it); test bug`);
|
|
177
|
+
}
|
|
178
|
+
return;
|
|
179
|
+
case "fail":
|
|
180
|
+
if (step.surface === "actionable") {
|
|
181
|
+
throw new Error(`${this.name}: fail(..., "actionable") is not producible by this subject (the native adapter has one failure surface, internal); test bug`);
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
case "cancelled":
|
|
185
|
+
throw new Error(`${this.name}: cancelled() is not producible by this subject (this harness has no engine-side cancel; the runtime arm is declared off for it); test bug`);
|
|
186
|
+
case "say":
|
|
187
|
+
case "read":
|
|
188
|
+
case "usage":
|
|
189
|
+
case "hang":
|
|
190
|
+
case "limit":
|
|
191
|
+
return;
|
|
192
|
+
default: {
|
|
193
|
+
const exhaustive = step;
|
|
194
|
+
throw new Error(`${this.name}: unknown scenario step ${JSON.stringify(exhaustive)}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/** The shell ledger of one session; outside the session's workspace so the engine's tree holds only what the engine wrote. */
|
|
199
|
+
shellLedgerOf(sessionId) {
|
|
200
|
+
return join(this.env.workspaceRootDir, "kit-ledgers", `${sessionId}.log`);
|
|
201
|
+
}
|
|
202
|
+
/** Put on disk what a step's tool will find there: the write ledger under its mark, the read target. */
|
|
203
|
+
seedFor(step, view) {
|
|
204
|
+
const workspaceDir = this.workspaceDirOf(view.sessionId);
|
|
205
|
+
if (step.kind === "propose" && step.action.kind === "write") {
|
|
206
|
+
const file = resolveWorkspacePath(step.action.resource, workspaceDir, true).absolutePath;
|
|
207
|
+
seedFile(file, `${WRITE_LEDGER_MARK}\n`);
|
|
208
|
+
this.ledgers.set(step.toolCallId, { kind: "write", file });
|
|
209
|
+
}
|
|
210
|
+
else if (step.kind === "propose" && step.action.kind === "shell") {
|
|
211
|
+
const file = this.shellLedgerOf(view.sessionId);
|
|
212
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
213
|
+
this.ledgers.set(step.toolCallId, { kind: "shell", file });
|
|
214
|
+
}
|
|
215
|
+
else if (step.kind === "read") {
|
|
216
|
+
seedFile(resolveWorkspacePath(step.path, workspaceDir, true).absolutePath, READ_FILE_CONTENT);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The one turn to play now: the plan's steps in order, each skipped when
|
|
221
|
+
* the conversation already shows it, until a step closes the turn (a tool
|
|
222
|
+
* call, a hang, a failure) or the plan runs out (an empty message, which
|
|
223
|
+
* ends the graph run).
|
|
224
|
+
*/
|
|
225
|
+
play(executionId, transcript) {
|
|
226
|
+
const plan = this.arranged.get(executionId);
|
|
227
|
+
if (!plan)
|
|
228
|
+
throw new Error(`${this.name}: the model was asked for execution '${executionId}' with no turn arranged (kit bug)`);
|
|
229
|
+
this.lastTranscripts.set(executionId, transcript);
|
|
230
|
+
const settled = settledToolCallIds(transcript);
|
|
231
|
+
const segment = messagesOfThisTurn(transcript);
|
|
232
|
+
const spoken = new Set(segment.filter((m) => isAIMessage(m)).map((m) => m.text));
|
|
233
|
+
const firstCallOfTurn = !segment.some((m) => isAIMessage(m));
|
|
234
|
+
let text;
|
|
235
|
+
let usage;
|
|
236
|
+
const close = (rest) => ({ text, usage, ...rest });
|
|
237
|
+
for (const step of plan.steps) {
|
|
238
|
+
switch (step.kind) {
|
|
239
|
+
case "say":
|
|
240
|
+
if (spoken.has(step.text))
|
|
241
|
+
break;
|
|
242
|
+
if (text !== undefined)
|
|
243
|
+
return close({ toolCalls: [this.thinkCall("boundary")] });
|
|
244
|
+
text = step.text;
|
|
245
|
+
break;
|
|
246
|
+
case "propose":
|
|
247
|
+
if (settled.has(step.toolCallId))
|
|
248
|
+
break;
|
|
249
|
+
return close({ toolCalls: [this.gatedCall(step.toolCallId, step.action, plan.view)] });
|
|
250
|
+
case "read":
|
|
251
|
+
if (settled.has(step.toolCallId))
|
|
252
|
+
break;
|
|
253
|
+
return close({ toolCalls: [{ id: step.toolCallId, name: "read_file", args: { file_path: step.path } }] });
|
|
254
|
+
case "usage":
|
|
255
|
+
if (!firstCallOfTurn)
|
|
256
|
+
break;
|
|
257
|
+
usage = addUsage(usage, step.delta);
|
|
258
|
+
break;
|
|
259
|
+
case "hang":
|
|
260
|
+
return close({ ends: { kind: "hang" } });
|
|
261
|
+
case "fail":
|
|
262
|
+
return close({ ends: { kind: "fail", error: new Error(step.message) } });
|
|
263
|
+
case "limit":
|
|
264
|
+
return close({ toolCalls: [this.thinkCall("limit")] });
|
|
265
|
+
case "cancelled":
|
|
266
|
+
// Refused at `arrange`; unreachable in a plan that got this far.
|
|
267
|
+
throw new Error(`${this.name}: cancelled() reached the engine (arrange should have refused it)`);
|
|
268
|
+
default: {
|
|
269
|
+
const exhaustive = step;
|
|
270
|
+
throw new Error(`${this.name}: unknown scenario step ${JSON.stringify(exhaustive)}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return close({});
|
|
275
|
+
}
|
|
276
|
+
/** An ungated, effect-free tool call: the step boundary a LangGraph agent needs between two texts, and the loop a `limit` spins. */
|
|
277
|
+
thinkCall(why) {
|
|
278
|
+
return { id: `kit-think-${why}-${++this.mintCounter}`, name: "think", args: { thought: `kit: ${why}` } };
|
|
279
|
+
}
|
|
280
|
+
gatedCall(toolCallId, action, view) {
|
|
281
|
+
switch (action.kind) {
|
|
282
|
+
case "write":
|
|
283
|
+
return {
|
|
284
|
+
id: toolCallId,
|
|
285
|
+
name: "edit_file",
|
|
286
|
+
args: {
|
|
287
|
+
file_path: action.resource,
|
|
288
|
+
old_string: WRITE_LEDGER_MARK,
|
|
289
|
+
new_string: `${WRITE_LEDGER_MARK}\n${toolCallId}`,
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
case "shell":
|
|
293
|
+
return {
|
|
294
|
+
id: toolCallId,
|
|
295
|
+
name: "execute",
|
|
296
|
+
args: { command: `printf '%s\\n' '${toolCallId}' >> '${this.shellLedgerOf(view.sessionId)}' # ${action.resource}` },
|
|
297
|
+
};
|
|
298
|
+
case "delete":
|
|
299
|
+
case "read":
|
|
300
|
+
case "mcp":
|
|
301
|
+
// Refused at `arrange`; unreachable in a plan that got this far.
|
|
302
|
+
throw new Error(`${this.name}: propose(${action.kind}) reached the engine (arrange should have refused it)`);
|
|
303
|
+
default: {
|
|
304
|
+
const exhaustive = action.kind;
|
|
305
|
+
throw new Error(`${this.name}: unknown action kind ${String(exhaustive)}`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// ── Reading the conversation ────────────────────────────────────────────────
|
|
311
|
+
/** Every tool call the thread has an answer for — executed, or answered by the gate's denial. */
|
|
312
|
+
function settledToolCallIds(transcript) {
|
|
313
|
+
const ids = new Set();
|
|
314
|
+
for (const m of transcript)
|
|
315
|
+
if (isToolMessage(m))
|
|
316
|
+
ids.add(m.tool_call_id);
|
|
317
|
+
return ids;
|
|
318
|
+
}
|
|
319
|
+
/** The messages after the last human message: what this kit turn has said and done so far. */
|
|
320
|
+
function messagesOfThisTurn(transcript) {
|
|
321
|
+
let start = 0;
|
|
322
|
+
transcript.forEach((m, i) => {
|
|
323
|
+
if (isHumanMessage(m))
|
|
324
|
+
start = i + 1;
|
|
325
|
+
});
|
|
326
|
+
return transcript.slice(start);
|
|
327
|
+
}
|
|
328
|
+
function addUsage(total, delta) {
|
|
329
|
+
const carriesCache = total?.cacheReadTokens !== undefined || delta.cacheReadTokens !== undefined || delta.cacheWriteTokens !== undefined;
|
|
330
|
+
return {
|
|
331
|
+
inputTokens: (total?.inputTokens ?? 0) + (delta.inputTokens ?? 0),
|
|
332
|
+
outputTokens: (total?.outputTokens ?? 0) + (delta.outputTokens ?? 0),
|
|
333
|
+
...(carriesCache
|
|
334
|
+
? {
|
|
335
|
+
cacheReadTokens: (total?.cacheReadTokens ?? 0) + (delta.cacheReadTokens ?? 0),
|
|
336
|
+
cacheWriteTokens: (total?.cacheWriteTokens ?? 0) + (delta.cacheWriteTokens ?? 0),
|
|
337
|
+
}
|
|
338
|
+
: {}),
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/** Create `file` with `content` unless it exists — a ledger keeps what earlier turns appended. */
|
|
342
|
+
function seedFile(file, content) {
|
|
343
|
+
if (existsSync(file))
|
|
344
|
+
return;
|
|
345
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
346
|
+
writeFileSync(file, content);
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=contract-subject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-subject.js","sourceRoot":"","sources":["../../../../src/activities/execute-deep-agent/__test-utils__/contract-subject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAoB,MAAM,0BAA0B,CAAC;AAaxG,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAgE,MAAM,qBAAqB,CAAC;AAClH,OAAO,EAAE,iBAAiB,EA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CAAC;KACR,CAAC;AACJ,CAAC;AAED,kGAAkG;AAClG,SAAS,QAAQ,CAAC,IAAY,EAAE,OAAe;IAC7C,IAAI,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO;IAC7B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The native (deep-agent) slice of the hermetic activity driver: build the
|
|
3
|
+
* fixture record, bind the scripted model and the `Config`, run the REAL
|
|
4
|
+
* `ExecuteDeepAgent` activity under `MockActivityEnvironment` with the REAL
|
|
5
|
+
* deepagents graph, and hand back what it persisted.
|
|
6
|
+
*
|
|
7
|
+
* Layering (the `approval-contract/` + `gateway-substrate.ts` split): everything
|
|
8
|
+
* harness-agnostic lives in `src/__test-utils__/hermetic-activity.ts` (the
|
|
9
|
+
* activity environment, the execution record behind the client, the temp
|
|
10
|
+
* `~/.stigmer`, the ticking clock, the shutdown signal) and its fixtures
|
|
11
|
+
* (`execution-record-fixture.ts`, `model-registry-fixture.ts`,
|
|
12
|
+
* `git-workspace-fixture.ts`). This module adds only what is native's: the
|
|
13
|
+
* scripted model as the one LLM (`scripted-model.ts`, reached through the
|
|
14
|
+
* `shared/model-client.ts` double), the native `Config` slice with its
|
|
15
|
+
* checkpointer, the per-scenario reset of module caches and of the session's
|
|
16
|
+
* durable state, and the production wire shape of the activity input.
|
|
17
|
+
*
|
|
18
|
+
* What the two `vi.mock` calls a scenario file must carry look like — they are
|
|
19
|
+
* hoisted by vitest and so cannot live here:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* vi.mock("../../../../shared/model-client.js", async () =>
|
|
23
|
+
* (await import("../../__test-utils__/scripted-model-module.js")).scriptedModelClientModule());
|
|
24
|
+
* vi.mock("../../../../client/stigmer-client.js", async () =>
|
|
25
|
+
* (await import("../../../../__test-utils__/hermetic-activity.js")).hermeticStigmerClientModule());
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Two facts about this harness the driver encodes, both read from production:
|
|
29
|
+
*
|
|
30
|
+
* - `thread_id` is `thread-{sessionId}` on EVERY invocation, the first
|
|
31
|
+
* included (`invoke-agent-execution.ts` runs `EnsureThread` once and passes
|
|
32
|
+
* the same id to `firstInvoke` and every `reinvoke`; `ensure-thread.ts`
|
|
33
|
+
* derives it from the session). Cursor's driver sends `""` on a first turn
|
|
34
|
+
* because Cursor's engine mints its own id; copying that here would key the
|
|
35
|
+
* sqlite checkpoint on `""` in turn 1 and look it up under `thread-…` in
|
|
36
|
+
* turn 2. A scenario overrides the default only to stage the empty-id edge.
|
|
37
|
+
* - The `memory` checkpointer is recreated empty per invocation
|
|
38
|
+
* (`checkpointer/factory.ts`), so a HITL reinvocation REPLAYS the graph; the
|
|
39
|
+
* `sqlite` checkpointer keys one file per session under `~/.stigmer`, so a
|
|
40
|
+
* reinvocation RESUMES from the interrupt — the durable posture with no
|
|
41
|
+
* network. A scenario picks one; the HITL arms record both.
|
|
42
|
+
*
|
|
43
|
+
* The ONE knowledge of production this driver holds is `activityFactory`: how
|
|
44
|
+
* to obtain the `ExecuteDeepAgent` function from a `Config`. Since S3 M2a it
|
|
45
|
+
* is the harness registry's: the native adapter booted and bound to its
|
|
46
|
+
* byte-pinned activity name through `createHarnessActivities`, exactly the
|
|
47
|
+
* way the composition roots bind it since S3 M2b through `harness-adapters.ts`
|
|
48
|
+
* (and the way the Cursor driver binds its own, `hermetic-cursor.ts`). The
|
|
49
|
+
* orchestrator this adapter replaced (`index.ts`, `setup.ts`) was deleted at
|
|
50
|
+
* M2b; the goldens moved once, with the M2a flip, each hunk quoted with its
|
|
51
|
+
* ruling in its test's header (Q-M2a-1), and the switch of the roots moved
|
|
52
|
+
* none (Q-M2b-4).
|
|
53
|
+
*
|
|
54
|
+
* `boot` registers the deepagents harness profiles as production does
|
|
55
|
+
* (S3 M2a F-M2a-14: the orchestrator-driven runs never did, so deepagents
|
|
56
|
+
* auto-injected its ungated `general-purpose` sub-agent into every M0
|
|
57
|
+
* scenario; the scripted model never delegated to it).
|
|
58
|
+
*
|
|
59
|
+
* Determinism beyond S0's: the clock ticks once per model turn (the scripted
|
|
60
|
+
* model's `onTurn`), so status timestamps and the persist cadence land on the
|
|
61
|
+
* same instants every run; a scenario's interruption (pause, worker shutdown)
|
|
62
|
+
* is scheduled on a model turn through the same hook, never on a timer.
|
|
63
|
+
*/
|
|
64
|
+
import type { Config } from "../../../config.js";
|
|
65
|
+
import type { StigmerClient } from "../../../client/stigmer-client.js";
|
|
66
|
+
import type { ExecuteActivityInput } from "../../../shared/activity-input.js";
|
|
67
|
+
import { ExecutionRecord, ScriptedClock, type ActivityInvocation, type HermeticEnvironment, type InvocationControls } from "../../../__test-utils__/hermetic-activity.js";
|
|
68
|
+
import { type ExecutionRecordOptions } from "../../../__test-utils__/execution-record-fixture.js";
|
|
69
|
+
import { ScriptedModel, type ScriptSelector, type ScriptedTurnInfo } from "./scripted-model.js";
|
|
70
|
+
export declare const FIXTURE: {
|
|
71
|
+
readonly org: "hermetic-org";
|
|
72
|
+
readonly executionId: "aex_hermetic_0001";
|
|
73
|
+
readonly sessionId: "ses_hermetic_0001";
|
|
74
|
+
readonly agentInstanceId: "ain_hermetic_0001";
|
|
75
|
+
readonly agentId: "agt_hermetic_0001";
|
|
76
|
+
readonly agentName: "hermetic-agent";
|
|
77
|
+
/** The pinned model; in the registry document as the native entry. */
|
|
78
|
+
readonly model: "claude-haiku-4.5";
|
|
79
|
+
/** The LangGraph thread id the control plane sends on every invocation (`ensure-thread.ts`). */
|
|
80
|
+
readonly threadId: "thread-ses_hermetic_0001";
|
|
81
|
+
};
|
|
82
|
+
/** The record's knobs; the ids and the default model are this harness's fixture. */
|
|
83
|
+
export type DeepAgentRecordOptions = Omit<ExecutionRecordOptions, "ids">;
|
|
84
|
+
/** The four resources of one execution, wired by id into a chain, under the native fixture ids. */
|
|
85
|
+
export declare function deepAgentExecutionRecord(options: DeepAgentRecordOptions): ExecutionRecord;
|
|
86
|
+
export type HermeticCheckpointer = "memory" | "sqlite";
|
|
87
|
+
/** The OSS/local runner posture: no proxy, local mode, the scenario's checkpointer. */
|
|
88
|
+
export declare function hermeticDeepAgentConfig(env: HermeticEnvironment, checkpointerType: HermeticCheckpointer): Config;
|
|
89
|
+
/**
|
|
90
|
+
* The primary workspace directory a session with NO workspace entries runs in
|
|
91
|
+
* (`session-root.ts`: `<workspaceRootDir>/sessions/<sessionId>`). A scenario
|
|
92
|
+
* seeds the files its script reads here.
|
|
93
|
+
*/
|
|
94
|
+
export declare function sessionWorkspaceDir(env: HermeticEnvironment): string;
|
|
95
|
+
/** The `ExecuteDeepAgent` function as the runner serves it: the typed object OR the legacy positional pair. */
|
|
96
|
+
export type ExecuteDeepAgentFn = (arg0: ExecuteActivityInput | string, arg1?: string) => Promise<unknown>;
|
|
97
|
+
/** How the driver obtains the activity from a `Config` — the one seam M2 flips. */
|
|
98
|
+
export type ActivityFactory = (config: Config) => Promise<ExecuteDeepAgentFn>;
|
|
99
|
+
/**
|
|
100
|
+
* The adapter through the registry: `createDeepAgentAdapter()` booted on the
|
|
101
|
+
* scenario's config, bound to `ExecuteDeepAgent` by `createHarnessActivities`
|
|
102
|
+
* over the turn runtime. Imported lazily so the scenario file's `vi.mock`
|
|
103
|
+
* declarations are in force before the engine slice loads the model client
|
|
104
|
+
* and before the registry loads the `StigmerClient` module.
|
|
105
|
+
*/
|
|
106
|
+
export declare const runtimeActivityFactory: ActivityFactory;
|
|
107
|
+
/**
|
|
108
|
+
* Drop every module-level cache the harness keeps across invocations and
|
|
109
|
+
* every durable trace the session left behind (its sqlite checkpoint, its
|
|
110
|
+
* session workspace), so a scenario starts where a new session starts.
|
|
111
|
+
* Called at the START of a scenario, never between its invocations: a HITL
|
|
112
|
+
* scenario relies on the sqlite checkpoint surviving from turn 1 into turn 2
|
|
113
|
+
* exactly as it does in a live runner.
|
|
114
|
+
*/
|
|
115
|
+
export declare function resetDeepAgentScenarioState(env: HermeticEnvironment): void;
|
|
116
|
+
/** One scenario: the record, the one LLM, the runner it runs on, and the invocation in flight. */
|
|
117
|
+
export declare class DeepAgentScenario {
|
|
118
|
+
readonly env: HermeticEnvironment;
|
|
119
|
+
readonly clock: ScriptedClock;
|
|
120
|
+
readonly record: ExecutionRecord;
|
|
121
|
+
/** The runner this scenario runs on: the OSS posture plus the scenario's knobs. */
|
|
122
|
+
readonly config: Config;
|
|
123
|
+
/** The controls of the invocation in flight; set by {@link runDeepAgentTurn} before the activity starts. */
|
|
124
|
+
controls: InvocationControls | undefined;
|
|
125
|
+
readonly model: ScriptedModel;
|
|
126
|
+
constructor(env: HermeticEnvironment, clock: ScriptedClock, record: ExecutionRecord,
|
|
127
|
+
/** The runner this scenario runs on: the OSS posture plus the scenario's knobs. */
|
|
128
|
+
config: Config, script: ScriptSelector, onTurn: DeepAgentScenarioOptions["onTurn"]);
|
|
129
|
+
}
|
|
130
|
+
export interface DeepAgentScenarioOptions {
|
|
131
|
+
readonly env: HermeticEnvironment;
|
|
132
|
+
readonly clock: ScriptedClock;
|
|
133
|
+
readonly record: ExecutionRecord;
|
|
134
|
+
/** The per-role script the one LLM plays (`scripted-model.ts`). */
|
|
135
|
+
readonly script: ScriptSelector;
|
|
136
|
+
/** `memory` (replay on reinvocation; the OSS default) or `sqlite` (durable resume). Defaults to `memory`. */
|
|
137
|
+
readonly checkpointer?: HermeticCheckpointer;
|
|
138
|
+
/**
|
|
139
|
+
* Runs on every model turn after the clock ticks, with the in-flight
|
|
140
|
+
* invocation's controls: where a scenario stages a user pause or a worker
|
|
141
|
+
* shutdown at a chosen role and round.
|
|
142
|
+
*/
|
|
143
|
+
readonly onTurn?: (info: ScriptedTurnInfo, controls: InvocationControls) => void | Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Control-plane facets the scenario opts INTO, or faults it injects, over
|
|
146
|
+
* the record's everyday answers (`ExecutionRecord.client`): a rejecting
|
|
147
|
+
* `getAgent` is how a blueprint-resolution failure is staged.
|
|
148
|
+
*/
|
|
149
|
+
readonly clientOverrides?: Partial<StigmerClient>;
|
|
150
|
+
/** Runner knobs over {@link hermeticDeepAgentConfig}: the workspace-lock window, for one. */
|
|
151
|
+
readonly config?: Partial<Config>;
|
|
152
|
+
}
|
|
153
|
+
/** Bind the record and the model for a scenario; resets the harness's module and session state first. */
|
|
154
|
+
export declare function beginDeepAgentScenario(options: DeepAgentScenarioOptions): DeepAgentScenario;
|
|
155
|
+
export interface DeepAgentTurnOptions {
|
|
156
|
+
/** The HITL cycle index (0 on the first turn); mints the change-set id. */
|
|
157
|
+
readonly turnSeq?: number;
|
|
158
|
+
/** Overrides the production thread id ({@link FIXTURE.threadId}) — only to stage the empty-id edge. */
|
|
159
|
+
readonly threadId?: string;
|
|
160
|
+
/** Drive the legacy positional `(executionId, threadId)` wire shape instead of the typed object. */
|
|
161
|
+
readonly positional?: boolean;
|
|
162
|
+
readonly activityFactory?: ActivityFactory;
|
|
163
|
+
readonly onControls?: (controls: InvocationControls) => void;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Run ONE `ExecuteDeepAgent` invocation for the scenario. Built per invocation
|
|
167
|
+
* (the factory constructs its client, which is the one bound at
|
|
168
|
+
* `beginDeepAgentScenario`).
|
|
169
|
+
*/
|
|
170
|
+
export declare function runDeepAgentTurn(scenario: DeepAgentScenario, options?: DeepAgentTurnOptions): Promise<ActivityInvocation>;
|