@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,225 @@
|
|
|
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 { rmSync } from "node:fs";
|
|
65
|
+
import { dirname, join } from "node:path";
|
|
66
|
+
import { getCheckpointDbPath } from "../../../shared/workspace/platform-dir.js";
|
|
67
|
+
import { _resetRegistryCache } from "../../../shared/model-registry.js";
|
|
68
|
+
import { _resetPricingCache } from "../../../shared/model-pricing-data.js";
|
|
69
|
+
import { bindHermeticClient, runActivityHermetically, } from "../../../__test-utils__/hermetic-activity.js";
|
|
70
|
+
import { executionRecordFixture } from "../../../__test-utils__/execution-record-fixture.js";
|
|
71
|
+
import { FIXTURE_NATIVE_MODEL } from "../../../__test-utils__/model-registry-fixture.js";
|
|
72
|
+
import { ScriptedModel } from "./scripted-model.js";
|
|
73
|
+
import { bindScriptedModel } from "./scripted-model-module.js";
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// Fixture ids — fixed so goldens are readable and byte-stable
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
const SESSION_ID = "ses_hermetic_0001";
|
|
78
|
+
export const FIXTURE = {
|
|
79
|
+
org: "hermetic-org",
|
|
80
|
+
executionId: "aex_hermetic_0001",
|
|
81
|
+
sessionId: SESSION_ID,
|
|
82
|
+
agentInstanceId: "ain_hermetic_0001",
|
|
83
|
+
agentId: "agt_hermetic_0001",
|
|
84
|
+
agentName: "hermetic-agent",
|
|
85
|
+
/** The pinned model; in the registry document as the native entry. */
|
|
86
|
+
model: FIXTURE_NATIVE_MODEL,
|
|
87
|
+
/** The LangGraph thread id the control plane sends on every invocation (`ensure-thread.ts`). */
|
|
88
|
+
threadId: `thread-${SESSION_ID}`,
|
|
89
|
+
};
|
|
90
|
+
/** The four resources of one execution, wired by id into a chain, under the native fixture ids. */
|
|
91
|
+
export function deepAgentExecutionRecord(options) {
|
|
92
|
+
return executionRecordFixture({
|
|
93
|
+
...options,
|
|
94
|
+
modelName: options.modelName ?? FIXTURE.model,
|
|
95
|
+
ids: {
|
|
96
|
+
org: FIXTURE.org,
|
|
97
|
+
executionId: FIXTURE.executionId,
|
|
98
|
+
sessionId: FIXTURE.sessionId,
|
|
99
|
+
agentInstanceId: FIXTURE.agentInstanceId,
|
|
100
|
+
agentId: FIXTURE.agentId,
|
|
101
|
+
agentName: FIXTURE.agentName,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** The OSS/local runner posture: no proxy, local mode, the scenario's checkpointer. */
|
|
106
|
+
export function hermeticDeepAgentConfig(env, checkpointerType) {
|
|
107
|
+
return {
|
|
108
|
+
taskQueue: "hermetic-test-queue",
|
|
109
|
+
temporalAddress: "localhost:7233",
|
|
110
|
+
temporalNamespace: "default",
|
|
111
|
+
stigmerBackendEndpoint: "http://localhost:7234",
|
|
112
|
+
mcpBridgeEndpoint: null,
|
|
113
|
+
stigmerToken: null,
|
|
114
|
+
cursorApiKey: "",
|
|
115
|
+
workspaceRootDir: env.workspaceRootDir,
|
|
116
|
+
mode: "local",
|
|
117
|
+
proxyEndpoint: null,
|
|
118
|
+
maxConcurrentActivities: 1,
|
|
119
|
+
idleTimeoutSeconds: null,
|
|
120
|
+
cloudModeEnabled: false,
|
|
121
|
+
checkpointerType,
|
|
122
|
+
checkpointerProxyEndpoint: null,
|
|
123
|
+
artifactProxyEndpoint: null,
|
|
124
|
+
primaryModel: FIXTURE.model,
|
|
125
|
+
cursorStreamStallTimeoutMs: 180_000,
|
|
126
|
+
agentResolveTimeoutMs: 120_000,
|
|
127
|
+
workspaceLockTimeoutMs: 900_000,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The primary workspace directory a session with NO workspace entries runs in
|
|
132
|
+
* (`session-root.ts`: `<workspaceRootDir>/sessions/<sessionId>`). A scenario
|
|
133
|
+
* seeds the files its script reads here.
|
|
134
|
+
*/
|
|
135
|
+
export function sessionWorkspaceDir(env) {
|
|
136
|
+
return join(env.workspaceRootDir, "sessions", FIXTURE.sessionId);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The adapter through the registry: `createDeepAgentAdapter()` booted on the
|
|
140
|
+
* scenario's config, bound to `ExecuteDeepAgent` by `createHarnessActivities`
|
|
141
|
+
* over the turn runtime. Imported lazily so the scenario file's `vi.mock`
|
|
142
|
+
* declarations are in force before the engine slice loads the model client
|
|
143
|
+
* and before the registry loads the `StigmerClient` module.
|
|
144
|
+
*/
|
|
145
|
+
export const runtimeActivityFactory = async (config) => {
|
|
146
|
+
const { createDeepAgentAdapter } = await import("../adapter.js");
|
|
147
|
+
const { createHarnessActivities } = await import("../../../harness/registry.js");
|
|
148
|
+
const adapter = createDeepAgentAdapter();
|
|
149
|
+
await adapter.boot(config);
|
|
150
|
+
const activities = await createHarnessActivities([{ harness: "deep-agent", adapter }], config);
|
|
151
|
+
return activities.ExecuteDeepAgent;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Drop every module-level cache the harness keeps across invocations and
|
|
155
|
+
* every durable trace the session left behind (its sqlite checkpoint, its
|
|
156
|
+
* session workspace), so a scenario starts where a new session starts.
|
|
157
|
+
* Called at the START of a scenario, never between its invocations: a HITL
|
|
158
|
+
* scenario relies on the sqlite checkpoint surviving from turn 1 into turn 2
|
|
159
|
+
* exactly as it does in a live runner.
|
|
160
|
+
*/
|
|
161
|
+
export function resetDeepAgentScenarioState(env) {
|
|
162
|
+
_resetRegistryCache();
|
|
163
|
+
_resetPricingCache();
|
|
164
|
+
rmSync(dirname(getCheckpointDbPath(FIXTURE.sessionId)), { recursive: true, force: true });
|
|
165
|
+
rmSync(sessionWorkspaceDir(env), { recursive: true, force: true });
|
|
166
|
+
}
|
|
167
|
+
/** One scenario: the record, the one LLM, the runner it runs on, and the invocation in flight. */
|
|
168
|
+
export class DeepAgentScenario {
|
|
169
|
+
env;
|
|
170
|
+
clock;
|
|
171
|
+
record;
|
|
172
|
+
config;
|
|
173
|
+
/** The controls of the invocation in flight; set by {@link runDeepAgentTurn} before the activity starts. */
|
|
174
|
+
controls;
|
|
175
|
+
model;
|
|
176
|
+
constructor(env, clock, record,
|
|
177
|
+
/** The runner this scenario runs on: the OSS posture plus the scenario's knobs. */
|
|
178
|
+
config, script, onTurn) {
|
|
179
|
+
this.env = env;
|
|
180
|
+
this.clock = clock;
|
|
181
|
+
this.record = record;
|
|
182
|
+
this.config = config;
|
|
183
|
+
this.model = new ScriptedModel(script, [], {
|
|
184
|
+
onTurn: async (info) => {
|
|
185
|
+
this.clock.tick();
|
|
186
|
+
if (onTurn && this.controls)
|
|
187
|
+
await onTurn(info, this.controls);
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** Bind the record and the model for a scenario; resets the harness's module and session state first. */
|
|
193
|
+
export function beginDeepAgentScenario(options) {
|
|
194
|
+
resetDeepAgentScenarioState(options.env);
|
|
195
|
+
const scenario = new DeepAgentScenario(options.env, options.clock, options.record, { ...hermeticDeepAgentConfig(options.env, options.checkpointer ?? "memory"), ...options.config }, options.script, options.onTurn);
|
|
196
|
+
bindScriptedModel(scenario.model);
|
|
197
|
+
bindHermeticClient(options.record.client(options.clientOverrides));
|
|
198
|
+
return scenario;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Run ONE `ExecuteDeepAgent` invocation for the scenario. Built per invocation
|
|
202
|
+
* (the factory constructs its client, which is the one bound at
|
|
203
|
+
* `beginDeepAgentScenario`).
|
|
204
|
+
*/
|
|
205
|
+
export async function runDeepAgentTurn(scenario, options = {}) {
|
|
206
|
+
const activity = await (options.activityFactory ?? runtimeActivityFactory)(scenario.config);
|
|
207
|
+
const threadId = options.threadId ?? FIXTURE.threadId;
|
|
208
|
+
const turnSeq = options.turnSeq ?? 0;
|
|
209
|
+
const input = {
|
|
210
|
+
execution_id: scenario.record.executionId,
|
|
211
|
+
thread_id: threadId,
|
|
212
|
+
turn_seq: turnSeq,
|
|
213
|
+
};
|
|
214
|
+
const args = options.positional
|
|
215
|
+
? [scenario.record.executionId, threadId]
|
|
216
|
+
: [input];
|
|
217
|
+
return runActivityHermetically(activity, args, {
|
|
218
|
+
taskQueue: scenario.config.taskQueue,
|
|
219
|
+
onControls: (controls) => {
|
|
220
|
+
scenario.controls = controls;
|
|
221
|
+
options.onControls?.(controls);
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=hermetic-deep-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hermetic-deep-agent.js","sourceRoot":"","sources":["../../../../src/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAI1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAA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OAAO,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one gated opening every HITL arm shares, so their first-invocation
|
|
3
|
+
* statuses are byte-identical and can match ONE golden file
|
|
4
|
+
* (`__tests__/hermetic/goldens/gate.turn1.status.json`). Matching the same
|
|
5
|
+
* file from the approve, skip, reject and sequential-gates arms is itself an
|
|
6
|
+
* assertion: the pending decision is invisible to the first invocation.
|
|
7
|
+
*
|
|
8
|
+
* Why `execute`: under capture mode (on whenever a workspace dir and artifact
|
|
9
|
+
* storage exist — every hermetic run) file writes FLOW into the CAS ledger
|
|
10
|
+
* and are reviewed post hoc; shell is the built-in that still interrupts
|
|
11
|
+
* (`middleware/approval-gate.ts`, `shared/tool-kind.ts` SHELL). `echo` is a
|
|
12
|
+
* real subprocess with byte-stable output, the same tool
|
|
13
|
+
* `__tests__/shell-execute-gate.test.ts` drives through the real gate.
|
|
14
|
+
*/
|
|
15
|
+
import type { ScriptedToolCall, ScriptedTurn } from "./scripted-model.js";
|
|
16
|
+
export declare const EXECUTE_CALL_A: ScriptedToolCall;
|
|
17
|
+
export declare const EXECUTE_CALL_B: ScriptedToolCall;
|
|
18
|
+
/** The gate's copy for a SHELL built-in (`CATEGORY_APPROVAL_MESSAGE.shell` over the args). */
|
|
19
|
+
export declare function executeApprovalMessage(call: ScriptedToolCall): string;
|
|
20
|
+
/** Round 0 of every gated arm: one text block and the gated `execute` A. */
|
|
21
|
+
export declare const GATED_OPENING_TURN: ScriptedTurn;
|
|
22
|
+
/** The closing text after the decision has been carried out (or declined). */
|
|
23
|
+
export declare const CLOSING_TURN: ScriptedTurn;
|
|
24
|
+
export declare const GATE_TURN1_GOLDEN = "./goldens/gate.turn1.status.json";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one gated opening every HITL arm shares, so their first-invocation
|
|
3
|
+
* statuses are byte-identical and can match ONE golden file
|
|
4
|
+
* (`__tests__/hermetic/goldens/gate.turn1.status.json`). Matching the same
|
|
5
|
+
* file from the approve, skip, reject and sequential-gates arms is itself an
|
|
6
|
+
* assertion: the pending decision is invisible to the first invocation.
|
|
7
|
+
*
|
|
8
|
+
* Why `execute`: under capture mode (on whenever a workspace dir and artifact
|
|
9
|
+
* storage exist — every hermetic run) file writes FLOW into the CAS ledger
|
|
10
|
+
* and are reviewed post hoc; shell is the built-in that still interrupts
|
|
11
|
+
* (`middleware/approval-gate.ts`, `shared/tool-kind.ts` SHELL). `echo` is a
|
|
12
|
+
* real subprocess with byte-stable output, the same tool
|
|
13
|
+
* `__tests__/shell-execute-gate.test.ts` drives through the real gate.
|
|
14
|
+
*/
|
|
15
|
+
export const EXECUTE_CALL_A = {
|
|
16
|
+
id: "call-hermetic-exec-0001",
|
|
17
|
+
name: "execute",
|
|
18
|
+
args: { command: "echo hermetic-a" },
|
|
19
|
+
};
|
|
20
|
+
export const EXECUTE_CALL_B = {
|
|
21
|
+
id: "call-hermetic-exec-0002",
|
|
22
|
+
name: "execute",
|
|
23
|
+
args: { command: "echo hermetic-b" },
|
|
24
|
+
};
|
|
25
|
+
/** The gate's copy for a SHELL built-in (`CATEGORY_APPROVAL_MESSAGE.shell` over the args). */
|
|
26
|
+
export function executeApprovalMessage(call) {
|
|
27
|
+
return `Execute command: ${String(call.args.command)}`;
|
|
28
|
+
}
|
|
29
|
+
/** Round 0 of every gated arm: one text block and the gated `execute` A. */
|
|
30
|
+
export const GATED_OPENING_TURN = {
|
|
31
|
+
text: "I will run the command.",
|
|
32
|
+
toolCalls: [EXECUTE_CALL_A],
|
|
33
|
+
usage: { inputTokens: 1_400, outputTokens: 50 },
|
|
34
|
+
};
|
|
35
|
+
/** The closing text after the decision has been carried out (or declined). */
|
|
36
|
+
export const CLOSING_TURN = {
|
|
37
|
+
text: "Done with the command.",
|
|
38
|
+
usage: { inputTokens: 1_600, outputTokens: 20 },
|
|
39
|
+
};
|
|
40
|
+
export const GATE_TURN1_GOLDEN = "./goldens/gate.turn1.status.json";
|
|
41
|
+
//# sourceMappingURL=hitl-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitl-script.js","sourceRoot":"","sources":["../../../../src/activities/execute-deep-agent/__test-utils__/hitl-script.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,EAAE,EAAE,yBAAyB;IAC7B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE;CACrC,CAAC;AAEF,8FAA8F;AAC9F,MAAM,UAAU,sBAAsB,CAAC,IAAsB;IAC3D,OAAO,oBAAoB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;AACzD,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,IAAI,EAAE,yBAAyB;IAC/B,SAAS,EAAE,CAAC,cAAc,CAAC;IAC3B,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE;CAChD,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE;CAChD,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module-boundary double for `shared/model-client.ts` — how a
|
|
3
|
+
* `ScriptedModel` reaches the REAL native engine build.
|
|
4
|
+
*
|
|
5
|
+
* `buildChatModel` is the runner's single construction point for LangChain
|
|
6
|
+
* chat models, and a native turn reaches it three ways: the primary model
|
|
7
|
+
* (`turn-setup.ts` `buildEngine`), every sub-agent's `modelFactory` (the same
|
|
8
|
+
* `buildModelFor`), and the runtime's tier-2 structured-output extractor
|
|
9
|
+
* (`shared/extract-structured-output.ts`). None of them takes a model as an
|
|
10
|
+
* argument, so the one seam a hermetic run has is this module — the native analog of the Cursor
|
|
11
|
+
* driver's `vi.mock("@cursor/sdk")`: the vendor engine doubled where the
|
|
12
|
+
* runner imports it, and nothing else (S3 M0 ruling Q-M0-1, amending
|
|
13
|
+
* Q-S3-11).
|
|
14
|
+
*
|
|
15
|
+
* `vi.mock` is hoisted and must live in the test file; the factory can
|
|
16
|
+
* `await import()` this module:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* vi.mock("../../../../shared/model-client.js", async () =>
|
|
20
|
+
* (await import("../../__test-utils__/scripted-model-module.js")).scriptedModelClientModule(),
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Every build the activity requests is recorded (`builds`) so a scenario can
|
|
25
|
+
* assert WHAT production asked for — the registry id, the service tier, the
|
|
26
|
+
* proxy posture — while the model handed back is the scenario's script. The
|
|
27
|
+
* provider is inferred from the requested name exactly as the real module
|
|
28
|
+
* does, so a golden's provider-labelled copy reads as in production.
|
|
29
|
+
*
|
|
30
|
+
* A scenario binds ONE model (every build of every execution gets it) or a
|
|
31
|
+
* RESOLVER over the build's options: production scopes every build to its
|
|
32
|
+
* execution through `headerScope.executionId` (the proxy's attribution
|
|
33
|
+
* header), so a test that runs several executions at once — the harness
|
|
34
|
+
* contract kit's concurrency invariant — routes each build to that
|
|
35
|
+
* execution's own engine through the id production already sends, and
|
|
36
|
+
* through nothing added for the test (S3 M3).
|
|
37
|
+
*/
|
|
38
|
+
import type { BuildChatModelOptions, BuiltChatModel } from "../../../shared/model-client.js";
|
|
39
|
+
import type { ScriptedModel } from "./scripted-model.js";
|
|
40
|
+
/** Which `ScriptedModel` answers one `buildChatModel` call. */
|
|
41
|
+
export type ScriptedModelResolver = (opts: BuildChatModelOptions) => ScriptedModel;
|
|
42
|
+
/**
|
|
43
|
+
* Bind the model every `buildChatModel` call hands back for the current
|
|
44
|
+
* scenario — or a resolver that picks one per call — and forget the previous
|
|
45
|
+
* scenario's build log. Called by the driver at `beginDeepAgentScenario`,
|
|
46
|
+
* before the activity factory runs.
|
|
47
|
+
*/
|
|
48
|
+
export declare function bindScriptedModel(model: ScriptedModel | ScriptedModelResolver): void;
|
|
49
|
+
/** The `buildChatModel` requests the activity made in this scenario, in order. */
|
|
50
|
+
export declare function recordedModelBuilds(): readonly BuildChatModelOptions[];
|
|
51
|
+
/** The factory a test passes to `vi.mock(".../shared/model-client.js", ...)`. */
|
|
52
|
+
export declare function scriptedModelClientModule(): {
|
|
53
|
+
buildChatModel: (opts: BuildChatModelOptions) => Promise<BuiltChatModel>;
|
|
54
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module-boundary double for `shared/model-client.ts` — how a
|
|
3
|
+
* `ScriptedModel` reaches the REAL native engine build.
|
|
4
|
+
*
|
|
5
|
+
* `buildChatModel` is the runner's single construction point for LangChain
|
|
6
|
+
* chat models, and a native turn reaches it three ways: the primary model
|
|
7
|
+
* (`turn-setup.ts` `buildEngine`), every sub-agent's `modelFactory` (the same
|
|
8
|
+
* `buildModelFor`), and the runtime's tier-2 structured-output extractor
|
|
9
|
+
* (`shared/extract-structured-output.ts`). None of them takes a model as an
|
|
10
|
+
* argument, so the one seam a hermetic run has is this module — the native analog of the Cursor
|
|
11
|
+
* driver's `vi.mock("@cursor/sdk")`: the vendor engine doubled where the
|
|
12
|
+
* runner imports it, and nothing else (S3 M0 ruling Q-M0-1, amending
|
|
13
|
+
* Q-S3-11).
|
|
14
|
+
*
|
|
15
|
+
* `vi.mock` is hoisted and must live in the test file; the factory can
|
|
16
|
+
* `await import()` this module:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* vi.mock("../../../../shared/model-client.js", async () =>
|
|
20
|
+
* (await import("../../__test-utils__/scripted-model-module.js")).scriptedModelClientModule(),
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Every build the activity requests is recorded (`builds`) so a scenario can
|
|
25
|
+
* assert WHAT production asked for — the registry id, the service tier, the
|
|
26
|
+
* proxy posture — while the model handed back is the scenario's script. The
|
|
27
|
+
* provider is inferred from the requested name exactly as the real module
|
|
28
|
+
* does, so a golden's provider-labelled copy reads as in production.
|
|
29
|
+
*
|
|
30
|
+
* A scenario binds ONE model (every build of every execution gets it) or a
|
|
31
|
+
* RESOLVER over the build's options: production scopes every build to its
|
|
32
|
+
* execution through `headerScope.executionId` (the proxy's attribution
|
|
33
|
+
* header), so a test that runs several executions at once — the harness
|
|
34
|
+
* contract kit's concurrency invariant — routes each build to that
|
|
35
|
+
* execution's own engine through the id production already sends, and
|
|
36
|
+
* through nothing added for the test (S3 M3).
|
|
37
|
+
*/
|
|
38
|
+
import { stripProviderPrefix, tryInferProvider } from "../../../shared/llm-proxy.js";
|
|
39
|
+
let resolve;
|
|
40
|
+
const builds = [];
|
|
41
|
+
/**
|
|
42
|
+
* Bind the model every `buildChatModel` call hands back for the current
|
|
43
|
+
* scenario — or a resolver that picks one per call — and forget the previous
|
|
44
|
+
* scenario's build log. Called by the driver at `beginDeepAgentScenario`,
|
|
45
|
+
* before the activity factory runs.
|
|
46
|
+
*/
|
|
47
|
+
export function bindScriptedModel(model) {
|
|
48
|
+
resolve = typeof model === "function" ? model : () => model;
|
|
49
|
+
builds.length = 0;
|
|
50
|
+
}
|
|
51
|
+
/** The `buildChatModel` requests the activity made in this scenario, in order. */
|
|
52
|
+
export function recordedModelBuilds() {
|
|
53
|
+
return builds;
|
|
54
|
+
}
|
|
55
|
+
/** The factory a test passes to `vi.mock(".../shared/model-client.js", ...)`. */
|
|
56
|
+
export function scriptedModelClientModule() {
|
|
57
|
+
return {
|
|
58
|
+
buildChatModel: async (opts) => {
|
|
59
|
+
if (!resolve) {
|
|
60
|
+
throw new Error("scripted-model-module: no ScriptedModel bound — call bindScriptedModel(model) " +
|
|
61
|
+
"before constructing the activities");
|
|
62
|
+
}
|
|
63
|
+
builds.push(opts);
|
|
64
|
+
return {
|
|
65
|
+
model: resolve(opts),
|
|
66
|
+
provider: tryInferProvider(opts.modelName) ?? "anthropic",
|
|
67
|
+
apiModelId: stripProviderPrefix(opts.modelName),
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=scripted-model-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripted-model-module.js","sourceRoot":"","sources":["../../../../src/activities/execute-deep-agent/__test-utils__/scripted-model-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAMrF,IAAI,OAA0C,CAAC;AAC/C,MAAM,MAAM,GAA4B,EAAE,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA4C;IAC5E,OAAO,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;IAC5D,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AACpB,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,mBAAmB;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,yBAAyB;IAGvC,OAAO;QACL,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CACb,gFAAgF;oBAC9E,oCAAoC,CACvC,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,OAAO;gBACL,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC;gBACpB,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,WAAW;gBACzD,UAAU,EAAE,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC;aAChD,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|