@namzu/sdk 2.0.0 → 3.0.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 +2265 -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 +50 -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 +24 -111
- 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 +224 -7
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +662 -35
- 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 +577 -34
- 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.test.js +10 -216
- 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__/write-file.test.js +13 -37
- package/dist/tools/builtins/__tests__/write-file.test.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/edit.d.ts +5 -2
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +125 -105
- 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 +38 -4
- 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 +40 -66
- 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/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 +80 -32
- 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 +193 -1
- 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 +111 -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 +25 -129
- 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 +847 -39
- 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 +656 -40
- 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.test.ts +10 -270
- 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__/write-file.test.ts +13 -52
- package/src/tools/builtins/bash.ts +34 -4
- package/src/tools/builtins/computer-use.ts +7 -1
- package/src/tools/builtins/edit.ts +162 -116
- 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 +40 -4
- package/src/tools/builtins/write-file.ts +44 -68
- package/src/tools/coordinator/__tests__/agent.test.ts +2 -2
- package/src/tools/coordinator/agent.ts +23 -10
- package/src/tools/coordinator/index.ts +111 -31
- 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 +204 -1
- 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,25 +1,46 @@
|
|
|
1
|
+
import { join } from 'node:path'
|
|
1
2
|
import {
|
|
2
3
|
AdvisorRegistry,
|
|
3
4
|
AdvisoryContext,
|
|
4
5
|
AdvisoryExecutor,
|
|
5
6
|
TriggerEvaluator,
|
|
7
|
+
assertBudgetEnforceable,
|
|
6
8
|
} from '../../advisory/index.js'
|
|
9
|
+
import { findDanglingMessages, removeDanglingMessages } from '../../compaction/dangling.js'
|
|
7
10
|
import { extractFromUserMessage } from '../../compaction/extractor.js'
|
|
8
11
|
import { WorkingStateManager } from '../../compaction/manager.js'
|
|
12
|
+
import { restoreWorkingState, snapshotWorkingState } from '../../compaction/wire.js'
|
|
9
13
|
import type { CompactionConfig } from '../../config/runtime.js'
|
|
14
|
+
import { TOOL_OUTPUT_DIR_NAME } from '../../constants/tools/index.js'
|
|
15
|
+
import { EmergencySaveManager } from '../../manager/run/emergency.js'
|
|
10
16
|
import { resolveProviderCapabilities } from '../../provider/capabilities.js'
|
|
17
|
+
import { type ProviderRetryConfig, withProviderRetry } from '../../provider/retry.js'
|
|
11
18
|
import type { PathBuilder } from '../../session/workspace/path-builder.js'
|
|
12
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
GENAI,
|
|
21
|
+
NAMZU,
|
|
22
|
+
agentRunSpanName,
|
|
23
|
+
parentContext,
|
|
24
|
+
serializeSpan,
|
|
25
|
+
} from '../../telemetry/attributes.js'
|
|
26
|
+
import { recordRunDuration } from '../../telemetry/metrics.js'
|
|
13
27
|
import { getTracer } from '../../telemetry/runtime-accessors.js'
|
|
14
28
|
import { buildAdvisoryTools } from '../../tools/advisory/index.js'
|
|
15
29
|
import { SearchToolsTool } from '../../tools/builtins/search-tools.js'
|
|
30
|
+
import {
|
|
31
|
+
STRUCTURED_OUTPUT_TOOL_NAME,
|
|
32
|
+
createStructuredOutputTool,
|
|
33
|
+
} from '../../tools/builtins/structuredOutput.js'
|
|
16
34
|
import { buildTaskTools } from '../../tools/task/index.js'
|
|
17
35
|
import type { AdvisoryConfig } from '../../types/advisory/index.js'
|
|
18
36
|
import type { AgentRuntimeContext, RuntimeToolOverrides } from '../../types/agent/base.js'
|
|
19
37
|
import type { AgentContextLevel } from '../../types/agent/factory.js'
|
|
20
38
|
import type { WorkingMemoryProvider } from '../../types/agent/working-memory.js'
|
|
39
|
+
import { NamzuError } from '../../types/errors/index.js'
|
|
40
|
+
import type { InputGuardrailSpec, OutputGuardrailSpec } from '../../types/guardrail/index.js'
|
|
21
41
|
import {
|
|
22
42
|
type CheckpointId,
|
|
43
|
+
type HITLResumeDecision,
|
|
23
44
|
type ResumeHandler,
|
|
24
45
|
autoApproveHandler,
|
|
25
46
|
} from '../../types/hitl/index.js'
|
|
@@ -29,28 +50,54 @@ import { type Message, createSystemMessage } from '../../types/message/index.js'
|
|
|
29
50
|
import type { AgentPersona } from '../../types/persona/index.js'
|
|
30
51
|
import type { LLMProvider } from '../../types/provider/index.js'
|
|
31
52
|
import type { TaskRouterConfig } from '../../types/router/index.js'
|
|
53
|
+
import type { ReviewAnswer } from '../../types/run/answer-review.js'
|
|
32
54
|
import type { CheckpointStore } from '../../types/run/checkpoint-store.js'
|
|
33
|
-
import type {
|
|
55
|
+
import type {
|
|
56
|
+
AgentRunConfig,
|
|
57
|
+
PrepareStepChain,
|
|
58
|
+
Run,
|
|
59
|
+
RunEvent,
|
|
60
|
+
RunEventListener,
|
|
61
|
+
StepResult,
|
|
62
|
+
StopCondition,
|
|
63
|
+
} from '../../types/run/index.js'
|
|
64
|
+
import type { PromoteMemory } from '../../types/run/memory-promotion.js'
|
|
65
|
+
import { memoryCandidateFor } from '../../types/run/memory-promotion.js'
|
|
34
66
|
import type { Sandbox, SandboxProvider } from '../../types/sandbox/index.js'
|
|
35
67
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
36
68
|
import type { Skill } from '../../types/skills/index.js'
|
|
69
|
+
import type { StructuredOutputConfig } from '../../types/structured-output/index.js'
|
|
37
70
|
import type { TaskStore } from '../../types/task/index.js'
|
|
38
71
|
import type { ToolRegistryContract } from '../../types/tool/index.js'
|
|
72
|
+
import type { RepairToolCall } from '../../types/tool/repair.js'
|
|
39
73
|
import type { VerificationGateConfig } from '../../types/verification/index.js'
|
|
40
74
|
import type { ModelPricing } from '../../utils/cost.js'
|
|
75
|
+
import { getRootLogger } from '../../utils/logger.js'
|
|
41
76
|
import { VerificationGate } from '../../verification/gate.js'
|
|
42
77
|
import { CheckpointManager } from './checkpoint.js'
|
|
43
78
|
import type { ContextCache } from './context-cache.js'
|
|
44
79
|
import { RunContextFactory } from './context.js'
|
|
45
80
|
import { EventTranslator } from './events.js'
|
|
46
81
|
import { GuardCoordinator } from './guard.js'
|
|
82
|
+
import { runInputGuardrails, runOutputGuardrails } from './guardrails.js'
|
|
47
83
|
import { IterationOrchestrator } from './iteration/index.js'
|
|
48
84
|
import { isCompactionMessage } from './iteration/phases/compaction.js'
|
|
49
85
|
import { isWorkingMemoryMessage } from './iteration/phases/working-memory.js'
|
|
50
86
|
import { applyLifecycleHookResults } from './plugin-hooks.js'
|
|
51
87
|
import { PromptBuilder } from './prompt.js'
|
|
52
88
|
import type { PromptSegments } from './prompt.js'
|
|
89
|
+
import type { PendingAnswers, QuestionParkBinding } from './question-park.js'
|
|
53
90
|
import { ResultAssembler } from './result.js'
|
|
91
|
+
import {
|
|
92
|
+
type PendingResumePlan,
|
|
93
|
+
applyPendingResume,
|
|
94
|
+
planCrashResume,
|
|
95
|
+
planPendingResume,
|
|
96
|
+
recoverCompletedCalls,
|
|
97
|
+
unansweredToolCalls,
|
|
98
|
+
} from './resume-pending.js'
|
|
99
|
+
import { ToolGrantSet } from './tool-grants.js'
|
|
100
|
+
import { createToolPause } from './tool-pause.js'
|
|
54
101
|
import { ToolingBootstrap } from './tooling.js'
|
|
55
102
|
|
|
56
103
|
export interface QueryParams {
|
|
@@ -59,6 +106,190 @@ export interface QueryParams {
|
|
|
59
106
|
skills?: Skill[]
|
|
60
107
|
basePrompt?: string
|
|
61
108
|
provider: LLMProvider
|
|
109
|
+
/**
|
|
110
|
+
* Transient-failure policy for model calls. A single 429 or 503 used to
|
|
111
|
+
* terminate a run outright — no driver in the estate retries. Defaults
|
|
112
|
+
* to {@link DEFAULT_PROVIDER_RETRY}; pass `false` to opt out (e.g. when
|
|
113
|
+
* the host already wraps the provider with its own policy).
|
|
114
|
+
*
|
|
115
|
+
* Only failures that happen BEFORE the first content chunk are retried;
|
|
116
|
+
* see `withProviderRetry`.
|
|
117
|
+
*/
|
|
118
|
+
retry?: Partial<ProviderRetryConfig> | false
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Install process-level crash handlers that dump this run's state to
|
|
122
|
+
* `<runDir>/../emergency/<runId>.json` on SIGINT, SIGTERM or an
|
|
123
|
+
* uncaught exception. `replay({ fromCheckpoint: 'emergency' })` reads
|
|
124
|
+
* that file.
|
|
125
|
+
*
|
|
126
|
+
* **Off by default, and it must stay that way.** `attach` registers
|
|
127
|
+
* `process.on(...)` handlers that call `process.exit()`. A library
|
|
128
|
+
* seizing a host's termination path is an overreach in any embedded
|
|
129
|
+
* context (an API server has its own drain sequence), and the manager
|
|
130
|
+
* is a singleton whose `attach` detaches whoever held it before — so
|
|
131
|
+
* with concurrent runs the last one to start would silently become the
|
|
132
|
+
* only one that gets saved.
|
|
133
|
+
*
|
|
134
|
+
* Turn it on for a process the run owns end-to-end: a CLI, a worker
|
|
135
|
+
* that handles one run at a time. The handlers are removed when the
|
|
136
|
+
* run settles.
|
|
137
|
+
*/
|
|
138
|
+
emergencySave?: boolean
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Durability for questions raised from inside a tool.
|
|
142
|
+
*
|
|
143
|
+
* The tool that asks is built before the run exists, so the binding is
|
|
144
|
+
* created by whoever builds the tools and attached here — that is what
|
|
145
|
+
* lets one tool instance be durable inside a run and inert outside one.
|
|
146
|
+
* Without it, a question park exists only as a suspended `await`: kill
|
|
147
|
+
* the process while somebody is looking at the card and the answer can
|
|
148
|
+
* never be applied.
|
|
149
|
+
*/
|
|
150
|
+
questionParks?: QuestionParkBinding
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The registry a re-entered `ask_user_question` reads its answer from.
|
|
154
|
+
*
|
|
155
|
+
* Same shape as {@link questionParks}: the tool is built before the run
|
|
156
|
+
* exists, so the instance is created by whoever builds the tools and
|
|
157
|
+
* filled here on the resume path. Without it a resumed run re-asks a
|
|
158
|
+
* question the user already answered.
|
|
159
|
+
*/
|
|
160
|
+
pendingAnswers?: PendingAnswers
|
|
161
|
+
|
|
162
|
+
/** Default per-tool execution deadline. See {@link ToolDefinition.timeoutMs}. */
|
|
163
|
+
toolTimeoutMs?: number
|
|
164
|
+
|
|
165
|
+
/** Max concurrently-executing concurrency-safe tools in one batch. */
|
|
166
|
+
maxToolConcurrency?: number
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Model-visible size cap for a single tool result. Over-budget output is
|
|
170
|
+
* spilled to the run directory and replaced with a head+tail preview
|
|
171
|
+
* naming the path, so nothing is lost and tokens are paid only if the
|
|
172
|
+
* agent decides the rest is worth re-reading. Set `0` to disable.
|
|
173
|
+
*/
|
|
174
|
+
maxToolOutputChars?: number
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Cap on the RICH channel of a single tool result, in base64 characters.
|
|
178
|
+
* `0` or absent disables it. Separate from {@link maxToolOutputChars}:
|
|
179
|
+
* that one bounds characters the model reads, this one bounds the image
|
|
180
|
+
* payload beside them, which no text budget ever touched.
|
|
181
|
+
*/
|
|
182
|
+
maxToolContentBytes?: number
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Last chance to fix a tool call the model got wrong, before the error
|
|
186
|
+
* reaches it.
|
|
187
|
+
*
|
|
188
|
+
* A malformed call costs a full round trip otherwise: the error goes
|
|
189
|
+
* back as a `tool_result`, the model re-reads the entire context, and
|
|
190
|
+
* issues a second inference to add a missing brace. A host that can
|
|
191
|
+
* repair the arguments locally — a cheap model handed the schema, or
|
|
192
|
+
* plain string surgery — turns that into nothing.
|
|
193
|
+
*
|
|
194
|
+
* See {@link RepairToolCall}. Declining is normal and cheap: the
|
|
195
|
+
* original error simply proceeds to the model as before.
|
|
196
|
+
*/
|
|
197
|
+
repairToolCall?: RepairToolCall
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Programmable halt condition, evaluated after each step's tools have
|
|
201
|
+
* run so a predicate can see what they returned.
|
|
202
|
+
*
|
|
203
|
+
* Before this the only halt was `GuardCoordinator`, which sees four
|
|
204
|
+
* numeric budgets and never the messages — so a terminal
|
|
205
|
+
* `submit_answer` tool could not end a run, and the model had to be
|
|
206
|
+
* prompt-begged to stop with `maxIterations: 200` as the only backstop.
|
|
207
|
+
*
|
|
208
|
+
* Helpers: `stepCountIs`, `hasToolCall`, `anyOf`.
|
|
209
|
+
*/
|
|
210
|
+
stopWhen?: StopCondition
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Judge the answer the run is about to settle with, and hand it back
|
|
214
|
+
* with feedback when it is not good enough.
|
|
215
|
+
*
|
|
216
|
+
* `stopWhen` is only consulted after tools have run, so there was no
|
|
217
|
+
* seam at the point the model stops calling them: the run finalized
|
|
218
|
+
* with whatever it had. Verify-then-fix — run the build, feed the
|
|
219
|
+
* failure back, let it try again — meant starting a new run and
|
|
220
|
+
* re-supplying the context the first one had already assembled.
|
|
221
|
+
*
|
|
222
|
+
* Bounded by {@link maxAnswerReviews}. Never called on the forced-final
|
|
223
|
+
* turn, which exists to extract a closing summary under pressure.
|
|
224
|
+
*/
|
|
225
|
+
reviewAnswer?: ReviewAnswer
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Decide what this run should leave behind when it settles.
|
|
229
|
+
*
|
|
230
|
+
* See {@link PromoteMemory}. Absent means nothing is offered and the
|
|
231
|
+
* run behaves exactly as it did.
|
|
232
|
+
*/
|
|
233
|
+
promoteMemory?: PromoteMemory
|
|
234
|
+
|
|
235
|
+
/** Rejections allowed before the run stops. Default 3. */
|
|
236
|
+
maxAnswerReviews?: number
|
|
237
|
+
|
|
238
|
+
/** Called with each completed step, as it completes. */
|
|
239
|
+
onStepFinish?: (step: StepResult) => void
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Shape each step before the model is called: narrow the tool surface,
|
|
243
|
+
* swap the model, add one-step guidance, change sampling.
|
|
244
|
+
*
|
|
245
|
+
* `stopWhen` let a run decide TO STOP from what its steps produced;
|
|
246
|
+
* this is the other half — deciding how the next step should look.
|
|
247
|
+
* Without it, the tool surface and model are fixed at `query()` time,
|
|
248
|
+
* so a phased agent (research with search tools, write with file tools,
|
|
249
|
+
* verify with a cheaper model) had to be three separate runs, each
|
|
250
|
+
* starting blind to the last one's context.
|
|
251
|
+
*
|
|
252
|
+
* Narrowing `activeTools` costs a prompt-cache prefix, since tools
|
|
253
|
+
* render at position 0 — worth it at a real phase boundary, not every
|
|
254
|
+
* step. It does not touch `tool_choice`: not every provider has an
|
|
255
|
+
* `allowed_tools`, and moving `tool_choice` invalidates cached MESSAGE
|
|
256
|
+
* blocks too, which is a strictly worse trade for the same effect.
|
|
257
|
+
*
|
|
258
|
+
* Fails open — a throw leaves the step with the run's configuration.
|
|
259
|
+
*/
|
|
260
|
+
prepareStep?: PrepareStepChain
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Force the run to finish by calling a schema-validated tool, and land
|
|
264
|
+
* the parsed value on `Run.structuredOutput`.
|
|
265
|
+
*
|
|
266
|
+
* Both leaf pieces already shipped and neither was reachable:
|
|
267
|
+
* `createStructuredOutputTool` is excluded from the default builtin set,
|
|
268
|
+
* and `StructuredOutputConfig` had no field on QueryParams at all. A host
|
|
269
|
+
* needing a typed result had to register the tool by hand and hope —
|
|
270
|
+
* nothing forced the call, and nothing stopped the loop when it came.
|
|
271
|
+
*/
|
|
272
|
+
structuredOutput?: StructuredOutputConfig
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Checks run BEFORE the first model call. A block settles the run as
|
|
276
|
+
* `input_guardrail` having spent nothing.
|
|
277
|
+
*
|
|
278
|
+
* namzu's three tool gates all point one way — they protect the world
|
|
279
|
+
* from the agent. These are the other direction.
|
|
280
|
+
*/
|
|
281
|
+
inputGuardrails?: readonly InputGuardrailSpec[]
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Checks run against the FINAL result. A block settles the run as
|
|
285
|
+
* `output_guardrail`; a `rewrite` replaces the text (so a PII policy
|
|
286
|
+
* can redact rather than discard the whole answer).
|
|
287
|
+
*
|
|
288
|
+
* These gate the result, not the stream: `text_delta` events already
|
|
289
|
+
* reached the host, so a rewrite arrives as a correction alongside a
|
|
290
|
+
* `guardrail_triggered` event.
|
|
291
|
+
*/
|
|
292
|
+
outputGuardrails?: readonly OutputGuardrailSpec[]
|
|
62
293
|
tools: ToolRegistryContract
|
|
63
294
|
runConfig: AgentRunConfig
|
|
64
295
|
allowedTools?: string[]
|
|
@@ -72,6 +303,46 @@ export interface QueryParams {
|
|
|
72
303
|
resumeHandler: ResumeHandler
|
|
73
304
|
resumeFromCheckpoint?: CheckpointId
|
|
74
305
|
|
|
306
|
+
/**
|
|
307
|
+
* The answer to the decision the checkpoint parked on, collected
|
|
308
|
+
* out-of-band — typically in a different process.
|
|
309
|
+
*
|
|
310
|
+
* Recording a park makes the request survive a restart; this is what
|
|
311
|
+
* makes the ANSWER survive one. Without it a resumed run repairs the
|
|
312
|
+
* unanswered `tool_use` blocks away and lets the model re-decide, so a
|
|
313
|
+
* human's "yes, delete that row" degrades into "ask the model again and
|
|
314
|
+
* hope it asks for the same thing".
|
|
315
|
+
*
|
|
316
|
+
* Applies only to a `tool_review` park (the others leave no tool calls
|
|
317
|
+
* to apply a decision to) and only when the checkpoint's tool calls
|
|
318
|
+
* still match the ones the decision was made about — otherwise the
|
|
319
|
+
* decision is ignored and the repair path runs, because consent to one
|
|
320
|
+
* batch is not consent to a different one.
|
|
321
|
+
*/
|
|
322
|
+
pendingDecision?: HITLResumeDecision
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* How long a HITL decision may take before the park is written to the
|
|
326
|
+
* checkpoint store. Defaults to {@link PARK_RECORD_DELAY_MS}.
|
|
327
|
+
*
|
|
328
|
+
* A park is only worth persisting if a human is actually looking at it:
|
|
329
|
+
* a programmatic handler answers in microseconds, and the iteration
|
|
330
|
+
* gate runs on every iteration, so recording every park unconditionally
|
|
331
|
+
* would take a long run from one full-history checkpoint write per
|
|
332
|
+
* iteration to three. Set `0` to record every park (tests, or a host
|
|
333
|
+
* that wants an unconditional audit trail).
|
|
334
|
+
*/
|
|
335
|
+
parkRecordDelayMs?: number
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Span this run should hang off, when it is a delegated one.
|
|
339
|
+
*
|
|
340
|
+
* A spawned sub-agent is part of its parent's work, and a trace that
|
|
341
|
+
* shows the delegation is the whole reason to trace a supervisor at
|
|
342
|
+
* all. Absent for a top-level run, which correctly starts its own root.
|
|
343
|
+
*/
|
|
344
|
+
parentSpan?: import('@opentelemetry/api').Span
|
|
345
|
+
|
|
75
346
|
/** Session scope for the run. Required — every run is attributed to a Session. */
|
|
76
347
|
sessionId: SessionId
|
|
77
348
|
|
|
@@ -182,11 +453,24 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
182
453
|
const cwdForMigration = params.workingDirectory ?? process.cwd()
|
|
183
454
|
await RunContextFactory.ensureMigrated(`${cwdForMigration}/.namzu`)
|
|
184
455
|
|
|
456
|
+
// Every model call in the run — the loop's turns, the forced-final
|
|
457
|
+
// summary, advisory and compaction side calls — goes through this one
|
|
458
|
+
// wrapped provider, so the retry policy cannot be bypassed by a code
|
|
459
|
+
// path that happens to hold the raw driver.
|
|
460
|
+
// The logger is passed on purpose: `withProviderRetry` guards every one
|
|
461
|
+
// of its warns behind `options.log`, and this is its only production
|
|
462
|
+
// call site — so without it the "failed, retrying" and "failed, giving
|
|
463
|
+
// up" lines were dead code and a backoff left no trace anywhere.
|
|
464
|
+
const resilientProvider =
|
|
465
|
+
params.retry === false
|
|
466
|
+
? params.provider
|
|
467
|
+
: withProviderRetry(params.provider, { config: params.retry, log: getRootLogger() })
|
|
468
|
+
|
|
185
469
|
const ctx = RunContextFactory.build({
|
|
186
470
|
agentId: params.agentId,
|
|
187
471
|
agentName: params.agentName,
|
|
188
472
|
runConfig: params.runConfig,
|
|
189
|
-
provider:
|
|
473
|
+
provider: resilientProvider,
|
|
190
474
|
workingDirectory: params.workingDirectory,
|
|
191
475
|
pricing: params.pricing,
|
|
192
476
|
enableActivityTracking: params.enableActivityTracking,
|
|
@@ -268,6 +552,15 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
268
552
|
}
|
|
269
553
|
}
|
|
270
554
|
|
|
555
|
+
// Registered HERE, before the first turn, not when the model is nearly
|
|
556
|
+
// done. Tools render at prefix position 0, so injecting one late would
|
|
557
|
+
// invalidate the whole prompt cache for the rest of the run — the same
|
|
558
|
+
// reason the forced-final turn keeps its tools array and uses
|
|
559
|
+
// `toolChoice: 'none'` instead of dropping it.
|
|
560
|
+
if (params.structuredOutput && !params.tools.has(STRUCTURED_OUTPUT_TOOL_NAME)) {
|
|
561
|
+
params.tools.register(createStructuredOutputTool(params.structuredOutput.schema))
|
|
562
|
+
}
|
|
563
|
+
|
|
271
564
|
// ─── Provider capability negotiation (before tooling bootstrap) ────────
|
|
272
565
|
// Compare what the request asks for with what the DRIVER declared it
|
|
273
566
|
// does. Undeclared capabilities resolve permissively (today's behavior
|
|
@@ -276,16 +569,27 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
276
569
|
const capabilities = resolveProviderCapabilities(params.provider)
|
|
277
570
|
const registeredToolCount = params.tools.listNames().length
|
|
278
571
|
const stripToolSurfaces = !capabilities.supportsTools && registeredToolCount > 0
|
|
572
|
+
// Counted separately because they are separate wire shapes: a driver can
|
|
573
|
+
// map images and drop documents, and a vision warning would send the
|
|
574
|
+
// reader looking at the wrong half.
|
|
575
|
+
const carries = (m: (typeof params.messages)[number], kind: 'image' | 'document') =>
|
|
576
|
+
m.role === 'user' && (m.attachments ?? []).some((a) => (a.type ?? 'image') === kind)
|
|
577
|
+
|
|
279
578
|
const attachmentMessageCount = capabilities.supportsVision
|
|
280
579
|
? 0
|
|
281
|
-
: params.messages.filter(
|
|
282
|
-
|
|
283
|
-
|
|
580
|
+
: params.messages.filter((m) => carries(m, 'image')).length
|
|
581
|
+
const documentMessageCount = capabilities.supportsDocuments
|
|
582
|
+
? 0
|
|
583
|
+
: params.messages.filter((m) => carries(m, 'document')).length
|
|
284
584
|
|
|
285
585
|
if (stripToolSurfaces) {
|
|
286
586
|
const message = `Provider '${params.provider.id}' declares supportsTools: false but ${registeredToolCount} tool(s) are registered — stripping all tool surfaces from the prompt and request so the model is never told about tools it cannot call. Pass strictCapabilities: true to fail instead, or use a tools-capable provider.`
|
|
287
587
|
if (params.strictCapabilities) {
|
|
288
|
-
throw new
|
|
588
|
+
throw new NamzuError({
|
|
589
|
+
code: 'capability_unavailable',
|
|
590
|
+
message,
|
|
591
|
+
details: { providerId: params.provider.id, capability: 'tools', registeredToolCount },
|
|
592
|
+
})
|
|
289
593
|
}
|
|
290
594
|
ctx.log.warn(`CAPABILITY MISMATCH: ${message}`, {
|
|
291
595
|
providerId: params.provider.id,
|
|
@@ -296,7 +600,11 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
296
600
|
if (attachmentMessageCount > 0) {
|
|
297
601
|
const message = `Provider '${params.provider.id}' declares supportsVision: false but ${attachmentMessageCount} user message(s) carry image attachments — the driver will not map them, so the model never sees the images. Pass strictCapabilities: true to fail instead, or use a vision-capable provider.`
|
|
298
602
|
if (params.strictCapabilities) {
|
|
299
|
-
throw new
|
|
603
|
+
throw new NamzuError({
|
|
604
|
+
code: 'capability_unavailable',
|
|
605
|
+
message,
|
|
606
|
+
details: { providerId: params.provider.id, capability: 'vision', attachmentMessageCount },
|
|
607
|
+
})
|
|
300
608
|
}
|
|
301
609
|
ctx.log.warn(`CAPABILITY MISMATCH: ${message}`, {
|
|
302
610
|
providerId: params.provider.id,
|
|
@@ -304,10 +612,30 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
304
612
|
})
|
|
305
613
|
}
|
|
306
614
|
|
|
615
|
+
if (documentMessageCount > 0) {
|
|
616
|
+
const message = `Provider '${params.provider.id}' declares supportsDocuments: false but ${documentMessageCount} user message(s) carry document attachments — the driver will not map them, so the model never sees the documents. Pass strictCapabilities: true to fail instead, or use a document-capable provider.`
|
|
617
|
+
if (params.strictCapabilities) {
|
|
618
|
+
throw new NamzuError({
|
|
619
|
+
code: 'capability_unavailable',
|
|
620
|
+
message,
|
|
621
|
+
details: { providerId: params.provider.id, capability: 'documents', documentMessageCount },
|
|
622
|
+
})
|
|
623
|
+
}
|
|
624
|
+
ctx.log.warn(`CAPABILITY MISMATCH: ${message}`, {
|
|
625
|
+
providerId: params.provider.id,
|
|
626
|
+
documentMessageCount,
|
|
627
|
+
})
|
|
628
|
+
}
|
|
629
|
+
|
|
307
630
|
const effectiveAllowedTools = stripToolSurfaces
|
|
308
631
|
? []
|
|
309
632
|
: withDeferredDiscoveryTool(params.tools, params.allowedTools)
|
|
310
633
|
|
|
634
|
+
// is null only when the run has no disk layout (tests,
|
|
635
|
+
// in-memory hosts); the budget then degrades to middle-elision.
|
|
636
|
+
const runDirForTools = ctx.runMgr.getRunDir()
|
|
637
|
+
const toolOutputDir = runDirForTools ? join(runDirForTools, TOOL_OUTPUT_DIR_NAME) : undefined
|
|
638
|
+
|
|
311
639
|
const toolExecutor = ToolingBootstrap.init(
|
|
312
640
|
{
|
|
313
641
|
tools: params.tools,
|
|
@@ -319,6 +647,34 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
319
647
|
allowedTools: effectiveAllowedTools,
|
|
320
648
|
invocationState: params.invocationState,
|
|
321
649
|
pluginManager: params.pluginManager,
|
|
650
|
+
...(params.toolTimeoutMs !== undefined ? { toolTimeoutMs: params.toolTimeoutMs } : {}),
|
|
651
|
+
...(params.maxToolConcurrency !== undefined
|
|
652
|
+
? { maxToolConcurrency: params.maxToolConcurrency }
|
|
653
|
+
: {}),
|
|
654
|
+
...(params.maxToolOutputChars !== undefined
|
|
655
|
+
? { maxToolOutputChars: params.maxToolOutputChars }
|
|
656
|
+
: {}),
|
|
657
|
+
...(params.maxToolContentBytes !== undefined
|
|
658
|
+
? { maxToolContentBytes: params.maxToolContentBytes }
|
|
659
|
+
: {}),
|
|
660
|
+
// Overflow lands beside the run's other artifacts, so it is
|
|
661
|
+
// cleaned up with the run and reachable by the model's own
|
|
662
|
+
// `read`/`grep` without a new affordance.
|
|
663
|
+
...(toolOutputDir ? { toolOutputDir } : {}),
|
|
664
|
+
...(params.repairToolCall ? { repairToolCall: params.repairToolCall } : {}),
|
|
665
|
+
// The durable pause, reachable from any tool rather than from the
|
|
666
|
+
// four kernel-owned points that used to own it. Built here from
|
|
667
|
+
// the machinery the run already holds; the recorder binds a few
|
|
668
|
+
// lines below, and until it does a pause is in-process only —
|
|
669
|
+
// the same degradation the built-in question tool has.
|
|
670
|
+
toolPause: (toolUseId) =>
|
|
671
|
+
createToolPause({
|
|
672
|
+
runId: ctx.runId,
|
|
673
|
+
toolUseId,
|
|
674
|
+
parkHandler: params.resumeHandler,
|
|
675
|
+
...(params.questionParks ? { recorder: params.questionParks } : {}),
|
|
676
|
+
...(params.pendingAnswers ? { pendingAnswers: params.pendingAnswers } : {}),
|
|
677
|
+
}),
|
|
322
678
|
},
|
|
323
679
|
ctx.activityStore,
|
|
324
680
|
eventTranslator.emitEvent,
|
|
@@ -353,6 +709,16 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
353
709
|
ctx.runMgr.getRunScope(),
|
|
354
710
|
)
|
|
355
711
|
|
|
712
|
+
// Every checkpoint carries compaction's accumulated state, so a run that
|
|
713
|
+
// comes back in a new process can adopt it (see the restore block).
|
|
714
|
+
// Without it, compaction's own justification for dropping the prior
|
|
715
|
+
// `[COMPACTED CONTEXT]` block — that `serializeState` is cumulative —
|
|
716
|
+
// holds within one process and fails across a resume.
|
|
717
|
+
if (workingStateManager) {
|
|
718
|
+
const manager = workingStateManager
|
|
719
|
+
checkpointMgr.setWorkingStateSource(() => snapshotWorkingState(manager))
|
|
720
|
+
}
|
|
721
|
+
|
|
356
722
|
const resultAssembler = new ResultAssembler({
|
|
357
723
|
runMgr: ctx.runMgr,
|
|
358
724
|
planManager: ctx.planManager,
|
|
@@ -360,6 +726,9 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
360
726
|
log: ctx.log,
|
|
361
727
|
emitEvent: eventTranslator.emitEvent,
|
|
362
728
|
drainPending: () => eventTranslator.drainPending(),
|
|
729
|
+
// Read at settle time, not now: checkpoints are written per
|
|
730
|
+
// iteration, so the answer changes as the run proceeds.
|
|
731
|
+
resumeCheckpointId: () => checkpointMgr.lastCheckpointId,
|
|
363
732
|
})
|
|
364
733
|
|
|
365
734
|
let advisoryCtx: AdvisoryContext | undefined
|
|
@@ -368,7 +737,10 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
368
737
|
params.advisory.advisors,
|
|
369
738
|
params.advisory.defaultAdvisorId,
|
|
370
739
|
)
|
|
371
|
-
|
|
740
|
+
// A budget the runtime cannot measure is refused here rather than
|
|
741
|
+
// silently ignored for the length of the run.
|
|
742
|
+
assertBudgetEnforceable(params.advisory)
|
|
743
|
+
const advisoryExecutor = new AdvisoryExecutor(ctx.log, params.advisory.budget)
|
|
372
744
|
const triggerEvaluator = new TriggerEvaluator(
|
|
373
745
|
params.advisory.triggers ?? [],
|
|
374
746
|
params.advisory.budget,
|
|
@@ -396,8 +768,17 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
396
768
|
: undefined
|
|
397
769
|
|
|
398
770
|
const iterationOrchestrator = new IterationOrchestrator({
|
|
399
|
-
provider:
|
|
771
|
+
provider: resilientProvider,
|
|
400
772
|
runConfig: params.runConfig,
|
|
773
|
+
...(params.stopWhen ? { stopWhen: params.stopWhen } : {}),
|
|
774
|
+
...(params.prepareStep ? { prepareStep: params.prepareStep } : {}),
|
|
775
|
+
...(params.onStepFinish ? { onStepFinish: params.onStepFinish } : {}),
|
|
776
|
+
...(params.reviewAnswer ? { reviewAnswer: params.reviewAnswer } : {}),
|
|
777
|
+
...(params.maxAnswerReviews !== undefined ? { maxAnswerReviews: params.maxAnswerReviews } : {}),
|
|
778
|
+
...(params.structuredOutput ? { structuredOutput: params.structuredOutput } : {}),
|
|
779
|
+
...(params.parkRecordDelayMs !== undefined
|
|
780
|
+
? { parkRecordDelayMs: params.parkRecordDelayMs }
|
|
781
|
+
: {}),
|
|
401
782
|
tools: params.tools,
|
|
402
783
|
allowedTools: effectiveAllowedTools,
|
|
403
784
|
runMgr: ctx.runMgr,
|
|
@@ -414,6 +795,9 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
414
795
|
taskGateway: params.taskGateway,
|
|
415
796
|
taskStore: params.taskStore,
|
|
416
797
|
launchedTasks: params.launchedTasks ?? new Map(),
|
|
798
|
+
// Run-scoped. An approval is a statement about this run's work;
|
|
799
|
+
// carrying one into a later run would be reuse nobody agreed to.
|
|
800
|
+
toolGrants: new ToolGrantSet(),
|
|
417
801
|
compactionConfig: params.compactionConfig,
|
|
418
802
|
workingStateManager,
|
|
419
803
|
workingMemoryProvider: params.workingMemoryProvider,
|
|
@@ -426,7 +810,98 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
426
810
|
const tracer = getTracer()
|
|
427
811
|
|
|
428
812
|
return yield* (async function* (): AsyncGenerator<RunEvent, Run> {
|
|
429
|
-
|
|
813
|
+
// Parent explicitly when a caller supplied one. Without this every
|
|
814
|
+
// run starts its OWN root trace, so a supervisor delegating to three
|
|
815
|
+
// children produced four disconnected traces instead of one tree —
|
|
816
|
+
// the same defect that made a 20-turn run show up as 21 roots before
|
|
817
|
+
// iterations were parented, except across the spawn boundary, where
|
|
818
|
+
// it is worse: the delegation structure is the thing you most want
|
|
819
|
+
// to see.
|
|
820
|
+
const runStartedAt = Date.now()
|
|
821
|
+
|
|
822
|
+
// Read before the span is minted, because a parent can only be set
|
|
823
|
+
// at creation. A resumed run used to start a brand-new trace with no
|
|
824
|
+
// link to the one that crashed, so the failure and its recovery
|
|
825
|
+
// could not be put on one timeline — the run id correlated them well
|
|
826
|
+
// enough to find both by query and not well enough to see a single
|
|
827
|
+
// waterfall, and for a replay fork (which mints a new run id) not
|
|
828
|
+
// even that. An explicit caller-supplied parent still wins: it is
|
|
829
|
+
// the more specific statement about where this run belongs.
|
|
830
|
+
const resumedTrace = params.resumeFromCheckpoint
|
|
831
|
+
? await checkpointMgr.readTraceContext(params.resumeFromCheckpoint)
|
|
832
|
+
: undefined
|
|
833
|
+
|
|
834
|
+
const rootSpan = tracer.startSpan(
|
|
835
|
+
agentRunSpanName(params.agentName),
|
|
836
|
+
{},
|
|
837
|
+
parentContext(params.parentSpan ?? resumedTrace),
|
|
838
|
+
)
|
|
839
|
+
// Hand the run span to the loop so every iteration parents to it.
|
|
840
|
+
iterationOrchestrator.setRootSpan(rootSpan)
|
|
841
|
+
// Every checkpoint from here on records the trace it was taken
|
|
842
|
+
// inside, so the next resume can join this one.
|
|
843
|
+
checkpointMgr.setTraceSource(() => serializeSpan(rootSpan))
|
|
844
|
+
// And every park it records carries an absolute deadline, so an
|
|
845
|
+
// unanswered approval cannot outlive the worker that asked for it.
|
|
846
|
+
checkpointMgr.setParkTtl(params.runConfig.hitlParkTtlMs)
|
|
847
|
+
|
|
848
|
+
// A question raised from inside a tool becomes a real checkpoint
|
|
849
|
+
// here. It used to park under a synthetic id nothing ever wrote, so
|
|
850
|
+
// the checkpoint did not exist: nothing on disk said a human owed
|
|
851
|
+
// this run an answer, and a remote host could not observe the
|
|
852
|
+
// question at all.
|
|
853
|
+
params.questionParks?.bind({
|
|
854
|
+
record: async (question) => {
|
|
855
|
+
try {
|
|
856
|
+
const checkpoint = await checkpointMgr.create(ctx.runMgr, ctx.runMgr.currentIteration)
|
|
857
|
+
const parked = await checkpointMgr.park(checkpoint, {
|
|
858
|
+
type: 'user_question',
|
|
859
|
+
runId: ctx.runMgr.id,
|
|
860
|
+
checkpointId: checkpoint.id,
|
|
861
|
+
question,
|
|
862
|
+
})
|
|
863
|
+
await eventTranslator.emitEvent({
|
|
864
|
+
type: 'user_question_asked',
|
|
865
|
+
runId: ctx.runMgr.id,
|
|
866
|
+
checkpointId: parked.id,
|
|
867
|
+
questionId: question.questionId,
|
|
868
|
+
question: question.question,
|
|
869
|
+
})
|
|
870
|
+
return parked.id
|
|
871
|
+
} catch (err) {
|
|
872
|
+
// A store that cannot record the park must not take the
|
|
873
|
+
// tool down with it: the in-process await is still valid
|
|
874
|
+
// and only the cross-process handoff is lost. Loudly,
|
|
875
|
+
// because a host building an approval queue from durable
|
|
876
|
+
// state will not see this question.
|
|
877
|
+
ctx.log.error('Failed to record a question park — it is not resumable', {
|
|
878
|
+
runId: ctx.runMgr.id,
|
|
879
|
+
questionId: question.questionId,
|
|
880
|
+
error: err instanceof Error ? err.message : String(err),
|
|
881
|
+
})
|
|
882
|
+
return null
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
resolve: async (checkpointId, decision) => {
|
|
886
|
+
await checkpointMgr.unpark(checkpointId, decision).catch((err: unknown) => {
|
|
887
|
+
ctx.log.error('Failed to clear a recorded question park', {
|
|
888
|
+
runId: ctx.runMgr.id,
|
|
889
|
+
checkpointId,
|
|
890
|
+
error: err instanceof Error ? err.message : String(err),
|
|
891
|
+
})
|
|
892
|
+
return null
|
|
893
|
+
})
|
|
894
|
+
await eventTranslator.emitEvent({
|
|
895
|
+
type: 'user_question_answered',
|
|
896
|
+
runId: ctx.runMgr.id,
|
|
897
|
+
checkpointId,
|
|
898
|
+
...(decision.action === 'answer_question' && decision.questionId !== undefined
|
|
899
|
+
? { questionId: decision.questionId }
|
|
900
|
+
: {}),
|
|
901
|
+
answered: decision.action === 'answer_question',
|
|
902
|
+
})
|
|
903
|
+
},
|
|
904
|
+
})
|
|
430
905
|
rootSpan.setAttributes({
|
|
431
906
|
[NAMZU.RUN_ID]: ctx.runMgr.id,
|
|
432
907
|
[GENAI.AGENT_NAME]: params.agentName,
|
|
@@ -436,6 +911,12 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
436
911
|
})
|
|
437
912
|
|
|
438
913
|
let sandbox: Sandbox | undefined
|
|
914
|
+
// Decided during checkpoint restore, executed after the sandbox
|
|
915
|
+
// exists — the approved tools may well need it.
|
|
916
|
+
let pendingResume: PendingResumePlan | null = null
|
|
917
|
+
/** Tool results recovered from the transcript; see the restore path. */
|
|
918
|
+
let recoveredResults: ReadonlyMap<string, { result: string; isError: boolean }> = new Map()
|
|
919
|
+
let emergencyManager: EmergencySaveManager | undefined
|
|
439
920
|
|
|
440
921
|
try {
|
|
441
922
|
await ctx.runMgr.init()
|
|
@@ -490,8 +971,103 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
490
971
|
})
|
|
491
972
|
yield* eventTranslator.drainPending()
|
|
492
973
|
|
|
974
|
+
// Budgets are properties of the RUN, not of the process hosting
|
|
975
|
+
// it. The checkpoint already carried all three; they were
|
|
976
|
+
// written and then discarded on the way back in, so a run
|
|
977
|
+
// recalled at $4.80 of a $5 cap came back with a fresh $5 and
|
|
978
|
+
// a fresh timeout clock. Restore before the first iteration so
|
|
979
|
+
// a resumed run that is already over budget stops immediately.
|
|
980
|
+
ctx.runMgr.restoreUsage(
|
|
981
|
+
checkpoint.tokenUsage,
|
|
982
|
+
checkpoint.costInfo,
|
|
983
|
+
checkpoint.guardState.iterationCount,
|
|
984
|
+
)
|
|
985
|
+
guard.restoreElapsed(checkpoint.guardState.elapsedMs)
|
|
986
|
+
|
|
987
|
+
// Adopt the working state the earlier summary was built from.
|
|
988
|
+
// The `[COMPACTED CONTEXT]` block below is preserved precisely
|
|
989
|
+
// because it is the only surviving record of the history the
|
|
990
|
+
// first pass deleted — and without this, the NEXT compaction
|
|
991
|
+
// would drop it and replace it with a summary covering only
|
|
992
|
+
// what happened after the resume, silently losing the run's
|
|
993
|
+
// first hour.
|
|
994
|
+
if (workingStateManager && checkpoint.workingState && params.compactionConfig) {
|
|
995
|
+
const revived = restoreWorkingState(checkpoint.workingState, params.compactionConfig)
|
|
996
|
+
workingStateManager.replaceState(revived.getState())
|
|
997
|
+
ctx.log.info('Restored compaction working state from checkpoint', {
|
|
998
|
+
runId: ctx.runMgr.id,
|
|
999
|
+
checkpointId: checkpoint.id,
|
|
1000
|
+
slots: workingStateManager.slotCount(),
|
|
1001
|
+
})
|
|
1002
|
+
}
|
|
1003
|
+
ctx.log.info('Restored budgets from checkpoint', {
|
|
1004
|
+
runId: ctx.runMgr.id,
|
|
1005
|
+
checkpointId: checkpoint.id,
|
|
1006
|
+
totalTokens: checkpoint.tokenUsage.totalTokens,
|
|
1007
|
+
totalCost: checkpoint.costInfo.totalCost,
|
|
1008
|
+
iteration: checkpoint.guardState.iterationCount,
|
|
1009
|
+
elapsedMs: checkpoint.guardState.elapsedMs,
|
|
1010
|
+
})
|
|
1011
|
+
|
|
493
1012
|
pushSystemMessages()
|
|
494
|
-
|
|
1013
|
+
|
|
1014
|
+
// A human answered the park in a different process; apply that
|
|
1015
|
+
// answer to the tool calls they were actually shown. Without
|
|
1016
|
+
// this the repair below throws the approval away and the model
|
|
1017
|
+
// re-decides, so "yes, delete that row" degrades into "ask
|
|
1018
|
+
// again and hope it asks for the same thing".
|
|
1019
|
+
pendingResume =
|
|
1020
|
+
params.pendingDecision && checkpoint.pending
|
|
1021
|
+
? planPendingResume(checkpoint, params.pendingDecision, ctx.log)
|
|
1022
|
+
: null
|
|
1023
|
+
|
|
1024
|
+
// Results of tools that finished before the process died. The
|
|
1025
|
+
// executor already emits one `tool_completed` per tool inline
|
|
1026
|
+
// and the transcript already persists it, so the record was
|
|
1027
|
+
// durable all along — it was simply never read back, and the
|
|
1028
|
+
// resumed run re-ran calls that had already charged a card or
|
|
1029
|
+
// sent an email.
|
|
1030
|
+
const unanswered = unansweredToolCalls(checkpoint.messages)
|
|
1031
|
+
recoveredResults =
|
|
1032
|
+
unanswered.length > 0
|
|
1033
|
+
? await recoverCompletedCalls(ctx.runMgr, unanswered, ctx.log)
|
|
1034
|
+
: new Map()
|
|
1035
|
+
|
|
1036
|
+
// A batch caught MID-execution is a resume, not a fresh
|
|
1037
|
+
// decision: stripping the turn and letting the model re-decide
|
|
1038
|
+
// would re-run everything that already ran. Only taken when
|
|
1039
|
+
// the transcript proves execution had begun — a tool-review
|
|
1040
|
+
// park has no completions and keeps the cheap repair below.
|
|
1041
|
+
if (!pendingResume && recoveredResults.size > 0) {
|
|
1042
|
+
pendingResume = planCrashResume(checkpoint, recoveredResults, ctx.log)
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// A checkpoint taken at a tool-review park snapshots the
|
|
1046
|
+
// assistant turn AFTER its `tool_use` blocks but BEFORE any
|
|
1047
|
+
// `tool_result` exists, so replaying it verbatim would send a
|
|
1048
|
+
// malformed request on the first model call of the resumed
|
|
1049
|
+
// run. Repair the incomplete turn rather than inheriting it:
|
|
1050
|
+
// the model re-decides from the last valid state.
|
|
1051
|
+
//
|
|
1052
|
+
// The pending-decision path uses the SAME repair: it strips
|
|
1053
|
+
// the unanswered turn here and `applyPendingResume` re-appends
|
|
1054
|
+
// it together with the results that answer it, so the history
|
|
1055
|
+
// stays well-formed either way.
|
|
1056
|
+
const dangling = findDanglingMessages(checkpoint.messages)
|
|
1057
|
+
const restoredMessages = dangling.isValid
|
|
1058
|
+
? checkpoint.messages
|
|
1059
|
+
: removeDanglingMessages(checkpoint.messages)
|
|
1060
|
+
if (!dangling.isValid && !pendingResume) {
|
|
1061
|
+
ctx.log.warn('Checkpoint contained unanswered tool calls — repaired on restore', {
|
|
1062
|
+
runId: ctx.runMgr.id,
|
|
1063
|
+
checkpointId: checkpoint.id,
|
|
1064
|
+
unansweredAssistantTurns: dangling.assistantsWithUnmatchedCalls.length,
|
|
1065
|
+
orphanedToolMessages: dangling.orphanedToolMessages.length,
|
|
1066
|
+
removed: checkpoint.messages.length - restoredMessages.length,
|
|
1067
|
+
})
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
for (const msg of restoredMessages) {
|
|
495
1071
|
if (msg.role === 'system') {
|
|
496
1072
|
// Re-push the FRESH static/dynamic floor (done above) but PRESERVE
|
|
497
1073
|
// the two system messages that carry irreplaceable run state: the
|
|
@@ -595,6 +1171,92 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
595
1171
|
})
|
|
596
1172
|
}
|
|
597
1173
|
|
|
1174
|
+
// Crash-save handlers live for exactly the run's lifetime, and are
|
|
1175
|
+
// removed in the `finally` below. Opt-in — see `emergencySave`.
|
|
1176
|
+
if (params.emergencySave) {
|
|
1177
|
+
const runDir = ctx.runMgr.getRunDir()
|
|
1178
|
+
if (runDir) {
|
|
1179
|
+
emergencyManager = EmergencySaveManager.instance(ctx.log)
|
|
1180
|
+
emergencyManager.attach(ctx.runMgr, runDir, ctx.log)
|
|
1181
|
+
} else {
|
|
1182
|
+
ctx.log.warn(
|
|
1183
|
+
'emergencySave requested but the run has no output directory — crash dumps disabled',
|
|
1184
|
+
{ runId: ctx.runId },
|
|
1185
|
+
)
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// Before the first model call: the cheapest place to refuse, since
|
|
1190
|
+
// nothing has been spent. Previously unreachable — `run_start`
|
|
1191
|
+
// fires with only `{ runId }` and `run_started` carries only the
|
|
1192
|
+
// system prompt, so no hook could see the user's message.
|
|
1193
|
+
const inputVerdict = await runInputGuardrails(
|
|
1194
|
+
params.inputGuardrails,
|
|
1195
|
+
{
|
|
1196
|
+
runId: ctx.runId,
|
|
1197
|
+
messages: ctx.runMgr.messages,
|
|
1198
|
+
...(segments?.static ? { systemPrompt: segments.static } : {}),
|
|
1199
|
+
},
|
|
1200
|
+
ctx.log,
|
|
1201
|
+
)
|
|
1202
|
+
if (inputVerdict.blocked) {
|
|
1203
|
+
await eventTranslator.emitEvent({
|
|
1204
|
+
type: 'guardrail_triggered',
|
|
1205
|
+
runId: ctx.runId,
|
|
1206
|
+
stage: 'input',
|
|
1207
|
+
action: 'block',
|
|
1208
|
+
...(inputVerdict.name ? { guardrail: inputVerdict.name } : {}),
|
|
1209
|
+
...(inputVerdict.reason ? { reason: inputVerdict.reason } : {}),
|
|
1210
|
+
})
|
|
1211
|
+
yield* eventTranslator.drainPending()
|
|
1212
|
+
ctx.runMgr.setStopReason('input_guardrail')
|
|
1213
|
+
ctx.runMgr.setLastError(inputVerdict.reason ?? 'blocked by an input guardrail')
|
|
1214
|
+
yield* resultAssembler.completeRun(rootSpan)
|
|
1215
|
+
return ctx.runMgr.getRun()
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
// Honor the approval a human already gave, before the loop's
|
|
1219
|
+
// first model call. The sandbox exists by now, so an approved
|
|
1220
|
+
// tool that needs one gets it.
|
|
1221
|
+
if (pendingResume) {
|
|
1222
|
+
ctx.log.info('Applying a pending HITL decision to the checkpointed tool calls', {
|
|
1223
|
+
runId: ctx.runId,
|
|
1224
|
+
tools: pendingResume.response.message.toolCalls?.map((tc) => tc.function.name),
|
|
1225
|
+
denied: pendingResume.denials.size,
|
|
1226
|
+
})
|
|
1227
|
+
// Hand the recorded answer to the already-built tool. The tool
|
|
1228
|
+
// closed over its registry when the agent was constructed,
|
|
1229
|
+
// long before this run existed, so the answers are copied in
|
|
1230
|
+
// rather than passed down.
|
|
1231
|
+
if (pendingResume.answers && params.pendingAnswers) {
|
|
1232
|
+
for (const [questionId, answer] of pendingResume.answers.entries()) {
|
|
1233
|
+
params.pendingAnswers.set(questionId, answer)
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
await applyPendingResume(pendingResume, ctx.runMgr, toolExecutor, recoveredResults)
|
|
1238
|
+
yield* eventTranslator.drainPending()
|
|
1239
|
+
|
|
1240
|
+
// The decision has now actually been carried out, so the park
|
|
1241
|
+
// is no longer outstanding. Without this the checkpoint keeps
|
|
1242
|
+
// reporting `pending` with no `resolvedAt`, and an approval
|
|
1243
|
+
// queue re-serves a destructive call that already ran — which
|
|
1244
|
+
// defeats the entire point of recording the park.
|
|
1245
|
+
const resolvedCheckpointId = pendingResume.checkpointId
|
|
1246
|
+
if (params.pendingDecision) {
|
|
1247
|
+
await checkpointMgr
|
|
1248
|
+
.unpark(resolvedCheckpointId, params.pendingDecision)
|
|
1249
|
+
.catch((err: unknown) => {
|
|
1250
|
+
ctx.log.error('Applied a pending decision but failed to clear the park', {
|
|
1251
|
+
runId: ctx.runId,
|
|
1252
|
+
checkpointId: resolvedCheckpointId,
|
|
1253
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1254
|
+
})
|
|
1255
|
+
return null
|
|
1256
|
+
})
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
598
1260
|
yield* iterationOrchestrator.runLoop()
|
|
599
1261
|
|
|
600
1262
|
if (params.pluginManager) {
|
|
@@ -607,10 +1269,90 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
607
1269
|
yield* eventTranslator.drainPending()
|
|
608
1270
|
}
|
|
609
1271
|
|
|
1272
|
+
// Hand the step record to the run before it settles, so the
|
|
1273
|
+
// returned `Run` carries it.
|
|
1274
|
+
ctx.runMgr.setSteps(iterationOrchestrator.getSteps())
|
|
1275
|
+
|
|
1276
|
+
// Gates the FINAL result, not the stream — `text_delta` already
|
|
1277
|
+
// reached the host as the model produced it. A rewrite is
|
|
1278
|
+
// therefore a correction, and the event says so; buffering every
|
|
1279
|
+
// token to gate the stream itself would trade the streaming UX
|
|
1280
|
+
// for the guarantee, which is the host's call, not the SDK's.
|
|
1281
|
+
if (params.outputGuardrails && params.outputGuardrails.length > 0) {
|
|
1282
|
+
// Read what the run produced WITHOUT settling it. This used to
|
|
1283
|
+
// call `markCompleted()` just to materialize the text, which
|
|
1284
|
+
// force-marked a cancelled or paused run `completed` merely
|
|
1285
|
+
// because a guardrail was configured — the presence of a
|
|
1286
|
+
// safety check silently rewrote the run's own outcome.
|
|
1287
|
+
const produced = ctx.runMgr.materializeResult()
|
|
1288
|
+
const outputVerdict = await runOutputGuardrails(
|
|
1289
|
+
params.outputGuardrails,
|
|
1290
|
+
{ runId: ctx.runId, output: produced, messages: ctx.runMgr.messages },
|
|
1291
|
+
ctx.log,
|
|
1292
|
+
)
|
|
1293
|
+
|
|
1294
|
+
if (outputVerdict.blocked) {
|
|
1295
|
+
await eventTranslator.emitEvent({
|
|
1296
|
+
type: 'guardrail_triggered',
|
|
1297
|
+
runId: ctx.runId,
|
|
1298
|
+
stage: 'output',
|
|
1299
|
+
action: 'block',
|
|
1300
|
+
...(outputVerdict.name ? { guardrail: outputVerdict.name } : {}),
|
|
1301
|
+
...(outputVerdict.reason ? { reason: outputVerdict.reason } : {}),
|
|
1302
|
+
})
|
|
1303
|
+
yield* eventTranslator.drainPending()
|
|
1304
|
+
ctx.runMgr.setStopReason('output_guardrail')
|
|
1305
|
+
ctx.runMgr.setLastError(outputVerdict.reason ?? 'blocked by an output guardrail')
|
|
1306
|
+
ctx.runMgr.setResult('')
|
|
1307
|
+
} else if (outputVerdict.rewritten !== undefined) {
|
|
1308
|
+
await eventTranslator.emitEvent({
|
|
1309
|
+
type: 'guardrail_triggered',
|
|
1310
|
+
runId: ctx.runId,
|
|
1311
|
+
stage: 'output',
|
|
1312
|
+
action: 'rewrite',
|
|
1313
|
+
...(outputVerdict.name ? { guardrail: outputVerdict.name } : {}),
|
|
1314
|
+
...(outputVerdict.reason ? { reason: outputVerdict.reason } : {}),
|
|
1315
|
+
})
|
|
1316
|
+
yield* eventTranslator.drainPending()
|
|
1317
|
+
ctx.runMgr.setResult(outputVerdict.rewritten)
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
|
|
610
1321
|
yield* resultAssembler.completeRun(rootSpan)
|
|
611
1322
|
} catch (err) {
|
|
1323
|
+
// A failed run still spent its steps; report them.
|
|
1324
|
+
ctx.runMgr.setSteps(iterationOrchestrator.getSteps())
|
|
612
1325
|
yield* resultAssembler.handleError(err, rootSpan)
|
|
613
1326
|
} finally {
|
|
1327
|
+
// Release the process's termination path as soon as this run is
|
|
1328
|
+
// done with it. Leaving the handlers installed would keep a
|
|
1329
|
+
// WeakRef'd, settled run as the crash target for the rest of the
|
|
1330
|
+
// process's life.
|
|
1331
|
+
emergencyManager?.detach()
|
|
1332
|
+
|
|
1333
|
+
// Same reasoning for the question channel: the tools outlive the
|
|
1334
|
+
// run that bound them, so leaving it attached would have a later
|
|
1335
|
+
// run's question written into this run's checkpoint store.
|
|
1336
|
+
params.questionParks?.unbind()
|
|
1337
|
+
|
|
1338
|
+
// Offer what the run learned to whoever decides what is worth
|
|
1339
|
+
// keeping. In `finally` and awaited: a run that failed still
|
|
1340
|
+
// discovered things, and a fire-and-forget write would race the
|
|
1341
|
+
// process exiting on a one-shot CLI run. A throw here is
|
|
1342
|
+
// swallowed — a memory that failed to form must not retract an
|
|
1343
|
+
// answer that was already produced.
|
|
1344
|
+
const candidate = memoryCandidateFor(ctx.runId, workingStateManager)
|
|
1345
|
+
if (params.promoteMemory && candidate) {
|
|
1346
|
+
try {
|
|
1347
|
+
await params.promoteMemory(candidate)
|
|
1348
|
+
} catch (promoteErr) {
|
|
1349
|
+
ctx.log.error('Memory promotion threw — the run is unaffected', {
|
|
1350
|
+
runId: ctx.runId,
|
|
1351
|
+
error: promoteErr instanceof Error ? promoteErr.message : String(promoteErr),
|
|
1352
|
+
})
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
|
|
614
1356
|
// --- Sandbox lifecycle: destroy after run ---
|
|
615
1357
|
if (sandbox) {
|
|
616
1358
|
const sandboxId = sandbox.id
|
|
@@ -631,6 +1373,11 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
631
1373
|
}
|
|
632
1374
|
|
|
633
1375
|
unsubscribeTaskStore?.()
|
|
1376
|
+
// Keyed by HOW it settled, not just that it did: a run that was
|
|
1377
|
+
// cancelled and a run that hit its budget have very different
|
|
1378
|
+
// duration distributions, and averaging them together describes
|
|
1379
|
+
// neither.
|
|
1380
|
+
recordRunDuration(ctx.runMgr.getRun().status ?? 'unknown', Date.now() - runStartedAt)
|
|
634
1381
|
rootSpan.end()
|
|
635
1382
|
}
|
|
636
1383
|
|