@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
|
@@ -1,67 +1,81 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HITL (human-in-the-loop) resume infrastructure for
|
|
2
|
+
* HITL (human-in-the-loop) resume infrastructure for the native deep-agent
|
|
3
|
+
* harness — the LangGraph side of an approval round trip.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The runtime reads the user's decisions off the persisted rows
|
|
6
|
+
* (`harness/approval-decisions.ts` `approvalDecisionsOf`, on `TurnInput`)
|
|
7
|
+
* and settles the rows that never run (SKIP, REJECT) after the turn; what is
|
|
8
|
+
* this harness's is how those decisions reach the ENGINE: the graph
|
|
9
|
+
* checkpoint's un-resumed interrupts, keyed by the interrupt's own id, become
|
|
10
|
+
* a `Command(resume)` map ({@link resolveResumeInput}), and after a stream the
|
|
11
|
+
* interrupts still pending become WAITING_APPROVAL rows
|
|
12
|
+
* ({@link detectPendingInterrupts}). {@link reconcileUnattendedSkips} is the
|
|
13
|
+
* one settlement that stays here because its evidence — the gate's registry
|
|
14
|
+
* of auto-skipped call ids — exists only inside this harness.
|
|
10
15
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
16
|
+
* Until S3 M2a this module also read the decisions from the execution itself
|
|
17
|
+
* and carried the SKIP/REJECT settlement; both are the runtime's now, one
|
|
18
|
+
* copy for every harness (S3 M1, Q-S3-2).
|
|
14
19
|
*/
|
|
15
20
|
import { Command } from "@langchain/langgraph";
|
|
16
21
|
import { ApprovalAction, ApprovalPolicySource, ToolCallStatus, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
17
22
|
import { POLICY_ENGINE_VERSION, unattendedSkipMessage } from "../../shared/approval-policy.js";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The gate's resume vocabulary for each decision. APPROVE_ALL resumes the
|
|
25
|
+
* interrupted tool exactly like APPROVE; its "auto-approve the rest of the
|
|
26
|
+
* run" effect is a scoped lease the gate config carries, not this map's.
|
|
27
|
+
* REJECT resumes the gate too (the gate returns a denial ToolMessage the
|
|
28
|
+
* model reads): it denies one tool and never fails the run — the runtime
|
|
29
|
+
* settles the row SKIPPED afterwards (`harness/approval-decisions.ts`).
|
|
30
|
+
*/
|
|
31
|
+
function resumeActionOf(action) {
|
|
32
|
+
switch (action) {
|
|
33
|
+
case ApprovalAction.APPROVE:
|
|
34
|
+
case ApprovalAction.APPROVE_ALL:
|
|
35
|
+
return "approve";
|
|
36
|
+
case ApprovalAction.SKIP:
|
|
37
|
+
return "skip";
|
|
38
|
+
case ApprovalAction.REJECT:
|
|
39
|
+
return "reject";
|
|
40
|
+
case ApprovalAction.UNSPECIFIED:
|
|
41
|
+
return undefined;
|
|
42
|
+
default: {
|
|
43
|
+
const exhaustive = action;
|
|
44
|
+
throw new Error(`hitl: unknown approval action ${String(exhaustive)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
31
48
|
/**
|
|
32
49
|
* Resolve the resume input for a reinvocation after approval.
|
|
33
50
|
*
|
|
34
51
|
* Returns a `Command(resume=...)` if there are pending interrupts with
|
|
35
52
|
* matching approval decisions; otherwise reports "not a resume" and the
|
|
36
|
-
* caller
|
|
53
|
+
* caller sends the turn's user message.
|
|
37
54
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
55
|
+
* `decisions` is the runtime's reading of the adjudicated rows
|
|
56
|
+
* (`TurnInput.approvalDecisions`, keyed by tool-call id) — the one
|
|
57
|
+
* projection both harnesses agree on; this module never re-derives the
|
|
58
|
+
* verdict from the rows. The graph checkpoint snapshot is read once by the
|
|
59
|
+
* caller and passed in: on the durable (http) saver an extra `getState` is a
|
|
60
|
+
* network round-trip best avoided.
|
|
42
61
|
*/
|
|
43
|
-
export function resolveResumeInput(
|
|
62
|
+
export function resolveResumeInput(decisions, graphState) {
|
|
44
63
|
const pendingInterrupts = extractPendingInterrupts(graphState);
|
|
45
64
|
if (pendingInterrupts.length === 0) {
|
|
46
65
|
return { isResumeFromApproval: false };
|
|
47
66
|
}
|
|
48
|
-
const decisions = extractApprovalDecisions(execution);
|
|
49
67
|
if (decisions.size === 0) {
|
|
50
68
|
return { isResumeFromApproval: false };
|
|
51
69
|
}
|
|
52
70
|
const resumeDict = {};
|
|
53
71
|
for (const intr of pendingInterrupts) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
if (!decision)
|
|
72
|
+
const decision = decisions.get(intr.toolCallId);
|
|
73
|
+
if (decision === undefined)
|
|
57
74
|
continue;
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
75
|
+
const action = resumeActionOf(decision);
|
|
76
|
+
if (!action)
|
|
60
77
|
continue;
|
|
61
|
-
resumeDict[intr.interruptId] = {
|
|
62
|
-
action: actionStr,
|
|
63
|
-
...(decision.comment ? { comment: decision.comment } : {}),
|
|
64
|
-
};
|
|
78
|
+
resumeDict[intr.interruptId] = { action };
|
|
65
79
|
}
|
|
66
80
|
if (Object.keys(resumeDict).length === 0) {
|
|
67
81
|
return { isResumeFromApproval: false };
|
|
@@ -95,72 +109,10 @@ function extractPendingInterrupts(state) {
|
|
|
95
109
|
}
|
|
96
110
|
return result;
|
|
97
111
|
}
|
|
98
|
-
function extractApprovalDecisions(execution) {
|
|
99
|
-
const decisions = new Map();
|
|
100
|
-
const status = execution.status;
|
|
101
|
-
if (!status)
|
|
102
|
-
return decisions;
|
|
103
|
-
for (const message of status.messages) {
|
|
104
|
-
for (const tc of message.toolCalls) {
|
|
105
|
-
if (tc.approvalAction !== ApprovalAction.UNSPECIFIED &&
|
|
106
|
-
tc.status === ToolCallStatus.TOOL_CALL_WAITING_APPROVAL) {
|
|
107
|
-
decisions.set(tc.id, {
|
|
108
|
-
action: tc.approvalAction,
|
|
109
|
-
comment: "",
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return decisions;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Terminalize tool calls whose approval decision is non-executing — SKIP or
|
|
118
|
-
* REJECT — so a denied or skipped call is never left stuck at WAITING_APPROVAL.
|
|
119
|
-
*
|
|
120
|
-
* This is the single, authoritative, checkpointer-independent reconciliation of
|
|
121
|
-
* the two decisions that never run the tool: their outcome is fully determined
|
|
122
|
-
* by the recorded decision (ToolCall.approval_action), not by any graph event.
|
|
123
|
-
* APPROVE / APPROVE_ALL are intentionally NOT handled here — the tool actually
|
|
124
|
-
* executes, and real tool events (v3 tool_started → tool_finished) terminalize
|
|
125
|
-
* it in place.
|
|
126
|
-
*
|
|
127
|
-
* Why a decision-derived reconciler rather than the resumed stream: on the
|
|
128
|
-
* durable path (sqlite local / http cloud) the gate returns a denial/skip
|
|
129
|
-
* ToolMessage WITHOUT an on_tool_start/on_tool_end pair, and on the memory path
|
|
130
|
-
* the graph replays without ever re-driving the gate — so in both cases the
|
|
131
|
-
* seeded WAITING_APPROVAL row is never flipped by the stream and would persist
|
|
132
|
-
* on a COMPLETED execution. Folding the recorded decision into a terminal status
|
|
133
|
-
* makes every checkpointer backend behave identically by construction.
|
|
134
|
-
*
|
|
135
|
-
* REJECT and SKIP share TOOL_CALL_SKIPPED as the terminal status (the tool did
|
|
136
|
-
* not run); they stay distinguishable by ToolCall.approval_action and by the
|
|
137
|
-
* append-only approval-event stream (REJECTED vs SKIPPED). Idempotent: a row
|
|
138
|
-
* already resolved carries the same decision and re-resolves identically.
|
|
139
|
-
*/
|
|
140
|
-
export function reconcileNonExecutingDecisions(status) {
|
|
141
|
-
const apply = (messages) => {
|
|
142
|
-
for (const msg of messages) {
|
|
143
|
-
for (const tc of msg.toolCalls) {
|
|
144
|
-
if (tc.approvalAction === ApprovalAction.SKIP) {
|
|
145
|
-
tc.status = ToolCallStatus.TOOL_CALL_SKIPPED;
|
|
146
|
-
}
|
|
147
|
-
else if (tc.approvalAction === ApprovalAction.REJECT) {
|
|
148
|
-
tc.status = ToolCallStatus.TOOL_CALL_SKIPPED;
|
|
149
|
-
if (!tc.error)
|
|
150
|
-
tc.error = "Rejected by user";
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
apply(status.messages);
|
|
156
|
-
for (const subAgent of status.subAgentExecutions) {
|
|
157
|
-
apply(subAgent.messages);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
112
|
/**
|
|
161
113
|
* Terminalize every tool call the approval gate auto-skipped under UNATTENDED
|
|
162
|
-
* approval mode — the sibling of
|
|
163
|
-
* skips that have no human decision behind them.
|
|
114
|
+
* approval mode — the sibling of the runtime's `terminalizeNonExecutingDecisions`
|
|
115
|
+
* for skips that have no human decision behind them.
|
|
164
116
|
*
|
|
165
117
|
* The gate (the single writer of the registry) records each auto-skipped
|
|
166
118
|
* tool-call id at the moment it returns the skip ToolMessage; this reconciler
|
|
@@ -203,4 +155,26 @@ export function reconcileUnattendedSkips(status, unattendedSkips) {
|
|
|
203
155
|
apply(subAgent.messages);
|
|
204
156
|
}
|
|
205
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Normalize the graph checkpoint's un-resumed interrupts into pending
|
|
160
|
+
* approvals — what a stream that ended on a gate left for the user. The
|
|
161
|
+
* caller seeds one WAITING_APPROVAL row per entry and ends the turn awaiting
|
|
162
|
+
* approval; the interrupt carries only `tool_call_id` and `message` beside
|
|
163
|
+
* the gate's own facts, so the row's args are read from the AI message in
|
|
164
|
+
* graph state, never from a second copy here.
|
|
165
|
+
*/
|
|
166
|
+
export function detectPendingInterrupts(graphState) {
|
|
167
|
+
return graphState.tasks.flatMap((task) => (task.interrupts ?? [])
|
|
168
|
+
.filter((intr) => intr.resumeValue === undefined)
|
|
169
|
+
.map((intr) => {
|
|
170
|
+
const val = intr.value;
|
|
171
|
+
return {
|
|
172
|
+
toolCallId: val?.tool_call_id ?? "",
|
|
173
|
+
toolName: val?.tool_name ?? "",
|
|
174
|
+
mcpServerSlug: val?.mcp_server_slug ?? "",
|
|
175
|
+
message: val?.message ?? "",
|
|
176
|
+
policySource: val?.policy_source || undefined,
|
|
177
|
+
};
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
206
180
|
//# sourceMappingURL=hitl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hitl.js","sourceRoot":"","sources":["../../../src/activities/execute-deep-agent/hitl.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hitl.js","sourceRoot":"","sources":["../../../src/activities/execute-deep-agent/hitl.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The native harness's system prompt: what `createDeepAgent` receives as
|
|
3
|
+
* `systemPrompt`, rebuilt on EVERY invocation (never checkpointed with the
|
|
4
|
+
* message history), so every standing fact is injected on every turn by
|
|
5
|
+
* design — a first-turn-only injection would vanish from turn 2 onward.
|
|
3
6
|
*
|
|
4
|
-
* Pure functions: no side effects, no I/O.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
+
* Pure functions: no side effects, no I/O. `turn-setup.ts` gathers the
|
|
8
|
+
* inputs from the runtime's resolved record and this module renders them.
|
|
9
|
+
*
|
|
10
|
+
* What is this harness's and what is shared (S3 M5, Q-S3-10 / Q-M5-2):
|
|
11
|
+
* - Shared through `shared/prompt-sections.ts`: WHICH standing sections
|
|
12
|
+
* render and in WHAT order (`standingContextSections`), the input-files
|
|
13
|
+
* bullet and disclosure lines (`inputFileLines`), which skills a prompt
|
|
14
|
+
* highlights (`selectSkillsForPrompt`, called from `turn-setup.ts`) and
|
|
15
|
+
* the also-available sentence. Their WORDS come from each fact's own
|
|
16
|
+
* module; this builder only frames them.
|
|
17
|
+
* - This harness's: the framing — `## Heading` markdown sections, the house
|
|
18
|
+
* style for a system prompt — and every text that quotes this engine's
|
|
19
|
+
* tools: the `## Skills` activation protocol (`read`, `execute(...)`), the
|
|
20
|
+
* response rules, the sub-agent delegation rules, the plan-mode
|
|
21
|
+
* read-boundary sentence, and the workspace section (the deepagents
|
|
22
|
+
* backend's path resolution is this engine's).
|
|
23
|
+
*
|
|
24
|
+
* The rendered bytes are load-bearing for the hermetic tests: `ScriptedModel`
|
|
25
|
+
* tells its scripted roles apart by the system prompt's text, so this
|
|
26
|
+
* module's whole output is pinned by `__tests__/prompt-goldens.test.ts`.
|
|
7
27
|
*/
|
|
8
28
|
import { InteractionMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
9
29
|
import type { ProvisionResult } from "../../shared/workspace/types.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { type
|
|
15
|
-
import type {
|
|
30
|
+
import type { SenderIdentity } from "../../shared/sender-identity.js";
|
|
31
|
+
import type { DeclaredPreferencesContent } from "../../shared/declared-preferences.js";
|
|
32
|
+
import type { RecalledMemoriesContent } from "../../shared/recalled-memories.js";
|
|
33
|
+
import type { DownloadUrlKind } from "../../shared/attachment-download-urls.js";
|
|
34
|
+
import { type VisionPromptInfo } from "../../shared/prompt-sections.js";
|
|
35
|
+
import type { ResolvedAttachment } from "../../shared/attachment-resolver.js";
|
|
36
|
+
import type { SkillMetadata } from "../../shared/skill-resolver.js";
|
|
37
|
+
/** The agent's instructions when the blueprint carries none; the prompt is never empty (S3 M2a, F-M2a-16: was `setup.ts`'s alone). */
|
|
38
|
+
export declare const DEFAULT_INSTRUCTIONS = "You are a helpful AI assistant.";
|
|
16
39
|
export interface PromptBuilderInput {
|
|
40
|
+
/** The blueprint's instructions, raw; empty falls back to {@link DEFAULT_INSTRUCTIONS}. */
|
|
17
41
|
instructions: string;
|
|
18
42
|
provisionResults: ProvisionResult[];
|
|
19
43
|
containerRoot: string;
|
|
@@ -26,7 +50,8 @@ export interface PromptBuilderInput {
|
|
|
26
50
|
channelTemplatesPromptSection?: string;
|
|
27
51
|
workspaceFileRefs: string[];
|
|
28
52
|
workspaceRoot: string;
|
|
29
|
-
|
|
53
|
+
/** The turn's resolved input files, as the runtime's attachment phase returns them. */
|
|
54
|
+
inputFiles: readonly ResolvedAttachment[];
|
|
30
55
|
/**
|
|
31
56
|
* Vision facts about this turn's attachments (T04): which images the model
|
|
32
57
|
* sees inline in the user message and which degraded to path-only.
|
|
@@ -42,7 +67,7 @@ export interface PromptBuilderInput {
|
|
|
42
67
|
/**
|
|
43
68
|
* The execution's interaction mode. PLAN appends the shared plan-mode
|
|
44
69
|
* directive so the model knows the turn's deliverable is a plan document.
|
|
45
|
-
* Tool-level write enforcement is separate (see setup.ts permissions) —
|
|
70
|
+
* Tool-level write enforcement is separate (see turn-setup.ts permissions) —
|
|
46
71
|
* without this directive the model is silently read-only but never told
|
|
47
72
|
* to produce a plan.
|
|
48
73
|
*/
|
|
@@ -98,17 +123,7 @@ export interface PromptBuilderInput {
|
|
|
98
123
|
*/
|
|
99
124
|
recalledMemories?: RecalledMemoriesContent;
|
|
100
125
|
}
|
|
101
|
-
export type {
|
|
102
|
-
/**
|
|
103
|
-
* Which images ride the user message inline (in send order) and which
|
|
104
|
-
* degraded to the file-pointer story — the shared vision wording
|
|
105
|
-
* (attachment-vision.ts) keeps this prompt and the Cursor harness's
|
|
106
|
-
* input-files section telling the agent the same thing.
|
|
107
|
-
*/
|
|
108
|
-
export interface VisionPromptInfo {
|
|
109
|
-
inlineFilenames: string[];
|
|
110
|
-
notViewable: NotViewableEntry[];
|
|
111
|
-
}
|
|
126
|
+
export type { VisionPromptInfo };
|
|
112
127
|
/**
|
|
113
128
|
* Assemble the full system prompt from base instructions and contextual
|
|
114
129
|
* sections. Pure function with no I/O.
|
|
@@ -125,3 +140,16 @@ export declare function buildEnhancedSystemPrompt(input: PromptBuilderInput): st
|
|
|
125
140
|
* exists only in the graph input.
|
|
126
141
|
*/
|
|
127
142
|
export declare function composeUserMessage(message: string, conversationCatchup: string | undefined): string;
|
|
143
|
+
/**
|
|
144
|
+
* The `## Skills` section of this harness's system prompt, rendered from the
|
|
145
|
+
* runtime's mounted-skill metadata (`shared/skill-resolver.ts`
|
|
146
|
+
* `SkillMetadata`), following the Agent Skills spec's progressive
|
|
147
|
+
* disclosure model: only name, description and location are injected; the
|
|
148
|
+
* agent reads SKILL.md on demand through its filesystem tools. Byte for byte
|
|
149
|
+
* the text the orchestrator-era `generatePromptSection` rendered from the
|
|
150
|
+
* `Skill` proto (deleted with `setup.ts` at S3 M2b); the one difference is
|
|
151
|
+
* the input — a mounted file's metadata, not a fetched resource — so this
|
|
152
|
+
* renderer needs no client and serves the root and every sub-agent alike.
|
|
153
|
+
* Empty for no skills.
|
|
154
|
+
*/
|
|
155
|
+
export declare function renderSkillsSection(skills: readonly SkillMetadata[]): string;
|
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The native harness's system prompt: what `createDeepAgent` receives as
|
|
3
|
+
* `systemPrompt`, rebuilt on EVERY invocation (never checkpointed with the
|
|
4
|
+
* message history), so every standing fact is injected on every turn by
|
|
5
|
+
* design — a first-turn-only injection would vanish from turn 2 onward.
|
|
3
6
|
*
|
|
4
|
-
* Pure functions: no side effects, no I/O.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
+
* Pure functions: no side effects, no I/O. `turn-setup.ts` gathers the
|
|
8
|
+
* inputs from the runtime's resolved record and this module renders them.
|
|
9
|
+
*
|
|
10
|
+
* What is this harness's and what is shared (S3 M5, Q-S3-10 / Q-M5-2):
|
|
11
|
+
* - Shared through `shared/prompt-sections.ts`: WHICH standing sections
|
|
12
|
+
* render and in WHAT order (`standingContextSections`), the input-files
|
|
13
|
+
* bullet and disclosure lines (`inputFileLines`), which skills a prompt
|
|
14
|
+
* highlights (`selectSkillsForPrompt`, called from `turn-setup.ts`) and
|
|
15
|
+
* the also-available sentence. Their WORDS come from each fact's own
|
|
16
|
+
* module; this builder only frames them.
|
|
17
|
+
* - This harness's: the framing — `## Heading` markdown sections, the house
|
|
18
|
+
* style for a system prompt — and every text that quotes this engine's
|
|
19
|
+
* tools: the `## Skills` activation protocol (`read`, `execute(...)`), the
|
|
20
|
+
* response rules, the sub-agent delegation rules, the plan-mode
|
|
21
|
+
* read-boundary sentence, and the workspace section (the deepagents
|
|
22
|
+
* backend's path resolution is this engine's).
|
|
23
|
+
*
|
|
24
|
+
* The rendered bytes are load-bearing for the hermetic tests: `ScriptedModel`
|
|
25
|
+
* tells its scripted roles apart by the system prompt's text, so this
|
|
26
|
+
* module's whole output is pinned by `__tests__/prompt-goldens.test.ts`.
|
|
7
27
|
*/
|
|
8
28
|
import { relative } from "node:path";
|
|
9
29
|
import { InteractionMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
10
30
|
import { SourceType } from "../../shared/workspace/types.js";
|
|
11
|
-
import { formatContextBridgeText } from "../../shared/context-bridge.js";
|
|
12
31
|
import { formatConversationCatchupText } from "../../shared/conversation-catchup.js";
|
|
13
|
-
import {
|
|
14
|
-
import { formatSessionContextText } from "../../shared/session-context.js";
|
|
15
|
-
import { formatDeclaredPreferencesText, } from "../../shared/declared-preferences.js";
|
|
16
|
-
import { formatRecalledMemoriesText, } from "../../shared/recalled-memories.js";
|
|
17
|
-
import { visionDisclosureLines, } from "../../shared/attachment-vision.js";
|
|
18
|
-
import { downloadUrlDisclosureLine, } from "../../shared/attachment-download-urls.js";
|
|
32
|
+
import { inputFileLines, standingContextSections, } from "../../shared/prompt-sections.js";
|
|
19
33
|
import { PLAN_MODE_DIRECTIVE } from "../../shared/plan-mode-prompt.js";
|
|
20
34
|
import { buildImplementPlanDirective, findApprovedPlanPath, } from "../../shared/implement-plan-prompt.js";
|
|
35
|
+
import { STIGMER_LOCAL_STATE_DIR } from "../../shared/workspace/stigmer-link.js";
|
|
21
36
|
const RESPONSE_RULES = `
|
|
22
37
|
|
|
23
38
|
## Response rules
|
|
@@ -82,12 +97,27 @@ influence your answer.
|
|
|
82
97
|
directly over delegating. Only delegate when context isolation \
|
|
83
98
|
or parallelism genuinely helps the user.
|
|
84
99
|
`;
|
|
100
|
+
/** The agent's instructions when the blueprint carries none; the prompt is never empty (S3 M2a, F-M2a-16: was `setup.ts`'s alone). */
|
|
101
|
+
export const DEFAULT_INSTRUCTIONS = "You are a helpful AI assistant.";
|
|
102
|
+
/**
|
|
103
|
+
* This harness's heading for each shared standing section (the section's
|
|
104
|
+
* identity and order are `prompt-sections.ts`'s; the `##` framing is the
|
|
105
|
+
* house style for a system prompt). Exhaustive by the compiler: a new kind
|
|
106
|
+
* fails here until it is named.
|
|
107
|
+
*/
|
|
108
|
+
const STANDING_SECTION_HEADINGS = {
|
|
109
|
+
"conversation-sender": "Conversation sender",
|
|
110
|
+
"declared-preferences": "Declared preferences",
|
|
111
|
+
"recalled-memories": "Remembered facts",
|
|
112
|
+
"session-context": "Session context",
|
|
113
|
+
"previous-conversation": "Previous conversation context",
|
|
114
|
+
};
|
|
85
115
|
/**
|
|
86
116
|
* Assemble the full system prompt from base instructions and contextual
|
|
87
117
|
* sections. Pure function with no I/O.
|
|
88
118
|
*/
|
|
89
119
|
export function buildEnhancedSystemPrompt(input) {
|
|
90
|
-
let prompt = input.instructions;
|
|
120
|
+
let prompt = input.instructions || DEFAULT_INSTRUCTIONS;
|
|
91
121
|
const workspaceSection = buildWorkspacePromptSection(input.provisionResults, input.containerRoot);
|
|
92
122
|
if (workspaceSection) {
|
|
93
123
|
prompt += workspaceSection;
|
|
@@ -104,43 +134,13 @@ export function buildEnhancedSystemPrompt(input) {
|
|
|
104
134
|
prompt += refSection;
|
|
105
135
|
}
|
|
106
136
|
}
|
|
107
|
-
if (input.
|
|
108
|
-
prompt +=
|
|
109
|
-
}
|
|
110
|
-
if (input.senderIdentity) {
|
|
111
|
-
prompt +=
|
|
112
|
-
"\n\n## Conversation sender\n\n" +
|
|
113
|
-
formatSenderIdentityText(input.senderIdentity);
|
|
114
|
-
}
|
|
115
|
-
// Platform-declared standing facts precede embedder-supplied context
|
|
116
|
-
// (DD-002 D3): both are standing background, but the declared preferences
|
|
117
|
-
// are platform-authored while session context is the embedder's overlay —
|
|
118
|
-
// the more specific overlay reads later and naturally refines.
|
|
119
|
-
if (input.declaredPreferences) {
|
|
120
|
-
prompt +=
|
|
121
|
-
"\n\n## Declared preferences\n\n" +
|
|
122
|
-
formatDeclaredPreferencesText(input.declaredPreferences);
|
|
123
|
-
}
|
|
124
|
-
// Declared-by-humans precedes learned-and-confirmed (DD-006 D4): both
|
|
125
|
-
// are platform-authored standing background, but a preference is the
|
|
126
|
-
// user's exact words while a memory is an agent's confirmed inference —
|
|
127
|
-
// the exact statement reads first.
|
|
128
|
-
if (input.recalledMemories) {
|
|
129
|
-
prompt +=
|
|
130
|
-
"\n\n## Remembered facts\n\n" +
|
|
131
|
-
formatRecalledMemoriesText(input.recalledMemories);
|
|
132
|
-
}
|
|
133
|
-
// Standing facts about the user (session context) come before the
|
|
134
|
-
// carried conversation (bridge): the bridge may refer back to them.
|
|
135
|
-
if (input.sessionContext) {
|
|
136
|
-
prompt +=
|
|
137
|
-
"\n\n## Session context\n\n" +
|
|
138
|
-
formatSessionContextText(input.sessionContext);
|
|
137
|
+
if (input.inputFiles.length > 0) {
|
|
138
|
+
prompt += buildInputFilesSection(input.inputFiles, input.vision, input.downloadUrlKind);
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
// The standing context, in the shared order (the doctrine is stated once,
|
|
141
|
+
// on `standingContextSections`); this harness only frames each section.
|
|
142
|
+
for (const section of standingContextSections(input)) {
|
|
143
|
+
prompt += `\n\n## ${STANDING_SECTION_HEADINGS[section.kind]}\n\n${section.body}`;
|
|
144
144
|
}
|
|
145
145
|
prompt += RESPONSE_RULES;
|
|
146
146
|
prompt += SUB_AGENT_RULES;
|
|
@@ -162,7 +162,7 @@ export function buildEnhancedSystemPrompt(input) {
|
|
|
162
162
|
"`.stigmer/` directory); paths outside it are refused.";
|
|
163
163
|
}
|
|
164
164
|
if (input.buildFromPlan) {
|
|
165
|
-
const planPath = findApprovedPlanPath(input.
|
|
165
|
+
const planPath = findApprovedPlanPath(input.inputFiles.map((f) => f.relativePath));
|
|
166
166
|
prompt +=
|
|
167
167
|
"\n\n## Implement the approved plan\n\n" +
|
|
168
168
|
buildImplementPlanDirective(planPath);
|
|
@@ -184,6 +184,58 @@ export function composeUserMessage(message, conversationCatchup) {
|
|
|
184
184
|
? `${formatConversationCatchupText(conversationCatchup)}\n\n---\n\n${message}`
|
|
185
185
|
: message;
|
|
186
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* The `## Skills` section of this harness's system prompt, rendered from the
|
|
189
|
+
* runtime's mounted-skill metadata (`shared/skill-resolver.ts`
|
|
190
|
+
* `SkillMetadata`), following the Agent Skills spec's progressive
|
|
191
|
+
* disclosure model: only name, description and location are injected; the
|
|
192
|
+
* agent reads SKILL.md on demand through its filesystem tools. Byte for byte
|
|
193
|
+
* the text the orchestrator-era `generatePromptSection` rendered from the
|
|
194
|
+
* `Skill` proto (deleted with `setup.ts` at S3 M2b); the one difference is
|
|
195
|
+
* the input — a mounted file's metadata, not a fetched resource — so this
|
|
196
|
+
* renderer needs no client and serves the root and every sub-agent alike.
|
|
197
|
+
* Empty for no skills.
|
|
198
|
+
*/
|
|
199
|
+
export function renderSkillsSection(skills) {
|
|
200
|
+
if (skills.length === 0)
|
|
201
|
+
return "";
|
|
202
|
+
const lines = [
|
|
203
|
+
"",
|
|
204
|
+
"",
|
|
205
|
+
"## Skills",
|
|
206
|
+
"",
|
|
207
|
+
"You have access to the following skills. Each skill provides specialized " +
|
|
208
|
+
"knowledge or capabilities.",
|
|
209
|
+
"",
|
|
210
|
+
"**Activation protocol**: To use a skill, read its SKILL.md file " +
|
|
211
|
+
"using the `read` tool. The SKILL.md contains detailed instructions, " +
|
|
212
|
+
"available tools, and usage examples.",
|
|
213
|
+
"",
|
|
214
|
+
"**Usage pattern**:",
|
|
215
|
+
"",
|
|
216
|
+
"1. Review the skill description below to determine relevance",
|
|
217
|
+
"2. Read `{location}/SKILL.md` for full instructions",
|
|
218
|
+
"3. Follow the skill's documented operations:",
|
|
219
|
+
"",
|
|
220
|
+
"`read {location}/references/schema.md`",
|
|
221
|
+
'`execute("python3 {location}/scripts/run.py")`',
|
|
222
|
+
"",
|
|
223
|
+
];
|
|
224
|
+
for (const skill of skills) {
|
|
225
|
+
const skillDir = skillDirOf(skill);
|
|
226
|
+
lines.push(`### ${skill.name}`);
|
|
227
|
+
lines.push(`**Description**: ${skill.description || "(no description)"}`);
|
|
228
|
+
lines.push(`**Location**: \`${skillDir}/\``);
|
|
229
|
+
lines.push(`**Activate**: \`read ${skillDir}/SKILL.md\``);
|
|
230
|
+
lines.push("");
|
|
231
|
+
}
|
|
232
|
+
return lines.join("\n");
|
|
233
|
+
}
|
|
234
|
+
/** The mount directory a skill's `SKILL.md` path names (`.stigmer/skills/<name>`). */
|
|
235
|
+
function skillDirOf(skill) {
|
|
236
|
+
const slash = skill.path.lastIndexOf("/");
|
|
237
|
+
return slash > 0 ? skill.path.slice(0, slash) : `${STIGMER_LOCAL_STATE_DIR}/skills/${skill.name}`;
|
|
238
|
+
}
|
|
187
239
|
function buildWorkspacePromptSection(provisionResults, containerRoot) {
|
|
188
240
|
if (provisionResults.length === 0)
|
|
189
241
|
return "";
|
|
@@ -268,7 +320,13 @@ function buildReferencedFilesSection(workspaceFileRefs, _workspaceRoot) {
|
|
|
268
320
|
}
|
|
269
321
|
return section;
|
|
270
322
|
}
|
|
271
|
-
|
|
323
|
+
/**
|
|
324
|
+
* The `## Input Files` section: this harness's intro (it names this engine's
|
|
325
|
+
* `read` tool) around the shared lines (`prompt-sections.ts` `inputFileLines`
|
|
326
|
+
* says what each bullet and disclosure carries and why). Each disclosure
|
|
327
|
+
* group is set off by a blank line, the markdown idiom.
|
|
328
|
+
*/
|
|
329
|
+
function buildInputFilesSection(files, vision, downloadUrlKind) {
|
|
272
330
|
let section = "\n\n## Input Files\n\n";
|
|
273
331
|
section +=
|
|
274
332
|
"The following files have been provided as read-only reference " +
|
|
@@ -278,34 +336,15 @@ function buildInjectedFilesSection(files, vision, downloadUrlKind) {
|
|
|
278
336
|
"Do NOT echo, reprint, or summarize file contents in your response " +
|
|
279
337
|
"-- they are reference material, not output. " +
|
|
280
338
|
"Do NOT modify or delete these files.\n\n";
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
// name so the agent can connect "the two report.pdfs" in the user's
|
|
285
|
-
// message to distinct files on disk. A file with a minted download URL
|
|
286
|
-
// (attachment-download-urls.ts) lists it beside the path for the remote
|
|
287
|
-
// hand-off story.
|
|
288
|
-
const renameInfo = f.renamedFrom !== undefined
|
|
289
|
-
? ` (renamed from duplicate '${f.renamedFrom}')`
|
|
290
|
-
: "";
|
|
291
|
-
const urlInfo = f.downloadUrl !== undefined ? ` — download URL: ${f.downloadUrl}` : "";
|
|
292
|
-
section += `- \`${f.path}\`${sizeInfo}${renameInfo}${urlInfo}\n`;
|
|
339
|
+
const lines = inputFileLines(files, vision, downloadUrlKind);
|
|
340
|
+
for (const entry of lines.entries) {
|
|
341
|
+
section += `${entry}\n`;
|
|
293
342
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
// keys on what kind of URL the storage backend mints.
|
|
297
|
-
if (downloadUrlKind !== undefined && files.some((f) => f.downloadUrl !== undefined)) {
|
|
298
|
-
section += "\n" + downloadUrlDisclosureLine(downloadUrlKind) + "\n";
|
|
343
|
+
if (lines.urlHandoff !== undefined) {
|
|
344
|
+
section += "\n" + lines.urlHandoff + "\n";
|
|
299
345
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
// which degraded to path-only — without them an agent silently ignores a
|
|
303
|
-
// photo the user believes it can see.
|
|
304
|
-
if (vision) {
|
|
305
|
-
const lines = visionDisclosureLines(vision.inlineFilenames, vision.notViewable);
|
|
306
|
-
if (lines.length > 0) {
|
|
307
|
-
section += "\n" + lines.join("\n") + "\n";
|
|
308
|
-
}
|
|
346
|
+
if (lines.vision.length > 0) {
|
|
347
|
+
section += "\n" + lines.vision.join("\n") + "\n";
|
|
309
348
|
}
|
|
310
349
|
return section;
|
|
311
350
|
}
|