@stigmer/runner 0.1.0-dev.20261017020314.g644422724c27
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/LICENSE +194 -0
- package/README.md +310 -0
- package/dist/.build-fingerprint +1 -0
- package/dist/__test-utils__/approval-contract/hook-commands.d.ts +25 -0
- package/dist/__test-utils__/approval-contract/hook-commands.js +87 -0
- package/dist/__test-utils__/approval-contract/hook-commands.js.map +1 -0
- package/dist/__test-utils__/approval-contract/types.d.ts +326 -0
- package/dist/__test-utils__/approval-contract/types.js +24 -0
- package/dist/__test-utils__/approval-contract/types.js.map +1 -0
- package/dist/__test-utils__/approval-log.d.ts +34 -0
- package/dist/__test-utils__/approval-log.js +126 -0
- package/dist/__test-utils__/approval-log.js.map +1 -0
- package/dist/__test-utils__/execution-record-fixture.d.ts +121 -0
- package/dist/__test-utils__/execution-record-fixture.js +134 -0
- package/dist/__test-utils__/execution-record-fixture.js.map +1 -0
- package/dist/__test-utils__/file-review-projection.d.ts +45 -0
- package/dist/__test-utils__/file-review-projection.js +61 -0
- package/dist/__test-utils__/file-review-projection.js.map +1 -0
- package/dist/__test-utils__/harness-contract/types.d.ts +188 -0
- package/dist/__test-utils__/harness-contract/types.js +64 -0
- package/dist/__test-utils__/harness-contract/types.js.map +1 -0
- package/dist/__test-utils__/hermetic-activity.d.ts +450 -0
- package/dist/__test-utils__/hermetic-activity.js +883 -0
- package/dist/__test-utils__/hermetic-activity.js.map +1 -0
- package/dist/__test-utils__/loopback-host.d.ts +23 -0
- package/dist/__test-utils__/loopback-host.js +45 -0
- package/dist/__test-utils__/loopback-host.js.map +1 -0
- package/dist/__test-utils__/mock-client.d.ts +13 -0
- package/dist/__test-utils__/mock-client.js +46 -0
- package/dist/__test-utils__/mock-client.js.map +1 -0
- package/dist/__test-utils__/mock-workspace.d.ts +15 -0
- package/dist/__test-utils__/mock-workspace.js +21 -0
- package/dist/__test-utils__/mock-workspace.js.map +1 -0
- package/dist/__test-utils__/model-registry-fixture.d.ts +111 -0
- package/dist/__test-utils__/model-registry-fixture.js +109 -0
- package/dist/__test-utils__/model-registry-fixture.js.map +1 -0
- package/dist/__test-utils__/turn-input-fixture.d.ts +60 -0
- package/dist/__test-utils__/turn-input-fixture.js +129 -0
- package/dist/__test-utils__/turn-input-fixture.js.map +1 -0
- package/dist/activities/attach-session.d.ts +34 -0
- package/dist/activities/attach-session.js +94 -0
- package/dist/activities/attach-session.js.map +1 -0
- package/dist/activities/ensure-thread.d.ts +24 -0
- package/dist/activities/ensure-thread.js +44 -0
- package/dist/activities/ensure-thread.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.d.ts +107 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +392 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +251 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +254 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/fold.d.ts +62 -0
- package/dist/activities/execute-cursor/__test-utils__/fold.js +94 -0
- package/dist/activities/execute-cursor/__test-utils__/fold.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.d.ts +34 -0
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +287 -0
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +202 -0
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +306 -0
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +176 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +278 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +182 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +241 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -0
- package/dist/activities/execute-cursor/adapter.d.ts +63 -0
- package/dist/activities/execute-cursor/adapter.js +141 -0
- package/dist/activities/execute-cursor/adapter.js.map +1 -0
- package/dist/activities/execute-cursor/agent-session-cache.d.ts +72 -0
- package/dist/activities/execute-cursor/agent-session-cache.js +186 -0
- package/dist/activities/execute-cursor/agent-session-cache.js.map +1 -0
- package/dist/activities/execute-cursor/approval-policy.d.ts +67 -0
- package/dist/activities/execute-cursor/approval-policy.js +101 -0
- package/dist/activities/execute-cursor/approval-policy.js.map +1 -0
- package/dist/activities/execute-cursor/approval-state.d.ts +657 -0
- package/dist/activities/execute-cursor/approval-state.js +682 -0
- package/dist/activities/execute-cursor/approval-state.js.map +1 -0
- package/dist/activities/execute-cursor/boundary-rows.d.ts +455 -0
- package/dist/activities/execute-cursor/boundary-rows.js +1268 -0
- package/dist/activities/execute-cursor/boundary-rows.js.map +1 -0
- package/dist/activities/execute-cursor/cas-observations.d.ts +126 -0
- package/dist/activities/execute-cursor/cas-observations.js +240 -0
- package/dist/activities/execute-cursor/cas-observations.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-capabilities.d.ts +37 -0
- package/dist/activities/execute-cursor/cursor-capabilities.js +74 -0
- package/dist/activities/execute-cursor/cursor-capabilities.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-event-recorder.d.ts +43 -0
- package/dist/activities/execute-cursor/cursor-event-recorder.js +88 -0
- package/dist/activities/execute-cursor/cursor-event-recorder.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-mcp-config.d.ts +58 -0
- package/dist/activities/execute-cursor/cursor-mcp-config.js +86 -0
- package/dist/activities/execute-cursor/cursor-mcp-config.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-mode.d.ts +32 -0
- package/dist/activities/execute-cursor/cursor-mode.js +36 -0
- package/dist/activities/execute-cursor/cursor-mode.js.map +1 -0
- package/dist/activities/execute-cursor/error-classifier.d.ts +138 -0
- package/dist/activities/execute-cursor/error-classifier.js +330 -0
- package/dist/activities/execute-cursor/error-classifier.js.map +1 -0
- package/dist/activities/execute-cursor/fetch-interceptor.d.ts +56 -0
- package/dist/activities/execute-cursor/fetch-interceptor.js +378 -0
- package/dist/activities/execute-cursor/fetch-interceptor.js.map +1 -0
- package/dist/activities/execute-cursor/hook-scope.d.ts +143 -0
- package/dist/activities/execute-cursor/hook-scope.js +149 -0
- package/dist/activities/execute-cursor/hook-scope.js.map +1 -0
- package/dist/activities/execute-cursor/hook-script.d.ts +172 -0
- package/dist/activities/execute-cursor/hook-script.js +1204 -0
- package/dist/activities/execute-cursor/hook-script.js.map +1 -0
- package/dist/activities/execute-cursor/hook-server.d.ts +152 -0
- package/dist/activities/execute-cursor/hook-server.js +422 -0
- package/dist/activities/execute-cursor/hook-server.js.map +1 -0
- package/dist/activities/execute-cursor/hook-tool-hiding.d.ts +37 -0
- package/dist/activities/execute-cursor/hook-tool-hiding.js +58 -0
- package/dist/activities/execute-cursor/hook-tool-hiding.js.map +1 -0
- package/dist/activities/execute-cursor/hook-views.d.ts +74 -0
- package/dist/activities/execute-cursor/hook-views.js +180 -0
- package/dist/activities/execute-cursor/hook-views.js.map +1 -0
- package/dist/activities/execute-cursor/http2-interceptor.d.ts +98 -0
- package/dist/activities/execute-cursor/http2-interceptor.js +218 -0
- package/dist/activities/execute-cursor/http2-interceptor.js.map +1 -0
- package/dist/activities/execute-cursor/model-pricing-data.d.ts +39 -0
- package/dist/activities/execute-cursor/model-pricing-data.js +109 -0
- package/dist/activities/execute-cursor/model-pricing-data.js.map +1 -0
- package/dist/activities/execute-cursor/model-pricing.d.ts +51 -0
- package/dist/activities/execute-cursor/model-pricing.js +160 -0
- package/dist/activities/execute-cursor/model-pricing.js.map +1 -0
- package/dist/activities/execute-cursor/prompt-builder.d.ts +437 -0
- package/dist/activities/execute-cursor/prompt-builder.js +719 -0
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -0
- package/dist/activities/execute-cursor/rejection-capture.d.ts +27 -0
- package/dist/activities/execute-cursor/rejection-capture.js +78 -0
- package/dist/activities/execute-cursor/rejection-capture.js.map +1 -0
- package/dist/activities/execute-cursor/run-telemetry.d.ts +61 -0
- package/dist/activities/execute-cursor/run-telemetry.js +149 -0
- package/dist/activities/execute-cursor/run-telemetry.js.map +1 -0
- package/dist/activities/execute-cursor/sdk-warmup.d.ts +53 -0
- package/dist/activities/execute-cursor/sdk-warmup.js +70 -0
- package/dist/activities/execute-cursor/sdk-warmup.js.map +1 -0
- package/dist/activities/execute-cursor/service-tier.d.ts +68 -0
- package/dist/activities/execute-cursor/service-tier.js +200 -0
- package/dist/activities/execute-cursor/service-tier.js.map +1 -0
- package/dist/activities/execute-cursor/session-lifecycle.d.ts +247 -0
- package/dist/activities/execute-cursor/session-lifecycle.js +330 -0
- package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -0
- package/dist/activities/execute-cursor/session-store.d.ts +99 -0
- package/dist/activities/execute-cursor/session-store.js +156 -0
- package/dist/activities/execute-cursor/session-store.js.map +1 -0
- package/dist/activities/execute-cursor/sub-agent-steps.d.ts +79 -0
- package/dist/activities/execute-cursor/sub-agent-steps.js +180 -0
- package/dist/activities/execute-cursor/sub-agent-steps.js.map +1 -0
- package/dist/activities/execute-cursor/subagent-config.d.ts +61 -0
- package/dist/activities/execute-cursor/subagent-config.js +102 -0
- package/dist/activities/execute-cursor/subagent-config.js.map +1 -0
- package/dist/activities/execute-cursor/tool-result.d.ts +49 -0
- package/dist/activities/execute-cursor/tool-result.js +130 -0
- package/dist/activities/execute-cursor/tool-result.js.map +1 -0
- package/dist/activities/execute-cursor/translator.d.ts +183 -0
- package/dist/activities/execute-cursor/translator.js +485 -0
- package/dist/activities/execute-cursor/translator.js.map +1 -0
- package/dist/activities/execute-cursor/turn-boundary.d.ts +124 -0
- package/dist/activities/execute-cursor/turn-boundary.js +210 -0
- package/dist/activities/execute-cursor/turn-boundary.js.map +1 -0
- package/dist/activities/execute-cursor/turn-recovery.d.ts +62 -0
- package/dist/activities/execute-cursor/turn-recovery.js +208 -0
- package/dist/activities/execute-cursor/turn-recovery.js.map +1 -0
- package/dist/activities/execute-cursor/turn-settle.d.ts +59 -0
- package/dist/activities/execute-cursor/turn-settle.js +512 -0
- package/dist/activities/execute-cursor/turn-settle.js.map +1 -0
- package/dist/activities/execute-cursor/turn-setup.d.ts +281 -0
- package/dist/activities/execute-cursor/turn-setup.js +739 -0
- package/dist/activities/execute-cursor/turn-setup.js.map +1 -0
- package/dist/activities/execute-cursor/turn-stream.d.ts +133 -0
- package/dist/activities/execute-cursor/turn-stream.js +239 -0
- package/dist/activities/execute-cursor/turn-stream.js.map +1 -0
- package/dist/activities/execute-cursor/turn.d.ts +46 -0
- package/dist/activities/execute-cursor/turn.js +247 -0
- package/dist/activities/execute-cursor/turn.js.map +1 -0
- package/dist/activities/execute-cursor/usage-pricing.d.ts +38 -0
- package/dist/activities/execute-cursor/usage-pricing.js +50 -0
- package/dist/activities/execute-cursor/usage-pricing.js.map +1 -0
- package/dist/activities/execute-cursor/workspace-hook-files.d.ts +116 -0
- package/dist/activities/execute-cursor/workspace-hook-files.js +390 -0
- package/dist/activities/execute-cursor/workspace-hook-files.js.map +1 -0
- package/dist/activities/execute-cursor/workspace-setup.d.ts +148 -0
- package/dist/activities/execute-cursor/workspace-setup.js +444 -0
- package/dist/activities/execute-cursor/workspace-setup.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.d.ts +102 -0
- package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js +361 -0
- package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.d.ts +33 -0
- package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.js +423 -0
- package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.d.ts +224 -0
- package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js +307 -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__/paused-session-fixture.d.ts +76 -0
- package/dist/activities/execute-deep-agent/__test-utils__/paused-session-fixture.js +112 -0
- package/dist/activities/execute-deep-agent/__test-utils__/paused-session-fixture.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.d.ts +53 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js +71 -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 +305 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js +368 -0
- package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/think-bound-session.d.ts +17 -0
- package/dist/activities/execute-deep-agent/__test-utils__/think-bound-session.js +23 -0
- package/dist/activities/execute-deep-agent/__test-utils__/think-bound-session.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.d.ts +80 -0
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js +195 -0
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js.map +1 -0
- package/dist/activities/execute-deep-agent/adapter.d.ts +41 -0
- package/dist/activities/execute-deep-agent/adapter.js +79 -0
- package/dist/activities/execute-deep-agent/adapter.js.map +1 -0
- package/dist/activities/execute-deep-agent/approval-file-change.d.ts +54 -0
- package/dist/activities/execute-deep-agent/approval-file-change.js +68 -0
- package/dist/activities/execute-deep-agent/approval-file-change.js.map +1 -0
- package/dist/activities/execute-deep-agent/auto-publish.d.ts +17 -0
- package/dist/activities/execute-deep-agent/auto-publish.js +71 -0
- package/dist/activities/execute-deep-agent/auto-publish.js.map +1 -0
- package/dist/activities/execute-deep-agent/cas-capture-backend.d.ts +84 -0
- package/dist/activities/execute-deep-agent/cas-capture-backend.js +106 -0
- package/dist/activities/execute-deep-agent/cas-capture-backend.js.map +1 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.d.ts +83 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.js +117 -0
- package/dist/activities/execute-deep-agent/cas-capture-observer.js.map +1 -0
- package/dist/activities/execute-deep-agent/deep-agent-capabilities.d.ts +32 -0
- package/dist/activities/execute-deep-agent/deep-agent-capabilities.js +45 -0
- package/dist/activities/execute-deep-agent/deep-agent-capabilities.js.map +1 -0
- package/dist/activities/execute-deep-agent/deepagents-profiles.d.ts +30 -0
- package/dist/activities/execute-deep-agent/deepagents-profiles.js +46 -0
- package/dist/activities/execute-deep-agent/deepagents-profiles.js.map +1 -0
- package/dist/activities/execute-deep-agent/engine-tools.d.ts +32 -0
- package/dist/activities/execute-deep-agent/engine-tools.js +32 -0
- package/dist/activities/execute-deep-agent/engine-tools.js.map +1 -0
- package/dist/activities/execute-deep-agent/hitl.d.ts +126 -0
- package/dist/activities/execute-deep-agent/hitl.js +194 -0
- package/dist/activities/execute-deep-agent/hitl.js.map +1 -0
- package/dist/activities/execute-deep-agent/hooks-setup.d.ts +25 -0
- package/dist/activities/execute-deep-agent/hooks-setup.js +59 -0
- package/dist/activities/execute-deep-agent/hooks-setup.js.map +1 -0
- package/dist/activities/execute-deep-agent/inline-publisher.d.ts +83 -0
- package/dist/activities/execute-deep-agent/inline-publisher.js +152 -0
- package/dist/activities/execute-deep-agent/inline-publisher.js.map +1 -0
- package/dist/activities/execute-deep-agent/platform-route.d.ts +145 -0
- package/dist/activities/execute-deep-agent/platform-route.js +237 -0
- package/dist/activities/execute-deep-agent/platform-route.js.map +1 -0
- package/dist/activities/execute-deep-agent/prompt-builder.d.ts +189 -0
- package/dist/activities/execute-deep-agent/prompt-builder.js +369 -0
- package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -0
- package/dist/activities/execute-deep-agent/resumed-history.d.ts +25 -0
- package/dist/activities/execute-deep-agent/resumed-history.js +47 -0
- package/dist/activities/execute-deep-agent/resumed-history.js.map +1 -0
- package/dist/activities/execute-deep-agent/streaming-side-effects.d.ts +49 -0
- package/dist/activities/execute-deep-agent/streaming-side-effects.js +73 -0
- package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -0
- package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +253 -0
- package/dist/activities/execute-deep-agent/subagent-transformer.js +474 -0
- package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -0
- package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +99 -0
- package/dist/activities/execute-deep-agent/subagent-wiring.js +119 -0
- package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -0
- package/dist/activities/execute-deep-agent/todo-list.d.ts +40 -0
- package/dist/activities/execute-deep-agent/todo-list.js +51 -0
- package/dist/activities/execute-deep-agent/todo-list.js.map +1 -0
- package/dist/activities/execute-deep-agent/translator.d.ts +167 -0
- package/dist/activities/execute-deep-agent/translator.js +521 -0
- package/dist/activities/execute-deep-agent/translator.js.map +1 -0
- package/dist/activities/execute-deep-agent/turn-settle.d.ts +48 -0
- package/dist/activities/execute-deep-agent/turn-settle.js +141 -0
- package/dist/activities/execute-deep-agent/turn-settle.js.map +1 -0
- package/dist/activities/execute-deep-agent/turn-setup.d.ts +281 -0
- package/dist/activities/execute-deep-agent/turn-setup.js +687 -0
- package/dist/activities/execute-deep-agent/turn-setup.js.map +1 -0
- package/dist/activities/execute-deep-agent/turn-stream.d.ts +105 -0
- package/dist/activities/execute-deep-agent/turn-stream.js +236 -0
- package/dist/activities/execute-deep-agent/turn-stream.js.map +1 -0
- package/dist/activities/execute-deep-agent/turn.d.ts +48 -0
- package/dist/activities/execute-deep-agent/turn.js +136 -0
- package/dist/activities/execute-deep-agent/turn.js.map +1 -0
- package/dist/activities/execute-deep-agent/v3-event-recorder.d.ts +32 -0
- package/dist/activities/execute-deep-agent/v3-event-recorder.js +72 -0
- package/dist/activities/execute-deep-agent/v3-event-recorder.js.map +1 -0
- package/dist/activities/generate-session-subject.d.ts +93 -0
- package/dist/activities/generate-session-subject.js +285 -0
- package/dist/activities/generate-session-subject.js.map +1 -0
- package/dist/activities/list-plugin-tools.d.ts +76 -0
- package/dist/activities/list-plugin-tools.js +170 -0
- package/dist/activities/list-plugin-tools.js.map +1 -0
- package/dist/agent-host/channel.d.ts +93 -0
- package/dist/agent-host/channel.js +332 -0
- package/dist/agent-host/channel.js.map +1 -0
- package/dist/agent-host/codec.d.ts +290 -0
- package/dist/agent-host/codec.js +437 -0
- package/dist/agent-host/codec.js.map +1 -0
- package/dist/agent-host/entry.d.ts +56 -0
- package/dist/agent-host/entry.js +137 -0
- package/dist/agent-host/entry.js.map +1 -0
- package/dist/agent-host/environment.d.ts +36 -0
- package/dist/agent-host/environment.js +72 -0
- package/dist/agent-host/environment.js.map +1 -0
- package/dist/agent-host/failed-boot.d.ts +15 -0
- package/dist/agent-host/failed-boot.js +26 -0
- package/dist/agent-host/failed-boot.js.map +1 -0
- package/dist/agent-host/fs-service.d.ts +18 -0
- package/dist/agent-host/fs-service.js +133 -0
- package/dist/agent-host/fs-service.js.map +1 -0
- package/dist/agent-host/host-sink.d.ts +63 -0
- package/dist/agent-host/host-sink.js +136 -0
- package/dist/agent-host/host-sink.js.map +1 -0
- package/dist/agent-host/host.d.ts +48 -0
- package/dist/agent-host/host.js +191 -0
- package/dist/agent-host/host.js.map +1 -0
- package/dist/agent-host/hosting.d.ts +80 -0
- package/dist/agent-host/hosting.js +126 -0
- package/dist/agent-host/hosting.js.map +1 -0
- package/dist/agent-host/protocol.d.ts +478 -0
- package/dist/agent-host/protocol.js +77 -0
- package/dist/agent-host/protocol.js.map +1 -0
- package/dist/agent-host/remote-adapter.d.ts +64 -0
- package/dist/agent-host/remote-adapter.js +283 -0
- package/dist/agent-host/remote-adapter.js.map +1 -0
- package/dist/agent-host/remote-fs.d.ts +19 -0
- package/dist/agent-host/remote-fs.js +120 -0
- package/dist/agent-host/remote-fs.js.map +1 -0
- package/dist/agent-host/supervisor.d.ts +149 -0
- package/dist/agent-host/supervisor.js +311 -0
- package/dist/agent-host/supervisor.js.map +1 -0
- package/dist/agent-proxy/cursor-lane.d.ts +124 -0
- package/dist/agent-proxy/cursor-lane.js +507 -0
- package/dist/agent-proxy/cursor-lane.js.map +1 -0
- package/dist/agent-proxy/lanes.d.ts +63 -0
- package/dist/agent-proxy/lanes.js +255 -0
- package/dist/agent-proxy/lanes.js.map +1 -0
- package/dist/agent-proxy/loopback-certificate.d.ts +27 -0
- package/dist/agent-proxy/loopback-certificate.js +115 -0
- package/dist/agent-proxy/loopback-certificate.js.map +1 -0
- package/dist/agent-proxy/otlp-forward.d.ts +67 -0
- package/dist/agent-proxy/otlp-forward.js +170 -0
- package/dist/agent-proxy/otlp-forward.js.map +1 -0
- package/dist/agent-proxy/relay.d.ts +67 -0
- package/dist/agent-proxy/relay.js +164 -0
- package/dist/agent-proxy/relay.js.map +1 -0
- package/dist/agent-proxy/server.d.ts +84 -0
- package/dist/agent-proxy/server.js +258 -0
- package/dist/agent-proxy/server.js.map +1 -0
- package/dist/attach/entry.d.ts +36 -0
- package/dist/attach/entry.js +69 -0
- package/dist/attach/entry.js.map +1 -0
- package/dist/attach/main.d.ts +14 -0
- package/dist/attach/main.js +25 -0
- package/dist/attach/main.js.map +1 -0
- package/dist/attach/push.d.ts +71 -0
- package/dist/attach/push.js +123 -0
- package/dist/attach/push.js.map +1 -0
- package/dist/attach/waiter.d.ts +108 -0
- package/dist/attach/waiter.js +323 -0
- package/dist/attach/waiter.js.map +1 -0
- package/dist/bootstrap.d.ts +80 -0
- package/dist/bootstrap.js +119 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/client/server-contracts.d.ts +51 -0
- package/dist/client/server-contracts.js +70 -0
- package/dist/client/server-contracts.js.map +1 -0
- package/dist/client/stigmer-client.d.ts +328 -0
- package/dist/client/stigmer-client.js +478 -0
- package/dist/client/stigmer-client.js.map +1 -0
- package/dist/client/token-claims.d.ts +40 -0
- package/dist/client/token-claims.js +88 -0
- package/dist/client/token-claims.js.map +1 -0
- package/dist/config.d.ts +216 -0
- package/dist/config.js +200 -0
- package/dist/config.js.map +1 -0
- package/dist/exit-backstop.d.ts +64 -0
- package/dist/exit-backstop.js +79 -0
- package/dist/exit-backstop.js.map +1 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/enum_pb.d.ts +1016 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/enum_pb.js +1035 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/enum_pb.js.map +1 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/ledger_pb.d.ts +402 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/ledger_pb.js +47 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/ledger_pb.js.map +1 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/rows_pb.d.ts +826 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/rows_pb.js +48 -0
- package/dist/gen/turn/ai/stigmer/runner/turn/v1/rows_pb.js.map +1 -0
- package/dist/gen-ai-conventions.d.ts +95 -0
- package/dist/gen-ai-conventions.js +102 -0
- package/dist/gen-ai-conventions.js.map +1 -0
- package/dist/harness/approval-answers.d.ts +104 -0
- package/dist/harness/approval-answers.js +136 -0
- package/dist/harness/approval-answers.js.map +1 -0
- package/dist/harness/approval-decisions.d.ts +50 -0
- package/dist/harness/approval-decisions.js +80 -0
- package/dist/harness/approval-decisions.js.map +1 -0
- package/dist/harness/capabilities.d.ts +149 -0
- package/dist/harness/capabilities.js +48 -0
- package/dist/harness/capabilities.js.map +1 -0
- package/dist/harness/capture.d.ts +154 -0
- package/dist/harness/capture.js +248 -0
- package/dist/harness/capture.js.map +1 -0
- package/dist/harness/cost-cap-watch.d.ts +31 -0
- package/dist/harness/cost-cap-watch.js +44 -0
- package/dist/harness/cost-cap-watch.js.map +1 -0
- package/dist/harness/events/emitter.d.ts +220 -0
- package/dist/harness/events/emitter.js +726 -0
- package/dist/harness/events/emitter.js.map +1 -0
- package/dist/harness/events/ids.d.ts +88 -0
- package/dist/harness/events/ids.js +136 -0
- package/dist/harness/events/ids.js.map +1 -0
- package/dist/harness/loaded-versions.d.ts +20 -0
- package/dist/harness/loaded-versions.js +70 -0
- package/dist/harness/loaded-versions.js.map +1 -0
- package/dist/harness/owed-undos.d.ts +119 -0
- package/dist/harness/owed-undos.js +200 -0
- package/dist/harness/owed-undos.js.map +1 -0
- package/dist/harness/persist-chokepoint.d.ts +113 -0
- package/dist/harness/persist-chokepoint.js +126 -0
- package/dist/harness/persist-chokepoint.js.map +1 -0
- package/dist/harness/registry.d.ts +108 -0
- package/dist/harness/registry.js +174 -0
- package/dist/harness/registry.js.map +1 -0
- package/dist/harness/run-span.d.ts +78 -0
- package/dist/harness/run-span.js +139 -0
- package/dist/harness/run-span.js.map +1 -0
- package/dist/harness/run-turn.d.ts +59 -0
- package/dist/harness/run-turn.js +749 -0
- package/dist/harness/run-turn.js.map +1 -0
- package/dist/harness/stop-controller.d.ts +65 -0
- package/dist/harness/stop-controller.js +70 -0
- package/dist/harness/stop-controller.js.map +1 -0
- package/dist/harness/terminal-table.d.ts +212 -0
- package/dist/harness/terminal-table.js +329 -0
- package/dist/harness/terminal-table.js.map +1 -0
- package/dist/harness/transcript/builder.d.ts +269 -0
- package/dist/harness/transcript/builder.js +842 -0
- package/dist/harness/transcript/builder.js.map +1 -0
- package/dist/harness/transcript/events.d.ts +236 -0
- package/dist/harness/transcript/events.js +55 -0
- package/dist/harness/transcript/events.js.map +1 -0
- package/dist/harness/transcript/resume-seed.d.ts +67 -0
- package/dist/harness/transcript/resume-seed.js +228 -0
- package/dist/harness/transcript/resume-seed.js.map +1 -0
- package/dist/harness/transcript/state.d.ts +111 -0
- package/dist/harness/transcript/state.js +147 -0
- package/dist/harness/transcript/state.js.map +1 -0
- package/dist/harness/turn-context.d.ts +923 -0
- package/dist/harness/turn-context.js +1448 -0
- package/dist/harness/turn-context.js.map +1 -0
- package/dist/harness/turn-timeline.d.ts +132 -0
- package/dist/harness/turn-timeline.js +213 -0
- package/dist/harness/turn-timeline.js.map +1 -0
- package/dist/harness/types.d.ts +700 -0
- package/dist/harness/types.js +72 -0
- package/dist/harness/types.js.map +1 -0
- package/dist/harness/usage-accumulator.d.ts +76 -0
- package/dist/harness/usage-accumulator.js +112 -0
- package/dist/harness/usage-accumulator.js.map +1 -0
- package/dist/harness-adapters.d.ts +40 -0
- package/dist/harness-adapters.js +45 -0
- package/dist/harness-adapters.js.map +1 -0
- package/dist/idle-watchdog.d.ts +11 -0
- package/dist/idle-watchdog.js +24 -0
- package/dist/idle-watchdog.js.map +1 -0
- package/dist/in-flight.d.ts +35 -0
- package/dist/in-flight.js +61 -0
- package/dist/in-flight.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/run-credential-activity.d.ts +24 -0
- package/dist/interceptors/run-credential-activity.js +36 -0
- package/dist/interceptors/run-credential-activity.js.map +1 -0
- package/dist/ipc-protocol-fixtures.d.ts +28 -0
- package/dist/ipc-protocol-fixtures.js +50 -0
- package/dist/ipc-protocol-fixtures.js.map +1 -0
- package/dist/ipc-protocol.d.ts +43 -0
- package/dist/ipc-protocol.js +20 -0
- package/dist/ipc-protocol.js.map +1 -0
- package/dist/main.d.ts +26 -0
- package/dist/main.js +451 -0
- package/dist/main.js.map +1 -0
- package/dist/middleware/advisory-message.d.ts +52 -0
- package/dist/middleware/advisory-message.js +58 -0
- package/dist/middleware/advisory-message.js.map +1 -0
- package/dist/middleware/approval-gate.d.ts +255 -0
- package/dist/middleware/approval-gate.js +502 -0
- package/dist/middleware/approval-gate.js.map +1 -0
- package/dist/middleware/cost-advisory.d.ts +65 -0
- package/dist/middleware/cost-advisory.js +185 -0
- package/dist/middleware/cost-advisory.js.map +1 -0
- package/dist/middleware/error-hints.d.ts +27 -0
- package/dist/middleware/error-hints.js +116 -0
- package/dist/middleware/error-hints.js.map +1 -0
- package/dist/middleware/execution-budget.d.ts +38 -0
- package/dist/middleware/execution-budget.js +168 -0
- package/dist/middleware/execution-budget.js.map +1 -0
- package/dist/middleware/index.d.ts +55 -0
- package/dist/middleware/index.js +80 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/loop-detection.d.ts +22 -0
- package/dist/middleware/loop-detection.js +161 -0
- package/dist/middleware/loop-detection.js.map +1 -0
- package/dist/middleware/otel-spans.d.ts +43 -0
- package/dist/middleware/otel-spans.js +281 -0
- package/dist/middleware/otel-spans.js.map +1 -0
- package/dist/middleware/path-normalization.d.ts +84 -0
- package/dist/middleware/path-normalization.js +161 -0
- package/dist/middleware/path-normalization.js.map +1 -0
- package/dist/middleware/tool-intent.d.ts +57 -0
- package/dist/middleware/tool-intent.js +152 -0
- package/dist/middleware/tool-intent.js.map +1 -0
- package/dist/middleware/tool-scope.d.ts +119 -0
- package/dist/middleware/tool-scope.js +159 -0
- package/dist/middleware/tool-scope.js.map +1 -0
- package/dist/middleware/tool-truncation.d.ts +16 -0
- package/dist/middleware/tool-truncation.js +67 -0
- package/dist/middleware/tool-truncation.js.map +1 -0
- package/dist/middleware/types.d.ts +119 -0
- package/dist/middleware/types.js +10 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/otel-export.d.ts +142 -0
- package/dist/otel-export.js +269 -0
- package/dist/otel-export.js.map +1 -0
- package/dist/otel-metrics.d.ts +22 -0
- package/dist/otel-metrics.js +47 -0
- package/dist/otel-metrics.js.map +1 -0
- package/dist/otel.d.ts +49 -0
- package/dist/otel.js +125 -0
- package/dist/otel.js.map +1 -0
- package/dist/payload-codecs.d.ts +17 -0
- package/dist/payload-codecs.js +45 -0
- package/dist/payload-codecs.js.map +1 -0
- package/dist/pipe-safety.d.ts +55 -0
- package/dist/pipe-safety.js +103 -0
- package/dist/pipe-safety.js.map +1 -0
- package/dist/pool-member.d.ts +61 -0
- package/dist/pool-member.js +51 -0
- package/dist/pool-member.js.map +1 -0
- package/dist/preflight.d.ts +77 -0
- package/dist/preflight.js +98 -0
- package/dist/preflight.js.map +1 -0
- package/dist/run-trace-id.d.ts +34 -0
- package/dist/run-trace-id.js +44 -0
- package/dist/run-trace-id.js.map +1 -0
- package/dist/runner-entry.d.ts +15 -0
- package/dist/runner-entry.js +17 -0
- package/dist/runner-entry.js.map +1 -0
- package/dist/runner-manager.d.ts +160 -0
- package/dist/runner-manager.js +590 -0
- package/dist/runner-manager.js.map +1 -0
- package/dist/runner-token-coordinator.d.ts +61 -0
- package/dist/runner-token-coordinator.js +89 -0
- package/dist/runner-token-coordinator.js.map +1 -0
- package/dist/runner.d.ts +155 -0
- package/dist/runner.js +392 -0
- package/dist/runner.js.map +1 -0
- package/dist/sandbox-token-renewal.d.ts +64 -0
- package/dist/sandbox-token-renewal.js +168 -0
- package/dist/sandbox-token-renewal.js.map +1 -0
- package/dist/shared/activity-input.d.ts +52 -0
- package/dist/shared/activity-input.js +34 -0
- package/dist/shared/activity-input.js.map +1 -0
- package/dist/shared/agent-fs.d.ts +144 -0
- package/dist/shared/agent-fs.js +171 -0
- package/dist/shared/agent-fs.js.map +1 -0
- package/dist/shared/agent-handover.d.ts +42 -0
- package/dist/shared/agent-handover.js +156 -0
- package/dist/shared/agent-handover.js.map +1 -0
- package/dist/shared/agent-identity.d.ts +96 -0
- package/dist/shared/agent-identity.js +153 -0
- package/dist/shared/agent-identity.js.map +1 -0
- package/dist/shared/agent-servers.d.ts +4 -0
- package/dist/shared/agent-servers.js +46 -0
- package/dist/shared/agent-servers.js.map +1 -0
- package/dist/shared/approval-canonicalize.d.ts +19 -0
- package/dist/shared/approval-canonicalize.js +119 -0
- package/dist/shared/approval-canonicalize.js.map +1 -0
- package/dist/shared/approval-fingerprint.d.ts +103 -0
- package/dist/shared/approval-fingerprint.js +110 -0
- package/dist/shared/approval-fingerprint.js.map +1 -0
- package/dist/shared/approval-policy.d.ts +323 -0
- package/dist/shared/approval-policy.js +375 -0
- package/dist/shared/approval-policy.js.map +1 -0
- package/dist/shared/archive-mount.d.ts +68 -0
- package/dist/shared/archive-mount.js +108 -0
- package/dist/shared/archive-mount.js.map +1 -0
- package/dist/shared/args-preview.d.ts +90 -0
- package/dist/shared/args-preview.js +121 -0
- package/dist/shared/args-preview.js.map +1 -0
- package/dist/shared/artifact-storage.d.ts +155 -0
- package/dist/shared/artifact-storage.js +373 -0
- package/dist/shared/artifact-storage.js.map +1 -0
- package/dist/shared/attachment-download-urls.d.ts +53 -0
- package/dist/shared/attachment-download-urls.js +68 -0
- package/dist/shared/attachment-download-urls.js.map +1 -0
- package/dist/shared/attachment-naming.d.ts +53 -0
- package/dist/shared/attachment-naming.js +59 -0
- package/dist/shared/attachment-naming.js.map +1 -0
- package/dist/shared/attachment-resolver.d.ts +124 -0
- package/dist/shared/attachment-resolver.js +322 -0
- package/dist/shared/attachment-resolver.js.map +1 -0
- package/dist/shared/attachment-vision.d.ts +245 -0
- package/dist/shared/attachment-vision.js +339 -0
- package/dist/shared/attachment-vision.js.map +1 -0
- 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/blueprint-resolver.d.ts +175 -0
- package/dist/shared/blueprint-resolver.js +305 -0
- package/dist/shared/blueprint-resolver.js.map +1 -0
- package/dist/shared/builtin-assistant-prompt.d.ts +30 -0
- package/dist/shared/builtin-assistant-prompt.js +36 -0
- package/dist/shared/builtin-assistant-prompt.js.map +1 -0
- package/dist/shared/builtin-judge.d.ts +9 -0
- package/dist/shared/builtin-judge.js +53 -0
- package/dist/shared/builtin-judge.js.map +1 -0
- package/dist/shared/caller-identity.d.ts +112 -0
- package/dist/shared/caller-identity.js +150 -0
- package/dist/shared/caller-identity.js.map +1 -0
- package/dist/shared/channel-attachment.d.ts +90 -0
- package/dist/shared/channel-attachment.js +209 -0
- package/dist/shared/channel-attachment.js.map +1 -0
- package/dist/shared/checkpointer/factory.d.ts +32 -0
- package/dist/shared/checkpointer/factory.js +72 -0
- package/dist/shared/checkpointer/factory.js.map +1 -0
- package/dist/shared/checkpointer/http-saver.d.ts +70 -0
- package/dist/shared/checkpointer/http-saver.js +335 -0
- package/dist/shared/checkpointer/http-saver.js.map +1 -0
- package/dist/shared/checkpointer/sqlite-saver.d.ts +54 -0
- package/dist/shared/checkpointer/sqlite-saver.js +272 -0
- package/dist/shared/checkpointer/sqlite-saver.js.map +1 -0
- package/dist/shared/checkpointer/types.d.ts +25 -0
- package/dist/shared/checkpointer/types.js +18 -0
- package/dist/shared/checkpointer/types.js.map +1 -0
- package/dist/shared/cold-start-timing.d.ts +124 -0
- package/dist/shared/cold-start-timing.js +220 -0
- package/dist/shared/cold-start-timing.js.map +1 -0
- package/dist/shared/context-bridge.d.ts +30 -0
- package/dist/shared/context-bridge.js +45 -0
- package/dist/shared/context-bridge.js.map +1 -0
- package/dist/shared/conversation-attachment.d.ts +103 -0
- package/dist/shared/conversation-attachment.js +128 -0
- package/dist/shared/conversation-attachment.js.map +1 -0
- package/dist/shared/conversation-catchup.d.ts +40 -0
- package/dist/shared/conversation-catchup.js +86 -0
- package/dist/shared/conversation-catchup.js.map +1 -0
- package/dist/shared/cost-guard.d.ts +51 -0
- package/dist/shared/cost-guard.js +58 -0
- package/dist/shared/cost-guard.js.map +1 -0
- package/dist/shared/declared-preferences.d.ts +47 -0
- package/dist/shared/declared-preferences.js +64 -0
- package/dist/shared/declared-preferences.js.map +1 -0
- package/dist/shared/eval-case/agent-mock.d.ts +61 -0
- package/dist/shared/eval-case/agent-mock.js +88 -0
- package/dist/shared/eval-case/agent-mock.js.map +1 -0
- package/dist/shared/eval-case/case-archive.d.ts +51 -0
- package/dist/shared/eval-case/case-archive.js +119 -0
- package/dist/shared/eval-case/case-archive.js.map +1 -0
- package/dist/shared/eval-case/mock-endpoint.d.ts +68 -0
- package/dist/shared/eval-case/mock-endpoint.js +209 -0
- package/dist/shared/eval-case/mock-endpoint.js.map +1 -0
- package/dist/shared/eval-case/prepare-case.d.ts +78 -0
- package/dist/shared/eval-case/prepare-case.js +193 -0
- package/dist/shared/eval-case/prepare-case.js.map +1 -0
- package/dist/shared/eval-case/read-files.d.ts +26 -0
- package/dist/shared/eval-case/read-files.js +88 -0
- package/dist/shared/eval-case/read-files.js.map +1 -0
- package/dist/shared/exact-apply.d.ts +109 -0
- package/dist/shared/exact-apply.js +205 -0
- package/dist/shared/exact-apply.js.map +1 -0
- package/dist/shared/execution-context.d.ts +47 -0
- package/dist/shared/execution-context.js +51 -0
- package/dist/shared/execution-context.js.map +1 -0
- package/dist/shared/execution-target.d.ts +13 -0
- package/dist/shared/execution-target.js +15 -0
- package/dist/shared/execution-target.js.map +1 -0
- package/dist/shared/extract-json.d.ts +26 -0
- package/dist/shared/extract-json.js +140 -0
- package/dist/shared/extract-json.js.map +1 -0
- package/dist/shared/extract-structured-output.d.ts +38 -0
- package/dist/shared/extract-structured-output.js +68 -0
- package/dist/shared/extract-structured-output.js.map +1 -0
- package/dist/shared/file-change.d.ts +42 -0
- package/dist/shared/file-change.js +55 -0
- package/dist/shared/file-change.js.map +1 -0
- package/dist/shared/file-tools.d.ts +105 -0
- package/dist/shared/file-tools.js +166 -0
- package/dist/shared/file-tools.js.map +1 -0
- package/dist/shared/filereview/capture.d.ts +238 -0
- package/dist/shared/filereview/capture.js +559 -0
- package/dist/shared/filereview/capture.js.map +1 -0
- package/dist/shared/filereview/cas-progress.d.ts +45 -0
- package/dist/shared/filereview/cas-progress.js +131 -0
- package/dist/shared/filereview/cas-progress.js.map +1 -0
- package/dist/shared/filereview/cas-substrate.d.ts +226 -0
- package/dist/shared/filereview/cas-substrate.js +315 -0
- package/dist/shared/filereview/cas-substrate.js.map +1 -0
- 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/command-provenance.d.ts +95 -0
- package/dist/shared/filereview/command-provenance.js +134 -0
- package/dist/shared/filereview/command-provenance.js.map +1 -0
- package/dist/shared/filereview/digest.d.ts +40 -0
- package/dist/shared/filereview/digest.js +66 -0
- package/dist/shared/filereview/digest.js.map +1 -0
- package/dist/shared/filereview/events.d.ts +199 -0
- package/dist/shared/filereview/events.js +348 -0
- package/dist/shared/filereview/events.js.map +1 -0
- package/dist/shared/filereview/git-substrate.d.ts +233 -0
- package/dist/shared/filereview/git-substrate.js +528 -0
- package/dist/shared/filereview/git-substrate.js.map +1 -0
- package/dist/shared/filereview/index.d.ts +15 -0
- package/dist/shared/filereview/index.js +16 -0
- package/dist/shared/filereview/index.js.map +1 -0
- package/dist/shared/filereview/line-counts.d.ts +48 -0
- package/dist/shared/filereview/line-counts.js +72 -0
- package/dist/shared/filereview/line-counts.js.map +1 -0
- package/dist/shared/filereview/progress.d.ts +200 -0
- package/dist/shared/filereview/progress.js +245 -0
- package/dist/shared/filereview/progress.js.map +1 -0
- package/dist/shared/filereview/record.d.ts +53 -0
- package/dist/shared/filereview/record.js +104 -0
- package/dist/shared/filereview/record.js.map +1 -0
- package/dist/shared/filereview/secret-paths.d.ts +61 -0
- package/dist/shared/filereview/secret-paths.js +103 -0
- package/dist/shared/filereview/secret-paths.js.map +1 -0
- package/dist/shared/fingerprint-secret.d.ts +35 -0
- package/dist/shared/fingerprint-secret.js +68 -0
- package/dist/shared/fingerprint-secret.js.map +1 -0
- package/dist/shared/grpc-retry.d.ts +28 -0
- package/dist/shared/grpc-retry.js +39 -0
- package/dist/shared/grpc-retry.js.map +1 -0
- package/dist/shared/heartbeat.d.ts +24 -0
- package/dist/shared/heartbeat.js +40 -0
- package/dist/shared/heartbeat.js.map +1 -0
- package/dist/shared/hooks/answer.d.ts +49 -0
- package/dist/shared/hooks/answer.js +152 -0
- package/dist/shared/hooks/answer.js.map +1 -0
- package/dist/shared/hooks/condition.d.ts +71 -0
- package/dist/shared/hooks/condition.js +341 -0
- package/dist/shared/hooks/condition.js.map +1 -0
- package/dist/shared/hooks/evaluate.d.ts +125 -0
- package/dist/shared/hooks/evaluate.js +253 -0
- package/dist/shared/hooks/evaluate.js.map +1 -0
- package/dist/shared/hooks/formats/claude-code.d.ts +43 -0
- package/dist/shared/hooks/formats/claude-code.js +90 -0
- package/dist/shared/hooks/formats/claude-code.js.map +1 -0
- package/dist/shared/hooks/formats/common.d.ts +30 -0
- package/dist/shared/hooks/formats/common.js +7 -0
- package/dist/shared/hooks/formats/common.js.map +1 -0
- package/dist/shared/hooks/formats/cursor.d.ts +72 -0
- package/dist/shared/hooks/formats/cursor.js +238 -0
- package/dist/shared/hooks/formats/cursor.js.map +1 -0
- package/dist/shared/hooks/hook-set.d.ts +84 -0
- package/dist/shared/hooks/hook-set.js +80 -0
- package/dist/shared/hooks/hook-set.js.map +1 -0
- package/dist/shared/hooks/matcher.d.ts +14 -0
- package/dist/shared/hooks/matcher.js +32 -0
- package/dist/shared/hooks/matcher.js.map +1 -0
- package/dist/shared/hooks/messages.d.ts +19 -0
- package/dist/shared/hooks/messages.js +34 -0
- package/dist/shared/hooks/messages.js.map +1 -0
- package/dist/shared/hooks/run.d.ts +89 -0
- package/dist/shared/hooks/run.js +146 -0
- package/dist/shared/hooks/run.js.map +1 -0
- package/dist/shared/hooks/setup.d.ts +73 -0
- package/dist/shared/hooks/setup.js +166 -0
- package/dist/shared/hooks/setup.js.map +1 -0
- package/dist/shared/hooks/shell-commands.d.ts +39 -0
- package/dist/shared/hooks/shell-commands.js +326 -0
- package/dist/shared/hooks/shell-commands.js.map +1 -0
- package/dist/shared/hooks/tool-view.d.ts +164 -0
- package/dist/shared/hooks/tool-view.js +310 -0
- package/dist/shared/hooks/tool-view.js.map +1 -0
- package/dist/shared/http-retry.d.ts +85 -0
- package/dist/shared/http-retry.js +101 -0
- package/dist/shared/http-retry.js.map +1 -0
- package/dist/shared/implement-plan-prompt.d.ts +44 -0
- package/dist/shared/implement-plan-prompt.js +98 -0
- package/dist/shared/implement-plan-prompt.js.map +1 -0
- package/dist/shared/json-schema-to-zod.d.ts +13 -0
- package/dist/shared/json-schema-to-zod.js +49 -0
- package/dist/shared/json-schema-to-zod.js.map +1 -0
- package/dist/shared/llm-backend.d.ts +303 -0
- package/dist/shared/llm-backend.js +491 -0
- package/dist/shared/llm-backend.js.map +1 -0
- package/dist/shared/llm-proxy.d.ts +64 -0
- package/dist/shared/llm-proxy.js +131 -0
- package/dist/shared/llm-proxy.js.map +1 -0
- package/dist/shared/mcp-manager.d.ts +61 -0
- package/dist/shared/mcp-manager.js +131 -0
- package/dist/shared/mcp-manager.js.map +1 -0
- package/dist/shared/mcp-oauth-detect.d.ts +23 -0
- package/dist/shared/mcp-oauth-detect.js +72 -0
- package/dist/shared/mcp-oauth-detect.js.map +1 -0
- package/dist/shared/mcp-resolver.d.ts +145 -0
- package/dist/shared/mcp-resolver.js +238 -0
- package/dist/shared/mcp-resolver.js.map +1 -0
- package/dist/shared/mcp-schema-sanitizer.d.ts +68 -0
- package/dist/shared/mcp-schema-sanitizer.js +195 -0
- package/dist/shared/mcp-schema-sanitizer.js.map +1 -0
- package/dist/shared/mcp-tool-listing.d.ts +80 -0
- package/dist/shared/mcp-tool-listing.js +166 -0
- package/dist/shared/mcp-tool-listing.js.map +1 -0
- package/dist/shared/mcp-transport-guard.d.ts +53 -0
- package/dist/shared/mcp-transport-guard.js +70 -0
- package/dist/shared/mcp-transport-guard.js.map +1 -0
- package/dist/shared/memory-attachment.d.ts +103 -0
- package/dist/shared/memory-attachment.js +142 -0
- package/dist/shared/memory-attachment.js.map +1 -0
- package/dist/shared/memory-retrieval.d.ts +126 -0
- package/dist/shared/memory-retrieval.js +293 -0
- package/dist/shared/memory-retrieval.js.map +1 -0
- package/dist/shared/model-client.d.ts +111 -0
- package/dist/shared/model-client.js +328 -0
- package/dist/shared/model-client.js.map +1 -0
- package/dist/shared/model-error.d.ts +94 -0
- package/dist/shared/model-error.js +475 -0
- package/dist/shared/model-error.js.map +1 -0
- package/dist/shared/model-facts.d.ts +21 -0
- package/dist/shared/model-facts.js +22 -0
- package/dist/shared/model-facts.js.map +1 -0
- package/dist/shared/model-lanes.d.ts +48 -0
- package/dist/shared/model-lanes.js +52 -0
- package/dist/shared/model-lanes.js.map +1 -0
- package/dist/shared/model-pricing-data.d.ts +20 -0
- package/dist/shared/model-pricing-data.js +82 -0
- package/dist/shared/model-pricing-data.js.map +1 -0
- package/dist/shared/model-pricing.d.ts +16 -0
- package/dist/shared/model-pricing.js +46 -0
- package/dist/shared/model-pricing.js.map +1 -0
- package/dist/shared/model-registry.d.ts +113 -0
- package/dist/shared/model-registry.js +250 -0
- package/dist/shared/model-registry.js.map +1 -0
- package/dist/shared/persist-decision.d.ts +38 -0
- package/dist/shared/persist-decision.js +40 -0
- package/dist/shared/persist-decision.js.map +1 -0
- package/dist/shared/placeholder-resolver.d.ts +39 -0
- package/dist/shared/placeholder-resolver.js +86 -0
- package/dist/shared/placeholder-resolver.js.map +1 -0
- package/dist/shared/plan-artifact.d.ts +105 -0
- package/dist/shared/plan-artifact.js +225 -0
- package/dist/shared/plan-artifact.js.map +1 -0
- package/dist/shared/plan-mode-permissions.d.ts +49 -0
- package/dist/shared/plan-mode-permissions.js +51 -0
- package/dist/shared/plan-mode-permissions.js.map +1 -0
- package/dist/shared/plan-mode-prompt.d.ts +41 -0
- package/dist/shared/plan-mode-prompt.js +74 -0
- package/dist/shared/plan-mode-prompt.js.map +1 -0
- package/dist/shared/platform-server-address.d.ts +72 -0
- package/dist/shared/platform-server-address.js +103 -0
- package/dist/shared/platform-server-address.js.map +1 -0
- package/dist/shared/plugin-mount.d.ts +165 -0
- package/dist/shared/plugin-mount.js +428 -0
- package/dist/shared/plugin-mount.js.map +1 -0
- package/dist/shared/plugin-servers.d.ts +16 -0
- package/dist/shared/plugin-servers.js +22 -0
- package/dist/shared/plugin-servers.js.map +1 -0
- package/dist/shared/prompt-sections.d.ts +140 -0
- package/dist/shared/prompt-sections.js +135 -0
- package/dist/shared/prompt-sections.js.map +1 -0
- package/dist/shared/recalled-memories.d.ts +55 -0
- package/dist/shared/recalled-memories.js +70 -0
- package/dist/shared/recalled-memories.js.map +1 -0
- package/dist/shared/registry-endpoint.d.ts +60 -0
- package/dist/shared/registry-endpoint.js +99 -0
- package/dist/shared/registry-endpoint.js.map +1 -0
- package/dist/shared/run-credential-store.d.ts +32 -0
- package/dist/shared/run-credential-store.js +39 -0
- package/dist/shared/run-credential-store.js.map +1 -0
- package/dist/shared/run-credential.d.ts +40 -0
- package/dist/shared/run-credential.js +47 -0
- package/dist/shared/run-credential.js.map +1 -0
- package/dist/shared/run-values.d.ts +88 -0
- package/dist/shared/run-values.js +101 -0
- package/dist/shared/run-values.js.map +1 -0
- package/dist/shared/runner-credential-keys.d.ts +20 -0
- package/dist/shared/runner-credential-keys.js +101 -0
- package/dist/shared/runner-credential-keys.js.map +1 -0
- package/dist/shared/runner-credential-store.d.ts +77 -0
- package/dist/shared/runner-credential-store.js +111 -0
- package/dist/shared/runner-credential-store.js.map +1 -0
- package/dist/shared/sender-identity.d.ts +50 -0
- package/dist/shared/sender-identity.js +69 -0
- package/dist/shared/sender-identity.js.map +1 -0
- package/dist/shared/service-tier.d.ts +55 -0
- package/dist/shared/service-tier.js +67 -0
- package/dist/shared/service-tier.js.map +1 -0
- package/dist/shared/session-context.d.ts +35 -0
- package/dist/shared/session-context.js +52 -0
- package/dist/shared/session-context.js.map +1 -0
- package/dist/shared/shell-env.d.ts +42 -0
- package/dist/shared/shell-env.js +65 -0
- package/dist/shared/shell-env.js.map +1 -0
- package/dist/shared/skill-mount.d.ts +135 -0
- package/dist/shared/skill-mount.js +178 -0
- package/dist/shared/skill-mount.js.map +1 -0
- package/dist/shared/skill-resolver.d.ts +57 -0
- package/dist/shared/skill-resolver.js +113 -0
- package/dist/shared/skill-resolver.js.map +1 -0
- package/dist/shared/stall-watchdog.d.ts +68 -0
- package/dist/shared/stall-watchdog.js +102 -0
- package/dist/shared/stall-watchdog.js.map +1 -0
- package/dist/shared/status-offload.d.ts +196 -0
- package/dist/shared/status-offload.js +655 -0
- package/dist/shared/status-offload.js.map +1 -0
- package/dist/shared/status.d.ts +100 -0
- package/dist/shared/status.js +191 -0
- package/dist/shared/status.js.map +1 -0
- package/dist/shared/streaming-scheduler.d.ts +59 -0
- package/dist/shared/streaming-scheduler.js +110 -0
- package/dist/shared/streaming-scheduler.js.map +1 -0
- package/dist/shared/subagent-gate.d.ts +47 -0
- package/dist/shared/subagent-gate.js +98 -0
- package/dist/shared/subagent-gate.js.map +1 -0
- package/dist/shared/subagent-rows.d.ts +21 -0
- package/dist/shared/subagent-rows.js +34 -0
- package/dist/shared/subagent-rows.js.map +1 -0
- package/dist/shared/subagents.d.ts +49 -0
- package/dist/shared/subagents.js +51 -0
- package/dist/shared/subagents.js.map +1 -0
- package/dist/shared/synthesized-attachment.d.ts +73 -0
- package/dist/shared/synthesized-attachment.js +59 -0
- package/dist/shared/synthesized-attachment.js.map +1 -0
- package/dist/shared/telemetry-content.d.ts +132 -0
- package/dist/shared/telemetry-content.js +239 -0
- package/dist/shared/telemetry-content.js.map +1 -0
- package/dist/shared/thinking-mode.d.ts +82 -0
- package/dist/shared/thinking-mode.js +105 -0
- package/dist/shared/thinking-mode.js.map +1 -0
- package/dist/shared/todos.d.ts +30 -0
- package/dist/shared/todos.js +58 -0
- package/dist/shared/todos.js.map +1 -0
- package/dist/shared/tool-kind.d.ts +41 -0
- package/dist/shared/tool-kind.js +107 -0
- package/dist/shared/tool-kind.js.map +1 -0
- package/dist/shared/tool-lists.d.ts +283 -0
- package/dist/shared/tool-lists.js +518 -0
- package/dist/shared/tool-lists.js.map +1 -0
- package/dist/shared/tool-rounds.d.ts +91 -0
- package/dist/shared/tool-rounds.js +136 -0
- package/dist/shared/tool-rounds.js.map +1 -0
- package/dist/shared/tool-row.d.ts +195 -0
- package/dist/shared/tool-row.js +320 -0
- package/dist/shared/tool-row.js.map +1 -0
- package/dist/shared/trace-context.d.ts +20 -0
- package/dist/shared/trace-context.js +36 -0
- package/dist/shared/trace-context.js.map +1 -0
- package/dist/shared/with-timeout.d.ts +27 -0
- package/dist/shared/with-timeout.js +47 -0
- package/dist/shared/with-timeout.js.map +1 -0
- package/dist/shared/worker-shutdown.d.ts +99 -0
- package/dist/shared/worker-shutdown.js +94 -0
- package/dist/shared/worker-shutdown.js.map +1 -0
- package/dist/shared/workspace/file-tree.d.ts +13 -0
- package/dist/shared/workspace/file-tree.js +101 -0
- package/dist/shared/workspace/file-tree.js.map +1 -0
- package/dist/shared/workspace/git-credential.d.ts +91 -0
- package/dist/shared/workspace/git-credential.js +222 -0
- package/dist/shared/workspace/git-credential.js.map +1 -0
- package/dist/shared/workspace/git-identity.d.ts +36 -0
- package/dist/shared/workspace/git-identity.js +39 -0
- package/dist/shared/workspace/git-identity.js.map +1 -0
- package/dist/shared/workspace/local-backend.d.ts +44 -0
- package/dist/shared/workspace/local-backend.js +110 -0
- package/dist/shared/workspace/local-backend.js.map +1 -0
- package/dist/shared/workspace/platform-dir.d.ts +106 -0
- package/dist/shared/workspace/platform-dir.js +151 -0
- package/dist/shared/workspace/platform-dir.js.map +1 -0
- package/dist/shared/workspace/platform-mount.d.ts +95 -0
- package/dist/shared/workspace/platform-mount.js +157 -0
- package/dist/shared/workspace/platform-mount.js.map +1 -0
- package/dist/shared/workspace/provisioner.d.ts +52 -0
- package/dist/shared/workspace/provisioner.js +70 -0
- package/dist/shared/workspace/provisioner.js.map +1 -0
- package/dist/shared/workspace/session-provision.d.ts +56 -0
- package/dist/shared/workspace/session-provision.js +54 -0
- package/dist/shared/workspace/session-provision.js.map +1 -0
- package/dist/shared/workspace/session-root.d.ts +35 -0
- package/dist/shared/workspace/session-root.js +53 -0
- package/dist/shared/workspace/session-root.js.map +1 -0
- package/dist/shared/workspace/sources/empty.d.ts +8 -0
- package/dist/shared/workspace/sources/empty.js +16 -0
- package/dist/shared/workspace/sources/empty.js.map +1 -0
- package/dist/shared/workspace/sources/git.d.ts +30 -0
- package/dist/shared/workspace/sources/git.js +224 -0
- package/dist/shared/workspace/sources/git.js.map +1 -0
- package/dist/shared/workspace/sources/local-path.d.ts +17 -0
- package/dist/shared/workspace/sources/local-path.js +61 -0
- package/dist/shared/workspace/sources/local-path.js.map +1 -0
- package/dist/shared/workspace/stigmer-link.d.ts +73 -0
- package/dist/shared/workspace/stigmer-link.js +173 -0
- package/dist/shared/workspace/stigmer-link.js.map +1 -0
- package/dist/shared/workspace/types.d.ts +71 -0
- package/dist/shared/workspace/types.js +19 -0
- package/dist/shared/workspace/types.js.map +1 -0
- package/dist/shared/workspace/workspace-lock.d.ts +86 -0
- package/dist/shared/workspace/workspace-lock.js +190 -0
- package/dist/shared/workspace/workspace-lock.js.map +1 -0
- package/dist/shared/workspace/writeback-coordinator.d.ts +119 -0
- package/dist/shared/workspace/writeback-coordinator.js +361 -0
- package/dist/shared/workspace/writeback-coordinator.js.map +1 -0
- package/dist/shared/zip-extract.d.ts +55 -0
- package/dist/shared/zip-extract.js +98 -0
- package/dist/shared/zip-extract.js.map +1 -0
- package/dist/tools/index.d.ts +26 -0
- package/dist/tools/index.js +26 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/url-guard.d.ts +77 -0
- package/dist/tools/url-guard.js +119 -0
- package/dist/tools/url-guard.js.map +1 -0
- package/dist/tools/web-fetch-tool.d.ts +55 -0
- package/dist/tools/web-fetch-tool.js +218 -0
- package/dist/tools/web-fetch-tool.js.map +1 -0
- package/dist/worker.d.ts +35 -0
- package/dist/worker.js +71 -0
- package/dist/worker.js.map +1 -0
- package/dist/workflow-source.d.ts +38 -0
- package/dist/workflow-source.js +53 -0
- package/dist/workflow-source.js.map +1 -0
- package/dist/workflows/index.d.ts +32 -0
- package/dist/workflows/index.js +33 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/list-plugin-tools.d.ts +23 -0
- package/dist/workflows/list-plugin-tools.js +56 -0
- package/dist/workflows/list-plugin-tools.js.map +1 -0
- package/dist/workflows/types.d.ts +43 -0
- package/dist/workflows/types.js +18 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +161 -0
- package/src/__test-utils__/__tests__/execution-record-barrier.test.ts +75 -0
- package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +361 -0
- package/src/__test-utils__/__tests__/live-gate.test.ts +100 -0
- package/src/__test-utils__/__tests__/real-model-registry.test.ts +53 -0
- package/src/__test-utils__/__tests__/vitest-global-setup.test.ts +37 -0
- package/src/__test-utils__/agent-host-probe-child.ts +77 -0
- package/src/__test-utils__/approval-contract/contract.ts +613 -0
- package/src/__test-utils__/approval-contract/hook-commands.ts +100 -0
- package/src/__test-utils__/approval-contract/types.ts +323 -0
- package/src/__test-utils__/approval-log.ts +142 -0
- package/src/__test-utils__/config-fixture.ts +65 -0
- package/src/__test-utils__/cursor-sdk-wire-child.ts +47 -0
- package/src/__test-utils__/execution-record-fixture.ts +229 -0
- package/src/__test-utils__/fake-artifact-storage.ts +83 -0
- package/src/__test-utils__/fake-upstream.ts +67 -0
- package/src/__test-utils__/file-review-projection.ts +77 -0
- package/src/__test-utils__/git-workspace-fixture.ts +58 -0
- package/src/__test-utils__/harness-boot-order-child.ts +78 -0
- package/src/__test-utils__/harness-contract/contract.ts +652 -0
- package/src/__test-utils__/harness-contract/recording-sink.ts +138 -0
- package/src/__test-utils__/harness-contract/runtime-contract.ts +1136 -0
- package/src/__test-utils__/harness-contract/scripted-adapter.ts +404 -0
- package/src/__test-utils__/harness-contract/types.ts +200 -0
- package/src/__test-utils__/hermetic-activity.ts +1061 -0
- package/src/__test-utils__/import-http2-first.ts +11 -0
- package/src/__test-utils__/live-gate.ts +106 -0
- package/src/__test-utils__/loopback-host.ts +48 -0
- package/src/__test-utils__/mock-client.ts +52 -0
- package/src/__test-utils__/mock-workspace.ts +28 -0
- package/src/__test-utils__/model-registry-fixture.ts +133 -0
- package/src/__test-utils__/module-specifiers.ts +177 -0
- package/src/__test-utils__/proto-helpers.ts +70 -0
- package/src/__test-utils__/real-model-registry.ts +85 -0
- package/src/__test-utils__/refuse-engine-sdks.ts +18 -0
- package/src/__test-utils__/timing-lines.ts +43 -0
- package/src/__test-utils__/turn-input-fixture.ts +166 -0
- package/src/__test-utils__/vitest-global-setup.ts +50 -0
- package/src/__tests__/agent-separation.container.test.ts +157 -0
- package/src/__tests__/approval-gateway-contract.test.ts +29 -0
- package/src/__tests__/bootstrap.test.ts +264 -0
- package/src/__tests__/config-boundary.test.ts +135 -0
- package/src/__tests__/config.test.ts +165 -0
- package/src/__tests__/exit-backstop.test.ts +91 -0
- package/src/__tests__/harness-boot-order.test.ts +87 -0
- package/src/__tests__/harness-contract.test.ts +27 -0
- package/src/__tests__/in-flight.test.ts +84 -0
- package/src/__tests__/ipc-protocol-fixtures.test.ts +61 -0
- package/src/__tests__/ipc-protocol.test.ts +33 -0
- package/src/__tests__/otel-export.test.ts +266 -0
- package/src/__tests__/otel-init.test.ts +111 -0
- package/src/__tests__/otel-metrics.test.ts +37 -0
- package/src/__tests__/pipe-safety.test.ts +119 -0
- package/src/__tests__/pool-member.test.ts +77 -0
- package/src/__tests__/preflight.test.ts +104 -0
- package/src/__tests__/readme-environment.test.ts +678 -0
- package/src/__tests__/run-credential-registration.test.ts +53 -0
- package/src/__tests__/run-trace-id.test.ts +53 -0
- package/src/__tests__/runner-hosting.test.ts +134 -0
- package/src/__tests__/runner-manager-interceptors.test.ts +67 -0
- package/src/__tests__/runner-manager-shutdown.test.ts +199 -0
- package/src/__tests__/runner-manager.test.ts +95 -0
- package/src/__tests__/runner-token-coordinator.test.ts +166 -0
- package/src/__tests__/runner.test.ts +284 -0
- package/src/__tests__/sandbox-token-renewal.test.ts +175 -0
- package/src/__tests__/worker.test.ts +107 -0
- package/src/activities/__tests__/attach-session.test.ts +133 -0
- package/src/activities/__tests__/ensure-thread.test.ts +96 -0
- package/src/activities/__tests__/error-classifier.test.ts +464 -0
- package/src/activities/__tests__/generate-session-subject-wire.test.ts +119 -0
- package/src/activities/__tests__/generate-session-subject.test.ts +356 -0
- package/src/activities/__tests__/list-plugin-tools.test.ts +392 -0
- package/src/activities/attach-session.ts +111 -0
- package/src/activities/ensure-thread.ts +45 -0
- package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +126 -0
- package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +445 -0
- package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +407 -0
- package/src/activities/execute-cursor/__test-utils__/fold.ts +118 -0
- package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +316 -0
- package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +428 -0
- package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +374 -0
- package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +310 -0
- package/src/activities/execute-cursor/__tests__/adapter-is-temporal-free.test.ts +45 -0
- package/src/activities/execute-cursor/__tests__/agent-session-cache.test.ts +220 -0
- package/src/activities/execute-cursor/__tests__/approval-decisions-agree.test.ts +141 -0
- package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +335 -0
- package/src/activities/execute-cursor/__tests__/approval-state.test.ts +288 -0
- package/src/activities/execute-cursor/__tests__/boundary-seal.test.ts +125 -0
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +1045 -0
- package/src/activities/execute-cursor/__tests__/cas-observations.test.ts +267 -0
- package/src/activities/execute-cursor/__tests__/check-tool-scope.test.ts +290 -0
- package/src/activities/execute-cursor/__tests__/coarse-fingerprint.test.ts +98 -0
- package/src/activities/execute-cursor/__tests__/cursor-baseurl-routing.live.test.ts +94 -0
- package/src/activities/execute-cursor/__tests__/cursor-event-recorder.test.ts +142 -0
- package/src/activities/execute-cursor/__tests__/cursor-fetch-interceptor-bypass.live.test.ts +76 -0
- package/src/activities/execute-cursor/__tests__/cursor-generate-image.live.test.ts +154 -0
- package/src/activities/execute-cursor/__tests__/cursor-hook-protocol.live.test.ts +479 -0
- package/src/activities/execute-cursor/__tests__/cursor-hooks-gate.live.test.ts +295 -0
- package/src/activities/execute-cursor/__tests__/cursor-mcp-config.test.ts +128 -0
- package/src/activities/execute-cursor/__tests__/cursor-mode.test.ts +95 -0
- package/src/activities/execute-cursor/__tests__/cursor-sdk-auth.live.test.ts +97 -0
- package/src/activities/execute-cursor/__tests__/cursor-transcript.live.test.ts +289 -0
- package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +200 -0
- package/src/activities/execute-cursor/__tests__/error-classifier-billing.test.ts +178 -0
- package/src/activities/execute-cursor/__tests__/error-classifier-extraction.test.ts +208 -0
- package/src/activities/execute-cursor/__tests__/error-classifier-introspection.test.ts +156 -0
- package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +389 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.append.prompt.md +147 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.everything.prompt.md +164 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.no-instructions.prompt.md +142 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.plan-mode.prompt.md +184 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.hitl.recovery.prompt.md +189 -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.append.prompt.md +5 -0
- package/src/activities/execute-cursor/__tests__/goldens/prompt.resumed.raw.prompt.md +1 -0
- package/src/activities/execute-cursor/__tests__/hermetic/answers.test.ts +279 -0
- package/src/activities/execute-cursor/__tests__/hermetic/built-in-assistant.test.ts +127 -0
- package/src/activities/execute-cursor/__tests__/hermetic/bypassed-tool-call.test.ts +120 -0
- package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +233 -0
- package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +262 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/approve-all.turn2.events.json +94 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/approve-all.turn2.rows.json +47 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/approve-all.turn2.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.events.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.rows.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.status.json +18 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.events.json +37 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.rows.json +29 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.status.json +4 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.events.json +71 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.rows.json +32 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.events.json +68 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.rows.json +96 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.status.json +74 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-off.events.json +50 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-off.rows.json +32 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-off.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-reconcile.events.json +91 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-reconcile.rows.json +9 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-reconcile.status.json +6 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn1.events.json +110 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn1.rows.json +77 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn1.status.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn2.events.json +144 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn2.rows.json +34 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn2.status.json +27 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/mcp-tool-call.events.json +50 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/mcp-tool-call.rows.json +30 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/mcp-tool-call.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.events.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.rows.json +9 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.status.json +4 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.events.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.rows.json +9 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.events.json +37 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.rows.json +29 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.status.json +6 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.events.json +26 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.rows.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.events.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.rows.json +9 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/reject.turn2.events.json +61 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/reject.turn2.rows.json +31 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/reject.turn2.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.events.json +1 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.rows.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.status.json +7 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.events.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.rows.json +9 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.status.json +5 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.events.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.rows.json +9 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.status.json +7 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.events.json +1 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.rows.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.status.json +7 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-task-note.events.json +56 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-task-note.rows.json +34 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-task-note.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.error-delta.events.json +64 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.error-delta.rows.json +36 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.error-delta.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.events.json +49 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.output-first.events.json +49 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.output-first.rows.json +31 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.output-first.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.rows.json +31 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.events.json +24 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.rows.json +29 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.status.json +7 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sub-agent-delegation.events.json +158 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sub-agent-delegation.rows.json +70 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sub-agent-delegation.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/thinking-turn.events.json +77 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/thinking-turn.rows.json +39 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/thinking-turn.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/todo-write.events.json +99 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/todo-write.rows.json +80 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/todo-write.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.events.json +49 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.rows.json +29 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-error.events.json +50 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-error.rows.json +29 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-error.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-only-step.events.json +37 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-only-step.rows.json +28 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-only-step.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattended-skip.events.json +51 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattended-skip.rows.json +31 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattended-skip.status.json +17 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.events.json +50 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.rows.json +36 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.status.json +19 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.events.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.rows.json +14 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.status.json +7 -0
- package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +198 -0
- package/src/activities/execute-cursor/__tests__/hermetic/hooks.test.ts +569 -0
- package/src/activities/execute-cursor/__tests__/hermetic/mcp-tool-call.test.ts +149 -0
- package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +222 -0
- package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +178 -0
- package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +162 -0
- package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +296 -0
- package/src/activities/execute-cursor/__tests__/hermetic/sdk-task-note.test.ts +125 -0
- package/src/activities/execute-cursor/__tests__/hermetic/shell-output-delta.test.ts +283 -0
- package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +342 -0
- package/src/activities/execute-cursor/__tests__/hermetic/sub-agent-delegation.test.ts +197 -0
- package/src/activities/execute-cursor/__tests__/hermetic/thinking-turn.test.ts +149 -0
- package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +214 -0
- package/src/activities/execute-cursor/__tests__/hermetic/todo-write.test.ts +169 -0
- package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +143 -0
- package/src/activities/execute-cursor/__tests__/hermetic/tool-error.test.ts +141 -0
- package/src/activities/execute-cursor/__tests__/hermetic/tool-lists.test.ts +391 -0
- package/src/activities/execute-cursor/__tests__/hermetic/tool-only-step.test.ts +134 -0
- package/src/activities/execute-cursor/__tests__/hermetic/turn-phases.test.ts +136 -0
- package/src/activities/execute-cursor/__tests__/hermetic/unattended-skip.test.ts +157 -0
- package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +200 -0
- package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +156 -0
- package/src/activities/execute-cursor/__tests__/hitl-ledger.test.ts +2109 -0
- package/src/activities/execute-cursor/__tests__/hitl-resume-history.test.ts +431 -0
- package/src/activities/execute-cursor/__tests__/hook-refusal-rows.test.ts +95 -0
- package/src/activities/execute-cursor/__tests__/hook-scope.test.ts +175 -0
- package/src/activities/execute-cursor/__tests__/hook-script.test.ts +1408 -0
- package/src/activities/execute-cursor/__tests__/hook-server.test.ts +465 -0
- package/src/activities/execute-cursor/__tests__/hook-views.test.ts +171 -0
- package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +408 -0
- package/src/activities/execute-cursor/__tests__/model-pricing.test.ts +173 -0
- package/src/activities/execute-cursor/__tests__/prepare-hooks.test.ts +97 -0
- package/src/activities/execute-cursor/__tests__/prompt-builder-delegation.test.ts +85 -0
- package/src/activities/execute-cursor/__tests__/prompt-goldens.test.ts +270 -0
- package/src/activities/execute-cursor/__tests__/resolve-timeout-message.test.ts +24 -0
- package/src/activities/execute-cursor/__tests__/run-telemetry.test.ts +177 -0
- package/src/activities/execute-cursor/__tests__/runner-error-regressions.test.ts +103 -0
- package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +174 -0
- package/src/activities/execute-cursor/__tests__/scope-refusal-rows.test.ts +269 -0
- package/src/activities/execute-cursor/__tests__/sdk-warmup.test.ts +45 -0
- package/src/activities/execute-cursor/__tests__/sequential-gate-resume.test.ts +182 -0
- package/src/activities/execute-cursor/__tests__/service-tier.test.ts +230 -0
- package/src/activities/execute-cursor/__tests__/session-lifecycle.test.ts +336 -0
- package/src/activities/execute-cursor/__tests__/session-store.test.ts +220 -0
- package/src/activities/execute-cursor/__tests__/subagent-config.test.ts +181 -0
- package/src/activities/execute-cursor/__tests__/tool-result-image.test.ts +250 -0
- package/src/activities/execute-cursor/__tests__/translator.test.ts +651 -0
- package/src/activities/execute-cursor/__tests__/turn-boundary.test.ts +415 -0
- package/src/activities/execute-cursor/__tests__/turn-recovery.test.ts +186 -0
- package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +354 -0
- package/src/activities/execute-cursor/__tests__/usage-pricing.test.ts +84 -0
- package/src/activities/execute-cursor/__tests__/workspace-setup.test.ts +814 -0
- package/src/activities/execute-cursor/adapter.ts +161 -0
- package/src/activities/execute-cursor/agent-session-cache.ts +229 -0
- package/src/activities/execute-cursor/approval-policy.ts +129 -0
- package/src/activities/execute-cursor/approval-state.ts +1097 -0
- package/src/activities/execute-cursor/boundary-rows.ts +1419 -0
- package/src/activities/execute-cursor/cas-observations.ts +263 -0
- package/src/activities/execute-cursor/cursor-capabilities.ts +80 -0
- package/src/activities/execute-cursor/cursor-event-recorder.ts +112 -0
- package/src/activities/execute-cursor/cursor-mcp-config.ts +124 -0
- package/src/activities/execute-cursor/cursor-mode.ts +42 -0
- package/src/activities/execute-cursor/error-classifier.ts +416 -0
- package/src/activities/execute-cursor/fetch-interceptor.ts +454 -0
- package/src/activities/execute-cursor/hook-scope.ts +216 -0
- package/src/activities/execute-cursor/hook-script.ts +1232 -0
- package/src/activities/execute-cursor/hook-server.ts +473 -0
- package/src/activities/execute-cursor/hook-tool-hiding.ts +76 -0
- package/src/activities/execute-cursor/hook-views.ts +195 -0
- package/src/activities/execute-cursor/http2-interceptor.ts +267 -0
- package/src/activities/execute-cursor/model-pricing-data.ts +170 -0
- package/src/activities/execute-cursor/model-pricing.ts +190 -0
- package/src/activities/execute-cursor/prompt-builder.ts +1081 -0
- package/src/activities/execute-cursor/rejection-capture.ts +93 -0
- package/src/activities/execute-cursor/run-telemetry.ts +189 -0
- package/src/activities/execute-cursor/sdk-warmup.ts +77 -0
- package/src/activities/execute-cursor/service-tier.ts +251 -0
- package/src/activities/execute-cursor/session-lifecycle.ts +543 -0
- package/src/activities/execute-cursor/session-store.ts +186 -0
- package/src/activities/execute-cursor/sub-agent-steps.ts +188 -0
- package/src/activities/execute-cursor/subagent-config.ts +124 -0
- package/src/activities/execute-cursor/tool-result.ts +128 -0
- package/src/activities/execute-cursor/translator.ts +544 -0
- package/src/activities/execute-cursor/turn-boundary.ts +373 -0
- package/src/activities/execute-cursor/turn-recovery.ts +223 -0
- package/src/activities/execute-cursor/turn-settle.ts +605 -0
- package/src/activities/execute-cursor/turn-setup.ts +964 -0
- package/src/activities/execute-cursor/turn-stream.ts +354 -0
- package/src/activities/execute-cursor/turn.ts +271 -0
- package/src/activities/execute-cursor/usage-pricing.ts +67 -0
- package/src/activities/execute-cursor/workspace-hook-files.ts +424 -0
- package/src/activities/execute-cursor/workspace-setup.ts +549 -0
- package/src/activities/execute-deep-agent/__test-utils__/contract-subject.ts +404 -0
- package/src/activities/execute-deep-agent/__test-utils__/gateway-substrate.ts +519 -0
- package/src/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.ts +430 -0
- package/src/activities/execute-deep-agent/__test-utils__/hitl-script.ts +48 -0
- package/src/activities/execute-deep-agent/__test-utils__/paused-session-fixture.ts +172 -0
- package/src/activities/execute-deep-agent/__test-utils__/scripted-model-module.ts +84 -0
- package/src/activities/execute-deep-agent/__test-utils__/scripted-model.ts +585 -0
- package/src/activities/execute-deep-agent/__test-utils__/think-bound-session.ts +29 -0
- package/src/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.ts +295 -0
- 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 +83 -0
- package/src/activities/execute-deep-agent/__tests__/approval-file-change.test.ts +88 -0
- package/src/activities/execute-deep-agent/__tests__/auto-publish.test.ts +144 -0
- package/src/activities/execute-deep-agent/__tests__/builtin-tool-surface.test.ts +108 -0
- package/src/activities/execute-deep-agent/__tests__/cas-capture-backend.test.ts +286 -0
- package/src/activities/execute-deep-agent/__tests__/cas-capture-observer.test.ts +163 -0
- package/src/activities/execute-deep-agent/__tests__/engine-tools.test.ts +97 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.build-from-plan.prompt.md +133 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.everything.prompt.md +151 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.judge.prompt.md +26 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.minimal.append.prompt.md +28 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.minimal.prompt.md +25 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.plan-mode.prompt.md +140 -0
- package/src/activities/execute-deep-agent/__tests__/goldens/user-message.everything.md +36 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/answers.test.ts +114 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/built-in-assistant.test.ts +103 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/cost-advisory.test.ts +239 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/file-review-capture.test.ts +306 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/fixtures/paused-session.deepagents-1.10.2.json +592 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/fixtures/paused-session.think-bound.json +498 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.events.json +49 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.rows.json +32 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.status.json +15 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.events.json +118 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.rows.json +45 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.events.json +69 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.rows.json +30 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.events.json +69 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.rows.json +97 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.status.json +84 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-off.events.json +51 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-off.rows.json +33 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-off.status.json +27 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-reconcile.events.json +92 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-reconcile.rows.json +9 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-reconcile.status.json +6 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.events.json +35 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.rows.json +27 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.status.json +15 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn1.events.json +107 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn1.rows.json +74 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn1.status.json +25 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn2.events.json +141 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn2.rows.json +31 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn2.status.json +26 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.events.json +71 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.rows.json +50 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.status.json +26 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.events.json +105 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.rows.json +30 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.status.json +27 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.events.json +37 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.rows.json +24 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.status.json +15 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.events.json +24 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.rows.json +22 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.status.json +15 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/plain-turn.events.json +14 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/plain-turn.rows.json +9 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/plain-turn.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.events.json +24 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.rows.json +27 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.status.json +17 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.events.json +352 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.rows.json +209 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.status.json +18 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.events.json +71 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.rows.json +29 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/resolution-error.events.json +1 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/resolution-error.rows.json +14 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/resolution-error.status.json +7 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.events.json +90 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.rows.json +48 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.status.json +15 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.events.json +124 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.rows.json +30 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.events.json +70 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.rows.json +29 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.text-fallback.events.json +24 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.text-fallback.rows.json +13 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.text-fallback.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tier2.events.json +24 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tier2.rows.json +13 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tier2.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tool-strategy.events.json +36 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tool-strategy.rows.json +18 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tool-strategy.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.events.json +118 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.rows.json +49 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.events.json +49 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.rows.json +29 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/unattended-skip.events.json +51 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/unattended-skip.rows.json +31 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/unattended-skip.status.json +16 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.events.json +37 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.rows.json +29 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.status.json +18 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/write-todos.events.json +58 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/write-todos.rows.json +54 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/write-todos.status.json +16 -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 +194 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-parallel-gates.test.ts +131 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-round-trips.test.ts +224 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-sequential-gates.test.ts +180 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/hooks.test.ts +556 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/inline-artifact-across-gate.test.ts +188 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/pause-vs-shutdown.test.ts +217 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/plain-turn.test.ts +162 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/platform-stop.test.ts +130 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/recorded-agent-version.test.ts +148 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/recursion-limit.test.ts +212 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/resolution-error.test.ts +130 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/resume-across-engine-upgrade.test.ts +268 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/resume-across-think-retirement.test.ts +181 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/run-finished-while-waiting.test.ts +110 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/run-values-refused.test.ts +106 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/structured-output.test.ts +242 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-concurrent-invocations.test.ts +312 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-delegation.test.ts +211 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-own-context.test.ts +192 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/thrown-turn-drains-publishes.test.ts +154 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/tool-call.test.ts +167 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/tool-lists.test.ts +291 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/turn-phases.test.ts +118 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/unattended-skip.test.ts +130 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/workspace-lock-timeout.test.ts +154 -0
- package/src/activities/execute-deep-agent/__tests__/hermetic/write-todos.test.ts +160 -0
- package/src/activities/execute-deep-agent/__tests__/hitl.test.ts +355 -0
- package/src/activities/execute-deep-agent/__tests__/hooks-setup.test.ts +333 -0
- package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +350 -0
- package/src/activities/execute-deep-agent/__tests__/loaded-tool-marks.test.ts +95 -0
- package/src/activities/execute-deep-agent/__tests__/plain-turn.live.test.ts +103 -0
- package/src/activities/execute-deep-agent/__tests__/plan-mode-path-normalization.test.ts +404 -0
- package/src/activities/execute-deep-agent/__tests__/platform-route.test.ts +185 -0
- package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +577 -0
- package/src/activities/execute-deep-agent/__tests__/prompt-goldens.test.ts +293 -0
- package/src/activities/execute-deep-agent/__tests__/resume-across-think-retirement.live.test.ts +98 -0
- package/src/activities/execute-deep-agent/__tests__/resumed-history.test.ts +48 -0
- package/src/activities/execute-deep-agent/__tests__/scripted-model.test.ts +408 -0
- package/src/activities/execute-deep-agent/__tests__/shell-execute-gate.test.ts +293 -0
- package/src/activities/execute-deep-agent/__tests__/streaming-side-effects.test.ts +120 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-approval-propagation.test.ts +160 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-gitignored-capture.test.ts +214 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-plan-mode-permissions.test.ts +213 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-spans.test.ts +110 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-transformer.test.ts +662 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +197 -0
- package/src/activities/execute-deep-agent/__tests__/summarization-verification.test.ts +330 -0
- package/src/activities/execute-deep-agent/__tests__/tool-call.live.test.ts +80 -0
- package/src/activities/execute-deep-agent/__tests__/tool-scope.test.ts +519 -0
- package/src/activities/execute-deep-agent/__tests__/translator-subagents.test.ts +519 -0
- package/src/activities/execute-deep-agent/__tests__/translator-through-builder.test.ts +830 -0
- package/src/activities/execute-deep-agent/__tests__/translator.test.ts +641 -0
- package/src/activities/execute-deep-agent/__tests__/turn-setup-connect.test.ts +89 -0
- package/src/activities/execute-deep-agent/__tests__/turn-setup-tool-lists.test.ts +192 -0
- package/src/activities/execute-deep-agent/__tests__/turn-stream.test.ts +381 -0
- package/src/activities/execute-deep-agent/__tests__/v3-event-recorder.test.ts +186 -0
- package/src/activities/execute-deep-agent/__tests__/vision-input.test.ts +152 -0
- package/src/activities/execute-deep-agent/adapter.ts +95 -0
- package/src/activities/execute-deep-agent/approval-file-change.ts +86 -0
- package/src/activities/execute-deep-agent/auto-publish.ts +80 -0
- package/src/activities/execute-deep-agent/cas-capture-backend.ts +154 -0
- package/src/activities/execute-deep-agent/cas-capture-observer.ts +132 -0
- package/src/activities/execute-deep-agent/deep-agent-capabilities.ts +49 -0
- package/src/activities/execute-deep-agent/deepagents-profiles.ts +51 -0
- package/src/activities/execute-deep-agent/engine-tools.ts +33 -0
- package/src/activities/execute-deep-agent/hitl.ts +274 -0
- package/src/activities/execute-deep-agent/hooks-setup.ts +75 -0
- package/src/activities/execute-deep-agent/inline-publisher.ts +208 -0
- package/src/activities/execute-deep-agent/platform-route.ts +284 -0
- package/src/activities/execute-deep-agent/prompt-builder.ts +547 -0
- package/src/activities/execute-deep-agent/resumed-history.ts +52 -0
- package/src/activities/execute-deep-agent/streaming-side-effects.ts +83 -0
- package/src/activities/execute-deep-agent/subagent-transformer.ts +732 -0
- package/src/activities/execute-deep-agent/subagent-wiring.ts +180 -0
- package/src/activities/execute-deep-agent/todo-list.ts +56 -0
- package/src/activities/execute-deep-agent/translator.ts +564 -0
- package/src/activities/execute-deep-agent/turn-settle.ts +162 -0
- package/src/activities/execute-deep-agent/turn-setup.ts +842 -0
- package/src/activities/execute-deep-agent/turn-stream.ts +309 -0
- package/src/activities/execute-deep-agent/turn.ts +151 -0
- package/src/activities/execute-deep-agent/v3-event-recorder.ts +112 -0
- package/src/activities/generate-session-subject.ts +376 -0
- package/src/activities/list-plugin-tools.ts +251 -0
- package/src/agent-host/__tests__/channel.test.ts +271 -0
- package/src/agent-host/__tests__/codec.test.ts +435 -0
- package/src/agent-host/__tests__/entry-telemetry.test.ts +159 -0
- package/src/agent-host/__tests__/entry.test.ts +223 -0
- package/src/agent-host/__tests__/environment.test.ts +73 -0
- package/src/agent-host/__tests__/failed-boot.test.ts +58 -0
- package/src/agent-host/__tests__/host-sink.test.ts +118 -0
- package/src/agent-host/__tests__/host.test.ts +162 -0
- package/src/agent-host/__tests__/hostile-host.test.ts +440 -0
- package/src/agent-host/__tests__/offload-through-host.test.ts +124 -0
- package/src/agent-host/__tests__/remote-fs.test.ts +177 -0
- package/src/agent-host/__tests__/spawned-host.test.ts +174 -0
- package/src/agent-host/__tests__/supervisor.test.ts +488 -0
- package/src/agent-host/channel.ts +334 -0
- package/src/agent-host/codec.ts +631 -0
- package/src/agent-host/entry.ts +153 -0
- package/src/agent-host/environment.ts +76 -0
- package/src/agent-host/failed-boot.ts +29 -0
- package/src/agent-host/fs-service.ts +133 -0
- package/src/agent-host/host-sink.ts +153 -0
- package/src/agent-host/host.ts +228 -0
- package/src/agent-host/hosting.ts +162 -0
- package/src/agent-host/protocol.ts +380 -0
- package/src/agent-host/remote-adapter.ts +320 -0
- package/src/agent-host/remote-fs.ts +128 -0
- package/src/agent-host/supervisor.ts +382 -0
- package/src/agent-proxy/__tests__/cursor-lane.test.ts +635 -0
- package/src/agent-proxy/__tests__/cursor-sdk-key-required.test.ts +119 -0
- package/src/agent-proxy/__tests__/cursor-sdk-wire.test.ts +175 -0
- package/src/agent-proxy/__tests__/lanes.test.ts +258 -0
- package/src/agent-proxy/__tests__/loopback-certificate.test.ts +100 -0
- package/src/agent-proxy/__tests__/otlp-forward-rebuild.test.ts +66 -0
- package/src/agent-proxy/__tests__/otlp-forward.test.ts +295 -0
- package/src/agent-proxy/__tests__/relay.test.ts +115 -0
- package/src/agent-proxy/__tests__/server.test.ts +436 -0
- package/src/agent-proxy/cursor-lane.ts +528 -0
- package/src/agent-proxy/lanes.ts +285 -0
- package/src/agent-proxy/loopback-certificate.ts +143 -0
- package/src/agent-proxy/otlp-forward.ts +190 -0
- package/src/agent-proxy/relay.ts +188 -0
- package/src/agent-proxy/server.ts +266 -0
- package/src/attach/__tests__/entry.test.ts +123 -0
- package/src/attach/__tests__/import-graph.test.ts +66 -0
- package/src/attach/__tests__/push.test.ts +162 -0
- package/src/attach/__tests__/waiter.test.ts +416 -0
- package/src/attach/entry.ts +92 -0
- package/src/attach/main.ts +26 -0
- package/src/attach/push.ts +165 -0
- package/src/attach/waiter.ts +370 -0
- package/src/bootstrap.ts +178 -0
- package/src/client/__tests__/agent-version-read.test.ts +39 -0
- package/src/client/__tests__/eval-read.test.ts +43 -0
- package/src/client/__tests__/plugin-read.test.ts +57 -0
- package/src/client/__tests__/run-calls.test.ts +65 -0
- package/src/client/__tests__/server-contracts.test.ts +157 -0
- package/src/client/__tests__/session-events-calls.test.ts +139 -0
- package/src/client/__tests__/stigmer-client.test.ts +577 -0
- package/src/client/__tests__/token-claims.test.ts +102 -0
- package/src/client/server-contracts.ts +124 -0
- package/src/client/stigmer-client.ts +686 -0
- package/src/client/token-claims.ts +103 -0
- package/src/config.ts +378 -0
- package/src/exit-backstop.ts +97 -0
- package/src/gen/turn/ai/stigmer/runner/turn/v1/enum_pb.ts +1142 -0
- package/src/gen/turn/ai/stigmer/runner/turn/v1/ledger_pb.ts +458 -0
- package/src/gen/turn/ai/stigmer/runner/turn/v1/rows_pb.ts +920 -0
- package/src/gen-ai-conventions.ts +121 -0
- package/src/harness/README.md +372 -0
- package/src/harness/__tests__/approval-answers.test.ts +202 -0
- package/src/harness/__tests__/approval-decisions.test.ts +114 -0
- package/src/harness/__tests__/attachment-credential.test.ts +115 -0
- package/src/harness/__tests__/capture.test.ts +285 -0
- package/src/harness/__tests__/import-direction.test.ts +169 -0
- package/src/harness/__tests__/loaded-versions.test.ts +76 -0
- package/src/harness/__tests__/mount-skills.test.ts +305 -0
- package/src/harness/__tests__/owed-undos.test.ts +305 -0
- package/src/harness/__tests__/persist-chokepoint.test.ts +344 -0
- package/src/harness/__tests__/readme-index.test.ts +339 -0
- package/src/harness/__tests__/reconcile-turn.test.ts +111 -0
- package/src/harness/__tests__/registry.test.ts +178 -0
- package/src/harness/__tests__/reinvocation-carry.test.ts +65 -0
- package/src/harness/__tests__/resolve-hooks.test.ts +241 -0
- package/src/harness/__tests__/resolve-subagents.test.ts +477 -0
- package/src/harness/__tests__/run-span.test.ts +255 -0
- package/src/harness/__tests__/run-turn-deterministic.test.ts +94 -0
- package/src/harness/__tests__/run-turn-eval-case.test.ts +211 -0
- package/src/harness/__tests__/run-turn.test.ts +435 -0
- package/src/harness/__tests__/runtime-touches-no-agent-path.test.ts +109 -0
- package/src/harness/__tests__/stop-controller.test.ts +93 -0
- package/src/harness/__tests__/terminal-table.test.ts +81 -0
- package/src/harness/__tests__/transcript-is-engine-free.test.ts +83 -0
- package/src/harness/__tests__/transcript-writers.test.ts +193 -0
- package/src/harness/__tests__/turn-attachments-vision.test.ts +105 -0
- package/src/harness/__tests__/turn-context.test.ts +213 -0
- package/src/harness/__tests__/turn-mcp.test.ts +554 -0
- package/src/harness/__tests__/turn-timeline.test.ts +290 -0
- package/src/harness/__tests__/usage-accumulator.test.ts +106 -0
- package/src/harness/approval-answers.ts +174 -0
- package/src/harness/approval-decisions.ts +82 -0
- package/src/harness/capabilities.ts +155 -0
- package/src/harness/capture.ts +337 -0
- package/src/harness/cost-cap-watch.ts +52 -0
- package/src/harness/events/__tests__/emitter.test.ts +715 -0
- package/src/harness/events/__tests__/ids-corpus.test.ts +86 -0
- package/src/harness/events/emitter.ts +805 -0
- package/src/harness/events/ids.ts +156 -0
- package/src/harness/loaded-versions.ts +78 -0
- package/src/harness/owed-undos.ts +258 -0
- package/src/harness/persist-chokepoint.ts +163 -0
- package/src/harness/registry.ts +203 -0
- package/src/harness/run-span.ts +184 -0
- package/src/harness/run-turn.ts +862 -0
- package/src/harness/stop-controller.ts +101 -0
- package/src/harness/terminal-table.ts +390 -0
- package/src/harness/transcript/__tests__/builder.test.ts +1246 -0
- package/src/harness/transcript/__tests__/resume-seed.test.ts +148 -0
- package/src/harness/transcript/__tests__/state.test.ts +144 -0
- package/src/harness/transcript/builder.ts +925 -0
- package/src/harness/transcript/events.ts +281 -0
- package/src/harness/transcript/resume-seed.ts +280 -0
- package/src/harness/transcript/state.ts +167 -0
- package/src/harness/turn-context.ts +1982 -0
- package/src/harness/turn-timeline.ts +248 -0
- package/src/harness/types.ts +725 -0
- package/src/harness/usage-accumulator.ts +134 -0
- package/src/harness-adapters.ts +48 -0
- package/src/idle-watchdog.ts +28 -0
- package/src/in-flight.ts +71 -0
- package/src/index.ts +48 -0
- package/src/interceptors/__tests__/run-credential-activity.test.ts +86 -0
- package/src/interceptors/run-credential-activity.ts +40 -0
- package/src/ipc-protocol-fixtures.ts +90 -0
- package/src/ipc-protocol.ts +89 -0
- package/src/main.ts +506 -0
- package/src/middleware/__tests__/advisory-message.test.ts +59 -0
- package/src/middleware/__tests__/approval-gate-hooks.test.ts +269 -0
- package/src/middleware/__tests__/approval-gate.test.ts +1072 -0
- package/src/middleware/__tests__/cost-advisory.test.ts +272 -0
- package/src/middleware/__tests__/error-hints.test.ts +90 -0
- package/src/middleware/__tests__/execution-budget.test.ts +239 -0
- package/src/middleware/__tests__/loop-detection.test.ts +194 -0
- package/src/middleware/__tests__/otel-spans.test.ts +460 -0
- package/src/middleware/__tests__/path-normalization.test.ts +198 -0
- package/src/middleware/__tests__/tool-intent.test.ts +266 -0
- package/src/middleware/__tests__/tool-truncation.test.ts +112 -0
- package/src/middleware/advisory-message.ts +62 -0
- package/src/middleware/approval-gate.ts +741 -0
- package/src/middleware/cost-advisory.ts +224 -0
- package/src/middleware/error-hints.ts +136 -0
- package/src/middleware/execution-budget.ts +197 -0
- package/src/middleware/index.ts +100 -0
- package/src/middleware/loop-detection.ts +197 -0
- package/src/middleware/otel-spans.ts +345 -0
- package/src/middleware/path-normalization.ts +178 -0
- package/src/middleware/tool-intent.ts +174 -0
- package/src/middleware/tool-scope.ts +201 -0
- package/src/middleware/tool-truncation.ts +94 -0
- package/src/middleware/types.ts +141 -0
- package/src/otel-export.ts +325 -0
- package/src/otel-metrics.ts +61 -0
- package/src/otel.ts +173 -0
- package/src/payload-codecs.ts +66 -0
- package/src/pipe-safety.ts +117 -0
- package/src/pool-member.ts +99 -0
- package/src/preflight.ts +104 -0
- package/src/run-trace-id.ts +50 -0
- package/src/runner-entry.ts +18 -0
- package/src/runner-manager.ts +882 -0
- package/src/runner-token-coordinator.ts +140 -0
- package/src/runner.ts +588 -0
- package/src/sandbox-token-renewal.ts +211 -0
- package/src/shared/__tests__/activity-input.test.ts +78 -0
- package/src/shared/__tests__/advisory-anthropic-payload.test.ts +194 -0
- package/src/shared/__tests__/agent-handover.test.ts +186 -0
- package/src/shared/__tests__/agent-identity.test.ts +144 -0
- package/src/shared/__tests__/agent-servers.test.ts +55 -0
- package/src/shared/__tests__/approval-canonicalize.test.ts +106 -0
- package/src/shared/__tests__/approval-fingerprint.test.ts +115 -0
- package/src/shared/__tests__/approval-policy.test.ts +466 -0
- package/src/shared/__tests__/args-preview.test.ts +147 -0
- package/src/shared/__tests__/artifact-storage-extended.test.ts +243 -0
- package/src/shared/__tests__/artifact-storage.test.ts +844 -0
- package/src/shared/__tests__/attachment-download-urls.test.ts +72 -0
- package/src/shared/__tests__/attachment-naming.test.ts +146 -0
- package/src/shared/__tests__/attachment-resolver.test.ts +644 -0
- package/src/shared/__tests__/attachment-vision.test.ts +424 -0
- package/src/shared/__tests__/attachment-zip.test.ts +236 -0
- package/src/shared/__tests__/bedrock-adapter.test.ts +213 -0
- package/src/shared/__tests__/bedrock-seam.test.ts +390 -0
- package/src/shared/__tests__/blueprint-resolver.test.ts +629 -0
- package/src/shared/__tests__/builtin-judge.test.ts +57 -0
- package/src/shared/__tests__/caller-identity.test.ts +172 -0
- package/src/shared/__tests__/channel-attachment.test.ts +285 -0
- package/src/shared/__tests__/cold-start-timing.test.ts +333 -0
- package/src/shared/__tests__/context-bridge.test.ts +51 -0
- package/src/shared/__tests__/conversation-attachment.test.ts +152 -0
- package/src/shared/__tests__/conversation-catchup.test.ts +94 -0
- package/src/shared/__tests__/cost-guard.test.ts +68 -0
- package/src/shared/__tests__/declared-preferences.test.ts +109 -0
- package/src/shared/__tests__/default-model-agrees-with-server.test.ts +74 -0
- package/src/shared/__tests__/exact-apply.test.ts +370 -0
- package/src/shared/__tests__/execution-target.test.ts +33 -0
- package/src/shared/__tests__/extract-json.test.ts +153 -0
- package/src/shared/__tests__/extract-structured-output.test.ts +149 -0
- package/src/shared/__tests__/file-change.test.ts +85 -0
- package/src/shared/__tests__/file-tools.test.ts +90 -0
- package/src/shared/__tests__/fingerprint-secret.test.ts +51 -0
- package/src/shared/__tests__/foundry-adapter.test.ts +276 -0
- package/src/shared/__tests__/foundry-seam.test.ts +482 -0
- package/src/shared/__tests__/grpc-retry-extended.test.ts +38 -0
- package/src/shared/__tests__/grpc-retry.test.ts +43 -0
- package/src/shared/__tests__/http-retry.test.ts +68 -0
- package/src/shared/__tests__/implement-plan-prompt.test.ts +86 -0
- package/src/shared/__tests__/json-schema-to-zod.test.ts +227 -0
- package/src/shared/__tests__/lease-scope-corpus.test.ts +78 -0
- package/src/shared/__tests__/llm-backend.test.ts +676 -0
- package/src/shared/__tests__/llm-proxy.test.ts +179 -0
- package/src/shared/__tests__/mcp-manager.test.ts +272 -0
- package/src/shared/__tests__/mcp-oauth-detect.test.ts +167 -0
- package/src/shared/__tests__/mcp-resolver.test.ts +454 -0
- package/src/shared/__tests__/mcp-schema-sanitizer.test.ts +267 -0
- package/src/shared/__tests__/mcp-tool-listing.hang.test.ts +82 -0
- package/src/shared/__tests__/mcp-tool-listing.test.ts +257 -0
- package/src/shared/__tests__/mcp-transport-guard.test.ts +71 -0
- package/src/shared/__tests__/memory-attachment.test.ts +183 -0
- package/src/shared/__tests__/memory-retrieval.test.ts +310 -0
- package/src/shared/__tests__/model-client-sampling.test.ts +110 -0
- package/src/shared/__tests__/model-client.test.ts +623 -0
- package/src/shared/__tests__/model-error.test.ts +579 -0
- package/src/shared/__tests__/model-lanes.test.ts +225 -0
- package/src/shared/__tests__/model-pricing.test.ts +131 -0
- package/src/shared/__tests__/model-registry-at-provider.live.test.ts +63 -0
- package/src/shared/__tests__/model-registry.test.ts +460 -0
- package/src/shared/__tests__/persist-decision.test.ts +87 -0
- package/src/shared/__tests__/placeholder-resolver.test.ts +210 -0
- package/src/shared/__tests__/plan-artifact.test.ts +260 -0
- package/src/shared/__tests__/plan-mode-permissions.test.ts +29 -0
- package/src/shared/__tests__/platform-server-address.test.ts +125 -0
- package/src/shared/__tests__/plugin-mount-faults.test.ts +71 -0
- package/src/shared/__tests__/plugin-mount.test.ts +407 -0
- package/src/shared/__tests__/plugin-servers.test.ts +53 -0
- package/src/shared/__tests__/policy-source-corpus.test.ts +69 -0
- package/src/shared/__tests__/prompt-sections.test.ts +113 -0
- package/src/shared/__tests__/recalled-memories.test.ts +88 -0
- package/src/shared/__tests__/registry-endpoint.test.ts +96 -0
- package/src/shared/__tests__/run-credential.test.ts +109 -0
- package/src/shared/__tests__/run-values.test.ts +125 -0
- package/src/shared/__tests__/runner-credential-store.test.ts +175 -0
- package/src/shared/__tests__/secret-leak-scan.test.ts +100 -0
- package/src/shared/__tests__/sender-identity.test.ts +92 -0
- package/src/shared/__tests__/session-context.test.ts +67 -0
- package/src/shared/__tests__/shell-env.test.ts +118 -0
- package/src/shared/__tests__/skill-mount.test.ts +353 -0
- package/src/shared/__tests__/skill-resolver.test.ts +401 -0
- package/src/shared/__tests__/stall-watchdog.test.ts +193 -0
- package/src/shared/__tests__/stamp-flowed-rows.test.ts +142 -0
- package/src/shared/__tests__/status-offload.test.ts +778 -0
- package/src/shared/__tests__/status.test.ts +350 -0
- package/src/shared/__tests__/streaming-scheduler.test.ts +198 -0
- package/src/shared/__tests__/subagent-gate.test.ts +112 -0
- package/src/shared/__tests__/subagent-rows.test.ts +34 -0
- package/src/shared/__tests__/subagents.test.ts +135 -0
- package/src/shared/__tests__/synthesized-attachment.test.ts +96 -0
- package/src/shared/__tests__/telemetry-content.test.ts +220 -0
- package/src/shared/__tests__/thinking-mode.test.ts +69 -0
- package/src/shared/__tests__/todos.test.ts +216 -0
- package/src/shared/__tests__/tool-kind.test.ts +81 -0
- package/src/shared/__tests__/tool-lists.test.ts +463 -0
- package/src/shared/__tests__/tool-rounds.test.ts +107 -0
- package/src/shared/__tests__/tool-row.test.ts +390 -0
- package/src/shared/__tests__/trace-context.test.ts +68 -0
- package/src/shared/__tests__/vertex-adapter.test.ts +196 -0
- package/src/shared/__tests__/vertex-seam.test.ts +296 -0
- package/src/shared/__tests__/with-timeout.test.ts +60 -0
- package/src/shared/__tests__/worker-shutdown.test.ts +106 -0
- package/src/shared/__tests__/zip-extract.test.ts +256 -0
- package/src/shared/activity-input.ts +78 -0
- package/src/shared/agent-fs.ts +264 -0
- package/src/shared/agent-handover.ts +171 -0
- package/src/shared/agent-identity.ts +185 -0
- package/src/shared/agent-servers.ts +51 -0
- package/src/shared/approval-canonicalize.ts +159 -0
- package/src/shared/approval-fingerprint.ts +145 -0
- package/src/shared/approval-policy.ts +536 -0
- package/src/shared/archive-mount.ts +140 -0
- package/src/shared/args-preview.ts +128 -0
- package/src/shared/artifact-storage.ts +496 -0
- package/src/shared/attachment-download-urls.ts +76 -0
- package/src/shared/attachment-naming.ts +78 -0
- package/src/shared/attachment-resolver.ts +468 -0
- package/src/shared/attachment-vision.ts +466 -0
- package/src/shared/attachment-zip.ts +281 -0
- package/src/shared/blueprint-resolver.ts +420 -0
- package/src/shared/builtin-assistant-prompt.ts +38 -0
- package/src/shared/builtin-judge.ts +62 -0
- package/src/shared/caller-identity.ts +186 -0
- package/src/shared/channel-attachment.ts +246 -0
- package/src/shared/checkpointer/__tests__/factory.test.ts +88 -0
- package/src/shared/checkpointer/__tests__/http-saver.test.ts +393 -0
- package/src/shared/checkpointer/__tests__/sqlite-saver.test.ts +212 -0
- package/src/shared/checkpointer/factory.ts +94 -0
- package/src/shared/checkpointer/http-saver.ts +429 -0
- package/src/shared/checkpointer/sqlite-saver.ts +384 -0
- package/src/shared/checkpointer/types.ts +27 -0
- package/src/shared/cold-start-timing.ts +260 -0
- package/src/shared/context-bridge.ts +51 -0
- package/src/shared/conversation-attachment.ts +141 -0
- package/src/shared/conversation-catchup.ts +93 -0
- package/src/shared/cost-guard.ts +63 -0
- package/src/shared/declared-preferences.ts +84 -0
- package/src/shared/eval-case/__tests__/agent-mock.test.ts +126 -0
- package/src/shared/eval-case/__tests__/case-archive.test.ts +159 -0
- package/src/shared/eval-case/__tests__/mock-endpoint-failure.test.ts +65 -0
- package/src/shared/eval-case/__tests__/mock-endpoint.test.ts +269 -0
- package/src/shared/eval-case/__tests__/prepare-case.test.ts +228 -0
- package/src/shared/eval-case/__tests__/read-files.test.ts +90 -0
- package/src/shared/eval-case/agent-mock.ts +131 -0
- package/src/shared/eval-case/case-archive.ts +135 -0
- package/src/shared/eval-case/mock-endpoint.ts +282 -0
- package/src/shared/eval-case/prepare-case.ts +227 -0
- package/src/shared/eval-case/read-files.ts +94 -0
- package/src/shared/exact-apply.ts +247 -0
- package/src/shared/execution-context.ts +62 -0
- package/src/shared/execution-target.ts +17 -0
- package/src/shared/extract-json.ts +153 -0
- package/src/shared/extract-structured-output.ts +83 -0
- package/src/shared/file-change.ts +62 -0
- package/src/shared/file-tools.ts +167 -0
- package/src/shared/filereview/__tests__/capture.test.ts +1178 -0
- package/src/shared/filereview/__tests__/cas-progress.test.ts +229 -0
- package/src/shared/filereview/__tests__/cas-substrate.test.ts +504 -0
- package/src/shared/filereview/__tests__/command-provenance.test.ts +249 -0
- package/src/shared/filereview/__tests__/digest.test.ts +100 -0
- package/src/shared/filereview/__tests__/events.test.ts +350 -0
- package/src/shared/filereview/__tests__/git-substrate.test.ts +365 -0
- package/src/shared/filereview/__tests__/line-counts.test.ts +73 -0
- package/src/shared/filereview/__tests__/progress.test.ts +480 -0
- package/src/shared/filereview/__tests__/proxy-reconcile.test.ts +265 -0
- package/src/shared/filereview/__tests__/record.test.ts +126 -0
- package/src/shared/filereview/__tests__/secret-paths.test.ts +121 -0
- package/src/shared/filereview/capture.ts +783 -0
- package/src/shared/filereview/cas-progress.ts +155 -0
- package/src/shared/filereview/cas-substrate.ts +460 -0
- package/src/shared/filereview/cas-touched.ts +89 -0
- package/src/shared/filereview/command-provenance.ts +182 -0
- package/src/shared/filereview/digest.ts +83 -0
- package/src/shared/filereview/events.ts +515 -0
- package/src/shared/filereview/git-substrate.ts +680 -0
- package/src/shared/filereview/index.ts +99 -0
- package/src/shared/filereview/line-counts.ts +83 -0
- package/src/shared/filereview/progress.ts +361 -0
- package/src/shared/filereview/record.ts +107 -0
- package/src/shared/filereview/secret-paths.ts +119 -0
- package/src/shared/fingerprint-secret.ts +77 -0
- package/src/shared/grpc-retry.ts +54 -0
- package/src/shared/heartbeat.ts +50 -0
- package/src/shared/hooks/__tests__/answer.test.ts +179 -0
- package/src/shared/hooks/__tests__/condition.test.ts +389 -0
- package/src/shared/hooks/__tests__/cursor-format.test.ts +209 -0
- package/src/shared/hooks/__tests__/evaluate.test.ts +473 -0
- package/src/shared/hooks/__tests__/run.test.ts +159 -0
- package/src/shared/hooks/__tests__/stall.test.ts +75 -0
- package/src/shared/hooks/__tests__/tool-view.test.ts +235 -0
- package/src/shared/hooks/answer.ts +180 -0
- package/src/shared/hooks/condition.ts +341 -0
- package/src/shared/hooks/evaluate.ts +381 -0
- package/src/shared/hooks/formats/claude-code.ts +106 -0
- package/src/shared/hooks/formats/common.ts +31 -0
- package/src/shared/hooks/formats/cursor.ts +261 -0
- package/src/shared/hooks/hook-set.ts +134 -0
- package/src/shared/hooks/matcher.ts +31 -0
- package/src/shared/hooks/messages.ts +38 -0
- package/src/shared/hooks/run.ts +190 -0
- package/src/shared/hooks/setup.ts +209 -0
- package/src/shared/hooks/shell-commands.ts +326 -0
- package/src/shared/hooks/tool-view.ts +406 -0
- package/src/shared/http-retry.ts +139 -0
- package/src/shared/implement-plan-prompt.ts +104 -0
- package/src/shared/json-schema-to-zod.ts +53 -0
- package/src/shared/llm-backend.ts +623 -0
- package/src/shared/llm-proxy.ts +154 -0
- package/src/shared/mcp-manager.ts +161 -0
- package/src/shared/mcp-oauth-detect.ts +80 -0
- package/src/shared/mcp-resolver.ts +338 -0
- package/src/shared/mcp-schema-sanitizer.ts +222 -0
- package/src/shared/mcp-tool-listing.ts +203 -0
- package/src/shared/mcp-transport-guard.ts +81 -0
- package/src/shared/memory-attachment.ts +177 -0
- package/src/shared/memory-retrieval.ts +380 -0
- package/src/shared/model-client.ts +465 -0
- package/src/shared/model-error.ts +551 -0
- package/src/shared/model-facts.ts +30 -0
- package/src/shared/model-lanes.ts +66 -0
- package/src/shared/model-pricing-data.ts +123 -0
- package/src/shared/model-pricing.ts +64 -0
- package/src/shared/model-registry.ts +352 -0
- package/src/shared/persist-decision.ts +47 -0
- package/src/shared/placeholder-resolver.ts +113 -0
- package/src/shared/plan-artifact.ts +255 -0
- package/src/shared/plan-mode-permissions.ts +53 -0
- package/src/shared/plan-mode-prompt.ts +74 -0
- package/src/shared/platform-server-address.ts +124 -0
- package/src/shared/plugin-mount.ts +495 -0
- package/src/shared/plugin-servers.ts +23 -0
- package/src/shared/prompt-sections.ts +205 -0
- package/src/shared/recalled-memories.ts +90 -0
- package/src/shared/registry-endpoint.ts +108 -0
- package/src/shared/run-credential-store.ts +45 -0
- package/src/shared/run-credential.ts +48 -0
- package/src/shared/run-values.ts +154 -0
- package/src/shared/runner-credential-keys.ts +106 -0
- package/src/shared/runner-credential-store.ts +115 -0
- package/src/shared/sender-identity.ts +85 -0
- package/src/shared/service-tier.ts +78 -0
- package/src/shared/session-context.ts +58 -0
- package/src/shared/shell-env.ts +75 -0
- package/src/shared/skill-mount.ts +214 -0
- package/src/shared/skill-resolver.ts +167 -0
- package/src/shared/stall-watchdog.ts +122 -0
- package/src/shared/status-offload.ts +742 -0
- package/src/shared/status.ts +268 -0
- package/src/shared/streaming-scheduler.ts +158 -0
- package/src/shared/subagent-gate.ts +122 -0
- package/src/shared/subagent-rows.ts +39 -0
- package/src/shared/subagents.ts +75 -0
- package/src/shared/synthesized-attachment.ts +100 -0
- package/src/shared/telemetry-content.ts +301 -0
- package/src/shared/thinking-mode.ts +125 -0
- package/src/shared/todos.ts +68 -0
- package/src/shared/tool-kind.ts +140 -0
- package/src/shared/tool-lists.ts +617 -0
- package/src/shared/tool-rounds.ts +151 -0
- package/src/shared/tool-row.ts +346 -0
- package/src/shared/trace-context.ts +35 -0
- package/src/shared/with-timeout.ts +53 -0
- package/src/shared/worker-shutdown.ts +134 -0
- package/src/shared/workspace/__tests__/file-tree.test.ts +210 -0
- package/src/shared/workspace/__tests__/git-credential.test.ts +470 -0
- package/src/shared/workspace/__tests__/git-identity.test.ts +124 -0
- package/src/shared/workspace/__tests__/git-source.test.ts +476 -0
- package/src/shared/workspace/__tests__/local-backend-platform.test.ts +259 -0
- package/src/shared/workspace/__tests__/local-backend.test.ts +160 -0
- package/src/shared/workspace/__tests__/platform-mount.test.ts +378 -0
- package/src/shared/workspace/__tests__/provisioner.test.ts +194 -0
- package/src/shared/workspace/__tests__/session-provision.test.ts +322 -0
- package/src/shared/workspace/__tests__/session-root.test.ts +42 -0
- package/src/shared/workspace/__tests__/stigmer-link.test.ts +278 -0
- package/src/shared/workspace/__tests__/workspace-lock.test.ts +207 -0
- package/src/shared/workspace/__tests__/writeback-coordinator-git.test.ts +244 -0
- package/src/shared/workspace/__tests__/writeback-coordinator.test.ts +495 -0
- package/src/shared/workspace/file-tree.ts +116 -0
- package/src/shared/workspace/git-credential.ts +247 -0
- package/src/shared/workspace/git-identity.ts +41 -0
- package/src/shared/workspace/local-backend.ts +132 -0
- package/src/shared/workspace/platform-dir.ts +163 -0
- package/src/shared/workspace/platform-mount.ts +190 -0
- package/src/shared/workspace/provisioner.ts +119 -0
- package/src/shared/workspace/session-provision.ts +104 -0
- package/src/shared/workspace/session-root.ts +60 -0
- package/src/shared/workspace/sources/empty.ts +19 -0
- package/src/shared/workspace/sources/git.ts +292 -0
- package/src/shared/workspace/sources/local-path.ts +92 -0
- package/src/shared/workspace/stigmer-link.ts +185 -0
- package/src/shared/workspace/types.ts +85 -0
- package/src/shared/workspace/workspace-lock.ts +245 -0
- package/src/shared/workspace/writeback-coordinator.ts +522 -0
- package/src/shared/zip-extract.ts +118 -0
- package/src/tools/__tests__/url-guard.test.ts +155 -0
- package/src/tools/__tests__/web-fetch-tool.test.ts +193 -0
- package/src/tools/index.ts +27 -0
- package/src/tools/url-guard.ts +140 -0
- package/src/tools/web-fetch-tool.ts +278 -0
- package/src/worker.ts +112 -0
- package/src/workflow-source.ts +72 -0
- package/src/workflows/__tests__/barrel.test.ts +21 -0
- package/src/workflows/__tests__/list-plugin-tools.test.ts +82 -0
- package/src/workflows/index.ts +36 -0
- package/src/workflows/list-plugin-tools.ts +70 -0
- package/src/workflows/types.ts +46 -0
|
@@ -0,0 +1,1204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template for the approval hook script that Cursor spawns.
|
|
3
|
+
*
|
|
4
|
+
* This module doesn't execute as a hook itself — it generates the shell script
|
|
5
|
+
* written to the HITL dir as stigmer-approval.sh. Cursor invokes that ONE script
|
|
6
|
+
* for THREE events (registered in .cursor/hooks.json by workspace-setup.ts):
|
|
7
|
+
* - `preToolUse` — fires for built-in tools (Write/Shell/Delete/…), and
|
|
8
|
+
* for MCP calls as `MCP:<tool>`, which it leaves to:
|
|
9
|
+
* - `beforeMCPExecution` — the only event Cursor enforces for MCP tool calls,
|
|
10
|
+
* and the one whose payload names the server
|
|
11
|
+
* (`mcp_server_name`). MCP is therefore gated in
|
|
12
|
+
* exactly ONE place, so a denial is never
|
|
13
|
+
* double-recorded.
|
|
14
|
+
* - `subagentStart` — documented to fire before a sub-agent starts,
|
|
15
|
+
* with its `subagent_type`; only the scope arm
|
|
16
|
+
* answers it. The 1.0.31 local runtime does not
|
|
17
|
+
* fire it for a `task` call (live probe,
|
|
18
|
+
* 2026-10-05), so it is a second line for a
|
|
19
|
+
* runtime that does, never the guard: an
|
|
20
|
+
* `Agent(type, …)` type list is refused at setup
|
|
21
|
+
* (`turn-setup.ts` `checkToolScope`).
|
|
22
|
+
* - `postToolUse` — hands the model what the agent's hooks say after
|
|
23
|
+
* a call. Registered for every turn, as the others
|
|
24
|
+
* are (the SDK keeps the first registration it
|
|
25
|
+
* reads); a turn with no hooks answers it with
|
|
26
|
+
* nothing, at once.
|
|
27
|
+
* The script branches on the payload's `hook_event_name`. An agent's own
|
|
28
|
+
* hooks run inside the runner, which serves them to this script on a local
|
|
29
|
+
* socket (`hook-server.ts`).
|
|
30
|
+
*
|
|
31
|
+
* The hook script:
|
|
32
|
+
* 1. Reads the tool call JSON from stdin
|
|
33
|
+
* 2. Reads the approval state JSON file written by the cursor-runner
|
|
34
|
+
* 3. Evaluates, in order: the agent's tool lists (any event), then
|
|
35
|
+
* auto-approve, approved grants (reinvocation) and — by event — gated
|
|
36
|
+
* built-in tools (preToolUse) or destructive MCP tools (beforeMCPExecution)
|
|
37
|
+
* 4. On a deny, appends the call's identity token to the denial ledger
|
|
38
|
+
* (denials.jsonl) — EVERY deny path records, each tagged with a `kind`
|
|
39
|
+
* (see below), so the ledger is the complete, authoritative record of what
|
|
40
|
+
* this hook blocked this turn. The runner marks approval-kind denials as
|
|
41
|
+
* WAITING_APPROVAL; the full ledger is its attribution set for
|
|
42
|
+
* distinguishing our denials from a FOREIGN hook's (issue #205): a
|
|
43
|
+
* hook-blocked tool with NO ledger entry of any kind was not blocked by us.
|
|
44
|
+
* 5. Returns { "permission": "allow" } or { "permission": "deny" } on stdout
|
|
45
|
+
*
|
|
46
|
+
* Denial kinds (the attribution taxonomy, mirrored in approval-state.ts):
|
|
47
|
+
* - "approval" — the normal gate: pauses the run for user approval.
|
|
48
|
+
* - "secret" — secret hard-block: the agent continues, no pause.
|
|
49
|
+
* - "capture-error" — CAS staging failed, write kept on the deny-gate.
|
|
50
|
+
* - "fail-closed" — approval state file missing, everything gated denies.
|
|
51
|
+
* - "disabled" — the agent's tool lists exclude the tool (or the
|
|
52
|
+
* sub-agent type): the agent continues, no pause,
|
|
53
|
+
* permanent for the run.
|
|
54
|
+
* - "hook" — an agent's hook refused the call, or a person's
|
|
55
|
+
* earlier refusal stood over a hook's allow: the agent
|
|
56
|
+
* continues, no pause; carries the refusal and the
|
|
57
|
+
* hook. An approval a hook asked for carries the hook
|
|
58
|
+
* and its message too.
|
|
59
|
+
* - "hook-unavailable" — the runner's hook server did not answer, so the
|
|
60
|
+
* agent's hooks could not be asked: the call is
|
|
61
|
+
* refused, no pause; unlike "fail-closed" the gate
|
|
62
|
+
* itself worked.
|
|
63
|
+
* Only approval-kind records carry the captured tool_input: a secret write's
|
|
64
|
+
* content must never be persisted, a capture-error's content is
|
|
65
|
+
* UNCLASSIFIED (the staging error means secret classification may never have
|
|
66
|
+
* run), and fail-closed has no state to classify against.
|
|
67
|
+
*
|
|
68
|
+
* Identity extraction runs on the SAME Node.js binary as the runner (its
|
|
69
|
+
* absolute path — process.execPath — is baked into the script at generation
|
|
70
|
+
* time), because the identity token must be byte-identical to the one the
|
|
71
|
+
* runner computes from the parsed stream event. The original grep/cut
|
|
72
|
+
* extraction is kept only as a best-effort fallback if that binary cannot run:
|
|
73
|
+
* grep's `"command":"[^"]*"` truncates at the first JSON-escaped quote, so for
|
|
74
|
+
* a shell command like `printf '%s' "x" > file` the fallback token will NOT
|
|
75
|
+
* match the runner's — the call is still denied (the gate holds) but the
|
|
76
|
+
* denial cannot be overlaid onto the real streamed tool call and a grant for
|
|
77
|
+
* it will not match on reinvocation. All policy decisions are pre-computed by
|
|
78
|
+
* the runner into the state file (and into this generated script); the hook
|
|
79
|
+
* only performs mechanical field extraction and string lookups — the policy
|
|
80
|
+
* itself is authored once in TypeScript (approval-policy.ts /
|
|
81
|
+
* approval-state.ts).
|
|
82
|
+
*
|
|
83
|
+
* Cross-taxonomy identity (the crux):
|
|
84
|
+
* The preToolUse hook and the SDK event stream name the same operation
|
|
85
|
+
* differently — the hook receives PascalCase `tool_name` (`Write` for any file
|
|
86
|
+
* create/edit, `Shell`, `Delete`) while the stream emits lowercase `event.name`
|
|
87
|
+
* (`edit`, `shell`, `delete`). They also name the salient argument differently
|
|
88
|
+
* (`file_path` in the hook input vs `path` in the stream). So the hook and the
|
|
89
|
+
* runner cannot correlate on the raw name. Instead both reduce a tool call to a
|
|
90
|
+
* canonical identity — `base64(category \n salient)` — where `category` is the
|
|
91
|
+
* approval category (`write`/`delete`/`shell`, baked into the case statement
|
|
92
|
+
* below from approval-policy.ts) and `salient` is the resource VALUE (the file
|
|
93
|
+
* path or shell command), which is identical on both sides. The runner mirrors
|
|
94
|
+
* this exactly in approval-state.ts (toolIdentity + grantToken), so a denial
|
|
95
|
+
* recorded here correlates to the streamed tool call, and an approval grant
|
|
96
|
+
* matches the agent's re-attempt on reinvocation.
|
|
97
|
+
*
|
|
98
|
+
* Content-exact identity (the sibling-hole fix): for a file edit the coarse
|
|
99
|
+
* (category, salient) is not enough — approving one edit to a file must not let
|
|
100
|
+
* a DIFFERENT edit to the SAME file ride through. So the hook ALSO computes a
|
|
101
|
+
* CONTENT token `base64(category \n salient \n contentDigest)`, where
|
|
102
|
+
* contentDigest is a sha256 over the edit content (mirror of file-tools.ts
|
|
103
|
+
* contentDigest; see buildContentDigestScript). It allows a built-in when EITHER
|
|
104
|
+
* the content token (a file edit approved with this exact content) OR the coarse
|
|
105
|
+
* token (shell/delete, or a content-less degrade) is granted, and records the
|
|
106
|
+
* content token as the denial identity. The runner grants the content token when
|
|
107
|
+
* it has the approved content (the persisted approval_content_digest), so a
|
|
108
|
+
* sibling edit re-gates; it degrades to the coarse grant only when the content is
|
|
109
|
+
* unrecoverable.
|
|
110
|
+
*
|
|
111
|
+
* Policy evaluation order (first match wins). The approval half is "gate the
|
|
112
|
+
* dangerous set, allow the rest", matching the native harness:
|
|
113
|
+
* 0. Scope guard: not the runner's own agent → allow (never touch the ledger)
|
|
114
|
+
* 1. Missing state file → deny (fail-closed)
|
|
115
|
+
* 1a. Tool lists (the state's `toolScope`, compiled by hook-scope.ts): a tool,
|
|
116
|
+
* MCP server tool or sub-agent type the agent's lists exclude → record
|
|
117
|
+
* kind "disabled", deny with the lists' refusal. Deliberately BEFORE the
|
|
118
|
+
* capture arms, autoApproveAll and every grant: a list says what the agent
|
|
119
|
+
* may call at all, so no approval posture may resurrect an excluded tool
|
|
120
|
+
* and no human is ever offered "approve" on one. The Node snippet only
|
|
121
|
+
* looks names up in the runner's tables; if it cannot run while the agent
|
|
122
|
+
* has lists, the call is denied (fail-closed).
|
|
123
|
+
* 0b. postToolUse event → the hook server's answer (the agent's hooks'
|
|
124
|
+
* context); on a turn with no hook server, nothing, before the pointer
|
|
125
|
+
* is even parsed
|
|
126
|
+
* 1b. subagentStart event that survived 1a → allow (no approval arm applies)
|
|
127
|
+
* 1h. The agent's hooks, when it has any (the hook server answers once per
|
|
128
|
+
* call; an MCP call on beforeMCPExecution): deny → record kind "hook",
|
|
129
|
+
* deny; ask → allow under autoApproveAll or an approved grant, record
|
|
130
|
+
* "unattended" under the unattended mode, else record "approval" (the
|
|
131
|
+
* hook's card); allow → the capture arms still run, then 1i; no decision
|
|
132
|
+
* → every arm below as without hooks; no answer → record
|
|
133
|
+
* "hook-unavailable", deny
|
|
134
|
+
* 1i. After the capture arms, a hook's allow → allow, with its context and
|
|
135
|
+
* any rewrite it made
|
|
136
|
+
* 1c. autoApproveAll (the pre-armed spec.auto_approve_all global bypass) →
|
|
137
|
+
* allow
|
|
138
|
+
* 2. beforeMCPExecution event → the server's tool listed in mcpDestructiveTools,
|
|
139
|
+
* or any tool of a server listed in mcpUnlistedServers:
|
|
140
|
+
* a. name token in approvedGrantTokens → allow (reinvocation grant)
|
|
141
|
+
* b. otherwise → record denial, deny
|
|
142
|
+
* (every other MCP tool falls through → allow; a server lease leaves its
|
|
143
|
+
* server out of both, so its tools fall through)
|
|
144
|
+
* 3. preToolUse event → gated built-in (category non-empty):
|
|
145
|
+
* 0. a git-tracked write or delete in capture mode, or with file review
|
|
146
|
+
* off → allow; a secret-like write left → record kind "secret", deny;
|
|
147
|
+
* any other write or delete with file review off → allow
|
|
148
|
+
* a. identity token in approvedGrantTokens → allow (reinvocation grant)
|
|
149
|
+
* b. category in leasedCategories → allow (run-lifetime scoped lease)
|
|
150
|
+
* c. otherwise → record denial, deny
|
|
151
|
+
* (read-only / ungated built-ins fall through → allow)
|
|
152
|
+
*/
|
|
153
|
+
import { SALIENT_ARG_FIELDS, getBuiltInGatedCategories } from "./approval-policy.js";
|
|
154
|
+
import { SKILL_CONTENT_PATTERN } from "../../shared/skill-mount.js";
|
|
155
|
+
import { normalizeSubAgentType } from "../../shared/tool-lists.js";
|
|
156
|
+
import { CURSOR_HOOK_MCP_PREFIX, ENGINE_EXTRA_SCOPE_KEY, AGENT_SCOPE_KEY, READ_SCOPE_KEY, SCOPE_KEY_PREFIX, TOOL_NAME_PLACEHOLDER, } from "./hook-scope.js";
|
|
157
|
+
import { EDIT_OLD_FIELDS, EDIT_NEW_FIELDS, WRITE_CONTENT_FIELDS, } from "../../shared/file-tools.js";
|
|
158
|
+
import { buildObservationStagingScript, buildSecretClassifyScript, CAS_OBSERVATIONS_DIRNAME } from "./cas-observations.js";
|
|
159
|
+
import { HOOK_ASK_DIGEST_PREFIX } from "./approval-state.js";
|
|
160
|
+
import { UNLISTED_MCP_APPROVAL_MESSAGE } from "../../shared/approval-policy.js";
|
|
161
|
+
// Shown to the model when the gate denies a tool call. It must NOT teach the
|
|
162
|
+
// model to ask for permission in prose or to "stop and wait" — that framing
|
|
163
|
+
// makes the model narrate approval requests instead of invoking tools (the
|
|
164
|
+
// platform's approval surface is driven by tool invocation; see
|
|
165
|
+
// formatToolApprovalProtocol in prompt-builder.ts). Instead it tells the model
|
|
166
|
+
// the approval is automatic and that it should not retry or work around THIS
|
|
167
|
+
// action. Embedded verbatim into the generated hook script inside a
|
|
168
|
+
// single-quoted bash echo of a JSON object, so the text must contain no double
|
|
169
|
+
// quotes, apostrophes, or backslashes.
|
|
170
|
+
export const APPROVAL_REQUIRED_AGENT_MESSAGE = "This action has been submitted to the user for approval automatically; you " +
|
|
171
|
+
"do not need to ask for permission. This is the platform approval gate working " +
|
|
172
|
+
"as intended — it is not an error and not a Cursor misconfiguration, so never " +
|
|
173
|
+
"tell the user to change Cursor settings or enable hooks. Do not retry it or " +
|
|
174
|
+
"attempt a workaround for this action. The platform will resume you " +
|
|
175
|
+
"automatically after the user responds — continue with the rest of the task.";
|
|
176
|
+
// Shown to the model when the gate denies a tool call under UNATTENDED
|
|
177
|
+
// approval mode: the lane the run came through (a Slack or WhatsApp
|
|
178
|
+
// channel, a chat link's guest) has no approver, so — unlike APPROVAL_REQUIRED_AGENT_MESSAGE — this
|
|
179
|
+
// must NOT promise a resume: the deny is final for this turn and the model
|
|
180
|
+
// must adapt. It also enforces the anti-leak posture: the end user hears a
|
|
181
|
+
// plain-language explanation, never tool/approval vocabulary. Same embedding
|
|
182
|
+
// constraint (single-quoted bash echo of a JSON object): no double quotes,
|
|
183
|
+
// apostrophes, or backslashes. Mirrors the native gate skip message
|
|
184
|
+
// (middleware/approval-gate.ts unattendedSkipMessage) in intent.
|
|
185
|
+
export const UNATTENDED_SKIP_AGENT_MESSAGE = "This action was skipped automatically because it requires an approval that " +
|
|
186
|
+
"is not available in this conversation. This is the platform approval gate " +
|
|
187
|
+
"working as intended — it is not an error and not a Cursor misconfiguration. " +
|
|
188
|
+
"Do not retry it or attempt a workaround; it will not be resumed. Adapt your " +
|
|
189
|
+
"plan, and explain to the user in plain language what you could not do and " +
|
|
190
|
+
"what they can do instead — never mention tools, approvals, or platform " +
|
|
191
|
+
"mechanics.";
|
|
192
|
+
// Shown to the model when a secret-like gitignored write is hard-blocked.
|
|
193
|
+
// Unlike APPROVAL_REQUIRED_AGENT_MESSAGE, this must NOT promise a resume:
|
|
194
|
+
// the write is discarded and never captured for review, so the model must move on
|
|
195
|
+
// rather than wait or retry. Same embedding constraint (single-quoted bash echo
|
|
196
|
+
// of a JSON object): no double quotes, apostrophes, or backslashes.
|
|
197
|
+
export const SECRET_BLOCKED_AGENT_MESSAGE = "This file was blocked for security because its path matches a secret-like " +
|
|
198
|
+
"pattern Stigmer will not capture for review. Nothing was written. This is the " +
|
|
199
|
+
"platform safety gate working as intended — it is not an error and not a Cursor " +
|
|
200
|
+
"misconfiguration, so never tell the user to change Cursor settings or enable " +
|
|
201
|
+
"hooks. Do not retry this write or attempt a workaround; the write will not be " +
|
|
202
|
+
"applied. Continue with the rest of the task.";
|
|
203
|
+
// Shown to the model when the agent has tool lists but the hook could not
|
|
204
|
+
// evaluate them (the runner's Node binary would not run, or the state would
|
|
205
|
+
// not parse): the call is refused, since a list the hook cannot read must not
|
|
206
|
+
// widen to "every tool". Same embedding constraint (single-quoted bash echo of
|
|
207
|
+
// a JSON object): no double quotes, apostrophes, or backslashes.
|
|
208
|
+
const SCOPE_UNAVAILABLE_AGENT_MESSAGE = "This tool call was refused because the platform could not check it against " +
|
|
209
|
+
"this agent tool lists. Do not retry it; continue without it and tell the " +
|
|
210
|
+
"user plainly what you could not do.";
|
|
211
|
+
// Shown to the model when the agent has hooks but the gate could not reach
|
|
212
|
+
// them (the runner's hook server did not answer): a hook that cannot be
|
|
213
|
+
// asked must not be skipped, so the call is refused. Same embedding
|
|
214
|
+
// constraint (single-quoted bash echo of a JSON object): no double quotes,
|
|
215
|
+
// apostrophes, or backslashes.
|
|
216
|
+
const HOOKS_UNAVAILABLE_AGENT_MESSAGE = "This tool call was refused because the platform could not run this agent hooks " +
|
|
217
|
+
"for it. Do not retry it; continue without it and tell the user plainly what you " +
|
|
218
|
+
"could not do.";
|
|
219
|
+
/**
|
|
220
|
+
* Build the inline client that asks the runner's hook server about a call
|
|
221
|
+
* (`hook-server.ts`), run on the runner's own Node like the identity
|
|
222
|
+
* extractor. It reads the hook payload on stdin and takes the socket, the
|
|
223
|
+
* turn's token, the mode (`pre` or `post`), and the call's identity and
|
|
224
|
+
* coarse tokens as arguments. For `pre` it prints seven lines: the decision
|
|
225
|
+
* (`allow`, `deny`, `ask`, `refused`, `none`, or `error` when the server did
|
|
226
|
+
* not answer), the deciding plugin's slug in base64 (`=` for the agent's own
|
|
227
|
+
* block, empty when no hook decided), then base64 of the allow, deny,
|
|
228
|
+
* approval and unattended answers and of the message the ledger records.
|
|
229
|
+
* For `post` it prints the answer itself, `{}` when the server did not
|
|
230
|
+
* answer (a hook after the call can no longer stop it). No timeout of its
|
|
231
|
+
* own: Cursor's timeout on the hook entry bounds the wait. Authored as part
|
|
232
|
+
* of a single-quoted bash string, so it contains no single quotes.
|
|
233
|
+
*/
|
|
234
|
+
export function buildHookClientScript() {
|
|
235
|
+
return [
|
|
236
|
+
`const net=require("net");`,
|
|
237
|
+
`const [sock,tok,mode,id,coarse,exact]=process.argv.slice(1);`,
|
|
238
|
+
`let input="";process.stdin.setEncoding("utf8");process.stdin.on("data",(c)=>{input+=c;});`,
|
|
239
|
+
`process.stdin.on("end",()=>{`,
|
|
240
|
+
`let payload=null;try{payload=JSON.parse(input);}catch(e){}`,
|
|
241
|
+
`let buf="",done=false;`,
|
|
242
|
+
`const fail=()=>{if(done)return;done=true;process.stdout.write(mode==="post"?"{}":"error");process.exit(0);};`,
|
|
243
|
+
`const b=(x)=>Buffer.from(String(x===undefined||x===null?"":x),"utf8").toString("base64");`,
|
|
244
|
+
`const c=net.createConnection(sock);`,
|
|
245
|
+
`c.setEncoding("utf8");`,
|
|
246
|
+
`c.on("error",fail);`,
|
|
247
|
+
`c.on("connect",()=>{c.write(JSON.stringify({token:tok,mode:mode,payload:payload,identity:id,coarse:coarse,exact:exact})+"\\n");});`,
|
|
248
|
+
`c.on("data",(d)=>{buf+=d;const i=buf.indexOf("\\n");if(i<0)return;`,
|
|
249
|
+
`let r=null;try{r=JSON.parse(buf.slice(0,i));}catch(e){return fail();}`,
|
|
250
|
+
`if(!r||typeof r!=="object"||r.error!==undefined)return fail();`,
|
|
251
|
+
`done=true;c.end();`,
|
|
252
|
+
`if(mode==="post"){process.stdout.write(typeof r.response==="string"?r.response:"{}");process.exit(0);}`,
|
|
253
|
+
`const h=typeof r.hook==="string"?(r.hook===""?"=":b(r.hook)):"";`,
|
|
254
|
+
`process.stdout.write([String(r.decision||"error"),h,b(r.allow),b(r.deny),b(r.approval),b(r.unattended),b(r.message)].join("\\n"));process.exit(0);});`,
|
|
255
|
+
`c.on("end",fail);`,
|
|
256
|
+
`});`,
|
|
257
|
+
].join("");
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Build the bash `case` arms that map an incoming hook `tool_name` to its
|
|
261
|
+
* canonical approval category. Generated from approval-policy.ts so the hook and
|
|
262
|
+
* the runner never disagree on which built-ins are gated or how they categorize.
|
|
263
|
+
*/
|
|
264
|
+
function buildCategoryCaseArms() {
|
|
265
|
+
const byCategory = new Map();
|
|
266
|
+
for (const [name, category] of getBuiltInGatedCategories()) {
|
|
267
|
+
const names = byCategory.get(category) ?? [];
|
|
268
|
+
names.push(name);
|
|
269
|
+
byCategory.set(category, names);
|
|
270
|
+
}
|
|
271
|
+
const arms = [];
|
|
272
|
+
for (const [category, names] of byCategory) {
|
|
273
|
+
const pattern = names.map((n) => `"${n}"`).join("|");
|
|
274
|
+
arms.push(` ${pattern}) CATEGORY="${category}" ;;`);
|
|
275
|
+
}
|
|
276
|
+
return arms.join("\n");
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Build the inline content-digest extractor — a BYTE-IDENTICAL MIRROR of
|
|
280
|
+
* {@link file://../../shared/file-tools.ts} `contentDigest()`.
|
|
281
|
+
*
|
|
282
|
+
* Computes the same `sha256(JSON.stringify(["w", content]))` /
|
|
283
|
+
* `sha256(JSON.stringify(["e", old, new]))` from the parsed tool_input `a`,
|
|
284
|
+
* using the SAME union field lists injected from file-tools.ts (so the
|
|
285
|
+
* file_path/path & content/contents cross-layer name divergence is normalized
|
|
286
|
+
* identically) and the SAME Node binary as the runner — so the hook-side and
|
|
287
|
+
* runner-side digests agree. Any change to the format here or in
|
|
288
|
+
* file-tools.ts MUST be mirrored in the other. Empty (`dig===""`) for a tool
|
|
289
|
+
* with no edit content (shell/delete/read/MCP).
|
|
290
|
+
*
|
|
291
|
+
* Authored as part of a single-quoted bash string, so the JS must not contain
|
|
292
|
+
* single quotes (JSON.stringify emits double quotes).
|
|
293
|
+
*/
|
|
294
|
+
function buildContentDigestScript() {
|
|
295
|
+
const wc = JSON.stringify(WRITE_CONTENT_FIELDS);
|
|
296
|
+
const eo = JSON.stringify(EDIT_OLD_FIELDS);
|
|
297
|
+
const en = JSON.stringify(EDIT_NEW_FIELDS);
|
|
298
|
+
return [
|
|
299
|
+
`const pick=(fl)=>{for(const f of fl){const v=a[f];if(typeof v==="string")return v;}return null;};`,
|
|
300
|
+
`const sha=(x)=>require("crypto").createHash("sha256").update(x,"utf8").digest("hex");`,
|
|
301
|
+
`let dig="";`,
|
|
302
|
+
`const _wc=pick(${wc});`,
|
|
303
|
+
`if(_wc!==null){dig=sha(JSON.stringify(["w",_wc]));}`,
|
|
304
|
+
`else{const _o=pick(${eo}),_n=pick(${en});if(_o!==null||_n!==null){dig=sha(JSON.stringify(["e",_o===null?"":_o,_n===null?"":_n]));}}`,
|
|
305
|
+
].join("");
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Build the inline tool-lists evaluator (policy arm 1a), part of the identity
|
|
309
|
+
* extractor below. It reads the turn's state file (`process.argv[1]`), decodes
|
|
310
|
+
* `toolScope` (`encodeHookToolScope`) and looks the call up in the tables `hook-scope.ts` compiled from
|
|
311
|
+
* the runner's `ToolScope`: it decides nothing those tables do not already
|
|
312
|
+
* say, so the list rules stay in `shared/tool-lists.ts` alone. Sets:
|
|
313
|
+
* - `sv`: "" (in scope, or no lists), "E" (could not evaluate), else
|
|
314
|
+
* base64(JSON) of the deny response, the refusal naming the tool;
|
|
315
|
+
* - `stk`: the ledger token a refusal is recorded under, the scope token
|
|
316
|
+
* (`approval-state.ts` `scopeRefusalToken`): keyed by the built-in's
|
|
317
|
+
* `scopeKey` (every engine extra shares one), by `server/tool` for an MCP
|
|
318
|
+
* call (the `mcpToolKey` form), by the `Task` key for a sub-agent start;
|
|
319
|
+
* and, for a tool the lists may exclude only in part (`READ_SCOPE_KEY`,
|
|
320
|
+
* `AGENT_SCOPE_KEY`), discriminated by the call: the path as given, the
|
|
321
|
+
* normalized sub-agent type;
|
|
322
|
+
* - `smsg`: base64 of the refusal text, which the ledger carries so the turn
|
|
323
|
+
* boundary can write the very words the model read onto the refused row.
|
|
324
|
+
* An excluded `Read` is let through only when the file's REAL path lies
|
|
325
|
+
* inside `readRoot` (the platform dir's real path, "" on a turn with no
|
|
326
|
+
* platform link), the path resolved against the payload's `cwd`, else the
|
|
327
|
+
* baked workspace root (`process.argv[2]`); a missing file is refused. Under
|
|
328
|
+
* lists that deny `Skill`, a `Read` whose real path, relative to `skillRoot`
|
|
329
|
+
* (the platform dir's real path), matches `SKILL_CONTENT_PATTERN` (its
|
|
330
|
+
* source and flags embedded) is refused whether or not `Read` is in scope;
|
|
331
|
+
* the real path is the filesystem's own spelling (`realpathSync.native`),
|
|
332
|
+
* since a case-insensitive filesystem opens `skills/` under spellings that
|
|
333
|
+
* lower case does not fold (U+017F, the Kelvin sign), and both paths are
|
|
334
|
+
* then compared in lower case, since the pattern holds a case-insensitive
|
|
335
|
+
* filesystem's view of the same file. A
|
|
336
|
+
* `Task` call naming its `subagent_type` is held to `Agent(type, …)` here as
|
|
337
|
+
* well as at `subagentStart`, refused under the same discriminator. Both are a
|
|
338
|
+
* second line for a runtime that fires them, never the guard: the 1.0.31
|
|
339
|
+
* local runtime fires neither for a `task` call (live probe, 2026-10-05), so
|
|
340
|
+
* an `Agent(type, …)` type list is refused at setup (`turn-setup.ts`). A
|
|
341
|
+
* sub-agent type is normalized by the source of `normalizeSubAgentType`
|
|
342
|
+
* itself, embedded, so the hook and the resolver share one rule. Expects `t`, `name`, `a`, `s`, `b`, `ev`
|
|
343
|
+
* and `srv` in scope.
|
|
344
|
+
*/
|
|
345
|
+
function buildScopeEvalScript() {
|
|
346
|
+
const placeholder = JSON.stringify(TOOL_NAME_PLACEHOLDER);
|
|
347
|
+
const mcpPrefix = JSON.stringify(CURSOR_HOOK_MCP_PREFIX);
|
|
348
|
+
const keyPrefix = JSON.stringify(SCOPE_KEY_PREFIX);
|
|
349
|
+
const extraKey = JSON.stringify(ENGINE_EXTRA_SCOPE_KEY);
|
|
350
|
+
const readKey = JSON.stringify(READ_SCOPE_KEY);
|
|
351
|
+
const agentKey = JSON.stringify(AGENT_SCOPE_KEY);
|
|
352
|
+
const skillPattern = JSON.stringify(SKILL_CONTENT_PATTERN.source);
|
|
353
|
+
const skillFlags = JSON.stringify(SKILL_CONTENT_PATTERN.flags);
|
|
354
|
+
return [
|
|
355
|
+
`let sv="",stk="",smsg="",disc="";`,
|
|
356
|
+
`try{`,
|
|
357
|
+
`const st=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"));`,
|
|
358
|
+
`const sc=st.toolListsRestricted===true?JSON.parse(Buffer.from(String(st.toolScope),"base64").toString("utf8")):null;`,
|
|
359
|
+
`if(sc&&sc.restricted===true){`,
|
|
360
|
+
`const own=(o,k)=>o!==null&&typeof o==="object"&&Object.prototype.hasOwnProperty.call(o,k);`,
|
|
361
|
+
`let ok=true,label=name,key=name;`,
|
|
362
|
+
`const nt=(${normalizeSubAgentType.toString()});`,
|
|
363
|
+
`const typeOk=(lt)=>own(sc.subAgentTypes.types,lt)?sc.subAgentTypes.types[lt]===true:sc.subAgentTypes.otherTypes===true;`,
|
|
364
|
+
`if(ev==="subagentStart"){`,
|
|
365
|
+
`const ty=typeof t.subagent_type==="string"?t.subagent_type:"";`,
|
|
366
|
+
`const lt=nt(ty);`,
|
|
367
|
+
`ok=typeOk(lt);`,
|
|
368
|
+
`label="Agent("+ty+")";`,
|
|
369
|
+
`disc=lt;`,
|
|
370
|
+
`key=own(sc.builtins,"Task")?sc.builtins.Task.key:"Task";`,
|
|
371
|
+
`}else if(ev==="beforeMCPExecution"){`,
|
|
372
|
+
`const sm=own(sc.mcp.servers,srv)?sc.mcp.servers[srv]:null;`,
|
|
373
|
+
`ok=sm?(own(sm.tools,name)?sm.tools[name]===true:sm.otherTools===true):sc.mcp.otherServers===true;`,
|
|
374
|
+
`key=srv+"/"+name;`,
|
|
375
|
+
`}else if(!name.startsWith(${mcpPrefix})){`,
|
|
376
|
+
`const e=own(sc.builtins,name)?sc.builtins[name]:null;`,
|
|
377
|
+
`ok=e?e.allowed===true:sc.otherBuiltins===true;`,
|
|
378
|
+
`key=e?e.key:${extraKey};`,
|
|
379
|
+
`if(key===${readKey})disc=s;`,
|
|
380
|
+
`if(ok&&key===${agentKey}&&typeof a.subagent_type==="string"&&a.subagent_type!==""){`,
|
|
381
|
+
`const lt=nt(a.subagent_type);`,
|
|
382
|
+
`if(!typeOk(lt)){ok=false;label="Agent("+a.subagent_type+")";disc=lt;}`,
|
|
383
|
+
`}`,
|
|
384
|
+
`if(!ok&&key===${readKey}&&s&&typeof sc.readRoot==="string"&&sc.readRoot!==""){`,
|
|
385
|
+
`const pth=require("path");`,
|
|
386
|
+
`const base=typeof t.cwd==="string"&&t.cwd?t.cwd:(process.argv[2]||"/");`,
|
|
387
|
+
`try{ok=require("fs").realpathSync(pth.resolve(base,s)).startsWith(sc.readRoot+pth.sep);}catch(e){ok=false;}`,
|
|
388
|
+
`}`,
|
|
389
|
+
`if(ok&&key===${readKey}&&s&&typeof sc.skillRoot==="string"&&sc.skillRoot!==""){`,
|
|
390
|
+
`const pth=require("path");`,
|
|
391
|
+
`const base=typeof t.cwd==="string"&&t.cwd?t.cwd:(process.argv[2]||"/");`,
|
|
392
|
+
`try{const rel=pth.relative(sc.skillRoot.toLowerCase(),require("fs").realpathSync.native(pth.resolve(base,s)).toLowerCase()).split(pth.sep).join("/");`,
|
|
393
|
+
`if(!rel.startsWith("../")&&rel!==".."&&!pth.isAbsolute(rel)&&new RegExp(${skillPattern},${skillFlags}).test(rel))ok=false;}catch(e){}`,
|
|
394
|
+
`}`,
|
|
395
|
+
`}`,
|
|
396
|
+
`if(!ok){`,
|
|
397
|
+
`const msg=String(sc.refusal).split(${placeholder}).join(label);`,
|
|
398
|
+
`sv=b(JSON.stringify(ev==="subagentStart"?{permission:"deny",user_message:msg}:{permission:"deny",agent_message:msg,user_message:msg}));`,
|
|
399
|
+
`stk=b(${keyPrefix}+key+"\\n"+disc);`,
|
|
400
|
+
`smsg=b(msg);`,
|
|
401
|
+
`}`,
|
|
402
|
+
`}`,
|
|
403
|
+
`}catch(e){sv="E";stk="";smsg="";}`,
|
|
404
|
+
].join("");
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Build the inline Node.js identity extractor embedded in the hook script.
|
|
408
|
+
*
|
|
409
|
+
* Parses the hook's stdin JSON properly (the bash fallback's grep truncates
|
|
410
|
+
* string values at the first escaped quote) and emits TWELVE lines: tool_name,
|
|
411
|
+
* canonical category, coarse identity token, MCP name-token, hook_event_name
|
|
412
|
+
* (the event discriminator: `preToolUse` for built-ins, `beforeMCPExecution`
|
|
413
|
+
* for MCP), base64(JSON(tool_input)) — the authoritative pre-execution args the
|
|
414
|
+
* runner overlays onto the gated tool call for the approval preview — the
|
|
415
|
+
* CONTENT token (base64(category \n salient \n contentDigest), empty when the
|
|
416
|
+
* tool has no edit content), base64(salient), and mcp_server_name (the MCP
|
|
417
|
+
* server slug the beforeMCPExecution payload carries; empty for built-ins),
|
|
418
|
+
* then the tool-lists verdict, its ledger token and its refusal text
|
|
419
|
+
* ({@link buildScopeEvalScript}).
|
|
420
|
+
* It runs with two arguments: the turn's state file and the baked workspace
|
|
421
|
+
* root. The token encodings must stay byte-identical to
|
|
422
|
+
* grantToken()/contentToken()/scopeRefusalToken() in approval-state.ts.
|
|
423
|
+
*
|
|
424
|
+
* Authored as a single-quoted bash string, so the JS must not contain single
|
|
425
|
+
* quotes. The category map, salient field list, and edit/content field lists are
|
|
426
|
+
* baked from approval-policy.ts / file-tools.ts — the same source the runner
|
|
427
|
+
* uses — so the two sides can never disagree.
|
|
428
|
+
*/
|
|
429
|
+
function buildNodeIdentityScript() {
|
|
430
|
+
const categoryMap = {};
|
|
431
|
+
for (const [name, category] of getBuiltInGatedCategories()) {
|
|
432
|
+
categoryMap[name] = category;
|
|
433
|
+
}
|
|
434
|
+
const categories = JSON.stringify(categoryMap);
|
|
435
|
+
const fields = JSON.stringify(SALIENT_ARG_FIELDS);
|
|
436
|
+
return [
|
|
437
|
+
`const t=JSON.parse(require("fs").readFileSync(0,"utf8"));`,
|
|
438
|
+
`const name=typeof t.tool_name==="string"?t.tool_name:"";`,
|
|
439
|
+
`const cat=(${categories})[name]||"";`,
|
|
440
|
+
// tool_input is an object for built-ins (preToolUse) but a JSON STRING for
|
|
441
|
+
// MCP tools (beforeMCPExecution). Parse the string form so the captured
|
|
442
|
+
// input is the same object shape on both paths.
|
|
443
|
+
`let a={};`,
|
|
444
|
+
`if(t.tool_input&&typeof t.tool_input==="object"){a=t.tool_input;}`,
|
|
445
|
+
`else if(typeof t.tool_input==="string"){try{const p=JSON.parse(t.tool_input);if(p&&typeof p==="object")a=p;}catch(e){}}`,
|
|
446
|
+
`let s="";`,
|
|
447
|
+
`for(const f of ${fields}){const v=a[f];if(typeof v==="string"&&v){s=v;break;}}`,
|
|
448
|
+
`const b=(x)=>Buffer.from(x,"utf8").toString("base64");`,
|
|
449
|
+
// Content digest of the edit (mirror of file-tools.ts contentDigest); `dig`
|
|
450
|
+
// is "" for a non-edit tool, in which case the content token (line 7) is "".
|
|
451
|
+
buildContentDigestScript(),
|
|
452
|
+
`const ev=typeof t.hook_event_name==="string"?t.hook_event_name:"";`,
|
|
453
|
+
`const srv=typeof t.mcp_server_name==="string"?t.mcp_server_name:"";`,
|
|
454
|
+
buildScopeEvalScript(),
|
|
455
|
+
// Line 6 is base64(JSON(tool_input)): the AUTHORITATIVE pre-execution args
|
|
456
|
+
// the runner overlays onto the gated tool call so the approval card can show
|
|
457
|
+
// the proposed change before the user approves. Base64 keeps the bash side
|
|
458
|
+
// free of quoting/escaping concerns even for large multi-line file content.
|
|
459
|
+
// Line 7 is the CONTENT token (empty when no digest) — the exact-identity
|
|
460
|
+
// grant the runner authorizes for a file edit. Line 8 is base64(salient) —
|
|
461
|
+
// the raw resource value (file path / command) capture mode needs to run
|
|
462
|
+
// `git check-ignore` on a file path; base64 keeps newlines/quotes out of the
|
|
463
|
+
// line-oriented bash parse. Line 9 is mcp_server_name — the server half of
|
|
464
|
+
// the destructive-tool key (a bare slug, never quoted/escaped, so it rides
|
|
465
|
+
// as a plain line).
|
|
466
|
+
// Lines 10 to 12 are the tool-lists verdict, its ledger token and its
|
|
467
|
+
// refusal text (buildScopeEvalScript), each a single base64 line or a
|
|
468
|
+
// sentinel.
|
|
469
|
+
// A call's key is its approval category, else the hook's name for the
|
|
470
|
+
// tool (a hook may ask on any tool); an MCP call's is `server/tool`.
|
|
471
|
+
// Line 13 is the token an approval of a hook's ask is granted under when
|
|
472
|
+
// the call has no file content: its identity and the digest of its whole
|
|
473
|
+
// input (mirror of approval-state.ts hookAskDigest).
|
|
474
|
+
`const key=cat||name;`,
|
|
475
|
+
`const hk=ev==="beforeMCPExecution"?srv+"/"+name:key;`,
|
|
476
|
+
`const hs=ev==="beforeMCPExecution"?"":s;`,
|
|
477
|
+
`const hd="${HOOK_ASK_DIGEST_PREFIX}"+require("crypto").createHash("sha256").update(JSON.stringify(a),"utf8").digest("hex");`,
|
|
478
|
+
`process.stdout.write(name+"\\n"+cat+"\\n"+b(key+"\\n"+s)+"\\n"+b(srv+"/"+name+"\\n")+"\\n"+ev+"\\n"+b(JSON.stringify(a))+"\\n"+(dig?b(key+"\\n"+s+"\\n"+dig):"")+"\\n"+b(s)+"\\n"+srv+"\\n"+sv+"\\n"+stk+"\\n"+smsg+"\\n"+b(hk+"\\n"+hs+"\\n"+hd));`,
|
|
479
|
+
].join("");
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Generates the STABLE bash hook script content.
|
|
483
|
+
*
|
|
484
|
+
* The script is STABLE across executions in a runner process — its only inputs
|
|
485
|
+
* are the absolute path of the active-turn pointer (and the runner's Node
|
|
486
|
+
* binary), both constant for a given workspace. This is deliberate and
|
|
487
|
+
* load-bearing: the Cursor SDK loads `<workspace>/.cursor/hooks.json` (the hook
|
|
488
|
+
* script PATH) ONCE per runner process and caches it, ignoring later
|
|
489
|
+
* per-execution rewrites. A per-session script with per-session baked paths
|
|
490
|
+
* therefore gets cached at the FIRST execution and reused for every later one,
|
|
491
|
+
* recording their denials into the FIRST session's ledger while each later runner
|
|
492
|
+
* reads its own (empty) ledger and silently completes — the no-approval-button /
|
|
493
|
+
* "execution completed" regression. Keeping the script stable and resolving the
|
|
494
|
+
* CURRENT turn's artifacts from the pointer (which bash re-reads every
|
|
495
|
+
* invocation; see {@link ActiveTurnPointer}/writeActiveTurnPointer) makes a
|
|
496
|
+
* long-lived multi-session runner correct.
|
|
497
|
+
*
|
|
498
|
+
* From the pointer the script reads the current turn's approval-state file (the
|
|
499
|
+
* single source of truth for the dynamic inputs: autoApproveAll, leasedCategories,
|
|
500
|
+
* mcpDestructiveTools, toolScope, approvedGrantTokens), denial ledger, and
|
|
501
|
+
* runner PID. The
|
|
502
|
+
* static policy (which built-ins are gated, their categories, the salient arg
|
|
503
|
+
* fields) is baked at generation time from approval-policy.ts.
|
|
504
|
+
*
|
|
505
|
+
* The identity token encoding (`base64(key \n salient)`) must stay byte-identical
|
|
506
|
+
* to grantToken() in approval-state.ts.
|
|
507
|
+
*
|
|
508
|
+
* Scope guard (the crux of issue #173): the Cursor SDK loads project hooks from
|
|
509
|
+
* `<workspace>/.cursor/hooks.json`, the SAME per-repo surface every Cursor client
|
|
510
|
+
* reads. When a session runs against the user's real repo, the user's own
|
|
511
|
+
* interactive Cursor IDE would otherwise load and run this hook too — gating the
|
|
512
|
+
* IDE, polluting the denial ledger, and (in multi-root windows) failing closed.
|
|
513
|
+
* We make the gate apply ONLY to the runner's own agent by checking, on every
|
|
514
|
+
* invocation, whether the runner PID (FROM THE POINTER) is an ancestor of the
|
|
515
|
+
* hook process. The SDK runs hooks in-process via child_process, so the runner's
|
|
516
|
+
* own agent (and its delegated sub-agents) spawn the hook as a descendant of the
|
|
517
|
+
* runner; any other Cursor client spawns it under a different process tree. A
|
|
518
|
+
* non-descendant invocation is allowed immediately and never touches the ledger.
|
|
519
|
+
* Combined with pointer teardown, a leftover hooks.json is self-neutralizing:
|
|
520
|
+
* once the turn ends (pointer removed) or the runner exits (PID dead), no
|
|
521
|
+
* invocation gates, so the gate is inert.
|
|
522
|
+
*/
|
|
523
|
+
/**
|
|
524
|
+
* The question for a tool of a server whose tools could not be listed, as a
|
|
525
|
+
* bash double-quoted string body with the tool's name spliced in at
|
|
526
|
+
* `{{tool_name}}`. The message holds no double quote, backslash, `$` or
|
|
527
|
+
* backtick, so it is embedded as it is.
|
|
528
|
+
*/
|
|
529
|
+
function unlistedMessage(toolNameExpression) {
|
|
530
|
+
return UNLISTED_MCP_APPROVAL_MESSAGE.replace("{{tool_name}}", toolNameExpression);
|
|
531
|
+
}
|
|
532
|
+
export function generateHookScript(activePointerPath, workspaceRoot = "") {
|
|
533
|
+
const salientFields = SALIENT_ARG_FIELDS.join(" ");
|
|
534
|
+
const categoryCaseArms = buildCategoryCaseArms();
|
|
535
|
+
const nodeIdentityScript = buildNodeIdentityScript();
|
|
536
|
+
const observationStagingScript = buildObservationStagingScript();
|
|
537
|
+
const secretClassifyScript = buildSecretClassifyScript();
|
|
538
|
+
const hookClientScript = buildHookClientScript();
|
|
539
|
+
const nodeBin = process.execPath;
|
|
540
|
+
return `#!/bin/bash
|
|
541
|
+
# Stigmer HITL approval hook for Cursor (preToolUse + beforeMCPExecution).
|
|
542
|
+
# Generated by cursor-runner — do not edit manually.
|
|
543
|
+
#
|
|
544
|
+
# Reads a tool call from stdin (JSON), checks the approval state file, returns a
|
|
545
|
+
# permission decision on stdout (JSON). Branches on hook_event_name: MCP tools
|
|
546
|
+
# are gated on beforeMCPExecution, built-ins on preToolUse (preToolUse does not
|
|
547
|
+
# enforce MCP), sub-agent types on subagentStart. On a deny, appends the call's
|
|
548
|
+
# canonical identity token to the denial ledger so the runner can mark the
|
|
549
|
+
# gated tool call as WAITING_APPROVAL.
|
|
550
|
+
# See hook-script.ts for the cross-taxonomy identity design.
|
|
551
|
+
|
|
552
|
+
set -euo pipefail
|
|
553
|
+
|
|
554
|
+
INPUT=$(cat)
|
|
555
|
+
|
|
556
|
+
NODE_BIN="${nodeBin}"
|
|
557
|
+
ACTIVE_FILE="${activePointerPath}"
|
|
558
|
+
|
|
559
|
+
# --- 0b, at once: after a call on a turn with no hooks ----------------------
|
|
560
|
+
# postToolUse is registered for every turn; a turn whose pointer names no hook
|
|
561
|
+
# server has nothing to add, so it answers before any Node or scope walk.
|
|
562
|
+
case "$INPUT" in
|
|
563
|
+
*'"hook_event_name":"postToolUse"'*)
|
|
564
|
+
if [ ! -f "$ACTIVE_FILE" ] || ! grep -q '"hookSocket":"[^"]' "$ACTIVE_FILE" 2>/dev/null; then
|
|
565
|
+
echo '{}'
|
|
566
|
+
exit 0
|
|
567
|
+
fi
|
|
568
|
+
;;
|
|
569
|
+
esac
|
|
570
|
+
# Baked workspace root for capture-mode's gitignore check (empty in unit tests
|
|
571
|
+
# that don't exercise capture mode; the check then falls back to the path's dir).
|
|
572
|
+
GIT_ROOT="${workspaceRoot}"
|
|
573
|
+
|
|
574
|
+
# --- Resolve the CURRENT turn from the runner-written pointer ----------------
|
|
575
|
+
# The Cursor SDK caches .cursor/hooks.json (the hook script PATH) for the runner
|
|
576
|
+
# process, so THIS script is stable across executions and the per-turn pointer
|
|
577
|
+
# (active.json) — which bash re-reads on every invocation — is the only thing
|
|
578
|
+
# that changes. It names the CURRENT turn's approval-state, denial ledger, and
|
|
579
|
+
# runner PID. This indirection is what makes a long-lived runner correct: a
|
|
580
|
+
# per-session script baked with per-session paths would be cached at the FIRST
|
|
581
|
+
# execution and reused for every later one, recording their denials to the FIRST
|
|
582
|
+
# session's ledger while each later runner reads its own empty ledger and
|
|
583
|
+
# silently completes (the no-approval-button / "completed" regression).
|
|
584
|
+
#
|
|
585
|
+
# A missing/garbled pointer means no active Stigmer turn (between turns, after
|
|
586
|
+
# teardown, or a dead runner) -> allow (inert), matching the
|
|
587
|
+
# leftover-hooks.json-is-inert invariant (issue #173).
|
|
588
|
+
if [ ! -f "$ACTIVE_FILE" ]; then
|
|
589
|
+
echo '{"permission":"allow"}'
|
|
590
|
+
exit 0
|
|
591
|
+
fi
|
|
592
|
+
PTR=$(ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e 'const p=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"));process.stdout.write((p.stateFile||"")+"\\n"+(p.ledgerFile||"")+"\\n"+((p.runnerPid==null)?"":String(p.runnerPid))+"\\n"+(p.hookSocket||"")+"\\n"+(p.hookToken||""))' "$ACTIVE_FILE" 2>/dev/null || true)
|
|
593
|
+
if [ -n "$PTR" ]; then
|
|
594
|
+
STATE_FILE=$(printf '%s\\n' "$PTR" | sed -n 1p)
|
|
595
|
+
LEDGER_FILE=$(printf '%s\\n' "$PTR" | sed -n 2p)
|
|
596
|
+
RUNNER_PID=$(printf '%s\\n' "$PTR" | sed -n 3p)
|
|
597
|
+
HOOK_SOCKET=$(printf '%s\\n' "$PTR" | sed -n 4p)
|
|
598
|
+
HOOK_TOKEN=$(printf '%s\\n' "$PTR" | sed -n 5p)
|
|
599
|
+
else
|
|
600
|
+
# Node unavailable: the pointer holds plain ~/.stigmer paths, an integer
|
|
601
|
+
# and a hex token (no JSON-escaped quotes), so grep/cut is reliable here.
|
|
602
|
+
STATE_FILE=$(grep -o '"stateFile":"[^"]*"' "$ACTIVE_FILE" | head -1 | cut -d'"' -f4 || true)
|
|
603
|
+
LEDGER_FILE=$(grep -o '"ledgerFile":"[^"]*"' "$ACTIVE_FILE" | head -1 | cut -d'"' -f4 || true)
|
|
604
|
+
RUNNER_PID=$(grep -o '"runnerPid":[0-9]*' "$ACTIVE_FILE" | head -1 | cut -d: -f2 || true)
|
|
605
|
+
HOOK_SOCKET=$(grep -o '"hookSocket":"[^"]*"' "$ACTIVE_FILE" | head -1 | cut -d'"' -f4 || true)
|
|
606
|
+
HOOK_TOKEN=$(grep -o '"hookToken":"[^"]*"' "$ACTIVE_FILE" | head -1 | cut -d'"' -f4 || true)
|
|
607
|
+
fi
|
|
608
|
+
if [ -z "$RUNNER_PID" ]; then
|
|
609
|
+
# Pointer unreadable -> no scope owner to gate for; stay inert.
|
|
610
|
+
echo '{"permission":"allow"}'
|
|
611
|
+
exit 0
|
|
612
|
+
fi
|
|
613
|
+
|
|
614
|
+
# --- Scope guard: gate ONLY the runner's own agent (issue #173) -------------
|
|
615
|
+
# The Cursor SDK runs hooks in-process, so the runner's own agent invocations
|
|
616
|
+
# spawn this script as a DESCENDANT of the runner process (RUNNER_PID); the
|
|
617
|
+
# user's interactive IDE — sharing the same repo .cursor/hooks.json — spawns it
|
|
618
|
+
# under a different process tree. Walk the parent-PID chain: if the runner is an
|
|
619
|
+
# ancestor, apply the gate; otherwise allow immediately and DO NOT write the
|
|
620
|
+
# ledger (so foreign tool calls never appear as phantom approvals). Pure bash so
|
|
621
|
+
# it works even when the Node identity binary below is unavailable.
|
|
622
|
+
__stigmer_ppid() {
|
|
623
|
+
_p="$1"
|
|
624
|
+
if [ -r "/proc/$_p/status" ]; then
|
|
625
|
+
awk '/^PPid:/{print $2; exit}' "/proc/$_p/status" 2>/dev/null || true
|
|
626
|
+
else
|
|
627
|
+
ps -o ppid= -p "$_p" 2>/dev/null | tr -d ' ' || true
|
|
628
|
+
fi
|
|
629
|
+
}
|
|
630
|
+
__stigmer_is_own_agent() {
|
|
631
|
+
_cur="$$"
|
|
632
|
+
_i=0
|
|
633
|
+
while [ "$_i" -lt 64 ]; do
|
|
634
|
+
if [ -z "$_cur" ]; then return 1; fi
|
|
635
|
+
if [ "$_cur" = "$RUNNER_PID" ]; then return 0; fi
|
|
636
|
+
if [ "$_cur" = "1" ] || [ "$_cur" = "0" ]; then return 1; fi
|
|
637
|
+
_cur="$(__stigmer_ppid "$_cur")"
|
|
638
|
+
_i=$((_i + 1))
|
|
639
|
+
done
|
|
640
|
+
return 1
|
|
641
|
+
}
|
|
642
|
+
if ! __stigmer_is_own_agent; then
|
|
643
|
+
echo '{"permission":"allow"}'
|
|
644
|
+
exit 0
|
|
645
|
+
fi
|
|
646
|
+
|
|
647
|
+
# --- Capture-mode helper: is a path gitignored? -----------------------------
|
|
648
|
+
# In capture mode the runner snapshots the working tree with git and reconciles
|
|
649
|
+
# it to the user's per-file decisions on resume, but a gitignored path (e.g.
|
|
650
|
+
# .env, build output) is invisible to that snapshot — so it can be neither
|
|
651
|
+
# captured for review nor reverted on reject. Such writes/deletes therefore stay
|
|
652
|
+
# on the deny-gate. Returns 0 (true) when the path is ignored. A non-git context
|
|
653
|
+
# or a missing path returns non-zero (treated as not-ignored -> allow).
|
|
654
|
+
__stigmer_is_gitignored() {
|
|
655
|
+
_p="$1"
|
|
656
|
+
[ -z "$_p" ] && return 1
|
|
657
|
+
if [ -n "$GIT_ROOT" ]; then
|
|
658
|
+
git -C "$GIT_ROOT" check-ignore -q -- "$_p" 2>/dev/null
|
|
659
|
+
else
|
|
660
|
+
git -C "$(dirname "$_p")" check-ignore -q -- "$_p" 2>/dev/null
|
|
661
|
+
fi
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
# --- Canonical identity: tool_name / category / identity token / MCP token ---
|
|
665
|
+
# Computed by the same Node.js binary that runs the cursor-runner (absolute path
|
|
666
|
+
# baked at generation time) so JSON string values — file paths and especially
|
|
667
|
+
# shell commands containing quotes, newlines, or unicode escapes — decode to the
|
|
668
|
+
# exact bytes the runner sees in the stream event. ELECTRON_RUN_AS_NODE makes
|
|
669
|
+
# the invocation safe when the runner is embedded in an Electron app (where
|
|
670
|
+
# process.execPath is the Electron binary). NODE_BIN is defined once near the top
|
|
671
|
+
# (it also parses the active-turn pointer).
|
|
672
|
+
IDENTITY=$(printf '%s' "$INPUT" | ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e '${nodeIdentityScript}' "$STATE_FILE" "$GIT_ROOT" 2>/dev/null || true)
|
|
673
|
+
if [ -n "$IDENTITY" ]; then
|
|
674
|
+
TOOL_NAME=$(printf '%s\\n' "$IDENTITY" | sed -n 1p)
|
|
675
|
+
CATEGORY=$(printf '%s\\n' "$IDENTITY" | sed -n 2p)
|
|
676
|
+
TOKEN=$(printf '%s\\n' "$IDENTITY" | sed -n 3p)
|
|
677
|
+
MCP_TOKEN=$(printf '%s\\n' "$IDENTITY" | sed -n 4p)
|
|
678
|
+
HOOK_EVENT=$(printf '%s\\n' "$IDENTITY" | sed -n 5p)
|
|
679
|
+
# base64(JSON(tool_input)) — the authoritative args the runner overlays onto
|
|
680
|
+
# the gated tool call. A single unwrapped base64 line (Node does not wrap), so
|
|
681
|
+
# sed reads it whole even for large file content.
|
|
682
|
+
INPUT_B64=$(printf '%s\\n' "$IDENTITY" | sed -n 6p)
|
|
683
|
+
# Content token (base64 of category\\nsalient\\ndigest), empty for a non-edit
|
|
684
|
+
# tool. The exact-identity grant the runner authorizes for a file edit.
|
|
685
|
+
CONTENT_TOKEN=$(printf '%s\\n' "$IDENTITY" | sed -n 7p)
|
|
686
|
+
# Raw salient (base64) — the file path / command. Capture mode decodes it to
|
|
687
|
+
# run git check-ignore on a file path.
|
|
688
|
+
SALIENT=$(printf '%s\\n' "$IDENTITY" | sed -n 8p | base64 -d 2>/dev/null || true)
|
|
689
|
+
# MCP server slug (beforeMCPExecution payloads only; empty for built-ins).
|
|
690
|
+
MCP_SERVER=$(printf '%s\\n' "$IDENTITY" | sed -n 9p)
|
|
691
|
+
# Tool-lists verdict: empty (in scope), E (could not evaluate), or the
|
|
692
|
+
# base64 deny response; and the ledger token a refusal is recorded under.
|
|
693
|
+
SCOPE_VERDICT=$(printf '%s\\n' "$IDENTITY" | sed -n 10p)
|
|
694
|
+
SCOPE_TOKEN=$(printf '%s\\n' "$IDENTITY" | sed -n 11p)
|
|
695
|
+
SCOPE_MESSAGE=$(printf '%s\\n' "$IDENTITY" | sed -n 12p)
|
|
696
|
+
HOOK_ARGS_TOKEN=$(printf '%s\\n' "$IDENTITY" | sed -n 13p)
|
|
697
|
+
else
|
|
698
|
+
# Fallback when the Node binary cannot run: grep/cut extraction. Best-effort
|
|
699
|
+
# only — '"field":"[^"]*"' truncates at the first JSON-escaped quote, so the
|
|
700
|
+
# token may not match the runner's for values containing escapes. Gating still
|
|
701
|
+
# holds (deny goes out); only denial correlation and grant precision degrade.
|
|
702
|
+
# Every extraction ends with '|| true': under 'set -e' a non-matching grep
|
|
703
|
+
# would otherwise abort the script and emit no decision.
|
|
704
|
+
TOOL_NAME=$(echo "$INPUT" | grep -o '"tool_name":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
705
|
+
HOOK_EVENT=$(echo "$INPUT" | grep -o '"hook_event_name":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
706
|
+
# Server slugs are plain identifiers (no JSON-escaped quotes), so the grep
|
|
707
|
+
# fallback extracts mcp_server_name reliably.
|
|
708
|
+
MCP_SERVER=$(echo "$INPUT" | grep -o '"mcp_server_name":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
709
|
+
SALIENT=""
|
|
710
|
+
for field in ${salientFields}; do
|
|
711
|
+
v=$(echo "$INPUT" | grep -o "\\"$field\\":\\"[^\\"]*\\"" | head -1 | cut -d'"' -f4 || true)
|
|
712
|
+
if [ -n "$v" ]; then SALIENT="$v"; break; fi
|
|
713
|
+
done
|
|
714
|
+
CATEGORY=""
|
|
715
|
+
case "$TOOL_NAME" in
|
|
716
|
+
${categoryCaseArms}
|
|
717
|
+
*) CATEGORY="" ;;
|
|
718
|
+
esac
|
|
719
|
+
TOKEN=$(printf '%s\\n%s' "$CATEGORY" "$SALIENT" | base64 | tr -d '\\n')
|
|
720
|
+
MCP_TOKEN=$(printf '%s/%s\\n' "$MCP_SERVER" "$TOOL_NAME" | base64 | tr -d '\\n')
|
|
721
|
+
# The grep fallback cannot reliably capture full multi-line tool_input, so the
|
|
722
|
+
# gated call degrades to today's stream-recovered args (no authoritative input)
|
|
723
|
+
# and cannot compute a content digest — the coarse token is the only identity.
|
|
724
|
+
INPUT_B64=""
|
|
725
|
+
CONTENT_TOKEN=""
|
|
726
|
+
# Without Node the tool lists cannot be evaluated; the scope arm refuses
|
|
727
|
+
# every call when the agent has lists (fail-closed).
|
|
728
|
+
SCOPE_VERDICT="E"
|
|
729
|
+
SCOPE_TOKEN=""
|
|
730
|
+
SCOPE_MESSAGE=""
|
|
731
|
+
HOOK_ARGS_TOKEN=""
|
|
732
|
+
fi
|
|
733
|
+
# The single identity a deny is recorded under: content-exact when the input
|
|
734
|
+
# carried edit content, else coarse — the same PRIMARY-token choice the runner
|
|
735
|
+
# grants on approval (approval-state.ts primaryToken).
|
|
736
|
+
if [ -n "$CONTENT_TOKEN" ]; then
|
|
737
|
+
PRIMARY_TOKEN="$CONTENT_TOKEN"
|
|
738
|
+
else
|
|
739
|
+
PRIMARY_TOKEN="$TOKEN"
|
|
740
|
+
fi
|
|
741
|
+
|
|
742
|
+
# --- 0b. After a call: what the agent's hooks hand back (postToolUse) ---
|
|
743
|
+
# Registered only for an agent with hooks that run after a call. The runner's
|
|
744
|
+
# hook server (hook-server.ts) runs them and answers with the context they
|
|
745
|
+
# hand the model. A call that already ran cannot be stopped, so a server that
|
|
746
|
+
# does not answer adds nothing.
|
|
747
|
+
if [ "$HOOK_EVENT" = "postToolUse" ]; then
|
|
748
|
+
if [ -n "$HOOK_SOCKET" ]; then
|
|
749
|
+
printf '%s' "$INPUT" | ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e '${hookClientScript}' "$HOOK_SOCKET" "$HOOK_TOKEN" post "" "" 2>/dev/null || printf '{}'
|
|
750
|
+
echo
|
|
751
|
+
else
|
|
752
|
+
echo '{}'
|
|
753
|
+
fi
|
|
754
|
+
exit 0
|
|
755
|
+
fi
|
|
756
|
+
|
|
757
|
+
# Append a denial record to the ledger: $1 = identity token, $2 = kind (the
|
|
758
|
+
# attribution taxonomy — see the module doc in hook-script.ts). EVERY deny arm
|
|
759
|
+
# below records, so the ledger is the complete record of what THIS hook blocked
|
|
760
|
+
# and the runner can tell its own denials from a foreign hook's (issue #205).
|
|
761
|
+
# Best-effort: a ledger write failure must never abort the decision (the deny
|
|
762
|
+
# still goes out on stdout). ONLY approval-kind records carry the captured
|
|
763
|
+
# tool_input (secret or unclassified content must never be persisted);
|
|
764
|
+
# input is base64(JSON(tool_input)) — the authoritative pre-execution args the
|
|
765
|
+
# runner overlays for the approval preview (empty on the grep fallback path).
|
|
766
|
+
# A tool-list refusal passes $3, base64 of the refusal text the model read,
|
|
767
|
+
# which the turn boundary writes onto the refused row. Written with printf (a builtin, so no ARG_MAX limit) because the input can be
|
|
768
|
+
# a large multi-MB file body. Defined BEFORE the first deny arm: bash resolves
|
|
769
|
+
# function calls at execution time, and under 'set -euo pipefail' with our
|
|
770
|
+
# failClosed hooks.json registration a call-before-define would abort with no
|
|
771
|
+
# decision and block EVERY tool.
|
|
772
|
+
record_denial() {
|
|
773
|
+
_extra=""
|
|
774
|
+
if [ -n "\${3:-}" ]; then _extra="$_extra"',"message":"'"$3"'"'; fi
|
|
775
|
+
if [ -n "\${4:-}" ]; then _extra="$_extra"',"hook":"'"$4"'"'; fi
|
|
776
|
+
if [ "$2" = "approval" ]; then
|
|
777
|
+
printf '{"toolName":"%s","token":"%s","kind":"%s","input":"%s"%s}\\n' "$TOOL_NAME" "$1" "$2" "$INPUT_B64" "$_extra" >> "$LEDGER_FILE" 2>/dev/null || true
|
|
778
|
+
else
|
|
779
|
+
printf '{"toolName":"%s","token":"%s","kind":"%s"%s}\\n' "$TOOL_NAME" "$1" "$2" "$_extra" >> "$LEDGER_FILE" 2>/dev/null || true
|
|
780
|
+
fi
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
# --- Failsafe: missing state file → deny (fail-closed) ---
|
|
784
|
+
# Recorded as kind "fail-closed" so the runner attributes the blocked call to
|
|
785
|
+
# its own (broken) gate instead of misdiagnosing a foreign hook. The ledger
|
|
786
|
+
# path comes from the POINTER, not the state file, so it is recordable here.
|
|
787
|
+
if [ ! -f "$STATE_FILE" ]; then
|
|
788
|
+
if [ "$HOOK_EVENT" = "beforeMCPExecution" ]; then
|
|
789
|
+
record_denial "$MCP_TOKEN" "fail-closed"
|
|
790
|
+
else
|
|
791
|
+
record_denial "$PRIMARY_TOKEN" "fail-closed"
|
|
792
|
+
fi
|
|
793
|
+
echo '{"permission":"deny","agent_message":"${APPROVAL_REQUIRED_AGENT_MESSAGE}","user_message":"Tool requires approval: '"$TOOL_NAME"'"}'
|
|
794
|
+
exit 0
|
|
795
|
+
fi
|
|
796
|
+
|
|
797
|
+
STATE=$(cat "$STATE_FILE")
|
|
798
|
+
# The approved grants alone, so a token elsewhere in the state (a refused
|
|
799
|
+
# call's, a tool-list key) never reads as a grant. Base64 holds no ']'.
|
|
800
|
+
GRANTS=$(echo "$STATE" | grep -o '"approvedGrantTokens":\\[[^]]*\\]' | head -1 || true)
|
|
801
|
+
# Whether an approved grant covers this call: the content-exact token (a file
|
|
802
|
+
# edit approved with this exact content) or the coarse one for a built-in;
|
|
803
|
+
# the server/tool token for an MCP tool.
|
|
804
|
+
# The approval of a hook's ask: a built-in's file content when it has some,
|
|
805
|
+
# else the call's whole input (HOOK_ARGS_TOKEN), never the tool alone, so an
|
|
806
|
+
# approved call lets through that call and no other.
|
|
807
|
+
__stigmer_hook_granted() {
|
|
808
|
+
if [ "$HOOK_EVENT" != "beforeMCPExecution" ] && [ -n "$CONTENT_TOKEN" ]; then
|
|
809
|
+
echo "$GRANTS" | grep -qF "\\"$CONTENT_TOKEN\\""
|
|
810
|
+
return
|
|
811
|
+
fi
|
|
812
|
+
[ -n "$HOOK_ARGS_TOKEN" ] && echo "$GRANTS" | grep -qF "\\"$HOOK_ARGS_TOKEN\\""
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
__stigmer_granted() {
|
|
816
|
+
if [ "$HOOK_EVENT" = "beforeMCPExecution" ]; then
|
|
817
|
+
echo "$GRANTS" | grep -qF "\\"$MCP_TOKEN\\""
|
|
818
|
+
return
|
|
819
|
+
fi
|
|
820
|
+
{ [ -n "$CONTENT_TOKEN" ] && echo "$GRANTS" | grep -qF "\\"$CONTENT_TOKEN\\""; } || echo "$GRANTS" | grep -qF "\\"$TOKEN\\""
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
# Capture mode (git workspaces): file mutations flow during the turn and are
|
|
824
|
+
# captured/gated per-file by the runner at the turn boundary (see
|
|
825
|
+
# shared/filereview/git-substrate.ts). Read once; consulted only in the
|
|
826
|
+
# gated-built-in arm below.
|
|
827
|
+
CAPTURE_MODE=false
|
|
828
|
+
if echo "$STATE" | grep -q '"captureMode":true'; then
|
|
829
|
+
CAPTURE_MODE=true
|
|
830
|
+
fi
|
|
831
|
+
# File review off: a built-in write or delete flows unreviewed (no capture, no
|
|
832
|
+
# ask); the secret-like write block still applies, keyed on the substrate (a
|
|
833
|
+
# git-tracked path flows, a gitignored or non-git one is refused). Default on
|
|
834
|
+
# when the key is absent, which keeps review's rules (capture or the
|
|
835
|
+
# deny-gate). Consulted in the hook-allow arm (1i) and the gated-built-in arm.
|
|
836
|
+
FILE_REVIEW=true
|
|
837
|
+
if echo "$STATE" | grep -q '"fileReview":false'; then
|
|
838
|
+
FILE_REVIEW=false
|
|
839
|
+
fi
|
|
840
|
+
# CAS capture of gitignored writes (the deep-agent parity switch). Set only when
|
|
841
|
+
# capture mode is on AND an artifact storage is configured (to persist blobs). It
|
|
842
|
+
# governs whether a non-secret gitignored write is staged+flowed for review vs.
|
|
843
|
+
# kept on the deny-gate. Read here; consulted only in the gitignored-capture arm
|
|
844
|
+
# below, which runs BEFORE auto-approve-all (capture is a turn property).
|
|
845
|
+
CAPTURE_IGNORED=false
|
|
846
|
+
if echo "$STATE" | grep -q '"captureIgnored":true'; then
|
|
847
|
+
CAPTURE_IGNORED=true
|
|
848
|
+
fi
|
|
849
|
+
# gitWorkspace selects the capture substrate. Default true when the
|
|
850
|
+
# key is absent (older state files). When false the workspace is NOT a git tree:
|
|
851
|
+
# there is no git snapshot, so EVERY file write/delete is CAS-staged below (not
|
|
852
|
+
# only gitignored ones) and the git-tracked flow arm is skipped.
|
|
853
|
+
GIT_WORKSPACE=true
|
|
854
|
+
if echo "$STATE" | grep -q '"gitWorkspace":false'; then
|
|
855
|
+
GIT_WORKSPACE=false
|
|
856
|
+
fi
|
|
857
|
+
# Unattended approval mode: the surface has no approver. Same gate,
|
|
858
|
+
# different RESOLUTION — the approval-deny arms below record kind "unattended"
|
|
859
|
+
# (non-pausing) with an adapt-and-explain message instead of kind "approval"
|
|
860
|
+
# (pausing). Secret/fail-closed/capture-error arms are mode-independent.
|
|
861
|
+
UNATTENDED_SKIP=false
|
|
862
|
+
if echo "$STATE" | grep -q '"unattendedSkip":true'; then
|
|
863
|
+
UNATTENDED_SKIP=true
|
|
864
|
+
fi
|
|
865
|
+
|
|
866
|
+
# --- 1a. Tool lists: what this agent may call at all ------------------------
|
|
867
|
+
# Runs BEFORE the capture arms, the auto-approve-all shortcut and every grant:
|
|
868
|
+
# a list is not an approval gate, so no bypass may resurrect an excluded tool
|
|
869
|
+
# and no human may be offered approval on one. The Node snippet looked the call
|
|
870
|
+
# up in the runner's compiled scope (toolScope, hook-scope.ts) and handed back
|
|
871
|
+
# the deny response; this arm only records and replies. Kind "disabled":
|
|
872
|
+
# attributable, non-pausing (the model adapts), permanent for the run.
|
|
873
|
+
if [ "$SCOPE_VERDICT" = "E" ]; then
|
|
874
|
+
if echo "$STATE" | grep -q '"toolListsRestricted":true'; then
|
|
875
|
+
record_denial "$PRIMARY_TOKEN" "fail-closed"
|
|
876
|
+
echo '{"permission":"deny","agent_message":"${SCOPE_UNAVAILABLE_AGENT_MESSAGE}","user_message":"Refused: the tool lists could not be checked"}'
|
|
877
|
+
exit 0
|
|
878
|
+
fi
|
|
879
|
+
elif [ -n "$SCOPE_VERDICT" ]; then
|
|
880
|
+
record_denial "$SCOPE_TOKEN" "disabled" "$SCOPE_MESSAGE"
|
|
881
|
+
printf '%s' "$SCOPE_VERDICT" | base64 -d
|
|
882
|
+
echo
|
|
883
|
+
exit 0
|
|
884
|
+
fi
|
|
885
|
+
|
|
886
|
+
# --- 1b. A sub-agent start the lists allow ----------------------------------
|
|
887
|
+
# subagentStart reaches this script only for the scope arm above; no approval
|
|
888
|
+
# arm below applies to it.
|
|
889
|
+
if [ "$HOOK_EVENT" = "subagentStart" ]; then
|
|
890
|
+
echo '{"permission":"allow"}'
|
|
891
|
+
exit 0
|
|
892
|
+
fi
|
|
893
|
+
|
|
894
|
+
# --- 1h. The agent's hooks -----------------------------------------------
|
|
895
|
+
# Present only when the agent has hooks: the runner serves them on a local
|
|
896
|
+
# socket the pointer names (hook-server.ts), and every hook, in either
|
|
897
|
+
# format, answers there, once per call. An MCP call is asked on
|
|
898
|
+
# beforeMCPExecution, the event that names its server; its preToolUse
|
|
899
|
+
# (MCP:<tool>) firing passes on. After the tool lists (1a), so an excluded
|
|
900
|
+
# call never reaches a hook.
|
|
901
|
+
# - deny, or a call a person refused earlier this run that a hook would let
|
|
902
|
+
# through (refused): record kind "hook" with the refusal, deny. The agent
|
|
903
|
+
# continues; nothing pauses.
|
|
904
|
+
# - ask: under the pre-armed bypass or an approved grant, as an allow;
|
|
905
|
+
# skipped under the unattended mode; otherwise recorded kind "approval"
|
|
906
|
+
# with the hook and its message, which pauses the turn on the hook's card.
|
|
907
|
+
# - allow: the capture arms below still review the call, and nothing after
|
|
908
|
+
# them may ask (1i).
|
|
909
|
+
# - none: no hook decided; every arm below runs as it would without hooks.
|
|
910
|
+
# - anything else: the server did not answer; a hook that cannot be asked
|
|
911
|
+
# is not skipped, so the call is refused (fail-closed).
|
|
912
|
+
# A secret-like write the hook asks on is blocked rather than shown on a
|
|
913
|
+
# card, and one it allows meets the same block the deny-gate applies (1i).
|
|
914
|
+
HOOK_ALLOW=false
|
|
915
|
+
HOOK_ALLOW_RESPONSE=""
|
|
916
|
+
# An allowed call's answer: a hook's (its context and any rewrite) once one
|
|
917
|
+
# allowed it, else the plain allow.
|
|
918
|
+
__stigmer_allow() {
|
|
919
|
+
if [ -n "$HOOK_ALLOW_RESPONSE" ]; then
|
|
920
|
+
printf '%s\\n' "$HOOK_ALLOW_RESPONSE"
|
|
921
|
+
else
|
|
922
|
+
echo '{"permission":"allow"}'
|
|
923
|
+
fi
|
|
924
|
+
}
|
|
925
|
+
# Whether this call is a secret-like write, outside the pre-armed bypass.
|
|
926
|
+
__stigmer_secret_write() {
|
|
927
|
+
[ "$CATEGORY" = "write" ] && [ -n "$SALIENT" ] || return 1
|
|
928
|
+
! echo "$STATE" | grep -q '"autoApproveAll":true' || return 1
|
|
929
|
+
[ "$(printf '%s' "$SALIENT" | ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e '${secretClassifyScript}' 2>/dev/null || echo ok)" = "secret" ]
|
|
930
|
+
}
|
|
931
|
+
if [ -n "$HOOK_SOCKET" ] && { [ "$HOOK_EVENT" = "beforeMCPExecution" ] || { [ "$HOOK_EVENT" = "preToolUse" ] && [ "\${TOOL_NAME#MCP:}" = "$TOOL_NAME" ]; }; }; then
|
|
932
|
+
if [ "$HOOK_EVENT" = "beforeMCPExecution" ]; then
|
|
933
|
+
HOOK_ID="$MCP_TOKEN"
|
|
934
|
+
HOOK_COARSE="$MCP_TOKEN"
|
|
935
|
+
else
|
|
936
|
+
HOOK_ID="$PRIMARY_TOKEN"
|
|
937
|
+
HOOK_COARSE="$TOKEN"
|
|
938
|
+
fi
|
|
939
|
+
HOOK_REPLY=$(printf '%s' "$INPUT" | ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e '${hookClientScript}' "$HOOK_SOCKET" "$HOOK_TOKEN" pre "$HOOK_ID" "$HOOK_COARSE" "$HOOK_ARGS_TOKEN" 2>/dev/null || echo error)
|
|
940
|
+
HOOK_DECISION=$(printf '%s\\n' "$HOOK_REPLY" | sed -n 1p)
|
|
941
|
+
HOOK_SLUG=$(printf '%s\\n' "$HOOK_REPLY" | sed -n 2p)
|
|
942
|
+
HOOK_MESSAGE=$(printf '%s\\n' "$HOOK_REPLY" | sed -n 7p)
|
|
943
|
+
case "$HOOK_DECISION" in
|
|
944
|
+
deny|refused)
|
|
945
|
+
record_denial "$HOOK_ID" "hook" "$HOOK_MESSAGE" "$HOOK_SLUG"
|
|
946
|
+
printf '%s\\n' "$HOOK_REPLY" | sed -n 4p | base64 -d
|
|
947
|
+
echo
|
|
948
|
+
exit 0
|
|
949
|
+
;;
|
|
950
|
+
ask)
|
|
951
|
+
if echo "$STATE" | grep -q '"autoApproveAll":true' || __stigmer_hook_granted; then
|
|
952
|
+
# Satisfied: an allow, so the capture arms below still review it.
|
|
953
|
+
HOOK_ALLOW=true
|
|
954
|
+
HOOK_ALLOW_RESPONSE=$(printf '%s\\n' "$HOOK_REPLY" | sed -n 3p | base64 -d)
|
|
955
|
+
elif [ "$UNATTENDED_SKIP" = "true" ]; then
|
|
956
|
+
record_denial "$HOOK_ID" "unattended" "" "$HOOK_SLUG"
|
|
957
|
+
printf '%s\\n' "$HOOK_REPLY" | sed -n 6p | base64 -d
|
|
958
|
+
echo
|
|
959
|
+
exit 0
|
|
960
|
+
elif __stigmer_secret_write; then
|
|
961
|
+
# Never shown on a card: its content is a secret's.
|
|
962
|
+
record_denial "$PRIMARY_TOKEN" "secret"
|
|
963
|
+
echo '{"permission":"deny","agent_message":"${SECRET_BLOCKED_AGENT_MESSAGE}","user_message":"Blocked for security: this file matches a secret-like path and was not written."}'
|
|
964
|
+
exit 0
|
|
965
|
+
else
|
|
966
|
+
record_denial "$HOOK_ID" "approval" "$HOOK_MESSAGE" "$HOOK_SLUG"
|
|
967
|
+
printf '%s\\n' "$HOOK_REPLY" | sed -n 5p | base64 -d
|
|
968
|
+
echo
|
|
969
|
+
exit 0
|
|
970
|
+
fi
|
|
971
|
+
;;
|
|
972
|
+
allow)
|
|
973
|
+
HOOK_ALLOW=true
|
|
974
|
+
HOOK_ALLOW_RESPONSE=$(printf '%s\\n' "$HOOK_REPLY" | sed -n 3p | base64 -d)
|
|
975
|
+
;;
|
|
976
|
+
none)
|
|
977
|
+
;;
|
|
978
|
+
*)
|
|
979
|
+
record_denial "$HOOK_ID" "hook-unavailable"
|
|
980
|
+
echo '{"permission":"deny","agent_message":"${HOOKS_UNAVAILABLE_AGENT_MESSAGE}","user_message":"Refused: the agent hooks could not be run"}'
|
|
981
|
+
exit 0
|
|
982
|
+
;;
|
|
983
|
+
esac
|
|
984
|
+
fi
|
|
985
|
+
|
|
986
|
+
# --- Capture mode: observe CAS-owned writes for review ----------------------
|
|
987
|
+
# Runs BEFORE the auto-approve-all shortcut and the grant/lease checks because
|
|
988
|
+
# capture is a property of the TURN, not authorization: a non-secret CAS-owned
|
|
989
|
+
# write must be staged and reviewed even under the global bypass, and a
|
|
990
|
+
# secret-like one must be hard-blocked in every mode. WHICH writes are CAS-owned
|
|
991
|
+
# depends on the substrate: in a git tree it is only the GITIGNORED writes (git
|
|
992
|
+
# captures the tracked ones); in a NON-GIT workspace it is EVERY write (there is
|
|
993
|
+
# no git snapshot). Only a built-in write/edit (category "write") takes THIS arm;
|
|
994
|
+
# deletes take their own staging arm just below (issue #303), shell/MCP stay on
|
|
995
|
+
# the deny-gate (parity with the deep-agent approval gate). The staging runs on
|
|
996
|
+
# the runner's own Node binary (the
|
|
997
|
+
# disk-backed mirror of CasCaptureFilesystemBackend.recordBefore): the salient
|
|
998
|
+
# path rides stdin (no argv escaping), the workspace root and the per-turn
|
|
999
|
+
# cas-observations dir ride argv. "captured" -> allow (apply-then-review);
|
|
1000
|
+
# "secret" -> hard-block; "error"/Node-unavailable -> fail closed (deny, since a
|
|
1001
|
+
# write we cannot capture cannot be reviewed).
|
|
1002
|
+
if [ "$CAPTURE_IGNORED" = "true" ] && [ "$CATEGORY" = "write" ] && [ -n "$SALIENT" ] && { [ "$GIT_WORKSPACE" = "false" ] || __stigmer_is_gitignored "$SALIENT"; }; then
|
|
1003
|
+
OBS_DIR="$(dirname "$STATE_FILE")/${CAS_OBSERVATIONS_DIRNAME}"
|
|
1004
|
+
OBS_RESULT=$(printf '%s' "$SALIENT" | ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e '${observationStagingScript}' "$GIT_ROOT" "$OBS_DIR" 2>/dev/null || echo error)
|
|
1005
|
+
if [ "$OBS_RESULT" = "captured" ]; then
|
|
1006
|
+
__stigmer_allow
|
|
1007
|
+
exit 0
|
|
1008
|
+
elif [ "$OBS_RESULT" = "secret" ]; then
|
|
1009
|
+
# Kind "secret": attributable but deliberately non-pausing (the agent moves
|
|
1010
|
+
# on) and content-free (the token is the only identity recorded).
|
|
1011
|
+
record_denial "$PRIMARY_TOKEN" "secret"
|
|
1012
|
+
echo '{"permission":"deny","agent_message":"${SECRET_BLOCKED_AGENT_MESSAGE}","user_message":"Blocked for security: this file matches a secret-like path and was not written or captured for review."}'
|
|
1013
|
+
exit 0
|
|
1014
|
+
else
|
|
1015
|
+
# Node unavailable or a staging error: fail closed. A gitignored write we
|
|
1016
|
+
# cannot stage cannot be captured for review, so keep gating it (today's
|
|
1017
|
+
# behavior) rather than letting unreviewable bytes flow. Kind
|
|
1018
|
+
# "capture-error" and content-free: the staging error means secret
|
|
1019
|
+
# classification may never have run, so the content is UNCLASSIFIED.
|
|
1020
|
+
record_denial "$PRIMARY_TOKEN" "capture-error"
|
|
1021
|
+
echo '{"permission":"deny","agent_message":"${APPROVAL_REQUIRED_AGENT_MESSAGE}","user_message":"Tool requires approval: '"$TOOL_NAME"'"}'
|
|
1022
|
+
exit 0
|
|
1023
|
+
fi
|
|
1024
|
+
fi
|
|
1025
|
+
|
|
1026
|
+
# --- Capture mode: observe CAS-owned deletes for review (issue #303) --------
|
|
1027
|
+
# The delete twin of the write arm above — a non-secret CAS-owned delete stages
|
|
1028
|
+
# its before-bytes (the one moment they still exist on disk) and flows; the
|
|
1029
|
+
# turn boundary then reads after=null and authors a reviewable, restorable
|
|
1030
|
+
# DELETE entry. One deliberate difference from the write arm: the path is
|
|
1031
|
+
# classified for secret-likeness BEFORE any staging touches the sidecar. A
|
|
1032
|
+
# secret-like delete must stay on the deny-gate below where a human may still
|
|
1033
|
+
# approve it (its args expose no secret content, unlike a write) — staging it
|
|
1034
|
+
# would both persist the secret before-bytes and mark the sidecar "secret",
|
|
1035
|
+
# making the boundary author a blocking DIFF_UNREVIEWABLE for a merely-gated
|
|
1036
|
+
# delete. Every failure mode (secret, classify error, staging error) falls
|
|
1037
|
+
# through to the deny-gate rather than denying here, so grants and leases keep
|
|
1038
|
+
# applying to a gated delete exactly as before this arm existed; the eventual
|
|
1039
|
+
# resolution records its own ledger kind.
|
|
1040
|
+
if [ "$CAPTURE_IGNORED" = "true" ] && [ "$CATEGORY" = "delete" ] && [ -n "$SALIENT" ] && { [ "$GIT_WORKSPACE" = "false" ] || __stigmer_is_gitignored "$SALIENT"; }; then
|
|
1041
|
+
DELETE_SECRET_RESULT=$(printf '%s' "$SALIENT" | ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e '${secretClassifyScript}' 2>/dev/null || echo error)
|
|
1042
|
+
if [ "$DELETE_SECRET_RESULT" = "ok" ]; then
|
|
1043
|
+
OBS_DIR="$(dirname "$STATE_FILE")/${CAS_OBSERVATIONS_DIRNAME}"
|
|
1044
|
+
OBS_RESULT=$(printf '%s' "$SALIENT" | ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e '${observationStagingScript}' "$GIT_ROOT" "$OBS_DIR" 2>/dev/null || echo error)
|
|
1045
|
+
if [ "$OBS_RESULT" = "captured" ]; then
|
|
1046
|
+
__stigmer_allow
|
|
1047
|
+
exit 0
|
|
1048
|
+
fi
|
|
1049
|
+
fi
|
|
1050
|
+
fi
|
|
1051
|
+
|
|
1052
|
+
# --- 1i. A hook's allow ---
|
|
1053
|
+
# Capture (above) has reviewed what it reviews; nothing below may ask. A
|
|
1054
|
+
# write takes the deny-gate's own rule (3): a git-tracked one flows (to the
|
|
1055
|
+
# turn's review in capture mode, unreviewed with review off), and any other
|
|
1056
|
+
# secret-like one is blocked.
|
|
1057
|
+
if [ "$HOOK_ALLOW" = "true" ]; then
|
|
1058
|
+
if ! { { [ "$CAPTURE_MODE" = "true" ] || [ "$FILE_REVIEW" = "false" ]; } && [ "$GIT_WORKSPACE" = "true" ] && [ "$CATEGORY" = "write" ] && ! __stigmer_is_gitignored "$SALIENT"; } && __stigmer_secret_write; then
|
|
1059
|
+
record_denial "$PRIMARY_TOKEN" "secret"
|
|
1060
|
+
echo '{"permission":"deny","agent_message":"${SECRET_BLOCKED_AGENT_MESSAGE}","user_message":"Blocked for security: this file matches a secret-like path and was not written."}'
|
|
1061
|
+
exit 0
|
|
1062
|
+
fi
|
|
1063
|
+
__stigmer_allow
|
|
1064
|
+
exit 0
|
|
1065
|
+
fi
|
|
1066
|
+
|
|
1067
|
+
# --- 1c. Auto-approve all ---
|
|
1068
|
+
if echo "$STATE" | grep -q '"autoApproveAll":true'; then
|
|
1069
|
+
echo '{"permission":"allow"}'
|
|
1070
|
+
exit 0
|
|
1071
|
+
fi
|
|
1072
|
+
|
|
1073
|
+
# --- 2. MCP tools (beforeMCPExecution event) ---
|
|
1074
|
+
# preToolUse does NOT enforce gating for MCP calls — beforeMCPExecution does — so
|
|
1075
|
+
# MCP is gated here and ONLY here (never double-recorded). mcpDestructiveTools
|
|
1076
|
+
# holds only the tools that ask, keyed "server/tool" from the payload's
|
|
1077
|
+
# mcp_server_name, so presence means "deny" and an equal tool name on another
|
|
1078
|
+
# server is never caught; mcpUnlistedServers names the servers whose every tool
|
|
1079
|
+
# asks, because their tools could not be listed at turn start. MCP tool and
|
|
1080
|
+
# server names are consistent across the hook and the stream, so the identity
|
|
1081
|
+
# token is base64("server/tool\\n").
|
|
1082
|
+
if [ "$HOOK_EVENT" = "beforeMCPExecution" ]; then
|
|
1083
|
+
if [ -n "$MCP_SERVER" ] && [ -n "$TOOL_NAME" ]; then
|
|
1084
|
+
MSG=""
|
|
1085
|
+
TOOL_POLICY=$(echo "$STATE" | grep -o "\\"$MCP_SERVER/$TOOL_NAME\\":{[^}]*}" | head -1 || true)
|
|
1086
|
+
if [ -n "$TOOL_POLICY" ]; then
|
|
1087
|
+
MSG=$(echo "$TOOL_POLICY" | grep -o '"message":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
1088
|
+
if [ -z "$MSG" ]; then
|
|
1089
|
+
MSG="Tool requires approval: $TOOL_NAME"
|
|
1090
|
+
fi
|
|
1091
|
+
elif echo "$STATE" | grep -o '"mcpUnlistedServers":\\[[^]]*\\]' | grep -qF "\\"$MCP_SERVER\\""; then
|
|
1092
|
+
MSG="${unlistedMessage("$TOOL_NAME")}"
|
|
1093
|
+
fi
|
|
1094
|
+
if [ -n "$MSG" ]; then
|
|
1095
|
+
# Reinvocation grant: this tool was approved earlier → allow.
|
|
1096
|
+
if __stigmer_granted; then
|
|
1097
|
+
echo '{"permission":"allow"}'
|
|
1098
|
+
exit 0
|
|
1099
|
+
fi
|
|
1100
|
+
if [ "$UNATTENDED_SKIP" = "true" ]; then
|
|
1101
|
+
# Unattended resolution: non-pausing kind, final for this
|
|
1102
|
+
# turn — the model adapts and the turn boundary stamps SKIPPED.
|
|
1103
|
+
record_denial "$MCP_TOKEN" "unattended"
|
|
1104
|
+
echo '{"permission":"deny","agent_message":"${UNATTENDED_SKIP_AGENT_MESSAGE}","user_message":"Skipped (approval not available on this surface): '"$TOOL_NAME"'"}'
|
|
1105
|
+
exit 0
|
|
1106
|
+
fi
|
|
1107
|
+
record_denial "$MCP_TOKEN" "approval"
|
|
1108
|
+
echo '{"permission":"deny","agent_message":"${APPROVAL_REQUIRED_AGENT_MESSAGE}","user_message":"'"$MSG"'"}'
|
|
1109
|
+
exit 0
|
|
1110
|
+
fi
|
|
1111
|
+
fi
|
|
1112
|
+
# Auto-approved or unmarked MCP tool → allow.
|
|
1113
|
+
echo '{"permission":"allow"}'
|
|
1114
|
+
exit 0
|
|
1115
|
+
fi
|
|
1116
|
+
|
|
1117
|
+
# --- 3. Gated built-in tools (preToolUse event, category non-empty) ---
|
|
1118
|
+
if [ -n "$CATEGORY" ]; then
|
|
1119
|
+
# Capture mode (GIT tree only): a git-tracked file mutation (write/edit/delete)
|
|
1120
|
+
# flows freely — the runner captures the whole change set with git at the turn
|
|
1121
|
+
# boundary and gates it per-file for review. A gitignored path is invisible to
|
|
1122
|
+
# that git snapshot: a non-secret gitignored WRITE or DELETE was already
|
|
1123
|
+
# handled above (staged + allowed, hard-blocked, or left to fall through) when
|
|
1124
|
+
# captureIgnored is on; here it only reaches the deny-gate when captureIgnored
|
|
1125
|
+
# is off (no artifact storage), or it is a secret-like DELETE (approvable, but
|
|
1126
|
+
# never staged — issue #303). shell (category "shell") never takes this branch
|
|
1127
|
+
# and stays gated as always. In a NON-GIT workspace this arm is skipped
|
|
1128
|
+
# entirely (there is no git diff): writes and deletes were CAS-staged above.
|
|
1129
|
+
# With file review off the same git-tracked mutation flows unreviewed: the
|
|
1130
|
+
# secret rule is keyed on the git substrate, not on review, so a committed
|
|
1131
|
+
# .env.example flows as before.
|
|
1132
|
+
if { [ "$CAPTURE_MODE" = "true" ] || [ "$FILE_REVIEW" = "false" ]; } && [ "$GIT_WORKSPACE" = "true" ] && { [ "$CATEGORY" = "write" ] || [ "$CATEGORY" = "delete" ]; }; then
|
|
1133
|
+
if ! __stigmer_is_gitignored "$SALIENT"; then
|
|
1134
|
+
echo '{"permission":"allow"}'
|
|
1135
|
+
exit 0
|
|
1136
|
+
fi
|
|
1137
|
+
fi
|
|
1138
|
+
# Deny-gate secret hard-block: a secret-like WRITE that reaches the
|
|
1139
|
+
# deny-gate (no capture substrate for it — capture off, or captureIgnored off in
|
|
1140
|
+
# a git-no-storage workspace) must not surface its content for approval. Classify
|
|
1141
|
+
# byte-identically to isSecretLikePath (no staging) and, on a match, hard-block
|
|
1142
|
+
# with the security message: the agent continues, nothing is written, and NO
|
|
1143
|
+
# content is recorded to the ledger. Placed before the grant/lease checks so a
|
|
1144
|
+
# write-category lease can never bypass it; only writes are content-bearing
|
|
1145
|
+
# (deletes stay gated). Fail-open on a classify error — the write falls to the
|
|
1146
|
+
# normal deny-gate and the runner-side backstop still withholds any secret
|
|
1147
|
+
# content before persist.
|
|
1148
|
+
if [ "$CATEGORY" = "write" ] && [ -n "$SALIENT" ]; then
|
|
1149
|
+
SECRET_RESULT=$(printf '%s' "$SALIENT" | ELECTRON_RUN_AS_NODE=1 "$NODE_BIN" -e '${secretClassifyScript}' 2>/dev/null || echo ok)
|
|
1150
|
+
if [ "$SECRET_RESULT" = "secret" ]; then
|
|
1151
|
+
# Kind "secret": attributable but non-pausing and content-free (only
|
|
1152
|
+
# the identity token is recorded, never the proposed content).
|
|
1153
|
+
record_denial "$PRIMARY_TOKEN" "secret"
|
|
1154
|
+
echo '{"permission":"deny","agent_message":"${SECRET_BLOCKED_AGENT_MESSAGE}","user_message":"Blocked for security: this file matches a secret-like path and was not written."}'
|
|
1155
|
+
exit 0
|
|
1156
|
+
fi
|
|
1157
|
+
fi
|
|
1158
|
+
# File review off: any other built-in write or delete flows unreviewed
|
|
1159
|
+
# (stigmer#1471). The secret-like write block above has already refused a
|
|
1160
|
+
# gitignored or non-git secret-like path; shell (category "shell") never
|
|
1161
|
+
# takes this branch and stays gated.
|
|
1162
|
+
if [ "$FILE_REVIEW" = "false" ] && { [ "$CATEGORY" = "write" ] || [ "$CATEGORY" = "delete" ]; }; then
|
|
1163
|
+
echo '{"permission":"allow"}'
|
|
1164
|
+
exit 0
|
|
1165
|
+
fi
|
|
1166
|
+
# Reinvocation grant: allow when the CONTENT-exact token (a file edit approved
|
|
1167
|
+
# earlier with this exact content) OR the COARSE token (a shell/delete, or the
|
|
1168
|
+
# content-less degrade) is in approvedGrantTokens. A sibling edit to the same
|
|
1169
|
+
# file has a different content token and no coarse grant, so it re-gates.
|
|
1170
|
+
if __stigmer_granted; then
|
|
1171
|
+
echo '{"permission":"allow"}'
|
|
1172
|
+
exit 0
|
|
1173
|
+
fi
|
|
1174
|
+
# Run-lifetime category lease: the user chose "approve all <category>" earlier
|
|
1175
|
+
# in this run (the scoped successor to autoApproveAll), so every built-in of
|
|
1176
|
+
# this category is allowed for the rest of the run. Matched within the extracted
|
|
1177
|
+
# leasedCategories array so a category word elsewhere in the state can't grant.
|
|
1178
|
+
LEASED_CATEGORIES=$(echo "$STATE" | grep -o '"leasedCategories":\\[[^]]*\\]' | head -1 || true)
|
|
1179
|
+
if [ -n "$LEASED_CATEGORIES" ] && echo "$LEASED_CATEGORIES" | grep -q "\\"$CATEGORY\\""; then
|
|
1180
|
+
echo '{"permission":"allow"}'
|
|
1181
|
+
exit 0
|
|
1182
|
+
fi
|
|
1183
|
+
# Record the PRIMARY token (content-exact when available, else coarse) so the
|
|
1184
|
+
# runner's denial correlation keys on the SAME identity it grants on approval.
|
|
1185
|
+
if [ "$UNATTENDED_SKIP" = "true" ]; then
|
|
1186
|
+
# Unattended resolution: non-pausing kind, final for this turn —
|
|
1187
|
+
# the model adapts and the turn boundary stamps SKIPPED.
|
|
1188
|
+
record_denial "$PRIMARY_TOKEN" "unattended"
|
|
1189
|
+
echo '{"permission":"deny","agent_message":"${UNATTENDED_SKIP_AGENT_MESSAGE}","user_message":"Skipped (approval not available on this surface): '"$TOOL_NAME"'"}'
|
|
1190
|
+
exit 0
|
|
1191
|
+
fi
|
|
1192
|
+
record_denial "$PRIMARY_TOKEN" "approval"
|
|
1193
|
+
echo '{"permission":"deny","agent_message":"${APPROVAL_REQUIRED_AGENT_MESSAGE}","user_message":"Tool requires approval: '"$TOOL_NAME"'"}'
|
|
1194
|
+
exit 0
|
|
1195
|
+
fi
|
|
1196
|
+
|
|
1197
|
+
# --- 4. Everything else → allow ---
|
|
1198
|
+
# Read-only built-ins and anything not explicitly gated. Fail-open mirrors the
|
|
1199
|
+
# native harness (gate the dangerous set, allow the rest).
|
|
1200
|
+
echo '{"permission":"allow"}'
|
|
1201
|
+
exit 0
|
|
1202
|
+
`;
|
|
1203
|
+
}
|
|
1204
|
+
//# sourceMappingURL=hook-script.js.map
|