@namzu/sdk 2.0.0 → 3.1.0
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/CHANGELOG.md +2311 -0
- package/README.md +49 -53
- package/dist/__tests__/default-path-conformance.test.d.ts +2 -0
- package/dist/__tests__/default-path-conformance.test.d.ts.map +1 -0
- package/dist/__tests__/default-path-conformance.test.js +262 -0
- package/dist/__tests__/default-path-conformance.test.js.map +1 -0
- package/dist/__tests__/shipped-defaults.test.d.ts +2 -0
- package/dist/__tests__/shipped-defaults.test.d.ts.map +1 -0
- package/dist/__tests__/shipped-defaults.test.js +97 -0
- package/dist/__tests__/shipped-defaults.test.js.map +1 -0
- package/dist/advisory/__tests__/budget-enforcement.test.d.ts +2 -0
- package/dist/advisory/__tests__/budget-enforcement.test.d.ts.map +1 -0
- package/dist/advisory/__tests__/budget-enforcement.test.js +159 -0
- package/dist/advisory/__tests__/budget-enforcement.test.js.map +1 -0
- package/dist/advisory/__tests__/structured-response.test.d.ts +2 -0
- package/dist/advisory/__tests__/structured-response.test.d.ts.map +1 -0
- package/dist/advisory/__tests__/structured-response.test.js +99 -0
- package/dist/advisory/__tests__/structured-response.test.js.map +1 -0
- package/dist/advisory/budget.d.ts +15 -0
- package/dist/advisory/budget.d.ts.map +1 -0
- package/dist/advisory/budget.js +21 -0
- package/dist/advisory/budget.js.map +1 -0
- package/dist/advisory/context.d.ts +2 -0
- package/dist/advisory/context.d.ts.map +1 -1
- package/dist/advisory/context.js +16 -0
- package/dist/advisory/context.js.map +1 -1
- package/dist/advisory/executor.d.ts +14 -11
- package/dist/advisory/executor.d.ts.map +1 -1
- package/dist/advisory/executor.js +36 -24
- package/dist/advisory/executor.js.map +1 -1
- package/dist/advisory/executor.test.d.ts +8 -6
- package/dist/advisory/executor.test.d.ts.map +1 -1
- package/dist/advisory/executor.test.js +12 -8
- package/dist/advisory/executor.test.js.map +1 -1
- package/dist/advisory/index.d.ts +2 -0
- package/dist/advisory/index.d.ts.map +1 -1
- package/dist/advisory/index.js +2 -0
- package/dist/advisory/index.js.map +1 -1
- package/dist/advisory/parse.d.ts +23 -0
- package/dist/advisory/parse.d.ts.map +1 -0
- package/dist/advisory/parse.js +56 -0
- package/dist/advisory/parse.js.map +1 -0
- package/dist/agents/AbstractAgent.d.ts +48 -0
- package/dist/agents/AbstractAgent.d.ts.map +1 -1
- package/dist/agents/AbstractAgent.js +77 -0
- package/dist/agents/AbstractAgent.js.map +1 -1
- package/dist/agents/PipelineAgent.d.ts +10 -0
- package/dist/agents/PipelineAgent.d.ts.map +1 -1
- package/dist/agents/PipelineAgent.js +12 -0
- package/dist/agents/PipelineAgent.js.map +1 -1
- package/dist/agents/ReactiveAgent.d.ts +10 -0
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +40 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts +10 -0
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +23 -2
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts +11 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +23 -1
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/__tests__/idempotency-key.test.d.ts +2 -0
- package/dist/agents/__tests__/idempotency-key.test.d.ts.map +1 -0
- package/dist/agents/__tests__/idempotency-key.test.js +149 -0
- package/dist/agents/__tests__/idempotency-key.test.js.map +1 -0
- package/dist/agents/__tests__/invocation-lock.test.d.ts +2 -0
- package/dist/agents/__tests__/invocation-lock.test.d.ts.map +1 -0
- package/dist/agents/__tests__/invocation-lock.test.js +126 -0
- package/dist/agents/__tests__/invocation-lock.test.js.map +1 -0
- package/dist/agents/__tests__/reachability.test.d.ts +2 -0
- package/dist/agents/__tests__/reachability.test.d.ts.map +1 -0
- package/dist/agents/__tests__/reachability.test.js +173 -0
- package/dist/agents/__tests__/reachability.test.js.map +1 -0
- package/dist/agents/__tests__/supervisor-ledger.test.js +1 -1
- package/dist/agents/__tests__/supervisor-ledger.test.js.map +1 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/lock.d.ts +0 -1
- package/dist/agents/lock.d.ts.map +1 -1
- package/dist/agents/lock.js.map +1 -1
- package/dist/bridge/a2a/late-events.test.d.ts +2 -0
- package/dist/bridge/a2a/late-events.test.d.ts.map +1 -0
- package/dist/bridge/a2a/late-events.test.js +70 -0
- package/dist/bridge/a2a/late-events.test.js.map +1 -0
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +55 -3
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/a2a/mapper.test.js +1 -1
- package/dist/bridge/a2a/mapper.test.js.map +1 -1
- package/dist/bridge/a2a/message.d.ts.map +1 -1
- package/dist/bridge/a2a/message.js +5 -1
- package/dist/bridge/a2a/message.js.map +1 -1
- package/dist/bridge/sse/late-events.test.d.ts +2 -0
- package/dist/bridge/sse/late-events.test.d.ts.map +1 -0
- package/dist/bridge/sse/late-events.test.js +163 -0
- package/dist/bridge/sse/late-events.test.js.map +1 -0
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +100 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/compaction/__tests__/cleared-result-recovery.test.d.ts +2 -0
- package/dist/compaction/__tests__/cleared-result-recovery.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/cleared-result-recovery.test.js +101 -0
- package/dist/compaction/__tests__/cleared-result-recovery.test.js.map +1 -0
- package/dist/compaction/__tests__/context-window.test.d.ts +2 -0
- package/dist/compaction/__tests__/context-window.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/context-window.test.js +62 -0
- package/dist/compaction/__tests__/context-window.test.js.map +1 -0
- package/dist/compaction/__tests__/dangling.test.js +16 -5
- package/dist/compaction/__tests__/dangling.test.js.map +1 -1
- package/dist/compaction/__tests__/lossiness.test.d.ts +2 -0
- package/dist/compaction/__tests__/lossiness.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/lossiness.test.js +163 -0
- package/dist/compaction/__tests__/lossiness.test.js.map +1 -0
- package/dist/compaction/__tests__/state-across-resume.test.d.ts +2 -0
- package/dist/compaction/__tests__/state-across-resume.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/state-across-resume.test.js +88 -0
- package/dist/compaction/__tests__/state-across-resume.test.js.map +1 -0
- package/dist/compaction/__tests__/tool-result-editing.test.d.ts +2 -0
- package/dist/compaction/__tests__/tool-result-editing.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/tool-result-editing.test.js +184 -0
- package/dist/compaction/__tests__/tool-result-editing.test.js.map +1 -0
- package/dist/compaction/__tests__/trim-opens-on-user.test.d.ts +2 -0
- package/dist/compaction/__tests__/trim-opens-on-user.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/trim-opens-on-user.test.js +109 -0
- package/dist/compaction/__tests__/trim-opens-on-user.test.js.map +1 -0
- package/dist/compaction/__tests__/verifier-model.test.d.ts +2 -0
- package/dist/compaction/__tests__/verifier-model.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/verifier-model.test.js +58 -0
- package/dist/compaction/__tests__/verifier-model.test.js.map +1 -0
- package/dist/compaction/context-window.d.ts +44 -0
- package/dist/compaction/context-window.d.ts.map +1 -0
- package/dist/compaction/context-window.js +97 -0
- package/dist/compaction/context-window.js.map +1 -0
- package/dist/compaction/dangling.js +48 -1
- package/dist/compaction/dangling.js.map +1 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +55 -1
- package/dist/compaction/extractor.js.map +1 -1
- package/dist/compaction/index.d.ts +5 -0
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +3 -0
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/manager.d.ts +25 -0
- package/dist/compaction/manager.d.ts.map +1 -1
- package/dist/compaction/manager.js +42 -8
- package/dist/compaction/manager.js.map +1 -1
- package/dist/compaction/managers/structured.d.ts.map +1 -1
- package/dist/compaction/managers/structured.js +7 -3
- package/dist/compaction/managers/structured.js.map +1 -1
- package/dist/compaction/retention.d.ts +15 -0
- package/dist/compaction/retention.d.ts.map +1 -0
- package/dist/compaction/retention.js +89 -0
- package/dist/compaction/retention.js.map +1 -0
- package/dist/compaction/serializer.d.ts.map +1 -1
- package/dist/compaction/serializer.js +28 -11
- package/dist/compaction/serializer.js.map +1 -1
- package/dist/compaction/tool-result-editing.d.ts +54 -0
- package/dist/compaction/tool-result-editing.d.ts.map +1 -0
- package/dist/compaction/tool-result-editing.js +164 -0
- package/dist/compaction/tool-result-editing.js.map +1 -0
- package/dist/compaction/types.d.ts +10 -0
- package/dist/compaction/types.d.ts.map +1 -1
- package/dist/compaction/verifier.d.ts +20 -1
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +11 -2
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/compaction/wire.d.ts +54 -0
- package/dist/compaction/wire.d.ts.map +1 -0
- package/dist/compaction/wire.js +45 -0
- package/dist/compaction/wire.js.map +1 -0
- package/dist/config/runtime.d.ts +161 -45
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +61 -19
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/builtins/http.d.ts.map +1 -1
- package/dist/connector/builtins/http.js +14 -1
- package/dist/connector/builtins/http.js.map +1 -1
- package/dist/connector/builtins/http.test.js +12 -0
- package/dist/connector/builtins/http.test.js.map +1 -1
- package/dist/connector/mcp/__tests__/discovery-policy.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/discovery-policy.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/discovery-policy.test.js +109 -0
- package/dist/connector/mcp/__tests__/discovery-policy.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/list-pagination.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/list-pagination.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/list-pagination.test.js +81 -0
- package/dist/connector/mcp/__tests__/list-pagination.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/policy.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/policy.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/policy.test.js +86 -0
- package/dist/connector/mcp/__tests__/policy.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/protocol-negotiation.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/protocol-negotiation.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/protocol-negotiation.test.js +81 -0
- package/dist/connector/mcp/__tests__/protocol-negotiation.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/schema-fidelity.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/schema-fidelity.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/schema-fidelity.test.js +206 -0
- package/dist/connector/mcp/__tests__/schema-fidelity.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/structured-result.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/structured-result.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/structured-result.test.js +112 -0
- package/dist/connector/mcp/__tests__/structured-result.test.js.map +1 -0
- package/dist/connector/mcp/adapter.d.ts +14 -0
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +292 -18
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +38 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +138 -12
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/client.test.d.ts +2 -0
- package/dist/connector/mcp/client.test.d.ts.map +1 -0
- package/dist/connector/mcp/client.test.js +105 -0
- package/dist/connector/mcp/client.test.js.map +1 -0
- package/dist/connector/mcp/discovery.d.ts +32 -1
- package/dist/connector/mcp/discovery.d.ts.map +1 -1
- package/dist/connector/mcp/discovery.js +41 -4
- package/dist/connector/mcp/discovery.js.map +1 -1
- package/dist/connector/mcp/http-sse.d.ts.map +1 -1
- package/dist/connector/mcp/http-sse.js +15 -1
- package/dist/connector/mcp/http-sse.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +3 -0
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +1 -0
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/policy.d.ts +57 -0
- package/dist/connector/mcp/policy.d.ts.map +1 -0
- package/dist/connector/mcp/policy.js +84 -0
- package/dist/connector/mcp/policy.js.map +1 -0
- package/dist/connector/mcp/schema-refs.d.ts +26 -0
- package/dist/connector/mcp/schema-refs.d.ts.map +1 -0
- package/dist/connector/mcp/schema-refs.js +111 -0
- package/dist/connector/mcp/schema-refs.js.map +1 -0
- package/dist/constants/agent/index.d.ts.map +1 -1
- package/dist/constants/agent/index.js +3 -0
- package/dist/constants/agent/index.js.map +1 -1
- package/dist/constants/compaction/index.js +1 -1
- package/dist/constants/compaction/index.js.map +1 -1
- package/dist/constants/continuation.d.ts +4 -4
- package/dist/constants/continuation.js +4 -4
- package/dist/constants/mcp/index.d.ts +31 -0
- package/dist/constants/mcp/index.d.ts.map +1 -1
- package/dist/constants/mcp/index.js +31 -0
- package/dist/constants/mcp/index.js.map +1 -1
- package/dist/constants/plugin/index.d.ts +23 -2
- package/dist/constants/plugin/index.d.ts.map +1 -1
- package/dist/constants/plugin/index.js +23 -2
- package/dist/constants/plugin/index.js.map +1 -1
- package/dist/constants/sandbox/index.d.ts +2 -3
- package/dist/constants/sandbox/index.d.ts.map +1 -1
- package/dist/constants/sandbox/index.js +6 -5
- package/dist/constants/sandbox/index.js.map +1 -1
- package/dist/constants/telemetry/index.d.ts +7 -0
- package/dist/constants/telemetry/index.d.ts.map +1 -1
- package/dist/constants/telemetry/index.js +7 -0
- package/dist/constants/telemetry/index.js.map +1 -1
- package/dist/constants/tools/index.d.ts +16 -0
- package/dist/constants/tools/index.d.ts.map +1 -1
- package/dist/constants/tools/index.js +16 -0
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/contracts/a2a.d.ts +94 -94
- package/dist/contracts/api.d.ts +40 -2
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/run-status.d.ts +17 -0
- package/dist/contracts/run-status.d.ts.map +1 -0
- package/dist/contracts/run-status.js +41 -0
- package/dist/contracts/run-status.js.map +1 -0
- package/dist/contracts/schemas.d.ts +6 -6
- package/dist/eval/__tests__/case-deadline.test.d.ts +2 -0
- package/dist/eval/__tests__/case-deadline.test.d.ts.map +1 -0
- package/dist/eval/__tests__/case-deadline.test.js +128 -0
- package/dist/eval/__tests__/case-deadline.test.js.map +1 -0
- package/dist/eval/__tests__/end-to-end.test.d.ts +2 -0
- package/dist/eval/__tests__/end-to-end.test.d.ts.map +1 -0
- package/dist/eval/__tests__/end-to-end.test.js +223 -0
- package/dist/eval/__tests__/end-to-end.test.js.map +1 -0
- package/dist/eval/__tests__/harness-honesty.test.d.ts +2 -0
- package/dist/eval/__tests__/harness-honesty.test.d.ts.map +1 -0
- package/dist/eval/__tests__/harness-honesty.test.js +85 -0
- package/dist/eval/__tests__/harness-honesty.test.js.map +1 -0
- package/dist/eval/__tests__/harness.test.d.ts +2 -0
- package/dist/eval/__tests__/harness.test.d.ts.map +1 -0
- package/dist/eval/__tests__/harness.test.js +207 -0
- package/dist/eval/__tests__/harness.test.js.map +1 -0
- package/dist/eval/__tests__/judge.test.d.ts +2 -0
- package/dist/eval/__tests__/judge.test.d.ts.map +1 -0
- package/dist/eval/__tests__/judge.test.js +255 -0
- package/dist/eval/__tests__/judge.test.js.map +1 -0
- package/dist/eval/__tests__/scorer-gates.test.d.ts +2 -0
- package/dist/eval/__tests__/scorer-gates.test.d.ts.map +1 -0
- package/dist/eval/__tests__/scorer-gates.test.js +136 -0
- package/dist/eval/__tests__/scorer-gates.test.js.map +1 -0
- package/dist/eval/experiment.d.ts +54 -0
- package/dist/eval/experiment.d.ts.map +1 -0
- package/dist/eval/experiment.js +263 -0
- package/dist/eval/experiment.js.map +1 -0
- package/dist/eval/from-run.d.ts +30 -0
- package/dist/eval/from-run.d.ts.map +1 -0
- package/dist/eval/from-run.js +46 -0
- package/dist/eval/from-run.js.map +1 -0
- package/dist/eval/index.d.ts +8 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +5 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/judge.d.ts +63 -0
- package/dist/eval/judge.d.ts.map +1 -0
- package/dist/eval/judge.js +136 -0
- package/dist/eval/judge.js.map +1 -0
- package/dist/eval/scorers.d.ts +40 -0
- package/dist/eval/scorers.d.ts.map +1 -0
- package/dist/eval/scorers.js +151 -0
- package/dist/eval/scorers.js.map +1 -0
- package/dist/eval/types.d.ts +150 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +2 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/execution/local.d.ts.map +1 -1
- package/dist/execution/local.js +6 -1
- package/dist/execution/local.js.map +1 -1
- package/dist/execution/local.test.d.ts +2 -0
- package/dist/execution/local.test.d.ts.map +1 -0
- package/dist/execution/local.test.js +37 -0
- package/dist/execution/local.test.js.map +1 -0
- package/dist/gateway/__tests__/list-survives-eviction.test.d.ts +2 -0
- package/dist/gateway/__tests__/list-survives-eviction.test.d.ts.map +1 -0
- package/dist/gateway/__tests__/list-survives-eviction.test.js +102 -0
- package/dist/gateway/__tests__/list-survives-eviction.test.js.map +1 -0
- package/dist/gateway/local.d.ts +42 -2
- package/dist/gateway/local.d.ts.map +1 -1
- package/dist/gateway/local.js +110 -3
- package/dist/gateway/local.js.map +1 -1
- package/dist/manager/agent/__tests__/dispose-cancels.test.d.ts +2 -0
- package/dist/manager/agent/__tests__/dispose-cancels.test.d.ts.map +1 -0
- package/dist/manager/agent/__tests__/dispose-cancels.test.js +88 -0
- package/dist/manager/agent/__tests__/dispose-cancels.test.js.map +1 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js +230 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +35 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +117 -7
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +90 -1
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +120 -0
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/plugin/__tests__/enable-contributions.test.js +3 -3
- package/dist/plugin/__tests__/enable-contributions.test.js.map +1 -1
- package/dist/plugin/__tests__/hook-ordering.test.d.ts +2 -0
- package/dist/plugin/__tests__/hook-ordering.test.d.ts.map +1 -0
- package/dist/plugin/__tests__/hook-ordering.test.js +227 -0
- package/dist/plugin/__tests__/hook-ordering.test.js.map +1 -0
- package/dist/plugin/__tests__/install-time-refusal.test.d.ts +2 -0
- package/dist/plugin/__tests__/install-time-refusal.test.d.ts.map +1 -0
- package/dist/plugin/__tests__/install-time-refusal.test.js +49 -0
- package/dist/plugin/__tests__/install-time-refusal.test.js.map +1 -0
- package/dist/plugin/__tests__/lifecycle.test.js +95 -68
- package/dist/plugin/__tests__/lifecycle.test.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +15 -1
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +67 -20
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/loader.d.ts +15 -0
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +33 -1
- package/dist/plugin/loader.js.map +1 -1
- package/dist/probe/registry.d.ts.map +1 -1
- package/dist/probe/registry.js +19 -1
- package/dist/probe/registry.js.map +1 -1
- package/dist/probe/registry.test.d.ts +9 -3
- package/dist/probe/registry.test.d.ts.map +1 -1
- package/dist/probe/registry.test.js +44 -6
- package/dist/probe/registry.test.js.map +1 -1
- package/dist/provider/__tests__/mock-script.test.d.ts +2 -0
- package/dist/provider/__tests__/mock-script.test.d.ts.map +1 -0
- package/dist/provider/__tests__/mock-script.test.js +151 -0
- package/dist/provider/__tests__/mock-script.test.js.map +1 -0
- package/dist/provider/__tests__/retry-visibility.test.d.ts +2 -0
- package/dist/provider/__tests__/retry-visibility.test.d.ts.map +1 -0
- package/dist/provider/__tests__/retry-visibility.test.js +137 -0
- package/dist/provider/__tests__/retry-visibility.test.js.map +1 -0
- package/dist/provider/__tests__/retry.test.d.ts +2 -0
- package/dist/provider/__tests__/retry.test.d.ts.map +1 -0
- package/dist/provider/__tests__/retry.test.js +259 -0
- package/dist/provider/__tests__/retry.test.js.map +1 -0
- package/dist/provider/capabilities.d.ts +1 -0
- package/dist/provider/capabilities.d.ts.map +1 -1
- package/dist/provider/capabilities.js +2 -0
- package/dist/provider/capabilities.js.map +1 -1
- package/dist/provider/collect.d.ts +1 -1
- package/dist/provider/collect.js +1 -1
- package/dist/provider/collect.test.d.ts +1 -1
- package/dist/provider/collect.test.js +1 -1
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +2 -0
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/mock-register.d.ts.map +1 -1
- package/dist/provider/mock-register.js +5 -2
- package/dist/provider/mock-register.js.map +1 -1
- package/dist/provider/mock.d.ts +35 -5
- package/dist/provider/mock.d.ts.map +1 -1
- package/dist/provider/mock.js +104 -32
- package/dist/provider/mock.js.map +1 -1
- package/dist/provider/retry.d.ts +42 -0
- package/dist/provider/retry.d.ts.map +1 -0
- package/dist/provider/retry.js +161 -0
- package/dist/provider/retry.js.map +1 -0
- package/dist/public-runtime.d.ts +26 -7
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +55 -7
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +5 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/rag/__tests__/retrieval-math.test.d.ts +2 -0
- package/dist/rag/__tests__/retrieval-math.test.d.ts.map +1 -0
- package/dist/rag/__tests__/retrieval-math.test.js +46 -0
- package/dist/rag/__tests__/retrieval-math.test.js.map +1 -0
- package/dist/rag/chunking.d.ts +12 -0
- package/dist/rag/chunking.d.ts.map +1 -1
- package/dist/rag/chunking.js +32 -1
- package/dist/rag/chunking.js.map +1 -1
- package/dist/rag/embedding.d.ts +4 -4
- package/dist/rag/embedding.d.ts.map +1 -1
- package/dist/rag/embedding.js +23 -3
- package/dist/rag/embedding.js.map +1 -1
- package/dist/rag/embedding.test.d.ts +1 -1
- package/dist/rag/embedding.test.js +59 -10
- package/dist/rag/embedding.test.js.map +1 -1
- package/dist/rag/index.d.ts +1 -1
- package/dist/rag/index.d.ts.map +1 -1
- package/dist/rag/index.js +1 -1
- package/dist/rag/index.js.map +1 -1
- package/dist/rag/retriever.d.ts +0 -1
- package/dist/rag/retriever.d.ts.map +1 -1
- package/dist/rag/retriever.js +75 -22
- package/dist/rag/retriever.js.map +1 -1
- package/dist/rag/vector-store.test.d.ts +1 -1
- package/dist/rag/vector-store.test.js +2 -2
- package/dist/rag/vector-store.test.js.map +1 -1
- package/dist/registry/ManagedRegistry.test.d.ts +1 -1
- package/dist/registry/ManagedRegistry.test.js +1 -1
- package/dist/registry/Registry.test.d.ts +1 -1
- package/dist/registry/Registry.test.js +1 -1
- package/dist/registry/connector/definitions.test.d.ts +1 -1
- package/dist/registry/connector/definitions.test.js +1 -1
- package/dist/registry/tool/__tests__/schema.test.d.ts +2 -0
- package/dist/registry/tool/__tests__/schema.test.d.ts.map +1 -0
- package/dist/registry/tool/__tests__/schema.test.js +176 -0
- package/dist/registry/tool/__tests__/schema.test.js.map +1 -0
- package/dist/registry/tool/__tests__/tool-name-validation.test.d.ts +2 -0
- package/dist/registry/tool/__tests__/tool-name-validation.test.d.ts.map +1 -0
- package/dist/registry/tool/__tests__/tool-name-validation.test.js +70 -0
- package/dist/registry/tool/__tests__/tool-name-validation.test.js.map +1 -0
- package/dist/registry/tool/execute.d.ts +37 -0
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +91 -21
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/schema.d.ts +26 -0
- package/dist/registry/tool/schema.d.ts.map +1 -0
- package/dist/registry/tool/schema.js +77 -0
- package/dist/registry/tool/schema.js.map +1 -0
- package/dist/registry/toolset/catalog.d.ts.map +1 -1
- package/dist/registry/toolset/catalog.js +0 -1
- package/dist/registry/toolset/catalog.js.map +1 -1
- package/dist/registry/toolset/catalog.test.js +0 -1
- package/dist/registry/toolset/catalog.test.js.map +1 -1
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +76 -0
- package/dist/run/reporter.js.map +1 -1
- package/dist/runtime/bidi/__tests__/session.test.d.ts +2 -0
- package/dist/runtime/bidi/__tests__/session.test.d.ts.map +1 -0
- package/dist/runtime/bidi/__tests__/session.test.js +201 -0
- package/dist/runtime/bidi/__tests__/session.test.js.map +1 -0
- package/dist/runtime/bidi/index.d.ts +5 -0
- package/dist/runtime/bidi/index.d.ts.map +1 -0
- package/dist/runtime/bidi/index.js +3 -0
- package/dist/runtime/bidi/index.js.map +1 -0
- package/dist/runtime/bidi/mock.d.ts +34 -0
- package/dist/runtime/bidi/mock.d.ts.map +1 -0
- package/dist/runtime/bidi/mock.js +60 -0
- package/dist/runtime/bidi/mock.js.map +1 -0
- package/dist/runtime/bidi/session.d.ts +44 -0
- package/dist/runtime/bidi/session.d.ts.map +1 -0
- package/dist/runtime/bidi/session.js +154 -0
- package/dist/runtime/bidi/session.js.map +1 -0
- package/dist/runtime/decision/parser.d.ts.map +1 -1
- package/dist/runtime/decision/parser.js +8 -1
- package/dist/runtime/decision/parser.js.map +1 -1
- package/dist/runtime/decision/parser.test.d.ts +2 -0
- package/dist/runtime/decision/parser.test.d.ts.map +1 -0
- package/dist/runtime/decision/parser.test.js +37 -0
- package/dist/runtime/decision/parser.test.js.map +1 -0
- package/dist/runtime/query/__tests__/answer-review.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/answer-review.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/answer-review.test.js +141 -0
- package/dist/runtime/query/__tests__/answer-review.test.js.map +1 -0
- package/dist/runtime/query/__tests__/capability-negotiation.test.js +77 -105
- package/dist/runtime/query/__tests__/capability-negotiation.test.js.map +1 -1
- package/dist/runtime/query/__tests__/checkpoint-store.test.js +12 -44
- package/dist/runtime/query/__tests__/checkpoint-store.test.js.map +1 -1
- package/dist/runtime/query/__tests__/checkpoint.test.js +2 -10
- package/dist/runtime/query/__tests__/checkpoint.test.js.map +1 -1
- package/dist/runtime/query/__tests__/citations.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/citations.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/citations.test.js +85 -0
- package/dist/runtime/query/__tests__/citations.test.js.map +1 -0
- package/dist/runtime/query/__tests__/content-budget.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/content-budget.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/content-budget.test.js +69 -0
- package/dist/runtime/query/__tests__/content-budget.test.js.map +1 -0
- package/dist/runtime/query/__tests__/context.test.js +3 -2
- package/dist/runtime/query/__tests__/context.test.js.map +1 -1
- package/dist/runtime/query/__tests__/deferred-tools.test.js +21 -130
- package/dist/runtime/query/__tests__/deferred-tools.test.js.map +1 -1
- package/dist/runtime/query/__tests__/delegation-resume.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/delegation-resume.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/delegation-resume.test.js +111 -0
- package/dist/runtime/query/__tests__/delegation-resume.test.js.map +1 -0
- package/dist/runtime/query/__tests__/document-attachments.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/document-attachments.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/document-attachments.test.js +92 -0
- package/dist/runtime/query/__tests__/document-attachments.test.js.map +1 -0
- package/dist/runtime/query/__tests__/durable-park-and-trace.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/durable-park-and-trace.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/durable-park-and-trace.test.js +194 -0
- package/dist/runtime/query/__tests__/durable-park-and-trace.test.js.map +1 -0
- package/dist/runtime/query/__tests__/durable-question-park.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/durable-question-park.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/durable-question-park.test.js +253 -0
- package/dist/runtime/query/__tests__/durable-question-park.test.js.map +1 -0
- package/dist/runtime/query/__tests__/durable-run-state.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/durable-run-state.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/durable-run-state.test.js +158 -0
- package/dist/runtime/query/__tests__/durable-run-state.test.js.map +1 -0
- package/dist/runtime/query/__tests__/executor-plugin-hooks.test.js +24 -20
- package/dist/runtime/query/__tests__/executor-plugin-hooks.test.js.map +1 -1
- package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.js +187 -0
- package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.js.map +1 -0
- package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.js +95 -0
- package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.js.map +1 -0
- package/dist/runtime/query/__tests__/guardrails-e2e.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/guardrails-e2e.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/guardrails-e2e.test.js +132 -0
- package/dist/runtime/query/__tests__/guardrails-e2e.test.js.map +1 -0
- package/dist/runtime/query/__tests__/guardrails.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/guardrails.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/guardrails.test.js +163 -0
- package/dist/runtime/query/__tests__/guardrails.test.js.map +1 -0
- package/dist/runtime/query/__tests__/hook-model-visibility.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/hook-model-visibility.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/hook-model-visibility.test.js +119 -0
- package/dist/runtime/query/__tests__/hook-model-visibility.test.js.map +1 -0
- package/dist/runtime/query/__tests__/long-document-flow.test.js +9 -2
- package/dist/runtime/query/__tests__/long-document-flow.test.js.map +1 -1
- package/dist/runtime/query/__tests__/memory-promotion.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/memory-promotion.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/memory-promotion.test.js +119 -0
- package/dist/runtime/query/__tests__/memory-promotion.test.js.map +1 -0
- package/dist/runtime/query/__tests__/orphan-task-turn-end.test.js +5 -27
- package/dist/runtime/query/__tests__/orphan-task-turn-end.test.js.map +1 -1
- package/dist/runtime/query/__tests__/overflow-relief.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/overflow-relief.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/overflow-relief.test.js +119 -0
- package/dist/runtime/query/__tests__/overflow-relief.test.js.map +1 -0
- package/dist/runtime/query/__tests__/partial-batch-resume.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/partial-batch-resume.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/partial-batch-resume.test.js +205 -0
- package/dist/runtime/query/__tests__/partial-batch-resume.test.js.map +1 -0
- package/dist/runtime/query/__tests__/plugin-hooks.test.js +0 -1
- package/dist/runtime/query/__tests__/plugin-hooks.test.js.map +1 -1
- package/dist/runtime/query/__tests__/prepare-step-chain.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/prepare-step-chain.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/prepare-step-chain.test.js +104 -0
- package/dist/runtime/query/__tests__/prepare-step-chain.test.js.map +1 -0
- package/dist/runtime/query/__tests__/prepare-step.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/prepare-step.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/prepare-step.test.js +194 -0
- package/dist/runtime/query/__tests__/prepare-step.test.js.map +1 -0
- package/dist/runtime/query/__tests__/probe-veto-is-error.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/probe-veto-is-error.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/probe-veto-is-error.test.js +111 -0
- package/dist/runtime/query/__tests__/probe-veto-is-error.test.js.map +1 -0
- package/dist/runtime/query/__tests__/prompt.test.js +1 -1
- package/dist/runtime/query/__tests__/prompt.test.js.map +1 -1
- package/dist/runtime/query/__tests__/provider-fault-pauses.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/provider-fault-pauses.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/provider-fault-pauses.test.js +86 -0
- package/dist/runtime/query/__tests__/provider-fault-pauses.test.js.map +1 -0
- package/dist/runtime/query/__tests__/reasoning-stream.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/reasoning-stream.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/reasoning-stream.test.js +146 -0
- package/dist/runtime/query/__tests__/reasoning-stream.test.js.map +1 -0
- package/dist/runtime/query/__tests__/recoverable-settle.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/recoverable-settle.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/recoverable-settle.test.js +119 -0
- package/dist/runtime/query/__tests__/recoverable-settle.test.js.map +1 -0
- package/dist/runtime/query/__tests__/resume-budget.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/resume-budget.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/resume-budget.test.js +130 -0
- package/dist/runtime/query/__tests__/resume-budget.test.js.map +1 -0
- package/dist/runtime/query/__tests__/resume-pending.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/resume-pending.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/resume-pending.test.js +226 -0
- package/dist/runtime/query/__tests__/resume-pending.test.js.map +1 -0
- package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.js +89 -0
- package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.js.map +1 -0
- package/dist/runtime/query/__tests__/stop-condition.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/stop-condition.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/stop-condition.test.js +205 -0
- package/dist/runtime/query/__tests__/stop-condition.test.js.map +1 -0
- package/dist/runtime/query/__tests__/structured-output.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/structured-output.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/structured-output.test.js +219 -0
- package/dist/runtime/query/__tests__/structured-output.test.js.map +1 -0
- package/dist/runtime/query/__tests__/structured-run-failure.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/structured-run-failure.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/structured-run-failure.test.js +117 -0
- package/dist/runtime/query/__tests__/structured-run-failure.test.js.map +1 -0
- package/dist/runtime/query/__tests__/terminal-tool.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/terminal-tool.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/terminal-tool.test.js +119 -0
- package/dist/runtime/query/__tests__/terminal-tool.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-grants.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-grants.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-grants.test.js +85 -0
- package/dist/runtime/query/__tests__/tool-grants.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-output-budget.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-output-budget.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-output-budget.test.js +0 -0
- package/dist/runtime/query/__tests__/tool-output-budget.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-pause.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-pause.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-pause.test.js +165 -0
- package/dist/runtime/query/__tests__/tool-pause.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-progress.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-progress.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-progress.test.js +122 -0
- package/dist/runtime/query/__tests__/tool-progress.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-repair-retry.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-repair-retry.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-repair-retry.test.js +196 -0
- package/dist/runtime/query/__tests__/tool-repair-retry.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-result-wire.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-result-wire.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-result-wire.test.js +106 -0
- package/dist/runtime/query/__tests__/tool-result-wire.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-timeout.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-timeout.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-timeout.test.js +184 -0
- package/dist/runtime/query/__tests__/tool-timeout.test.js.map +1 -0
- package/dist/runtime/query/__tests__/trace-parenting.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/trace-parenting.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/trace-parenting.test.js +111 -0
- package/dist/runtime/query/__tests__/trace-parenting.test.js.map +1 -0
- package/dist/runtime/query/__tests__/wiring-seams.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/wiring-seams.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/wiring-seams.test.js +237 -0
- package/dist/runtime/query/__tests__/wiring-seams.test.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +124 -6
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +207 -6
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/events.js +2 -2
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +225 -7
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +672 -36
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/guard.d.ts +18 -0
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +16 -1
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/guardrail-presets.d.ts +36 -0
- package/dist/runtime/query/guardrail-presets.d.ts.map +1 -0
- package/dist/runtime/query/guardrail-presets.js +96 -0
- package/dist/runtime/query/guardrail-presets.js.map +1 -0
- package/dist/runtime/query/guardrails.d.ts +35 -0
- package/dist/runtime/query/guardrails.d.ts.map +1 -0
- package/dist/runtime/query/guardrails.js +102 -0
- package/dist/runtime/query/guardrails.js.map +1 -0
- package/dist/runtime/query/index.d.ts +213 -2
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +458 -10
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.d.ts +2 -0
- package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.js +131 -0
- package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.js.map +1 -0
- package/dist/runtime/query/iteration/index.d.ts +76 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +594 -29
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +14 -2
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.test.d.ts +1 -1
- package/dist/runtime/query/iteration/phases/advisory.test.js +4 -1
- package/dist/runtime/query/iteration/phases/advisory.test.js.map +1 -1
- package/dist/runtime/query/iteration/phases/checkpoint.js +2 -2
- package/dist/runtime/query/iteration/phases/checkpoint.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.js +1 -1
- package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts +22 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +297 -64
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context-measurement.test.d.ts +21 -0
- package/dist/runtime/query/iteration/phases/context-measurement.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/context-measurement.test.js +161 -0
- package/dist/runtime/query/iteration/phases/context-measurement.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/context.d.ts +62 -2
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +87 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/hitl-answer-question.test.js +3 -1
- package/dist/runtime/query/iteration/phases/hitl-answer-question.test.js.map +1 -1
- package/dist/runtime/query/iteration/phases/overflow-escalation.test.d.ts +15 -0
- package/dist/runtime/query/iteration/phases/overflow-escalation.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/overflow-escalation.test.js +130 -0
- package/dist/runtime/query/iteration/phases/overflow-escalation.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/plan.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/plan.js +8 -2
- package/dist/runtime/query/iteration/phases/plan.js.map +1 -1
- package/dist/runtime/query/iteration/phases/retained-messages.test.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/retained-messages.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/retained-messages.test.js +180 -0
- package/dist/runtime/query/iteration/phases/retained-messages.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/tool-review-denials.test.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/tool-review-denials.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/tool-review-denials.test.js +224 -0
- package/dist/runtime/query/iteration/phases/tool-review-denials.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/tool-review.d.ts +29 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +114 -44
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/working-memory-compaction.test.js +20 -9
- package/dist/runtime/query/iteration/phases/working-memory-compaction.test.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts +2 -26
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +254 -16
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/plugin-hooks.d.ts.map +1 -1
- package/dist/runtime/query/plugin-hooks.js +6 -2
- package/dist/runtime/query/plugin-hooks.js.map +1 -1
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +25 -1
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/question-park.d.ts +85 -0
- package/dist/runtime/query/question-park.d.ts.map +1 -0
- package/dist/runtime/query/question-park.js +71 -0
- package/dist/runtime/query/question-park.js.map +1 -0
- package/dist/runtime/query/result.d.ts +9 -0
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +49 -0
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +106 -0
- package/dist/runtime/query/resume-pending.d.ts.map +1 -0
- package/dist/runtime/query/resume-pending.js +312 -0
- package/dist/runtime/query/resume-pending.js.map +1 -0
- package/dist/runtime/query/run-state.d.ts +52 -0
- package/dist/runtime/query/run-state.d.ts.map +1 -0
- package/dist/runtime/query/run-state.js +87 -0
- package/dist/runtime/query/run-state.js.map +1 -0
- package/dist/runtime/query/tool-grants.d.ts +44 -0
- package/dist/runtime/query/tool-grants.d.ts.map +1 -0
- package/dist/runtime/query/tool-grants.js +63 -0
- package/dist/runtime/query/tool-grants.js.map +1 -0
- package/dist/runtime/query/tool-output-budget.d.ts +83 -0
- package/dist/runtime/query/tool-output-budget.d.ts.map +1 -0
- package/dist/runtime/query/tool-output-budget.js +147 -0
- package/dist/runtime/query/tool-output-budget.js.map +1 -0
- package/dist/runtime/query/tool-pause.d.ts +41 -0
- package/dist/runtime/query/tool-pause.d.ts.map +1 -0
- package/dist/runtime/query/tool-pause.js +94 -0
- package/dist/runtime/query/tool-pause.js.map +1 -0
- package/dist/runtime/query/tooling.d.ts +10 -1
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +13 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/sandbox/__tests__/isolation.test.d.ts +2 -0
- package/dist/sandbox/__tests__/isolation.test.d.ts.map +1 -0
- package/dist/sandbox/__tests__/isolation.test.js +139 -0
- package/dist/sandbox/__tests__/isolation.test.js.map +1 -0
- package/dist/sandbox/__tests__/output-truncation.test.d.ts +2 -0
- package/dist/sandbox/__tests__/output-truncation.test.d.ts.map +1 -0
- package/dist/sandbox/__tests__/output-truncation.test.js +88 -0
- package/dist/sandbox/__tests__/output-truncation.test.js.map +1 -0
- package/dist/sandbox/__tests__/resource-limits.test.d.ts +2 -0
- package/dist/sandbox/__tests__/resource-limits.test.d.ts.map +1 -0
- package/dist/sandbox/__tests__/resource-limits.test.js +86 -0
- package/dist/sandbox/__tests__/resource-limits.test.js.map +1 -0
- package/dist/sandbox/factory.js +1 -1
- package/dist/sandbox/factory.js.map +1 -1
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +1 -0
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/isolation.d.ts +15 -0
- package/dist/sandbox/isolation.d.ts.map +1 -0
- package/dist/sandbox/isolation.js +53 -0
- package/dist/sandbox/isolation.js.map +1 -0
- package/dist/sandbox/provider/local.d.ts +51 -2
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +139 -69
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/session/__tests__/integration/spawn-rollback.test.d.ts +1 -1
- package/dist/session/__tests__/integration/spawn-rollback.test.js +1 -1
- package/dist/session/handoff/broadcast.js +3 -3
- package/dist/session/handoff/broadcast.js.map +1 -1
- package/dist/session/migration/__tests__/filesystem.test.js +5 -1
- package/dist/session/migration/__tests__/filesystem.test.js.map +1 -1
- package/dist/session/migration/filesystem.d.ts.map +1 -1
- package/dist/session/migration/filesystem.js +7 -13
- package/dist/session/migration/filesystem.js.map +1 -1
- package/dist/session/migration/marker.d.ts.map +1 -1
- package/dist/session/migration/marker.js +5 -10
- package/dist/session/migration/marker.js.map +1 -1
- package/dist/session/retention/disk-backend.d.ts.map +1 -1
- package/dist/session/retention/disk-backend.js +5 -12
- package/dist/session/retention/disk-backend.js.map +1 -1
- package/dist/session/workspace/__tests__/git-worktree.test.js +6 -2
- package/dist/session/workspace/__tests__/git-worktree.test.js.map +1 -1
- package/dist/session/workspace/__tests__/shared-run.test.js +15 -0
- package/dist/session/workspace/__tests__/shared-run.test.js.map +1 -1
- package/dist/session/workspace/shared-run.js +8 -1
- package/dist/session/workspace/shared-run.js.map +1 -1
- package/dist/skills/__tests__/frontmatter.test.d.ts +2 -0
- package/dist/skills/__tests__/frontmatter.test.d.ts.map +1 -0
- package/dist/skills/__tests__/frontmatter.test.js +106 -0
- package/dist/skills/__tests__/frontmatter.test.js.map +1 -0
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +42 -3
- package/dist/skills/loader.js.map +1 -1
- package/dist/store/__tests__/checkpoint-integrity.test.d.ts +2 -0
- package/dist/store/__tests__/checkpoint-integrity.test.d.ts.map +1 -0
- package/dist/store/__tests__/checkpoint-integrity.test.js +112 -0
- package/dist/store/__tests__/checkpoint-integrity.test.js.map +1 -0
- package/dist/store/__tests__/checkpoint-versioning.test.d.ts +2 -0
- package/dist/store/__tests__/checkpoint-versioning.test.d.ts.map +1 -0
- package/dist/store/__tests__/checkpoint-versioning.test.js +151 -0
- package/dist/store/__tests__/checkpoint-versioning.test.js.map +1 -0
- package/dist/store/__tests__/schema-adoption.test.d.ts +2 -0
- package/dist/store/__tests__/schema-adoption.test.d.ts.map +1 -0
- package/dist/store/__tests__/schema-adoption.test.js +90 -0
- package/dist/store/__tests__/schema-adoption.test.js.map +1 -0
- package/dist/store/__tests__/schema.test.d.ts +2 -0
- package/dist/store/__tests__/schema.test.d.ts.map +1 -0
- package/dist/store/__tests__/schema.test.js +93 -0
- package/dist/store/__tests__/schema.test.js.map +1 -0
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +16 -16
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/run/disk.d.ts +23 -0
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js +148 -23
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/schema.d.ts +73 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +103 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +25 -13
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/task/__tests__/lookup-across-runs.test.d.ts +2 -0
- package/dist/store/task/__tests__/lookup-across-runs.test.d.ts.map +1 -0
- package/dist/store/task/__tests__/lookup-across-runs.test.js +60 -0
- package/dist/store/task/__tests__/lookup-across-runs.test.js.map +1 -0
- package/dist/store/task/disk.d.ts +18 -0
- package/dist/store/task/disk.d.ts.map +1 -1
- package/dist/store/task/disk.js +61 -16
- package/dist/store/task/disk.js.map +1 -1
- package/dist/store/thread/disk.d.ts.map +1 -1
- package/dist/store/thread/disk.js +20 -11
- package/dist/store/thread/disk.js.map +1 -1
- package/dist/streaming/coalesce.d.ts +1 -1
- package/dist/streaming/coalesce.js +1 -1
- package/dist/telemetry/__tests__/latency-instruments.test.d.ts +2 -0
- package/dist/telemetry/__tests__/latency-instruments.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/latency-instruments.test.js +82 -0
- package/dist/telemetry/__tests__/latency-instruments.test.js.map +1 -0
- package/dist/telemetry/__tests__/metrics.test.d.ts +2 -0
- package/dist/telemetry/__tests__/metrics.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/metrics.test.js +112 -0
- package/dist/telemetry/__tests__/metrics.test.js.map +1 -0
- package/dist/telemetry/__tests__/span-hierarchy.test.d.ts +2 -0
- package/dist/telemetry/__tests__/span-hierarchy.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/span-hierarchy.test.js +84 -0
- package/dist/telemetry/__tests__/span-hierarchy.test.js.map +1 -0
- package/dist/telemetry/attributes.d.ts +44 -0
- package/dist/telemetry/attributes.d.ts.map +1 -1
- package/dist/telemetry/attributes.js +80 -0
- package/dist/telemetry/attributes.js.map +1 -1
- package/dist/telemetry/metrics.d.ts +41 -0
- package/dist/telemetry/metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics.js +160 -0
- package/dist/telemetry/metrics.js.map +1 -0
- package/dist/test-setup.d.ts +3 -3
- package/dist/test-setup.js +3 -3
- package/dist/test-support/paths.d.ts +14 -0
- package/dist/test-support/paths.d.ts.map +1 -0
- package/dist/test-support/paths.js +16 -0
- package/dist/test-support/paths.js.map +1 -0
- package/dist/tools/__tests__/path-containment.test.d.ts +2 -0
- package/dist/tools/__tests__/path-containment.test.d.ts.map +1 -0
- package/dist/tools/__tests__/path-containment.test.js +133 -0
- package/dist/tools/__tests__/path-containment.test.js.map +1 -0
- package/dist/tools/__tests__/posix-path.test.d.ts +2 -0
- package/dist/tools/__tests__/posix-path.test.d.ts.map +1 -0
- package/dist/tools/__tests__/posix-path.test.js +67 -0
- package/dist/tools/__tests__/posix-path.test.js.map +1 -0
- package/dist/tools/__tests__/sandboxed-search.test.d.ts +2 -0
- package/dist/tools/__tests__/sandboxed-search.test.d.ts.map +1 -0
- package/dist/tools/__tests__/sandboxed-search.test.js +114 -0
- package/dist/tools/__tests__/sandboxed-search.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/computer-use.test.js +12 -2
- package/dist/tools/builtins/__tests__/computer-use.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/edit-commits-atomically.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/edit-commits-atomically.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/edit-commits-atomically.test.js +78 -0
- package/dist/tools/builtins/__tests__/edit-commits-atomically.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/edit.test.js +52 -17
- package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/payload-budget.test.js +16 -30
- package/dist/tools/builtins/__tests__/payload-budget.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/read-file.test.js +23 -1
- package/dist/tools/builtins/__tests__/read-file.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/stale-file-refusal.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/stale-file-refusal.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/stale-file-refusal.test.js +187 -0
- package/dist/tools/builtins/__tests__/stale-file-refusal.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/write-file.test.js +13 -37
- package/dist/tools/builtins/__tests__/write-file.test.js.map +1 -1
- package/dist/tools/builtins/atomic-write-file.d.ts +1 -1
- package/dist/tools/builtins/atomic-write-file.d.ts.map +1 -1
- package/dist/tools/builtins/atomic-write-file.js +31 -2
- package/dist/tools/builtins/atomic-write-file.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +33 -4
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +22 -22
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +7 -1
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +23 -0
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -0
- package/dist/tools/builtins/content-fingerprint.js +30 -0
- package/dist/tools/builtins/content-fingerprint.js.map +1 -0
- package/dist/tools/builtins/edit.d.ts +5 -2
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +218 -57
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts +1 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +63 -6
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +61 -8
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/index.js +6 -6
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/ls.d.ts.map +1 -1
- package/dist/tools/builtins/ls.js +4 -2
- package/dist/tools/builtins/ls.js.map +1 -1
- package/dist/tools/builtins/read-file.d.ts +1 -1
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +43 -6
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts +2 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +47 -25
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/__tests__/agent.test.d.ts +1 -1
- package/dist/tools/coordinator/__tests__/agent.test.js +2 -2
- package/dist/tools/coordinator/__tests__/agent.test.js.map +1 -1
- package/dist/tools/coordinator/__tests__/ask-user-question.test.js +55 -0
- package/dist/tools/coordinator/__tests__/ask-user-question.test.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts +20 -9
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +2 -1
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts +20 -0
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +142 -36
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/defineTool.d.ts +16 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +4 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/glob-match.d.ts +18 -0
- package/dist/tools/glob-match.d.ts.map +1 -0
- package/dist/tools/glob-match.js +50 -0
- package/dist/tools/glob-match.js.map +1 -0
- package/dist/tools/paths.d.ts +20 -0
- package/dist/tools/paths.d.ts.map +1 -0
- package/dist/tools/paths.js +41 -0
- package/dist/tools/paths.js.map +1 -0
- package/dist/tools/posix-path.d.ts +24 -0
- package/dist/tools/posix-path.d.ts.map +1 -0
- package/dist/tools/posix-path.js +67 -0
- package/dist/tools/posix-path.js.map +1 -0
- package/dist/types/advisory/config.d.ts +21 -3
- package/dist/types/advisory/config.d.ts.map +1 -1
- package/dist/types/advisory/result.d.ts +12 -10
- package/dist/types/advisory/result.d.ts.map +1 -1
- package/dist/types/agent/base.d.ts +20 -2
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +15 -9
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/dist/types/agent/gateway.d.ts +18 -0
- package/dist/types/agent/gateway.d.ts.map +1 -1
- package/dist/types/agent/manager.d.ts +19 -0
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/reactive.d.ts +48 -0
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/agent/router.d.ts +11 -0
- package/dist/types/agent/router.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +2 -2
- package/dist/types/agent/task.d.ts +24 -0
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/bidi/index.d.ts +140 -0
- package/dist/types/bidi/index.d.ts.map +1 -0
- package/dist/types/bidi/index.js +2 -0
- package/dist/types/bidi/index.js.map +1 -0
- package/dist/types/common/__tests__/numeric-correctness.test.d.ts +2 -0
- package/dist/types/common/__tests__/numeric-correctness.test.d.ts.map +1 -0
- package/dist/types/common/__tests__/numeric-correctness.test.js +108 -0
- package/dist/types/common/__tests__/numeric-correctness.test.js.map +1 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +15 -4
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +29 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/errors/__tests__/catalog.test.d.ts +2 -0
- package/dist/types/errors/__tests__/catalog.test.d.ts.map +1 -0
- package/dist/types/errors/__tests__/catalog.test.js +106 -0
- package/dist/types/errors/__tests__/catalog.test.js.map +1 -0
- package/dist/types/errors/__tests__/errors.test.d.ts +2 -0
- package/dist/types/errors/__tests__/errors.test.d.ts.map +1 -0
- package/dist/types/errors/__tests__/errors.test.js +104 -0
- package/dist/types/errors/__tests__/errors.test.js.map +1 -0
- package/dist/types/errors/catalog.d.ts +83 -0
- package/dist/types/errors/catalog.d.ts.map +1 -0
- package/dist/types/errors/catalog.js +148 -0
- package/dist/types/errors/catalog.js.map +1 -0
- package/dist/types/errors/index.d.ts +73 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/errors/index.js +70 -0
- package/dist/types/errors/index.js.map +1 -0
- package/dist/types/guardrail/index.d.ts +57 -0
- package/dist/types/guardrail/index.d.ts.map +1 -0
- package/dist/types/guardrail/index.js +2 -0
- package/dist/types/guardrail/index.js.map +1 -0
- package/dist/types/hitl/index.d.ts +97 -14
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/ids/index.d.ts +2 -2
- package/dist/types/message/content.d.ts +22 -0
- package/dist/types/message/content.d.ts.map +1 -0
- package/dist/types/message/content.js +49 -0
- package/dist/types/message/content.js.map +1 -0
- package/dist/types/message/index.d.ts +193 -8
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +19 -4
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +78 -3
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +0 -1
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/__tests__/cause-chain.test.d.ts +2 -0
- package/dist/types/provider/__tests__/cause-chain.test.d.ts.map +1 -0
- package/dist/types/provider/__tests__/cause-chain.test.js +108 -0
- package/dist/types/provider/__tests__/cause-chain.test.js.map +1 -0
- package/dist/types/provider/__tests__/declared-retryable.test.d.ts +2 -0
- package/dist/types/provider/__tests__/declared-retryable.test.d.ts.map +1 -0
- package/dist/types/provider/__tests__/declared-retryable.test.js +70 -0
- package/dist/types/provider/__tests__/declared-retryable.test.js.map +1 -0
- package/dist/types/provider/__tests__/overflow-classification.test.d.ts +2 -0
- package/dist/types/provider/__tests__/overflow-classification.test.d.ts.map +1 -0
- package/dist/types/provider/__tests__/overflow-classification.test.js +80 -0
- package/dist/types/provider/__tests__/overflow-classification.test.js.map +1 -0
- package/dist/types/provider/chat.d.ts +27 -1
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +83 -2
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/errors.d.ts +102 -0
- package/dist/types/provider/errors.d.ts.map +1 -0
- package/dist/types/provider/errors.js +393 -0
- package/dist/types/provider/errors.js.map +1 -0
- package/dist/types/provider/index.d.ts +3 -2
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +59 -3
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/rag/embedding.d.ts +11 -2
- package/dist/types/rag/embedding.d.ts.map +1 -1
- package/dist/types/run/__tests__/step.test.d.ts +2 -0
- package/dist/types/run/__tests__/step.test.d.ts.map +1 -0
- package/dist/types/run/__tests__/step.test.js +107 -0
- package/dist/types/run/__tests__/step.test.js.map +1 -0
- package/dist/types/run/answer-review.d.ts +46 -0
- package/dist/types/run/answer-review.d.ts.map +1 -0
- package/dist/types/run/answer-review.js +2 -0
- package/dist/types/run/answer-review.js.map +1 -0
- package/dist/types/run/config.d.ts +33 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/derive-status.d.ts +29 -0
- package/dist/types/run/derive-status.d.ts.map +1 -0
- package/dist/types/run/derive-status.js +49 -0
- package/dist/types/run/derive-status.js.map +1 -0
- package/dist/types/run/entity.d.ts +16 -0
- package/dist/types/run/entity.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +228 -4
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js +7 -0
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/run/index.d.ts +5 -0
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +3 -0
- package/dist/types/run/index.js.map +1 -1
- package/dist/types/run/memory-promotion.d.ts +90 -0
- package/dist/types/run/memory-promotion.d.ts.map +1 -0
- package/dist/types/run/memory-promotion.js +38 -0
- package/dist/types/run/memory-promotion.js.map +1 -0
- package/dist/types/run/prepare-step.d.ts +100 -0
- package/dist/types/run/prepare-step.d.ts.map +1 -0
- package/dist/types/run/prepare-step.js +2 -0
- package/dist/types/run/prepare-step.js.map +1 -0
- package/dist/types/run/state.d.ts +85 -0
- package/dist/types/run/state.d.ts.map +1 -0
- package/dist/types/run/state.js +33 -0
- package/dist/types/run/state.js.map +1 -0
- package/dist/types/run/step.d.ts +77 -0
- package/dist/types/run/step.d.ts.map +1 -0
- package/dist/types/run/step.js +26 -0
- package/dist/types/run/step.js.map +1 -0
- package/dist/types/run/stop-reason.d.ts +31 -3
- package/dist/types/run/stop-reason.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +82 -10
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js +13 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/structured-output/index.d.ts +6 -5
- package/dist/types/structured-output/index.d.ts.map +1 -1
- package/dist/types/thread/entity.d.ts +2 -3
- package/dist/types/thread/entity.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +210 -2
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/repair.d.ts +49 -0
- package/dist/types/tool/repair.d.ts.map +1 -0
- package/dist/types/tool/repair.js +2 -0
- package/dist/types/tool/repair.js.map +1 -0
- package/dist/types/toolset/index.d.ts +2 -5
- package/dist/types/toolset/index.d.ts.map +1 -1
- package/dist/utils/__tests__/atomic-write.test.d.ts +2 -0
- package/dist/utils/__tests__/atomic-write.test.d.ts.map +1 -0
- package/dist/utils/__tests__/atomic-write.test.js +91 -0
- package/dist/utils/__tests__/atomic-write.test.js.map +1 -0
- package/dist/utils/__tests__/shell-compress.test.d.ts +2 -0
- package/dist/utils/__tests__/shell-compress.test.d.ts.map +1 -0
- package/dist/utils/__tests__/shell-compress.test.js +41 -0
- package/dist/utils/__tests__/shell-compress.test.js.map +1 -0
- package/dist/utils/atomic-write.d.ts +10 -0
- package/dist/utils/atomic-write.d.ts.map +1 -0
- package/dist/utils/atomic-write.js +83 -0
- package/dist/utils/atomic-write.js.map +1 -0
- package/dist/utils/shell-compress.d.ts.map +1 -1
- package/dist/utils/shell-compress.js +12 -1
- package/dist/utils/shell-compress.js.map +1 -1
- package/dist/verification/presets.d.ts +6 -3
- package/dist/verification/presets.d.ts.map +1 -1
- package/dist/verification/presets.js +6 -3
- package/dist/verification/presets.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/default-path-conformance.test.ts +306 -0
- package/src/__tests__/shipped-defaults.test.ts +111 -0
- package/src/advisory/__tests__/budget-enforcement.test.ts +208 -0
- package/src/advisory/__tests__/structured-response.test.ts +128 -0
- package/src/advisory/budget.ts +27 -0
- package/src/advisory/context.ts +19 -0
- package/src/advisory/executor.test.ts +12 -8
- package/src/advisory/executor.ts +37 -25
- package/src/advisory/index.ts +2 -0
- package/src/advisory/parse.ts +63 -0
- package/src/agents/AbstractAgent.ts +82 -0
- package/src/agents/PipelineAgent.ts +19 -0
- package/src/agents/ReactiveAgent.ts +47 -0
- package/src/agents/RouterAgent.ts +32 -2
- package/src/agents/SupervisorAgent.ts +31 -1
- package/src/agents/__tests__/idempotency-key.test.ts +177 -0
- package/src/agents/__tests__/invocation-lock.test.ts +154 -0
- package/src/agents/__tests__/reachability.test.ts +224 -0
- package/src/agents/__tests__/supervisor-ledger.test.ts +1 -1
- package/src/agents/index.ts +1 -1
- package/src/agents/lock.ts +0 -2
- package/src/bridge/a2a/late-events.test.ts +84 -0
- package/src/bridge/a2a/mapper.test.ts +1 -1
- package/src/bridge/a2a/mapper.ts +70 -5
- package/src/bridge/a2a/message.ts +5 -1
- package/src/bridge/sse/late-events.test.ts +182 -0
- package/src/bridge/sse/mapper.ts +109 -0
- package/src/compaction/__tests__/cleared-result-recovery.test.ts +118 -0
- package/src/compaction/__tests__/context-window.test.ts +77 -0
- package/src/compaction/__tests__/dangling.test.ts +16 -6
- package/src/compaction/__tests__/lossiness.test.ts +187 -0
- package/src/compaction/__tests__/state-across-resume.test.ts +99 -0
- package/src/compaction/__tests__/tool-result-editing.test.ts +213 -0
- package/src/compaction/__tests__/trim-opens-on-user.test.ts +118 -0
- package/src/compaction/__tests__/verifier-model.test.ts +83 -0
- package/src/compaction/context-window.ts +107 -0
- package/src/compaction/dangling.ts +48 -1
- package/src/compaction/extractor.ts +56 -1
- package/src/compaction/index.ts +16 -0
- package/src/compaction/manager.ts +53 -8
- package/src/compaction/managers/structured.ts +7 -6
- package/src/compaction/retention.ts +89 -0
- package/src/compaction/serializer.ts +42 -11
- package/src/compaction/tool-result-editing.ts +229 -0
- package/src/compaction/types.ts +10 -0
- package/src/compaction/verifier.ts +24 -1
- package/src/compaction/wire.ts +91 -0
- package/src/config/runtime.ts +63 -19
- package/src/connector/builtins/http.test.ts +13 -0
- package/src/connector/builtins/http.ts +15 -1
- package/src/connector/mcp/__tests__/discovery-policy.test.ts +133 -0
- package/src/connector/mcp/__tests__/list-pagination.test.ts +98 -0
- package/src/connector/mcp/__tests__/policy.test.ts +100 -0
- package/src/connector/mcp/__tests__/protocol-negotiation.test.ts +105 -0
- package/src/connector/mcp/__tests__/schema-fidelity.test.ts +250 -0
- package/src/connector/mcp/__tests__/structured-result.test.ts +143 -0
- package/src/connector/mcp/adapter.ts +306 -19
- package/src/connector/mcp/client.test.ts +159 -0
- package/src/connector/mcp/client.ts +160 -13
- package/src/connector/mcp/discovery.ts +74 -5
- package/src/connector/mcp/http-sse.ts +16 -1
- package/src/connector/mcp/index.ts +4 -0
- package/src/connector/mcp/policy.ts +134 -0
- package/src/connector/mcp/schema-refs.ts +126 -0
- package/src/constants/agent/index.ts +3 -0
- package/src/constants/compaction/index.ts +1 -1
- package/src/constants/continuation.ts +4 -4
- package/src/constants/mcp/index.ts +34 -0
- package/src/constants/plugin/index.ts +24 -2
- package/src/constants/sandbox/index.ts +6 -5
- package/src/constants/telemetry/index.ts +8 -0
- package/src/constants/tools/index.ts +20 -0
- package/src/contracts/api.ts +40 -0
- package/src/contracts/run-status.ts +43 -0
- package/src/eval/__tests__/case-deadline.test.ts +147 -0
- package/src/eval/__tests__/end-to-end.test.ts +259 -0
- package/src/eval/__tests__/harness-honesty.test.ts +99 -0
- package/src/eval/__tests__/harness.test.ts +249 -0
- package/src/eval/__tests__/judge.test.ts +306 -0
- package/src/eval/__tests__/scorer-gates.test.ts +156 -0
- package/src/eval/experiment.ts +335 -0
- package/src/eval/from-run.ts +48 -0
- package/src/eval/index.ts +21 -0
- package/src/eval/judge.ts +240 -0
- package/src/eval/scorers.ts +169 -0
- package/src/eval/types.ts +157 -0
- package/src/execution/local.test.ts +46 -0
- package/src/execution/local.ts +6 -1
- package/src/gateway/__tests__/list-survives-eviction.test.ts +124 -0
- package/src/gateway/local.ts +117 -3
- package/src/manager/agent/__tests__/dispose-cancels.test.ts +104 -0
- package/src/manager/agent/__tests__/lifecycle.test.ts +297 -0
- package/src/manager/agent/lifecycle.ts +127 -7
- package/src/manager/run/persistence.ts +132 -1
- package/src/plugin/__tests__/enable-contributions.test.ts +3 -3
- package/src/plugin/__tests__/hook-ordering.test.ts +252 -0
- package/src/plugin/__tests__/install-time-refusal.test.ts +68 -0
- package/src/plugin/__tests__/lifecycle.test.ts +95 -73
- package/src/plugin/lifecycle.ts +76 -22
- package/src/plugin/loader.ts +37 -1
- package/src/probe/registry.test.ts +49 -6
- package/src/probe/registry.ts +21 -1
- package/src/provider/__tests__/mock-script.test.ts +179 -0
- package/src/provider/__tests__/registry.test.ts +1 -1
- package/src/provider/__tests__/retry-visibility.test.ts +160 -0
- package/src/provider/__tests__/retry.test.ts +296 -0
- package/src/provider/capabilities.ts +4 -0
- package/src/provider/collect.test.ts +1 -1
- package/src/provider/collect.ts +1 -1
- package/src/provider/index.ts +8 -0
- package/src/provider/mock-register.ts +5 -2
- package/src/provider/mock.ts +117 -34
- package/src/provider/retry.ts +199 -0
- package/src/public-runtime.ts +118 -7
- package/src/public-types.ts +5 -1
- package/src/rag/__tests__/retrieval-math.test.ts +54 -0
- package/src/rag/chunking.ts +32 -1
- package/src/rag/embedding.test.ts +65 -10
- package/src/rag/embedding.ts +26 -5
- package/src/rag/index.ts +1 -1
- package/src/rag/retriever.ts +92 -21
- package/src/rag/vector-store.test.ts +2 -2
- package/src/registry/ManagedRegistry.test.ts +1 -1
- package/src/registry/Registry.test.ts +1 -1
- package/src/registry/connector/definitions.test.ts +1 -1
- package/src/registry/tool/__tests__/schema.test.ts +208 -0
- package/src/registry/tool/__tests__/tool-name-validation.test.ts +88 -0
- package/src/registry/tool/execute.ts +104 -22
- package/src/registry/tool/schema.ts +80 -0
- package/src/registry/toolset/catalog.test.ts +0 -1
- package/src/registry/toolset/catalog.ts +0 -1
- package/src/run/reporter.ts +84 -0
- package/src/runtime/bidi/__tests__/session.test.ts +232 -0
- package/src/runtime/bidi/index.ts +4 -0
- package/src/runtime/bidi/mock.ts +90 -0
- package/src/runtime/bidi/session.ts +205 -0
- package/src/runtime/decision/parser.test.ts +46 -0
- package/src/runtime/decision/parser.ts +8 -1
- package/src/runtime/query/__tests__/answer-review.test.ts +172 -0
- package/src/runtime/query/__tests__/capability-negotiation.test.ts +88 -123
- package/src/runtime/query/__tests__/checkpoint-store.test.ts +13 -50
- package/src/runtime/query/__tests__/checkpoint.test.ts +2 -10
- package/src/runtime/query/__tests__/citations.test.ts +111 -0
- package/src/runtime/query/__tests__/content-budget.test.ts +83 -0
- package/src/runtime/query/__tests__/context.test.ts +3 -2
- package/src/runtime/query/__tests__/deferred-tools.test.ts +23 -148
- package/src/runtime/query/__tests__/delegation-resume.test.ts +159 -0
- package/src/runtime/query/__tests__/document-attachments.test.ts +125 -0
- package/src/runtime/query/__tests__/durable-park-and-trace.test.ts +245 -0
- package/src/runtime/query/__tests__/durable-question-park.test.ts +305 -0
- package/src/runtime/query/__tests__/durable-run-state.test.ts +194 -0
- package/src/runtime/query/__tests__/executor-plugin-hooks.test.ts +24 -20
- package/src/runtime/query/__tests__/finish-reason-vs-tool-calls.test.ts +206 -0
- package/src/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.ts +115 -0
- package/src/runtime/query/__tests__/guardrails-e2e.test.ts +164 -0
- package/src/runtime/query/__tests__/guardrails.test.ts +236 -0
- package/src/runtime/query/__tests__/hook-model-visibility.test.ts +143 -0
- package/src/runtime/query/__tests__/long-document-flow.test.ts +9 -2
- package/src/runtime/query/__tests__/memory-promotion.test.ts +148 -0
- package/src/runtime/query/__tests__/orphan-task-turn-end.test.ts +5 -31
- package/src/runtime/query/__tests__/overflow-relief.test.ts +139 -0
- package/src/runtime/query/__tests__/partial-batch-resume.test.ts +264 -0
- package/src/runtime/query/__tests__/plugin-hooks.test.ts +0 -1
- package/src/runtime/query/__tests__/prepare-step-chain.test.ts +127 -0
- package/src/runtime/query/__tests__/prepare-step.test.ts +233 -0
- package/src/runtime/query/__tests__/probe-veto-is-error.test.ts +145 -0
- package/src/runtime/query/__tests__/prompt.test.ts +1 -1
- package/src/runtime/query/__tests__/provider-fault-pauses.test.ts +104 -0
- package/src/runtime/query/__tests__/reasoning-stream.test.ts +177 -0
- package/src/runtime/query/__tests__/recoverable-settle.test.ts +145 -0
- package/src/runtime/query/__tests__/resume-budget.test.ts +158 -0
- package/src/runtime/query/__tests__/resume-pending.test.ts +273 -0
- package/src/runtime/query/__tests__/rich-content-budget-wiring.test.ts +109 -0
- package/src/runtime/query/__tests__/stop-condition.test.ts +265 -0
- package/src/runtime/query/__tests__/structured-output.test.ts +268 -0
- package/src/runtime/query/__tests__/structured-run-failure.test.ts +144 -0
- package/src/runtime/query/__tests__/terminal-tool.test.ts +148 -0
- package/src/runtime/query/__tests__/tool-grants.test.ts +102 -0
- package/src/runtime/query/__tests__/tool-output-budget.test.ts +0 -0
- package/src/runtime/query/__tests__/tool-pause.test.ts +209 -0
- package/src/runtime/query/__tests__/tool-progress.test.ts +154 -0
- package/src/runtime/query/__tests__/tool-repair-retry.test.ts +255 -0
- package/src/runtime/query/__tests__/tool-result-wire.test.ts +135 -0
- package/src/runtime/query/__tests__/tool-timeout.test.ts +230 -0
- package/src/runtime/query/__tests__/trace-parenting.test.ts +128 -0
- package/src/runtime/query/__tests__/wiring-seams.test.ts +288 -0
- package/src/runtime/query/checkpoint.ts +242 -10
- package/src/runtime/query/events.ts +2 -2
- package/src/runtime/query/executor.ts +856 -40
- package/src/runtime/query/guard.ts +26 -1
- package/src/runtime/query/guardrail-presets.ts +124 -0
- package/src/runtime/query/guardrails.ts +144 -0
- package/src/runtime/query/index.ts +759 -12
- package/src/runtime/query/iteration/__tests__/cancel-settles-turn.test.ts +177 -0
- package/src/runtime/query/iteration/index.ts +674 -31
- package/src/runtime/query/iteration/phases/advisory.test.ts +4 -1
- package/src/runtime/query/iteration/phases/advisory.ts +14 -2
- package/src/runtime/query/iteration/phases/checkpoint.ts +2 -2
- package/src/runtime/query/iteration/phases/compaction-safe-cut.test.ts +3 -1
- package/src/runtime/query/iteration/phases/compaction.ts +329 -64
- package/src/runtime/query/iteration/phases/context-measurement.test.ts +196 -0
- package/src/runtime/query/iteration/phases/context.ts +155 -2
- package/src/runtime/query/iteration/phases/hitl-answer-question.test.ts +3 -1
- package/src/runtime/query/iteration/phases/overflow-escalation.test.ts +167 -0
- package/src/runtime/query/iteration/phases/plan.ts +10 -2
- package/src/runtime/query/iteration/phases/retained-messages.test.ts +226 -0
- package/src/runtime/query/iteration/phases/tool-review-denials.test.ts +270 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +140 -51
- package/src/runtime/query/iteration/phases/working-memory-compaction.test.ts +21 -9
- package/src/runtime/query/iteration/stream-turn.ts +285 -15
- package/src/runtime/query/plugin-hooks.ts +6 -2
- package/src/runtime/query/prompt.ts +26 -1
- package/src/runtime/query/question-park.ts +120 -0
- package/src/runtime/query/result.ts +64 -0
- package/src/runtime/query/resume-pending.ts +394 -0
- package/src/runtime/query/run-state.ts +124 -0
- package/src/runtime/query/tool-grants.ts +83 -0
- package/src/runtime/query/tool-output-budget.ts +183 -0
- package/src/runtime/query/tool-pause.ts +119 -0
- package/src/runtime/query/tooling.ts +23 -1
- package/src/sandbox/__tests__/isolation.test.ts +164 -0
- package/src/sandbox/__tests__/output-truncation.test.ts +106 -0
- package/src/sandbox/__tests__/resource-limits.test.ts +106 -0
- package/src/sandbox/factory.ts +1 -1
- package/src/sandbox/index.ts +2 -0
- package/src/sandbox/isolation.ts +72 -0
- package/src/sandbox/provider/local.ts +173 -74
- package/src/session/__tests__/integration/spawn-rollback.test.ts +1 -1
- package/src/session/handoff/broadcast.ts +3 -3
- package/src/session/migration/__tests__/filesystem.test.ts +26 -19
- package/src/session/migration/filesystem.ts +7 -12
- package/src/session/migration/marker.ts +5 -9
- package/src/session/retention/disk-backend.ts +5 -11
- package/src/session/workspace/__tests__/git-worktree.test.ts +6 -2
- package/src/session/workspace/__tests__/shared-run.test.ts +18 -0
- package/src/session/workspace/shared-run.ts +7 -1
- package/src/skills/__tests__/frontmatter.test.ts +135 -0
- package/src/skills/loader.ts +47 -3
- package/src/store/__tests__/checkpoint-integrity.test.ts +134 -0
- package/src/store/__tests__/checkpoint-versioning.test.ts +194 -0
- package/src/store/__tests__/schema-adoption.test.ts +118 -0
- package/src/store/__tests__/schema.test.ts +119 -0
- package/src/store/memory/disk.ts +17 -16
- package/src/store/run/disk.ts +169 -22
- package/src/store/schema.ts +135 -0
- package/src/store/session/disk.ts +30 -21
- package/src/store/task/__tests__/lookup-across-runs.test.ts +77 -0
- package/src/store/task/disk.ts +59 -15
- package/src/store/thread/disk.ts +21 -10
- package/src/streaming/coalesce.ts +1 -1
- package/src/telemetry/__tests__/latency-instruments.test.ts +120 -0
- package/src/telemetry/__tests__/metrics.test.ts +160 -0
- package/src/telemetry/__tests__/span-hierarchy.test.ts +94 -0
- package/src/telemetry/attributes.ts +109 -0
- package/src/telemetry/metrics.ts +190 -0
- package/src/test-setup.ts +3 -3
- package/src/test-support/paths.ts +17 -0
- package/src/tools/__tests__/path-containment.test.ts +167 -0
- package/src/tools/__tests__/posix-path.test.ts +83 -0
- package/src/tools/__tests__/sandboxed-search.test.ts +140 -0
- package/src/tools/builtins/__tests__/computer-use.test.ts +15 -2
- package/src/tools/builtins/__tests__/edit-commits-atomically.test.ts +103 -0
- package/src/tools/builtins/__tests__/edit.test.ts +80 -17
- package/src/tools/builtins/__tests__/payload-budget.test.ts +20 -40
- package/src/tools/builtins/__tests__/read-file.test.ts +29 -1
- package/src/tools/builtins/__tests__/stale-file-refusal.test.ts +258 -0
- package/src/tools/builtins/__tests__/write-file.test.ts +13 -52
- package/src/tools/builtins/atomic-write-file.ts +30 -2
- package/src/tools/builtins/bash.ts +34 -4
- package/src/tools/builtins/computer-use.ts +7 -1
- package/src/tools/builtins/content-fingerprint.ts +33 -0
- package/src/tools/builtins/edit.ts +258 -60
- package/src/tools/builtins/glob.ts +71 -6
- package/src/tools/builtins/grep.ts +82 -8
- package/src/tools/builtins/index.ts +6 -6
- package/src/tools/builtins/ls.ts +4 -2
- package/src/tools/builtins/read-file.ts +45 -6
- package/src/tools/builtins/write-file.ts +52 -25
- package/src/tools/coordinator/__tests__/agent.test.ts +2 -2
- package/src/tools/coordinator/__tests__/ask-user-question.test.ts +68 -0
- package/src/tools/coordinator/agent.ts +23 -10
- package/src/tools/coordinator/index.ts +213 -72
- package/src/tools/defineTool.ts +20 -0
- package/src/tools/glob-match.ts +50 -0
- package/src/tools/paths.ts +44 -0
- package/src/tools/posix-path.ts +73 -0
- package/src/types/advisory/config.ts +21 -3
- package/src/types/advisory/result.ts +12 -7
- package/src/types/agent/base.ts +22 -2
- package/src/types/agent/factory.ts +15 -9
- package/src/types/agent/gateway.ts +20 -0
- package/src/types/agent/manager.ts +19 -0
- package/src/types/agent/reactive.ts +50 -0
- package/src/types/agent/router.ts +11 -0
- package/src/types/agent/supervisor.ts +2 -2
- package/src/types/agent/task.ts +26 -0
- package/src/types/bidi/index.ts +119 -0
- package/src/types/common/__tests__/numeric-correctness.test.ts +123 -0
- package/src/types/common/index.ts +16 -4
- package/src/types/computer-use/index.ts +1 -1
- package/src/types/connector/mcp.ts +29 -0
- package/src/types/errors/__tests__/catalog.test.ts +130 -0
- package/src/types/errors/__tests__/errors.test.ts +118 -0
- package/src/types/errors/catalog.ts +211 -0
- package/src/types/errors/index.ts +121 -0
- package/src/types/guardrail/index.ts +62 -0
- package/src/types/hitl/index.ts +102 -20
- package/src/types/ids/index.ts +2 -2
- package/src/types/message/content.ts +50 -0
- package/src/types/message/index.ts +210 -9
- package/src/types/plugin/index.ts +82 -2
- package/src/types/provider/__tests__/cause-chain.test.ts +132 -0
- package/src/types/provider/__tests__/declared-retryable.test.ts +85 -0
- package/src/types/provider/__tests__/overflow-classification.test.ts +113 -0
- package/src/types/provider/chat.ts +29 -1
- package/src/types/provider/config.ts +83 -2
- package/src/types/provider/errors.ts +472 -0
- package/src/types/provider/index.ts +5 -0
- package/src/types/provider/stream.ts +63 -3
- package/src/types/rag/embedding.ts +11 -2
- package/src/types/run/__tests__/step.test.ts +123 -0
- package/src/types/run/answer-review.ts +51 -0
- package/src/types/run/config.ts +35 -0
- package/src/types/run/derive-status.ts +62 -0
- package/src/types/run/entity.ts +18 -0
- package/src/types/run/events.ts +230 -3
- package/src/types/run/index.ts +5 -0
- package/src/types/run/memory-promotion.ts +112 -0
- package/src/types/run/prepare-step.ts +109 -0
- package/src/types/run/state.ts +111 -0
- package/src/types/run/step.ts +95 -0
- package/src/types/run/stop-reason.ts +29 -1
- package/src/types/sandbox/index.ts +93 -12
- package/src/types/structured-output/index.ts +6 -5
- package/src/types/thread/entity.ts +2 -3
- package/src/types/tool/index.ts +221 -2
- package/src/types/tool/repair.ts +54 -0
- package/src/types/toolset/index.ts +2 -6
- package/src/utils/__tests__/atomic-write.test.ts +108 -0
- package/src/utils/__tests__/shell-compress.test.ts +49 -0
- package/src/utils/atomic-write.ts +85 -0
- package/src/utils/shell-compress.ts +12 -1
- package/src/verification/presets.ts +6 -3
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import type { Span } from '@opentelemetry/api'
|
|
1
2
|
import { extractFromToolCall, extractFromToolResult } from '../../compaction/extractor.js'
|
|
2
3
|
import type { WorkingStateManager } from '../../compaction/manager.js'
|
|
3
4
|
import type { PluginLifecycleManager } from '../../plugin/lifecycle.js'
|
|
4
5
|
import { buildProbeContext } from '../../probe/context.js'
|
|
5
6
|
import { ProbeVetoError } from '../../probe/errors.js'
|
|
6
7
|
import { type ProbeRegistry, probe as defaultProbeRegistry } from '../../probe/registry.js'
|
|
8
|
+
import { renderToolSchema } from '../../registry/tool/schema.js'
|
|
7
9
|
import type { ActivityStore } from '../../store/activity/memory.js'
|
|
8
|
-
import
|
|
10
|
+
import { fingerprintContent } from '../../tools/builtins/content-fingerprint.js'
|
|
11
|
+
import type { RunId, ToolUseId } from '../../types/ids/index.js'
|
|
9
12
|
import type { InvocationState } from '../../types/invocation/index.js'
|
|
10
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
type Message,
|
|
15
|
+
type ToolCall,
|
|
16
|
+
type ToolResultContent,
|
|
17
|
+
createToolMessage,
|
|
18
|
+
} from '../../types/message/index.js'
|
|
11
19
|
import type { PermissionMode } from '../../types/permission/index.js'
|
|
12
20
|
import type { PluginHookResult } from '../../types/plugin/index.js'
|
|
13
21
|
import type { ChatCompletionResponse } from '../../types/provider/index.js'
|
|
@@ -15,15 +23,64 @@ import type { RunEvent } from '../../types/run/index.js'
|
|
|
15
23
|
import type { Sandbox } from '../../types/sandbox/index.js'
|
|
16
24
|
import type {
|
|
17
25
|
FileReadTracker,
|
|
26
|
+
RequestToolPause,
|
|
18
27
|
ToolContext,
|
|
19
28
|
ToolRegistryContract,
|
|
20
29
|
ToolResult,
|
|
21
30
|
} from '../../types/tool/index.js'
|
|
31
|
+
import type {
|
|
32
|
+
RepairToolCall,
|
|
33
|
+
ToolCallRepair,
|
|
34
|
+
ToolCallRepairReason,
|
|
35
|
+
} from '../../types/tool/repair.js'
|
|
36
|
+
import { toErrorMessage } from '../../utils/error.js'
|
|
22
37
|
import type { Logger } from '../../utils/logger.js'
|
|
23
38
|
import { compressShellOutput } from '../../utils/shell-compress.js'
|
|
39
|
+
import {
|
|
40
|
+
DEFAULT_MAX_TOOL_OUTPUT_CHARS,
|
|
41
|
+
applyToolOutputBudget,
|
|
42
|
+
describeDroppedContent,
|
|
43
|
+
measureContentBytes,
|
|
44
|
+
} from './tool-output-budget.js'
|
|
24
45
|
|
|
25
46
|
export type EmitEvent = (event: RunEvent) => Promise<void>
|
|
26
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Default per-tool deadline. Long enough for a real build or test run,
|
|
50
|
+
* short enough that a wedged tool does not hold a turn open indefinitely.
|
|
51
|
+
* A tool that legitimately runs longer declares its own `timeoutMs`.
|
|
52
|
+
*/
|
|
53
|
+
export const DEFAULT_TOOL_TIMEOUT_MS = 120_000
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Cap on tools executing at once within a single batch.
|
|
57
|
+
*
|
|
58
|
+
* `executeBatch` used to `Promise.all` an unbounded fan-out, so a model
|
|
59
|
+
* emitting fifty parallel reads opened fifty file handles and fifty
|
|
60
|
+
* activity records at once. The serial chain is unaffected — it is
|
|
61
|
+
* already one-at-a-time by construction.
|
|
62
|
+
*/
|
|
63
|
+
export const DEFAULT_TOOL_CONCURRENCY = 8
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Re-runs granted to a `post_tool_use` hook that returns `{action:'retry'}`
|
|
67
|
+
* on a tool which did not opt into {@link ToolDefinition.maxRetries}.
|
|
68
|
+
*
|
|
69
|
+
* Small on purpose. The hook is host code reacting to one specific result,
|
|
70
|
+
* which is a more specific signal than the tool's blanket idempotency
|
|
71
|
+
* declaration — but the tool still never said it was safe to re-run, so
|
|
72
|
+
* this buys one correction, not a loop.
|
|
73
|
+
*/
|
|
74
|
+
export const HOOK_RETRY_BUDGET = 1
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* An empty arguments string means "no arguments", not "malformed" — the
|
|
78
|
+
* shape a no-parameter tool arrives in.
|
|
79
|
+
*/
|
|
80
|
+
function parseArguments(raw: string): unknown {
|
|
81
|
+
return JSON.parse(raw || '{}')
|
|
82
|
+
}
|
|
83
|
+
|
|
27
84
|
export interface ToolExecutorConfig {
|
|
28
85
|
tools: ToolRegistryContract
|
|
29
86
|
runId: RunId
|
|
@@ -35,6 +92,55 @@ export interface ToolExecutorConfig {
|
|
|
35
92
|
sandbox?: Sandbox
|
|
36
93
|
invocationState?: InvocationState
|
|
37
94
|
pluginManager?: PluginLifecycleManager
|
|
95
|
+
/** Run-level default deadline; per-tool `timeoutMs` overrides it. */
|
|
96
|
+
toolTimeoutMs?: number
|
|
97
|
+
/** Max concurrently-executing concurrency-safe tools. */
|
|
98
|
+
maxToolConcurrency?: number
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Builds the durable-pause seam handed to one tool call.
|
|
102
|
+
*
|
|
103
|
+
* Absent when the run has no route to a human, which is why
|
|
104
|
+
* {@link ToolContext.requestPause} is optional: a tool must be able to
|
|
105
|
+
* run in a headless context and decide what to do without one.
|
|
106
|
+
*/
|
|
107
|
+
toolPause?: (toolUseId: string) => RequestToolPause
|
|
108
|
+
/**
|
|
109
|
+
* Model-visible size cap for a single tool result. Defaults to
|
|
110
|
+
* {@link DEFAULT_MAX_TOOL_OUTPUT_CHARS}; set `0` to disable.
|
|
111
|
+
*/
|
|
112
|
+
maxToolOutputChars?: number
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Cap on the RICH channel of a single tool result, in base64
|
|
116
|
+
* characters. `0` or absent disables it.
|
|
117
|
+
*
|
|
118
|
+
* Separate from {@link maxToolOutputChars} because the two are different
|
|
119
|
+
* quantities with different costs: the text budget bounds characters the
|
|
120
|
+
* model reads, and an image block of any size passed it untouched — the
|
|
121
|
+
* single largest payload a tool result can carry was the one thing not
|
|
122
|
+
* bounded on the turn that produced it.
|
|
123
|
+
*
|
|
124
|
+
* **Off by default, deliberately.** The right number depends entirely on
|
|
125
|
+
* what a host's tools return and on the model's own image budget, and
|
|
126
|
+
* inventing one here would either break screenshot workflows or be so
|
|
127
|
+
* generous it bounds nothing. A host that knows its payloads sets it;
|
|
128
|
+
* the steady state is already bounded, because reclamation clears
|
|
129
|
+
* image-bearing results first.
|
|
130
|
+
*/
|
|
131
|
+
maxToolContentBytes?: number
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Where over-budget output is spilled so the model can read it back
|
|
135
|
+
* with `read`/`grep`. Absent ⇒ over-budget output is middle-elided and
|
|
136
|
+
* the overflow is lost.
|
|
137
|
+
*/
|
|
138
|
+
toolOutputDir?: string
|
|
139
|
+
/**
|
|
140
|
+
* Last chance to fix a tool call the model got wrong, before the error
|
|
141
|
+
* reaches it. See {@link RepairToolCall}.
|
|
142
|
+
*/
|
|
143
|
+
repairToolCall?: RepairToolCall
|
|
38
144
|
}
|
|
39
145
|
|
|
40
146
|
type PreToolHookOutcome =
|
|
@@ -42,9 +148,53 @@ type PreToolHookOutcome =
|
|
|
42
148
|
| { kind: 'skip'; input: unknown; output: string }
|
|
43
149
|
| { kind: 'error'; input: unknown; output: string }
|
|
44
150
|
|
|
151
|
+
/** What one tool call produced, before it becomes a message. */
|
|
152
|
+
export interface ToolCallOutcome {
|
|
153
|
+
toolCallId: string
|
|
154
|
+
/** Which tool produced it. */
|
|
155
|
+
toolName: string
|
|
156
|
+
/** Text form — what the host, the transcript and compaction see. */
|
|
157
|
+
output: string
|
|
158
|
+
/** Rich form for the model, when the tool supplied one. */
|
|
159
|
+
content?: ToolResultContent
|
|
160
|
+
isError?: boolean
|
|
161
|
+
}
|
|
162
|
+
|
|
45
163
|
export interface ToolExecutionBatch {
|
|
46
164
|
messages: Message[]
|
|
47
|
-
results:
|
|
165
|
+
results: ToolCallOutcome[]
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Denial reasons keyed by `tool_use` id. Any id present here is answered
|
|
170
|
+
* with a synthetic `tool_result` carrying the reason INSTEAD of being
|
|
171
|
+
* executed — see {@link ToolExecutor.executeBatch}.
|
|
172
|
+
*/
|
|
173
|
+
export type ToolCallDenials = ReadonlyMap<string, string>
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Results for calls that already ran, keyed by `toolUseId`.
|
|
177
|
+
*
|
|
178
|
+
* A batch's results reach the history only when the whole batch settles,
|
|
179
|
+
* so a hard kill part-way through loses whatever had already come back and
|
|
180
|
+
* the resumed run re-executes those calls. Supplying them here answers
|
|
181
|
+
* those `tool_use` blocks from the record instead of by running the tool
|
|
182
|
+
* again — which for a payment or an email is the difference between
|
|
183
|
+
* resuming and repeating.
|
|
184
|
+
*/
|
|
185
|
+
export type PriorToolResults = ReadonlyMap<string, { result: string; isError: boolean }>
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Model-visible text for a tool call that was never executed.
|
|
189
|
+
*
|
|
190
|
+
* The reason travels INSIDE the `tool_result` rather than as a trailing
|
|
191
|
+
* user message: a `tool_use` block must be answered by a `tool_result`
|
|
192
|
+
* with the same id, and a denial is an answer, not an omission. Putting
|
|
193
|
+
* the reason here is also what makes rejection *steer* — the model reads
|
|
194
|
+
* it in the slot it already attends to for tool outcomes.
|
|
195
|
+
*/
|
|
196
|
+
export function deniedToolOutput(toolName: string, reason: string): string {
|
|
197
|
+
return `Error: Tool "${toolName}" was not executed. ${reason}`
|
|
48
198
|
}
|
|
49
199
|
|
|
50
200
|
export class ToolExecutor {
|
|
@@ -54,12 +204,20 @@ export class ToolExecutor {
|
|
|
54
204
|
private log: Logger
|
|
55
205
|
private workingStateManager?: WorkingStateManager
|
|
56
206
|
private probes: ProbeRegistry
|
|
207
|
+
private parentSpan?: Span
|
|
57
208
|
private readonly readPaths: Set<string> = new Set()
|
|
209
|
+
private readonly readFingerprints: Map<string, string> = new Map()
|
|
58
210
|
private readonly fileReadTracker: FileReadTracker = {
|
|
59
|
-
recordRead: (key: string) => {
|
|
211
|
+
recordRead: (key: string, content?: string) => {
|
|
60
212
|
this.readPaths.add(key)
|
|
213
|
+
// Only when the reader had the body. A tool that records a read
|
|
214
|
+
// without one leaves the previous fingerprint alone rather than
|
|
215
|
+
// clearing it, so a later write is still checked against the last
|
|
216
|
+
// body anyone actually saw.
|
|
217
|
+
if (content !== undefined) this.readFingerprints.set(key, fingerprintContent(content))
|
|
61
218
|
},
|
|
62
219
|
hasRead: (key: string) => this.readPaths.has(key),
|
|
220
|
+
fingerprint: (key: string) => this.readFingerprints.get(key),
|
|
63
221
|
}
|
|
64
222
|
|
|
65
223
|
constructor(
|
|
@@ -84,7 +242,35 @@ export class ToolExecutor {
|
|
|
84
242
|
this.config = { ...this.config, sandbox }
|
|
85
243
|
}
|
|
86
244
|
|
|
87
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Span that this executor's tool spans should hang off — the current
|
|
247
|
+
* iteration. Re-set each turn by the orchestrator, because a tool span
|
|
248
|
+
* belongs under the iteration that requested it.
|
|
249
|
+
*/
|
|
250
|
+
setParentSpan(span: Span | undefined): void {
|
|
251
|
+
this.parentSpan = span
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Answer every `tool_use` block in `response` with exactly one
|
|
256
|
+
* `tool_result`.
|
|
257
|
+
*
|
|
258
|
+
* `denials` marks ids that must NOT run: each is answered with a
|
|
259
|
+
* synthetic error result carrying the caller's reason instead of being
|
|
260
|
+
* executed. This is what makes the invariant hold by construction —
|
|
261
|
+
* a gate denial, a human rejection and a partial approval all leave
|
|
262
|
+
* the history valid, because there is exactly one place that turns a
|
|
263
|
+
* batch of tool calls into messages and it always covers all of them.
|
|
264
|
+
*
|
|
265
|
+
* Answering with `is_error` semantics rather than dropping the call is
|
|
266
|
+
* the universal contract across providers: an unanswered `tool_use`
|
|
267
|
+
* is a protocol violation, not a decline.
|
|
268
|
+
*/
|
|
269
|
+
async executeBatch(
|
|
270
|
+
response: ChatCompletionResponse,
|
|
271
|
+
denials?: ToolCallDenials,
|
|
272
|
+
prior?: PriorToolResults,
|
|
273
|
+
): Promise<ToolExecutionBatch> {
|
|
88
274
|
const toolCalls = response.message.toolCalls
|
|
89
275
|
if (!toolCalls) {
|
|
90
276
|
return { messages: [], results: [] }
|
|
@@ -93,6 +279,8 @@ export class ToolExecutor {
|
|
|
93
279
|
this.log.debug('Executing tool batch', {
|
|
94
280
|
runId: this.config.runId,
|
|
95
281
|
toolCount: toolCalls.length,
|
|
282
|
+
deniedCount: denials?.size ?? 0,
|
|
283
|
+
recoveredCount: prior?.size ?? 0,
|
|
96
284
|
tools: toolCalls.map((tc) => tc.function.name),
|
|
97
285
|
})
|
|
98
286
|
|
|
@@ -108,14 +296,77 @@ export class ToolExecutor {
|
|
|
108
296
|
// turn apply one-after-another instead of racing read→modify→write
|
|
109
297
|
// (which let the last writer clobber the rest). Results are written by
|
|
110
298
|
// index to preserve the original tool-call order.
|
|
111
|
-
const results:
|
|
299
|
+
const results: ToolCallOutcome[] = new Array(toolCalls.length)
|
|
112
300
|
const parallel: Promise<void>[] = []
|
|
113
301
|
let serial: Promise<void> = Promise.resolve()
|
|
302
|
+
// Bounded fan-out. A model emitting fifty parallel reads used to open
|
|
303
|
+
// fifty file handles and fifty activity records simultaneously; the
|
|
304
|
+
// gate keeps that at a working-set size while preserving completion
|
|
305
|
+
// order independence.
|
|
306
|
+
const gate = new Semaphore(this.config.maxToolConcurrency ?? DEFAULT_TOOL_CONCURRENCY)
|
|
114
307
|
toolCalls.forEach((toolCall, i) => {
|
|
115
|
-
const
|
|
308
|
+
const recovered = prior?.get(toolCall.id)
|
|
309
|
+
if (recovered !== undefined) {
|
|
310
|
+
// This call already ran, in a process that died before the
|
|
311
|
+
// batch settled. Re-running it would be a second charge, a
|
|
312
|
+
// second email, a second row deleted — so the recorded result
|
|
313
|
+
// answers the `tool_use` block and the tool is not touched.
|
|
314
|
+
results[i] = {
|
|
315
|
+
toolCallId: toolCall.id,
|
|
316
|
+
toolName: toolCall.function.name,
|
|
317
|
+
output: recovered.result,
|
|
318
|
+
isError: recovered.isError,
|
|
319
|
+
}
|
|
320
|
+
return
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const denialReason = denials?.get(toolCall.id)
|
|
324
|
+
if (denialReason !== undefined) {
|
|
325
|
+
// Denied calls never touch the tool; they still get a result
|
|
326
|
+
// message so the assistant turn stays fully answered. Run them
|
|
327
|
+
// on the parallel branch — they perform no side effects, so
|
|
328
|
+
// serialization would only add latency.
|
|
329
|
+
parallel.push(
|
|
330
|
+
this.recordDenial(toolCall, denialReason).then((r) => {
|
|
331
|
+
results[i] = r
|
|
332
|
+
}),
|
|
333
|
+
)
|
|
334
|
+
return
|
|
335
|
+
}
|
|
336
|
+
// Per-call, because the event has to name which call it is about:
|
|
337
|
+
// a batch can run several tools at once and a host rendering them
|
|
338
|
+
// side by side needs to know whose progress this is.
|
|
339
|
+
const ctx: ToolContext = {
|
|
340
|
+
...baseContext,
|
|
341
|
+
toolUseId: toolCall.id,
|
|
342
|
+
// Per-call for the same reason: a pause has to be routed back
|
|
343
|
+
// to the call that raised it, and a batch can raise several.
|
|
344
|
+
...(this.config.toolPause ? { requestPause: this.config.toolPause(toolCall.id) } : {}),
|
|
345
|
+
report: (message: string, fraction?: number) => {
|
|
346
|
+
// Fire-and-forget: a tool reporting progress must never be
|
|
347
|
+
// able to fail because the host's listener threw, and must
|
|
348
|
+
// never have to await the emit mid-work.
|
|
349
|
+
void this.emitEvent({
|
|
350
|
+
type: 'tool_progress',
|
|
351
|
+
runId: this.config.runId,
|
|
352
|
+
toolUseId: toolCall.id as ToolUseId,
|
|
353
|
+
toolName: toolCall.function.name,
|
|
354
|
+
message,
|
|
355
|
+
...(fraction !== undefined ? { fraction: Math.min(1, Math.max(0, fraction)) } : {}),
|
|
356
|
+
}).catch(() => {})
|
|
357
|
+
},
|
|
358
|
+
}
|
|
116
359
|
const run = async () => {
|
|
117
360
|
results[i] = await this.executeSingle(toolCall, ctx)
|
|
118
361
|
}
|
|
362
|
+
const gated = async () => {
|
|
363
|
+
await gate.acquire()
|
|
364
|
+
try {
|
|
365
|
+
await run()
|
|
366
|
+
} finally {
|
|
367
|
+
gate.release()
|
|
368
|
+
}
|
|
369
|
+
}
|
|
119
370
|
let input: unknown = {}
|
|
120
371
|
try {
|
|
121
372
|
input = JSON.parse(toolCall.function.arguments || '{}')
|
|
@@ -124,12 +375,37 @@ export class ToolExecutor {
|
|
|
124
375
|
}
|
|
125
376
|
const safe =
|
|
126
377
|
this.config.tools.get(toolCall.function.name)?.isConcurrencySafe?.(input) === true
|
|
127
|
-
if (safe) parallel.push(
|
|
378
|
+
if (safe) parallel.push(gated())
|
|
128
379
|
else serial = serial.then(run)
|
|
129
380
|
})
|
|
130
381
|
await Promise.all([...parallel, serial])
|
|
131
382
|
|
|
132
|
-
|
|
383
|
+
// Whatever failed above left a hole in `results`; fill every one, so
|
|
384
|
+
// the invariant holds by construction rather than by everything having
|
|
385
|
+
// gone well.
|
|
386
|
+
for (let i = 0; i < toolCalls.length; i++) {
|
|
387
|
+
if (results[i]) continue
|
|
388
|
+
const toolCall = toolCalls[i] as ToolCall
|
|
389
|
+
const toolName = toolCall.function.name
|
|
390
|
+
const message = `Error: Tool "${toolName}" did not complete — the batch failed before it produced a result.`
|
|
391
|
+
results[i] = { toolCallId: toolCall.id, toolName, output: message, isError: true }
|
|
392
|
+
await this.emitEvent({
|
|
393
|
+
type: 'tool_completed',
|
|
394
|
+
runId: this.config.runId,
|
|
395
|
+
toolUseId: toolCall.id,
|
|
396
|
+
toolName,
|
|
397
|
+
result: message,
|
|
398
|
+
isError: true,
|
|
399
|
+
})
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// isError and rich content were computed and then discarded here: the
|
|
403
|
+
// tuple narrowed to {toolCallId, output} BEFORE the message was built,
|
|
404
|
+
// so the failure signal and any image block were structurally lost at
|
|
405
|
+
// the last possible moment.
|
|
406
|
+
const messages: Message[] = results.map((r) =>
|
|
407
|
+
createToolMessage(r.content ?? r.output, r.toolCallId, r.isError),
|
|
408
|
+
)
|
|
133
409
|
|
|
134
410
|
return { messages, results }
|
|
135
411
|
}
|
|
@@ -151,16 +427,27 @@ export class ToolExecutor {
|
|
|
151
427
|
allowedTools: this.config.allowedTools,
|
|
152
428
|
sandbox: this.config.sandbox,
|
|
153
429
|
fileReadTracker: this.fileReadTracker,
|
|
430
|
+
...(this.parentSpan ? { parentSpan: this.parentSpan } : {}),
|
|
154
431
|
}
|
|
155
432
|
}
|
|
156
433
|
|
|
157
434
|
private async executeSingle(
|
|
158
435
|
toolCall: ToolCall,
|
|
159
436
|
toolContext: ToolContext,
|
|
160
|
-
): Promise<
|
|
161
|
-
|
|
437
|
+
): Promise<ToolCallOutcome> {
|
|
438
|
+
let toolName = toolCall.function.name
|
|
162
439
|
|
|
163
|
-
|
|
440
|
+
// A stream that cut off mid-JSON is the case `repairToolCall` exists
|
|
441
|
+
// for, and it used to be the one case that never reached it: this
|
|
442
|
+
// branch returned before `resolveCall` ran, so the motivating failure
|
|
443
|
+
// was answered with a generic hint while the configured repairer sat
|
|
444
|
+
// unused. Offer it the partial buffer first.
|
|
445
|
+
const truncationRepair =
|
|
446
|
+
toolCall.metadata?.inputTruncated === true
|
|
447
|
+
? await this.repairTruncatedCall(toolCall, toolName)
|
|
448
|
+
: null
|
|
449
|
+
|
|
450
|
+
if (toolCall.metadata?.inputTruncated === true && !truncationRepair) {
|
|
164
451
|
const message = truncatedToolInputMessage(toolName)
|
|
165
452
|
await this.emitEvent({
|
|
166
453
|
type: 'tool_executing',
|
|
@@ -177,19 +464,34 @@ export class ToolExecutor {
|
|
|
177
464
|
result: message,
|
|
178
465
|
isError: true,
|
|
179
466
|
})
|
|
180
|
-
return { toolCallId: toolCall.id, output: message }
|
|
467
|
+
return { toolCallId: toolCall.id, toolName, output: message, isError: true }
|
|
181
468
|
}
|
|
182
469
|
|
|
183
|
-
|
|
470
|
+
// A malformed call used to cost a full model round trip to fix: the
|
|
471
|
+
// error went back as a `tool_result`, the model re-read the whole
|
|
472
|
+
// context and tried again. A host that can repair it locally turns
|
|
473
|
+
// that into nothing. No-op when no repairer is configured.
|
|
474
|
+
const resolved = await this.resolveCall(
|
|
475
|
+
truncationRepair
|
|
476
|
+
? {
|
|
477
|
+
...toolCall,
|
|
478
|
+
function: {
|
|
479
|
+
...toolCall.function,
|
|
480
|
+
name: truncationRepair.toolName ?? toolName,
|
|
481
|
+
arguments: truncationRepair.arguments,
|
|
482
|
+
},
|
|
483
|
+
metadata: {},
|
|
484
|
+
}
|
|
485
|
+
: toolCall,
|
|
486
|
+
)
|
|
487
|
+
toolName = resolved.toolName
|
|
184
488
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
} catch {
|
|
188
|
-
// Codex M2: malformed JSON args used to return without ever
|
|
489
|
+
if (!resolved.ok) {
|
|
490
|
+
// malformed JSON args used to return without ever
|
|
189
491
|
// emitting tool_executing or tool_completed, leaving UI cards
|
|
190
492
|
// orphaned in `streaming_input`. Emit the executing→completed
|
|
191
493
|
// terminal pair so the card lifecycle closes.
|
|
192
|
-
const message =
|
|
494
|
+
const message = resolved.message
|
|
193
495
|
await this.emitEvent({
|
|
194
496
|
type: 'tool_executing',
|
|
195
497
|
runId: this.config.runId,
|
|
@@ -205,9 +507,11 @@ export class ToolExecutor {
|
|
|
205
507
|
result: message,
|
|
206
508
|
isError: true,
|
|
207
509
|
})
|
|
208
|
-
return { toolCallId: toolCall.id, output: message }
|
|
510
|
+
return { toolCallId: toolCall.id, toolName, output: message, isError: true }
|
|
209
511
|
}
|
|
210
512
|
|
|
513
|
+
let input: unknown = resolved.input
|
|
514
|
+
|
|
211
515
|
const preOutcome = await this.runPreToolHook(toolName, input)
|
|
212
516
|
if (preOutcome.kind === 'skip' || preOutcome.kind === 'error') {
|
|
213
517
|
return this.recordSyntheticHookOutcome(toolCall.id, toolName, preOutcome.input, preOutcome)
|
|
@@ -256,7 +560,7 @@ export class ToolExecutor {
|
|
|
256
560
|
if (activity) {
|
|
257
561
|
this.activityStore.fail(activity.id, veto.message)
|
|
258
562
|
}
|
|
259
|
-
//
|
|
563
|
+
// probe veto used to skip tool_completed entirely.
|
|
260
564
|
// Emit the terminal event with isError so UI cards finalize.
|
|
261
565
|
await this.emitEvent({
|
|
262
566
|
type: 'tool_completed',
|
|
@@ -268,7 +572,22 @@ export class ToolExecutor {
|
|
|
268
572
|
})
|
|
269
573
|
return {
|
|
270
574
|
toolCallId: toolCall.id,
|
|
575
|
+
toolName,
|
|
271
576
|
output: `Error: ${veto.message}`,
|
|
577
|
+
// The event emitted just above says this failed; the RESULT
|
|
578
|
+
// has to say so too. This was the only result-producing
|
|
579
|
+
// branch in the file that left it off, and `isError` being
|
|
580
|
+
// optional meant the compiler could not notice.
|
|
581
|
+
//
|
|
582
|
+
// Four things degraded off the omission, not one. Two drivers
|
|
583
|
+
// emit their failure marker only when this is true, so the
|
|
584
|
+
// model read a SUCCESSFUL result whose body begins "Error: …"
|
|
585
|
+
// and the failure-recovery path it was trained on never
|
|
586
|
+
// fired. The persisted step recorded a literal
|
|
587
|
+
// `isError: false`, so the run record contradicted its own
|
|
588
|
+
// event stream. And compaction's guard against clearing error
|
|
589
|
+
// results silently excluded vetoed ones.
|
|
590
|
+
isError: true,
|
|
272
591
|
}
|
|
273
592
|
}
|
|
274
593
|
|
|
@@ -277,21 +596,49 @@ export class ToolExecutor {
|
|
|
277
596
|
}
|
|
278
597
|
|
|
279
598
|
const startMs = Date.now()
|
|
280
|
-
//
|
|
599
|
+
// an unhandled throw from `tools.execute(...)` used to
|
|
281
600
|
// propagate up to `result.ts` as `run_failed` without emitting a
|
|
282
601
|
// terminal `tool_completed`, leaving UI cards stuck in `executing`.
|
|
283
602
|
// Wrap so any throw materialises as an error result.
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
603
|
+
// Typed as the full ToolResult, not a narrowed literal: the narrow
|
|
604
|
+
// version silently DROPPED `content`, so a tool returning an image
|
|
605
|
+
// block had it discarded here — before the wire mapper that was
|
|
606
|
+
// built to carry it ever saw it.
|
|
607
|
+
let result: ToolResult = await this.runOnce(toolName, input, toolContext)
|
|
608
|
+
let post = await this.runPostToolHook(toolName, input, result)
|
|
609
|
+
|
|
610
|
+
// In-loop retry. A transient failure used to cost a full model round
|
|
611
|
+
// trip: the error went back as a `tool_result`, the model read it and
|
|
612
|
+
// decided (or didn't) to call again. Strictly opt-in per tool,
|
|
613
|
+
// because the SDK cannot know a tool is idempotent — silently
|
|
614
|
+
// re-running a write or a payment is worse than never retrying.
|
|
615
|
+
const maxRetries = Math.max(0, this.config.tools.get(toolName)?.maxRetries ?? 0)
|
|
616
|
+
for (let attempt = 1; ; attempt++) {
|
|
617
|
+
// A missing file will not appear on the second attempt; burning
|
|
618
|
+
// the budget on it only delays the error the model needs to see.
|
|
619
|
+
const toolWants = !result.success && result.retryable === true
|
|
620
|
+
// A `post_tool_use` hook asking for a retry gets its OWN budget.
|
|
621
|
+
// Bounding it by `maxRetries` made it a silent no-op at the
|
|
622
|
+
// shipped default of 0: the hook's answer was read and discarded
|
|
623
|
+
// on every tool that had not separately opted in. The hook is
|
|
624
|
+
// host code looking at this specific result — a more specific
|
|
625
|
+
// signal than the tool's blanket idempotency declaration — so it
|
|
626
|
+
// is honored, but still bounded so a plugin cannot spin the
|
|
627
|
+
// executor.
|
|
628
|
+
if (!toolWants && !post.retry) break
|
|
629
|
+
const budget = post.retry ? Math.max(maxRetries, HOOK_RETRY_BUDGET) : maxRetries
|
|
630
|
+
if (attempt > budget) break
|
|
631
|
+
|
|
632
|
+
this.log.info('Retrying a failed tool call', {
|
|
290
633
|
runId: this.config.runId,
|
|
291
634
|
tool: toolName,
|
|
292
|
-
|
|
635
|
+
attempt,
|
|
636
|
+
budget,
|
|
637
|
+
requestedByHook: post.retry,
|
|
638
|
+
error: result.error,
|
|
293
639
|
})
|
|
294
|
-
result =
|
|
640
|
+
result = await this.runOnce(toolName, input, toolContext)
|
|
641
|
+
post = await this.runPostToolHook(toolName, input, result)
|
|
295
642
|
}
|
|
296
643
|
const durationMs = Date.now() - startMs
|
|
297
644
|
|
|
@@ -301,7 +648,44 @@ export class ToolExecutor {
|
|
|
301
648
|
|
|
302
649
|
let output = result.success ? this.maybeCompress(toolName, rawOutput) : rawOutput
|
|
303
650
|
|
|
304
|
-
|
|
651
|
+
// Compression is opportunistic and shell-only; the budget is the
|
|
652
|
+
// hard bound that applies to every tool. Runs after compression so
|
|
653
|
+
// a result that shrinks under the cap is never spilled needlessly.
|
|
654
|
+
const budgeted = applyToolOutputBudget({
|
|
655
|
+
toolName,
|
|
656
|
+
toolUseId: toolCall.id,
|
|
657
|
+
output,
|
|
658
|
+
maxChars: this.config.maxToolOutputChars ?? DEFAULT_MAX_TOOL_OUTPUT_CHARS,
|
|
659
|
+
spillDir: this.config.toolOutputDir,
|
|
660
|
+
onError: (message) =>
|
|
661
|
+
this.log.warn('Failed to spill oversized tool output', {
|
|
662
|
+
runId: this.config.runId,
|
|
663
|
+
tool: toolName,
|
|
664
|
+
error: message,
|
|
665
|
+
}),
|
|
666
|
+
})
|
|
667
|
+
if (budgeted.truncated) {
|
|
668
|
+
this.log.warn('Tool output exceeded the model-visible budget', {
|
|
669
|
+
runId: this.config.runId,
|
|
670
|
+
tool: toolName,
|
|
671
|
+
originalLength: budgeted.originalLength,
|
|
672
|
+
spillPath: budgeted.spillPath,
|
|
673
|
+
})
|
|
674
|
+
}
|
|
675
|
+
output = budgeted.output
|
|
676
|
+
|
|
677
|
+
// A truncated text half drops the rich half with it — the preview is
|
|
678
|
+
// no longer the tool's own payload, so an image alongside it would be
|
|
679
|
+
// illustrating something the model can no longer read. Dropping is
|
|
680
|
+
// right; doing it SILENTLY is not. The model saw a preview and had no
|
|
681
|
+
// way to know an image existed at all, so it reasoned as though the
|
|
682
|
+
// tool had returned text only.
|
|
683
|
+
if (budgeted.truncated && result.content !== undefined) {
|
|
684
|
+
const dropped = describeDroppedContent(result.content)
|
|
685
|
+
if (dropped) output = `${output}\n\n${dropped}`
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
const postOverride = post.override
|
|
305
689
|
if (postOverride !== null) {
|
|
306
690
|
output = postOverride
|
|
307
691
|
}
|
|
@@ -343,9 +727,130 @@ export class ToolExecutor {
|
|
|
343
727
|
toolName,
|
|
344
728
|
result: output,
|
|
345
729
|
isError: effectiveIsError,
|
|
730
|
+
durationMs,
|
|
731
|
+
// Pre-truncation size, so a host can show "returned 2.1 MB" even
|
|
732
|
+
// though the model only ever saw a preview.
|
|
733
|
+
outputLength: budgeted.originalLength,
|
|
734
|
+
...(budgeted.truncated ? { outputTruncated: true } : {}),
|
|
735
|
+
...(budgeted.spillPath ? { outputSpillPath: budgeted.spillPath } : {}),
|
|
346
736
|
})
|
|
347
737
|
|
|
348
|
-
return {
|
|
738
|
+
return {
|
|
739
|
+
toolCallId: toolCall.id,
|
|
740
|
+
toolName,
|
|
741
|
+
output,
|
|
742
|
+
isError: effectiveIsError,
|
|
743
|
+
// A plugin override replaces what the model sees, and a spilled
|
|
744
|
+
// preview is no longer the tool's own payload — neither may carry
|
|
745
|
+
// rich content through.
|
|
746
|
+
...(result.content !== undefined && postOverride === null && !budgeted.truncated
|
|
747
|
+
? { content: this.budgetContent(result.content, toolName) }
|
|
748
|
+
: {}),
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Run a tool under a deadline, with the run abort folded in.
|
|
754
|
+
*
|
|
755
|
+
* `ToolContext.abortSignal` existed but was produced and consumed by
|
|
756
|
+
* nothing: a Stop tore down the model stream and then parked inside
|
|
757
|
+
* `Promise.all` waiting for a tool that had no idea it should quit. A
|
|
758
|
+
* hung MCP stdio server or a `bash` with the old one-hour default
|
|
759
|
+
* could hold a turn open long after the user cancelled.
|
|
760
|
+
*
|
|
761
|
+
* Two mechanisms, because neither alone is enough:
|
|
762
|
+
*
|
|
763
|
+
* 1. The composed signal (run abort OR deadline) is handed to the tool
|
|
764
|
+
* so a cooperative tool actually stops working.
|
|
765
|
+
* 2. The `race` bounds the *executor's* wait regardless, so an
|
|
766
|
+
* uncooperative tool becomes detached rather than blocking.
|
|
767
|
+
*
|
|
768
|
+
* A timeout is reported as a normal failed result, not a throw: the
|
|
769
|
+
* model sees "this timed out" as a `tool_result` and can route around
|
|
770
|
+
* it. A throw would end the run over one slow tool.
|
|
771
|
+
*/
|
|
772
|
+
private async executeWithDeadline(
|
|
773
|
+
toolName: string,
|
|
774
|
+
input: unknown,
|
|
775
|
+
toolContext: ToolContext,
|
|
776
|
+
): Promise<ToolResult> {
|
|
777
|
+
const timeoutMs =
|
|
778
|
+
this.config.tools.get(toolName)?.timeoutMs ??
|
|
779
|
+
this.config.toolTimeoutMs ??
|
|
780
|
+
DEFAULT_TOOL_TIMEOUT_MS
|
|
781
|
+
|
|
782
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
783
|
+
return this.config.tools.execute(toolName, input, toolContext)
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const controller = new AbortController()
|
|
787
|
+
const runSignal = this.config.abortSignal
|
|
788
|
+
const onRunAbort = () => controller.abort(runSignal.reason)
|
|
789
|
+
if (runSignal.aborted) controller.abort(runSignal.reason)
|
|
790
|
+
else runSignal.addEventListener('abort', onRunAbort, { once: true })
|
|
791
|
+
|
|
792
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
793
|
+
let timedOut = false
|
|
794
|
+
|
|
795
|
+
try {
|
|
796
|
+
const expired = new Promise<'timeout'>((resolve) => {
|
|
797
|
+
timer = setTimeout(() => {
|
|
798
|
+
timedOut = true
|
|
799
|
+
controller.abort(new Error(`Tool "${toolName}" exceeded ${timeoutMs}ms`))
|
|
800
|
+
resolve('timeout')
|
|
801
|
+
}, timeoutMs)
|
|
802
|
+
})
|
|
803
|
+
|
|
804
|
+
const aborted = new Promise<'aborted'>((resolve) => {
|
|
805
|
+
if (controller.signal.aborted && !timedOut) {
|
|
806
|
+
resolve('aborted')
|
|
807
|
+
return
|
|
808
|
+
}
|
|
809
|
+
controller.signal.addEventListener(
|
|
810
|
+
'abort',
|
|
811
|
+
() => {
|
|
812
|
+
if (!timedOut) resolve('aborted')
|
|
813
|
+
},
|
|
814
|
+
{ once: true },
|
|
815
|
+
)
|
|
816
|
+
})
|
|
817
|
+
|
|
818
|
+
const execution = this.config.tools.execute(toolName, input, {
|
|
819
|
+
...toolContext,
|
|
820
|
+
abortSignal: controller.signal,
|
|
821
|
+
})
|
|
822
|
+
// The loser of the race may still reject later; neutralize it so
|
|
823
|
+
// it is never an unhandled rejection.
|
|
824
|
+
execution.catch(() => {})
|
|
825
|
+
|
|
826
|
+
const outcome = await Promise.race([execution, expired, aborted])
|
|
827
|
+
|
|
828
|
+
if (outcome === 'timeout') {
|
|
829
|
+
this.log.warn('Tool timed out', {
|
|
830
|
+
runId: this.config.runId,
|
|
831
|
+
tool: toolName,
|
|
832
|
+
timeoutMs,
|
|
833
|
+
})
|
|
834
|
+
return {
|
|
835
|
+
success: false,
|
|
836
|
+
output: '',
|
|
837
|
+
error: `Tool "${toolName}" timed out after ${timeoutMs}ms and was abandoned. It may still be running. Try a narrower input, or a different approach.`,
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
if (outcome === 'aborted') {
|
|
842
|
+
return {
|
|
843
|
+
success: false,
|
|
844
|
+
output: '',
|
|
845
|
+
error: `Tool "${toolName}" was cancelled.`,
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
return outcome
|
|
850
|
+
} finally {
|
|
851
|
+
if (timer !== undefined) clearTimeout(timer)
|
|
852
|
+
runSignal.removeEventListener('abort', onRunAbort)
|
|
853
|
+
}
|
|
349
854
|
}
|
|
350
855
|
|
|
351
856
|
private async runPreToolHook(toolName: string, input: unknown): Promise<PreToolHookOutcome> {
|
|
@@ -384,7 +889,6 @@ export class ToolExecutor {
|
|
|
384
889
|
output: `Error: ${result.message}`,
|
|
385
890
|
}
|
|
386
891
|
case 'retry':
|
|
387
|
-
case 'resume':
|
|
388
892
|
throw new Error(
|
|
389
893
|
`Plugin hook pre_tool_use returned unsupported action '${result.action}' for tool ${toolName}`,
|
|
390
894
|
)
|
|
@@ -397,18 +901,204 @@ export class ToolExecutor {
|
|
|
397
901
|
return { kind: 'continue', input: currentInput }
|
|
398
902
|
}
|
|
399
903
|
|
|
904
|
+
/**
|
|
905
|
+
* Turn the call the model issued into a name and a parsed input, giving
|
|
906
|
+
* a configured repairer one chance to fix it first.
|
|
907
|
+
*
|
|
908
|
+
* Exactly one chance: a repairer that produces a call which is still
|
|
909
|
+
* broken will not do better on a second look, and an unbounded loop
|
|
910
|
+
* here is a hang rather than a degradation.
|
|
911
|
+
*
|
|
912
|
+
* `invalid_json` is the ONLY failure that stops the call here, and it
|
|
913
|
+
* stopped it before this function existed too. `unknown_tool` and
|
|
914
|
+
* `schema_validation` merely OFFER the repair and otherwise fall
|
|
915
|
+
* through to the registry, which reports both with better messages —
|
|
916
|
+
* its schema error already ships a "Required: <field>: <type>" hint the
|
|
917
|
+
* model can self-correct from. So with no repairer configured this is
|
|
918
|
+
* behaviorally identical to the bare `JSON.parse` it replaced.
|
|
919
|
+
*/
|
|
920
|
+
private async resolveCall(
|
|
921
|
+
toolCall: ToolCall,
|
|
922
|
+
): Promise<
|
|
923
|
+
| { ok: true; toolName: string; input: unknown }
|
|
924
|
+
| { ok: false; toolName: string; message: string }
|
|
925
|
+
> {
|
|
926
|
+
let toolName = toolCall.function.name
|
|
927
|
+
let raw = toolCall.function.arguments
|
|
928
|
+
|
|
929
|
+
for (let attempt = 0; ; attempt++) {
|
|
930
|
+
const failure = this.inspectCall(toolName, raw)
|
|
931
|
+
if (!failure) return { ok: true, toolName, input: parseArguments(raw) }
|
|
932
|
+
|
|
933
|
+
const repair =
|
|
934
|
+
attempt === 0 && this.config.repairToolCall
|
|
935
|
+
? await this.requestRepair(toolCall, toolName, failure)
|
|
936
|
+
: null
|
|
937
|
+
|
|
938
|
+
if (!repair) {
|
|
939
|
+
if (failure.reason === 'invalid_json') {
|
|
940
|
+
return { ok: false, toolName, message: failure.message }
|
|
941
|
+
}
|
|
942
|
+
return { ok: true, toolName, input: parseArguments(raw) }
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
this.log.info('Repaired a malformed tool call', {
|
|
946
|
+
runId: this.config.runId,
|
|
947
|
+
tool: toolName,
|
|
948
|
+
reason: failure.reason,
|
|
949
|
+
...(repair.toolName && repair.toolName !== toolName ? { repairedTo: repair.toolName } : {}),
|
|
950
|
+
})
|
|
951
|
+
toolName = repair.toolName ?? toolName
|
|
952
|
+
raw = repair.arguments
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* What is wrong with this call, or `null` if nothing is.
|
|
958
|
+
*
|
|
959
|
+
* JSON is checked before the tool is looked up: an unparseable argument
|
|
960
|
+
* string is broken regardless of which tool it was aimed at, and it is
|
|
961
|
+
* the one problem the executor itself has to answer.
|
|
962
|
+
*/
|
|
963
|
+
private async repairTruncatedCall(
|
|
964
|
+
toolCall: ToolCall,
|
|
965
|
+
toolName: string,
|
|
966
|
+
): Promise<ToolCallRepair | null> {
|
|
967
|
+
if (!this.config.repairToolCall) return null
|
|
968
|
+
|
|
969
|
+
// Present the PARTIAL buffer, not the normalized `"{}"` — a repairer
|
|
970
|
+
// handed an empty object has nothing to work from.
|
|
971
|
+
const partial = toolCall.metadata?.partialArguments ?? ''
|
|
972
|
+
const repair = await this.requestRepair(
|
|
973
|
+
{ ...toolCall, function: { ...toolCall.function, arguments: partial } },
|
|
974
|
+
toolName,
|
|
975
|
+
{ reason: 'invalid_json', message: truncatedToolInputMessage(toolName) },
|
|
976
|
+
)
|
|
977
|
+
if (repair) {
|
|
978
|
+
this.log.info('Repaired a tool call whose input stream was truncated', {
|
|
979
|
+
runId: this.config.runId,
|
|
980
|
+
tool: toolName,
|
|
981
|
+
partialLength: partial.length,
|
|
982
|
+
})
|
|
983
|
+
}
|
|
984
|
+
return repair
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
private inspectCall(
|
|
988
|
+
toolName: string,
|
|
989
|
+
raw: string,
|
|
990
|
+
): { reason: ToolCallRepairReason; message: string } | null {
|
|
991
|
+
let parsed: unknown
|
|
992
|
+
try {
|
|
993
|
+
parsed = parseArguments(raw)
|
|
994
|
+
} catch {
|
|
995
|
+
return {
|
|
996
|
+
reason: 'invalid_json',
|
|
997
|
+
message: `Error: Invalid JSON in tool arguments for "${toolName}"`,
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
const tool = this.config.tools.get?.(toolName)
|
|
1002
|
+
if (!tool) {
|
|
1003
|
+
// Either the model named a tool that does not exist, or this
|
|
1004
|
+
// registry does not implement `get`. Both are the registry's to
|
|
1005
|
+
// answer; a repairer still gets offered the `unknown_tool` case.
|
|
1006
|
+
return { reason: 'unknown_tool', message: `Error: Unknown tool "${toolName}"` }
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// A registry that hands back a tool with no schema has nothing to
|
|
1010
|
+
// validate against; that is not a repairable condition, just an
|
|
1011
|
+
// unvalidatable one.
|
|
1012
|
+
const validation = tool.inputSchema?.safeParse(parsed)
|
|
1013
|
+
if (validation && !validation.success) {
|
|
1014
|
+
return {
|
|
1015
|
+
reason: 'schema_validation',
|
|
1016
|
+
message: `Error: Invalid arguments for "${toolName}": ${validation.error.issues
|
|
1017
|
+
.map((issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`)
|
|
1018
|
+
.join('; ')}`,
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
return null
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
private async requestRepair(
|
|
1026
|
+
toolCall: ToolCall,
|
|
1027
|
+
toolName: string,
|
|
1028
|
+
failure: { reason: ToolCallRepairReason; message: string },
|
|
1029
|
+
): Promise<ToolCallRepair | null> {
|
|
1030
|
+
const repairToolCall = this.config.repairToolCall
|
|
1031
|
+
if (!repairToolCall) return null
|
|
1032
|
+
|
|
1033
|
+
const tool = this.config.tools.get(toolName)
|
|
1034
|
+
try {
|
|
1035
|
+
return await repairToolCall({
|
|
1036
|
+
toolCall,
|
|
1037
|
+
reason: failure.reason,
|
|
1038
|
+
message: failure.message,
|
|
1039
|
+
...(tool ? { tool, jsonSchema: renderToolSchema(tool.inputSchema) } : {}),
|
|
1040
|
+
availableTools: this.config.tools.listNames(),
|
|
1041
|
+
})
|
|
1042
|
+
} catch (err) {
|
|
1043
|
+
// A broken repairer must not turn a recoverable tool error into a
|
|
1044
|
+
// failed run: the original error is still a perfectly good answer
|
|
1045
|
+
// to give the model.
|
|
1046
|
+
this.log.error('repairToolCall threw — falling back to the original error', {
|
|
1047
|
+
runId: this.config.runId,
|
|
1048
|
+
tool: toolName,
|
|
1049
|
+
error: toErrorMessage(err),
|
|
1050
|
+
})
|
|
1051
|
+
return null
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* One execution attempt, with a throw materialized as an error result.
|
|
1057
|
+
*
|
|
1058
|
+
* an unhandled throw from `tools.execute(...)` used to
|
|
1059
|
+
* propagate up to `result.ts` as `run_failed` without emitting a
|
|
1060
|
+
* terminal `tool_completed`, leaving UI cards stuck in `executing`.
|
|
1061
|
+
*
|
|
1062
|
+
* The return is the full `ToolResult`, not a narrowed literal: the
|
|
1063
|
+
* narrow version silently DROPPED `content`, so a tool returning an
|
|
1064
|
+
* image block had it discarded here — before the wire mapper built to
|
|
1065
|
+
* carry it ever saw it.
|
|
1066
|
+
*/
|
|
1067
|
+
private async runOnce(
|
|
1068
|
+
toolName: string,
|
|
1069
|
+
input: unknown,
|
|
1070
|
+
toolContext: ToolContext,
|
|
1071
|
+
): Promise<ToolResult> {
|
|
1072
|
+
try {
|
|
1073
|
+
return await this.executeWithDeadline(toolName, input, toolContext)
|
|
1074
|
+
} catch (err) {
|
|
1075
|
+
const message = toErrorMessage(err)
|
|
1076
|
+
this.log.warn('Tool execution threw', {
|
|
1077
|
+
runId: this.config.runId,
|
|
1078
|
+
tool: toolName,
|
|
1079
|
+
error: message,
|
|
1080
|
+
})
|
|
1081
|
+
return { success: false, output: '', error: message }
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* @returns `override` — text replacing the tool's output, or `null`.
|
|
1087
|
+
* `retry` — the hook asked for the tool to run again.
|
|
1088
|
+
*/
|
|
400
1089
|
private async runPostToolHook(
|
|
401
1090
|
toolName: string,
|
|
402
1091
|
input: unknown,
|
|
403
1092
|
toolResult: ToolResult,
|
|
404
|
-
): Promise<string | null> {
|
|
405
|
-
if (!this.config.pluginManager) return null
|
|
1093
|
+
): Promise<{ override: string | null; retry: boolean }> {
|
|
1094
|
+
if (!this.config.pluginManager) return { override: null, retry: false }
|
|
406
1095
|
const results = await this.config.pluginManager.executeHooks(
|
|
407
1096
|
'post_tool_use',
|
|
408
1097
|
{ runId: this.config.runId, toolName, toolInput: input, toolResult },
|
|
409
1098
|
this.emitEvent,
|
|
410
1099
|
)
|
|
411
1100
|
let override: string | null = null
|
|
1101
|
+
let retry = false
|
|
412
1102
|
for (const result of results) {
|
|
413
1103
|
switch (result.action) {
|
|
414
1104
|
case 'continue':
|
|
@@ -416,10 +1106,16 @@ export class ToolExecutor {
|
|
|
416
1106
|
case 'error':
|
|
417
1107
|
override = `Error: ${result.message}`
|
|
418
1108
|
continue
|
|
1109
|
+
// `retry` was a declared variant with no implementation: every
|
|
1110
|
+
// site that consumed it threw. Here it finally means something
|
|
1111
|
+
// — the hook saw the result and wants the tool run again —
|
|
1112
|
+
// and it is bounded by the same per-tool retry budget, so a
|
|
1113
|
+
// plugin cannot spin the executor.
|
|
1114
|
+
case 'retry':
|
|
1115
|
+
retry = true
|
|
1116
|
+
continue
|
|
419
1117
|
case 'skip':
|
|
420
1118
|
case 'modify':
|
|
421
|
-
case 'retry':
|
|
422
|
-
case 'resume':
|
|
423
1119
|
throw new Error(
|
|
424
1120
|
`Plugin hook post_tool_use returned unsupported action '${result.action}' for tool ${toolName}`,
|
|
425
1121
|
)
|
|
@@ -429,7 +1125,62 @@ export class ToolExecutor {
|
|
|
429
1125
|
}
|
|
430
1126
|
}
|
|
431
1127
|
}
|
|
432
|
-
return override
|
|
1128
|
+
return { override, retry }
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Answer a tool call that policy or a human refused, without executing
|
|
1133
|
+
* it. Emits the same `tool_executing` → `tool_completed` pair as a real
|
|
1134
|
+
* execution so UI cards reach a terminal state instead of hanging in
|
|
1135
|
+
* `executing`, and records a failed activity for the trace.
|
|
1136
|
+
*/
|
|
1137
|
+
private async recordDenial(toolCall: ToolCall, reason: string): Promise<ToolCallOutcome> {
|
|
1138
|
+
const toolName = toolCall.function.name
|
|
1139
|
+
let input: unknown = {}
|
|
1140
|
+
try {
|
|
1141
|
+
input = JSON.parse(toolCall.function.arguments || '{}')
|
|
1142
|
+
} catch {
|
|
1143
|
+
input = toolCall.function.arguments
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
const output = deniedToolOutput(toolName, reason)
|
|
1147
|
+
|
|
1148
|
+
this.log.info('Tool call denied — synthesizing tool_result', {
|
|
1149
|
+
runId: this.config.runId,
|
|
1150
|
+
tool: toolName,
|
|
1151
|
+
toolUseId: toolCall.id,
|
|
1152
|
+
reason,
|
|
1153
|
+
})
|
|
1154
|
+
|
|
1155
|
+
const activity = this.activityStore.create({
|
|
1156
|
+
type: 'tool_call',
|
|
1157
|
+
description: toolName,
|
|
1158
|
+
input,
|
|
1159
|
+
toolName,
|
|
1160
|
+
toolCallId: toolCall.id,
|
|
1161
|
+
})
|
|
1162
|
+
if (activity) {
|
|
1163
|
+
this.activityStore.start(activity.id)
|
|
1164
|
+
this.activityStore.fail(activity.id, output)
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
await this.emitEvent({
|
|
1168
|
+
type: 'tool_executing',
|
|
1169
|
+
runId: this.config.runId,
|
|
1170
|
+
toolUseId: toolCall.id,
|
|
1171
|
+
toolName,
|
|
1172
|
+
input,
|
|
1173
|
+
})
|
|
1174
|
+
await this.emitEvent({
|
|
1175
|
+
type: 'tool_completed',
|
|
1176
|
+
runId: this.config.runId,
|
|
1177
|
+
toolUseId: toolCall.id,
|
|
1178
|
+
toolName,
|
|
1179
|
+
result: output,
|
|
1180
|
+
isError: true,
|
|
1181
|
+
})
|
|
1182
|
+
|
|
1183
|
+
return { toolCallId: toolCall.id, toolName, output, isError: true }
|
|
433
1184
|
}
|
|
434
1185
|
|
|
435
1186
|
private async recordSyntheticHookOutcome(
|
|
@@ -437,7 +1188,7 @@ export class ToolExecutor {
|
|
|
437
1188
|
toolName: string,
|
|
438
1189
|
input: unknown,
|
|
439
1190
|
outcome: { kind: 'skip' | 'error'; output: string },
|
|
440
|
-
): Promise<
|
|
1191
|
+
): Promise<ToolCallOutcome> {
|
|
441
1192
|
const activity = this.activityStore.create({
|
|
442
1193
|
type: 'tool_call',
|
|
443
1194
|
description: toolName,
|
|
@@ -468,7 +1219,46 @@ export class ToolExecutor {
|
|
|
468
1219
|
result: outcome.output,
|
|
469
1220
|
isError: outcome.kind === 'error',
|
|
470
1221
|
})
|
|
471
|
-
return { toolCallId, output: outcome.output }
|
|
1222
|
+
return { toolCallId, toolName, output: outcome.output, isError: outcome.kind === 'error' }
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Bound the rich channel, or leave it alone when no cap is configured.
|
|
1227
|
+
*
|
|
1228
|
+
* Refused whole rather than trimmed: half a base64 payload is not a
|
|
1229
|
+
* smaller image, it is a corrupt one, and a driver handed it would
|
|
1230
|
+
* either fail the request or show the model noise. The text half stays
|
|
1231
|
+
* untouched, so the result still says what happened — and the
|
|
1232
|
+
* replacement names what was withheld and how big it was, which is what
|
|
1233
|
+
* lets the agent ask for a smaller region instead of retrying the same
|
|
1234
|
+
* call.
|
|
1235
|
+
*/
|
|
1236
|
+
private budgetContent(
|
|
1237
|
+
content: import('../../types/message/index.js').ToolResultContent,
|
|
1238
|
+
toolName: string,
|
|
1239
|
+
): import('../../types/message/index.js').ToolResultContent {
|
|
1240
|
+
const cap = this.config.maxToolContentBytes ?? 0
|
|
1241
|
+
if (cap <= 0) return content
|
|
1242
|
+
|
|
1243
|
+
const size = measureContentBytes(content)
|
|
1244
|
+
if (size <= cap) return content
|
|
1245
|
+
|
|
1246
|
+
this.log.warn('Tool result content exceeded the rich-content budget', {
|
|
1247
|
+
runId: this.config.runId,
|
|
1248
|
+
tool: toolName,
|
|
1249
|
+
contentBytes: size,
|
|
1250
|
+
cap,
|
|
1251
|
+
})
|
|
1252
|
+
|
|
1253
|
+
const described = describeDroppedContent(content)
|
|
1254
|
+
return [
|
|
1255
|
+
{
|
|
1256
|
+
type: 'text',
|
|
1257
|
+
text: `[rich content withheld: ${size} base64 chars exceeds this run's ${cap} cap${
|
|
1258
|
+
described ? ` — ${described}` : ''
|
|
1259
|
+
}]`,
|
|
1260
|
+
},
|
|
1261
|
+
] as import('../../types/message/index.js').ToolResultContent
|
|
472
1262
|
}
|
|
473
1263
|
|
|
474
1264
|
private maybeCompress(toolName: string, output: string): string {
|
|
@@ -490,6 +1280,32 @@ export class ToolExecutor {
|
|
|
490
1280
|
}
|
|
491
1281
|
}
|
|
492
1282
|
|
|
1283
|
+
/** Minimal counting semaphore. FIFO, no timeout — the deadline is per-tool. */
|
|
1284
|
+
class Semaphore {
|
|
1285
|
+
private available: number
|
|
1286
|
+
private readonly waiters: Array<() => void> = []
|
|
1287
|
+
|
|
1288
|
+
constructor(permits: number) {
|
|
1289
|
+
this.available = Math.max(1, permits)
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
acquire(): Promise<void> {
|
|
1293
|
+
if (this.available > 0) {
|
|
1294
|
+
this.available--
|
|
1295
|
+
return Promise.resolve()
|
|
1296
|
+
}
|
|
1297
|
+
return new Promise<void>((resolve) => {
|
|
1298
|
+
this.waiters.push(resolve)
|
|
1299
|
+
})
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
release(): void {
|
|
1303
|
+
const next = this.waiters.shift()
|
|
1304
|
+
if (next) next()
|
|
1305
|
+
else this.available++
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
|
|
493
1309
|
function formatFailedToolOutput(output: string | undefined, error: string | undefined): string {
|
|
494
1310
|
const errorText = `Error: ${error ?? 'Tool execution failed'}`
|
|
495
1311
|
if (!output || output.trim().length === 0) return errorText
|