@namzu/sdk 2.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2311 -0
- package/README.md +49 -53
- package/dist/__tests__/default-path-conformance.test.d.ts +2 -0
- package/dist/__tests__/default-path-conformance.test.d.ts.map +1 -0
- package/dist/__tests__/default-path-conformance.test.js +262 -0
- package/dist/__tests__/default-path-conformance.test.js.map +1 -0
- package/dist/__tests__/shipped-defaults.test.d.ts +2 -0
- package/dist/__tests__/shipped-defaults.test.d.ts.map +1 -0
- package/dist/__tests__/shipped-defaults.test.js +97 -0
- package/dist/__tests__/shipped-defaults.test.js.map +1 -0
- package/dist/advisory/__tests__/budget-enforcement.test.d.ts +2 -0
- package/dist/advisory/__tests__/budget-enforcement.test.d.ts.map +1 -0
- package/dist/advisory/__tests__/budget-enforcement.test.js +159 -0
- package/dist/advisory/__tests__/budget-enforcement.test.js.map +1 -0
- package/dist/advisory/__tests__/structured-response.test.d.ts +2 -0
- package/dist/advisory/__tests__/structured-response.test.d.ts.map +1 -0
- package/dist/advisory/__tests__/structured-response.test.js +99 -0
- package/dist/advisory/__tests__/structured-response.test.js.map +1 -0
- package/dist/advisory/budget.d.ts +15 -0
- package/dist/advisory/budget.d.ts.map +1 -0
- package/dist/advisory/budget.js +21 -0
- package/dist/advisory/budget.js.map +1 -0
- package/dist/advisory/context.d.ts +2 -0
- package/dist/advisory/context.d.ts.map +1 -1
- package/dist/advisory/context.js +16 -0
- package/dist/advisory/context.js.map +1 -1
- package/dist/advisory/executor.d.ts +14 -11
- package/dist/advisory/executor.d.ts.map +1 -1
- package/dist/advisory/executor.js +36 -24
- package/dist/advisory/executor.js.map +1 -1
- package/dist/advisory/executor.test.d.ts +8 -6
- package/dist/advisory/executor.test.d.ts.map +1 -1
- package/dist/advisory/executor.test.js +12 -8
- package/dist/advisory/executor.test.js.map +1 -1
- package/dist/advisory/index.d.ts +2 -0
- package/dist/advisory/index.d.ts.map +1 -1
- package/dist/advisory/index.js +2 -0
- package/dist/advisory/index.js.map +1 -1
- package/dist/advisory/parse.d.ts +23 -0
- package/dist/advisory/parse.d.ts.map +1 -0
- package/dist/advisory/parse.js +56 -0
- package/dist/advisory/parse.js.map +1 -0
- package/dist/agents/AbstractAgent.d.ts +48 -0
- package/dist/agents/AbstractAgent.d.ts.map +1 -1
- package/dist/agents/AbstractAgent.js +77 -0
- package/dist/agents/AbstractAgent.js.map +1 -1
- package/dist/agents/PipelineAgent.d.ts +10 -0
- package/dist/agents/PipelineAgent.d.ts.map +1 -1
- package/dist/agents/PipelineAgent.js +12 -0
- package/dist/agents/PipelineAgent.js.map +1 -1
- package/dist/agents/ReactiveAgent.d.ts +10 -0
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +40 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts +10 -0
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +23 -2
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts +11 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +23 -1
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/__tests__/idempotency-key.test.d.ts +2 -0
- package/dist/agents/__tests__/idempotency-key.test.d.ts.map +1 -0
- package/dist/agents/__tests__/idempotency-key.test.js +149 -0
- package/dist/agents/__tests__/idempotency-key.test.js.map +1 -0
- package/dist/agents/__tests__/invocation-lock.test.d.ts +2 -0
- package/dist/agents/__tests__/invocation-lock.test.d.ts.map +1 -0
- package/dist/agents/__tests__/invocation-lock.test.js +126 -0
- package/dist/agents/__tests__/invocation-lock.test.js.map +1 -0
- package/dist/agents/__tests__/reachability.test.d.ts +2 -0
- package/dist/agents/__tests__/reachability.test.d.ts.map +1 -0
- package/dist/agents/__tests__/reachability.test.js +173 -0
- package/dist/agents/__tests__/reachability.test.js.map +1 -0
- package/dist/agents/__tests__/supervisor-ledger.test.js +1 -1
- package/dist/agents/__tests__/supervisor-ledger.test.js.map +1 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/lock.d.ts +0 -1
- package/dist/agents/lock.d.ts.map +1 -1
- package/dist/agents/lock.js.map +1 -1
- package/dist/bridge/a2a/late-events.test.d.ts +2 -0
- package/dist/bridge/a2a/late-events.test.d.ts.map +1 -0
- package/dist/bridge/a2a/late-events.test.js +70 -0
- package/dist/bridge/a2a/late-events.test.js.map +1 -0
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +55 -3
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/a2a/mapper.test.js +1 -1
- package/dist/bridge/a2a/mapper.test.js.map +1 -1
- package/dist/bridge/a2a/message.d.ts.map +1 -1
- package/dist/bridge/a2a/message.js +5 -1
- package/dist/bridge/a2a/message.js.map +1 -1
- package/dist/bridge/sse/late-events.test.d.ts +2 -0
- package/dist/bridge/sse/late-events.test.d.ts.map +1 -0
- package/dist/bridge/sse/late-events.test.js +163 -0
- package/dist/bridge/sse/late-events.test.js.map +1 -0
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +100 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/compaction/__tests__/cleared-result-recovery.test.d.ts +2 -0
- package/dist/compaction/__tests__/cleared-result-recovery.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/cleared-result-recovery.test.js +101 -0
- package/dist/compaction/__tests__/cleared-result-recovery.test.js.map +1 -0
- package/dist/compaction/__tests__/context-window.test.d.ts +2 -0
- package/dist/compaction/__tests__/context-window.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/context-window.test.js +62 -0
- package/dist/compaction/__tests__/context-window.test.js.map +1 -0
- package/dist/compaction/__tests__/dangling.test.js +16 -5
- package/dist/compaction/__tests__/dangling.test.js.map +1 -1
- package/dist/compaction/__tests__/lossiness.test.d.ts +2 -0
- package/dist/compaction/__tests__/lossiness.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/lossiness.test.js +163 -0
- package/dist/compaction/__tests__/lossiness.test.js.map +1 -0
- package/dist/compaction/__tests__/state-across-resume.test.d.ts +2 -0
- package/dist/compaction/__tests__/state-across-resume.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/state-across-resume.test.js +88 -0
- package/dist/compaction/__tests__/state-across-resume.test.js.map +1 -0
- package/dist/compaction/__tests__/tool-result-editing.test.d.ts +2 -0
- package/dist/compaction/__tests__/tool-result-editing.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/tool-result-editing.test.js +184 -0
- package/dist/compaction/__tests__/tool-result-editing.test.js.map +1 -0
- package/dist/compaction/__tests__/trim-opens-on-user.test.d.ts +2 -0
- package/dist/compaction/__tests__/trim-opens-on-user.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/trim-opens-on-user.test.js +109 -0
- package/dist/compaction/__tests__/trim-opens-on-user.test.js.map +1 -0
- package/dist/compaction/__tests__/verifier-model.test.d.ts +2 -0
- package/dist/compaction/__tests__/verifier-model.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/verifier-model.test.js +58 -0
- package/dist/compaction/__tests__/verifier-model.test.js.map +1 -0
- package/dist/compaction/context-window.d.ts +44 -0
- package/dist/compaction/context-window.d.ts.map +1 -0
- package/dist/compaction/context-window.js +97 -0
- package/dist/compaction/context-window.js.map +1 -0
- package/dist/compaction/dangling.js +48 -1
- package/dist/compaction/dangling.js.map +1 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +55 -1
- package/dist/compaction/extractor.js.map +1 -1
- package/dist/compaction/index.d.ts +5 -0
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +3 -0
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/manager.d.ts +25 -0
- package/dist/compaction/manager.d.ts.map +1 -1
- package/dist/compaction/manager.js +42 -8
- package/dist/compaction/manager.js.map +1 -1
- package/dist/compaction/managers/structured.d.ts.map +1 -1
- package/dist/compaction/managers/structured.js +7 -3
- package/dist/compaction/managers/structured.js.map +1 -1
- package/dist/compaction/retention.d.ts +15 -0
- package/dist/compaction/retention.d.ts.map +1 -0
- package/dist/compaction/retention.js +89 -0
- package/dist/compaction/retention.js.map +1 -0
- package/dist/compaction/serializer.d.ts.map +1 -1
- package/dist/compaction/serializer.js +28 -11
- package/dist/compaction/serializer.js.map +1 -1
- package/dist/compaction/tool-result-editing.d.ts +54 -0
- package/dist/compaction/tool-result-editing.d.ts.map +1 -0
- package/dist/compaction/tool-result-editing.js +164 -0
- package/dist/compaction/tool-result-editing.js.map +1 -0
- package/dist/compaction/types.d.ts +10 -0
- package/dist/compaction/types.d.ts.map +1 -1
- package/dist/compaction/verifier.d.ts +20 -1
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +11 -2
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/compaction/wire.d.ts +54 -0
- package/dist/compaction/wire.d.ts.map +1 -0
- package/dist/compaction/wire.js +45 -0
- package/dist/compaction/wire.js.map +1 -0
- package/dist/config/runtime.d.ts +161 -45
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +61 -19
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/builtins/http.d.ts.map +1 -1
- package/dist/connector/builtins/http.js +14 -1
- package/dist/connector/builtins/http.js.map +1 -1
- package/dist/connector/builtins/http.test.js +12 -0
- package/dist/connector/builtins/http.test.js.map +1 -1
- package/dist/connector/mcp/__tests__/discovery-policy.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/discovery-policy.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/discovery-policy.test.js +109 -0
- package/dist/connector/mcp/__tests__/discovery-policy.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/list-pagination.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/list-pagination.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/list-pagination.test.js +81 -0
- package/dist/connector/mcp/__tests__/list-pagination.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/policy.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/policy.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/policy.test.js +86 -0
- package/dist/connector/mcp/__tests__/policy.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/protocol-negotiation.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/protocol-negotiation.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/protocol-negotiation.test.js +81 -0
- package/dist/connector/mcp/__tests__/protocol-negotiation.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/schema-fidelity.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/schema-fidelity.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/schema-fidelity.test.js +206 -0
- package/dist/connector/mcp/__tests__/schema-fidelity.test.js.map +1 -0
- package/dist/connector/mcp/__tests__/structured-result.test.d.ts +2 -0
- package/dist/connector/mcp/__tests__/structured-result.test.d.ts.map +1 -0
- package/dist/connector/mcp/__tests__/structured-result.test.js +112 -0
- package/dist/connector/mcp/__tests__/structured-result.test.js.map +1 -0
- package/dist/connector/mcp/adapter.d.ts +14 -0
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +292 -18
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +38 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +138 -12
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/client.test.d.ts +2 -0
- package/dist/connector/mcp/client.test.d.ts.map +1 -0
- package/dist/connector/mcp/client.test.js +105 -0
- package/dist/connector/mcp/client.test.js.map +1 -0
- package/dist/connector/mcp/discovery.d.ts +32 -1
- package/dist/connector/mcp/discovery.d.ts.map +1 -1
- package/dist/connector/mcp/discovery.js +41 -4
- package/dist/connector/mcp/discovery.js.map +1 -1
- package/dist/connector/mcp/http-sse.d.ts.map +1 -1
- package/dist/connector/mcp/http-sse.js +15 -1
- package/dist/connector/mcp/http-sse.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +3 -0
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +1 -0
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/policy.d.ts +57 -0
- package/dist/connector/mcp/policy.d.ts.map +1 -0
- package/dist/connector/mcp/policy.js +84 -0
- package/dist/connector/mcp/policy.js.map +1 -0
- package/dist/connector/mcp/schema-refs.d.ts +26 -0
- package/dist/connector/mcp/schema-refs.d.ts.map +1 -0
- package/dist/connector/mcp/schema-refs.js +111 -0
- package/dist/connector/mcp/schema-refs.js.map +1 -0
- package/dist/constants/agent/index.d.ts.map +1 -1
- package/dist/constants/agent/index.js +3 -0
- package/dist/constants/agent/index.js.map +1 -1
- package/dist/constants/compaction/index.js +1 -1
- package/dist/constants/compaction/index.js.map +1 -1
- package/dist/constants/continuation.d.ts +4 -4
- package/dist/constants/continuation.js +4 -4
- package/dist/constants/mcp/index.d.ts +31 -0
- package/dist/constants/mcp/index.d.ts.map +1 -1
- package/dist/constants/mcp/index.js +31 -0
- package/dist/constants/mcp/index.js.map +1 -1
- package/dist/constants/plugin/index.d.ts +23 -2
- package/dist/constants/plugin/index.d.ts.map +1 -1
- package/dist/constants/plugin/index.js +23 -2
- package/dist/constants/plugin/index.js.map +1 -1
- package/dist/constants/sandbox/index.d.ts +2 -3
- package/dist/constants/sandbox/index.d.ts.map +1 -1
- package/dist/constants/sandbox/index.js +6 -5
- package/dist/constants/sandbox/index.js.map +1 -1
- package/dist/constants/telemetry/index.d.ts +7 -0
- package/dist/constants/telemetry/index.d.ts.map +1 -1
- package/dist/constants/telemetry/index.js +7 -0
- package/dist/constants/telemetry/index.js.map +1 -1
- package/dist/constants/tools/index.d.ts +16 -0
- package/dist/constants/tools/index.d.ts.map +1 -1
- package/dist/constants/tools/index.js +16 -0
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/contracts/a2a.d.ts +94 -94
- package/dist/contracts/api.d.ts +40 -2
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/run-status.d.ts +17 -0
- package/dist/contracts/run-status.d.ts.map +1 -0
- package/dist/contracts/run-status.js +41 -0
- package/dist/contracts/run-status.js.map +1 -0
- package/dist/contracts/schemas.d.ts +6 -6
- package/dist/eval/__tests__/case-deadline.test.d.ts +2 -0
- package/dist/eval/__tests__/case-deadline.test.d.ts.map +1 -0
- package/dist/eval/__tests__/case-deadline.test.js +128 -0
- package/dist/eval/__tests__/case-deadline.test.js.map +1 -0
- package/dist/eval/__tests__/end-to-end.test.d.ts +2 -0
- package/dist/eval/__tests__/end-to-end.test.d.ts.map +1 -0
- package/dist/eval/__tests__/end-to-end.test.js +223 -0
- package/dist/eval/__tests__/end-to-end.test.js.map +1 -0
- package/dist/eval/__tests__/harness-honesty.test.d.ts +2 -0
- package/dist/eval/__tests__/harness-honesty.test.d.ts.map +1 -0
- package/dist/eval/__tests__/harness-honesty.test.js +85 -0
- package/dist/eval/__tests__/harness-honesty.test.js.map +1 -0
- package/dist/eval/__tests__/harness.test.d.ts +2 -0
- package/dist/eval/__tests__/harness.test.d.ts.map +1 -0
- package/dist/eval/__tests__/harness.test.js +207 -0
- package/dist/eval/__tests__/harness.test.js.map +1 -0
- package/dist/eval/__tests__/judge.test.d.ts +2 -0
- package/dist/eval/__tests__/judge.test.d.ts.map +1 -0
- package/dist/eval/__tests__/judge.test.js +255 -0
- package/dist/eval/__tests__/judge.test.js.map +1 -0
- package/dist/eval/__tests__/scorer-gates.test.d.ts +2 -0
- package/dist/eval/__tests__/scorer-gates.test.d.ts.map +1 -0
- package/dist/eval/__tests__/scorer-gates.test.js +136 -0
- package/dist/eval/__tests__/scorer-gates.test.js.map +1 -0
- package/dist/eval/experiment.d.ts +54 -0
- package/dist/eval/experiment.d.ts.map +1 -0
- package/dist/eval/experiment.js +263 -0
- package/dist/eval/experiment.js.map +1 -0
- package/dist/eval/from-run.d.ts +30 -0
- package/dist/eval/from-run.d.ts.map +1 -0
- package/dist/eval/from-run.js +46 -0
- package/dist/eval/from-run.js.map +1 -0
- package/dist/eval/index.d.ts +8 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +5 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/judge.d.ts +63 -0
- package/dist/eval/judge.d.ts.map +1 -0
- package/dist/eval/judge.js +136 -0
- package/dist/eval/judge.js.map +1 -0
- package/dist/eval/scorers.d.ts +40 -0
- package/dist/eval/scorers.d.ts.map +1 -0
- package/dist/eval/scorers.js +151 -0
- package/dist/eval/scorers.js.map +1 -0
- package/dist/eval/types.d.ts +150 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +2 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/execution/local.d.ts.map +1 -1
- package/dist/execution/local.js +6 -1
- package/dist/execution/local.js.map +1 -1
- package/dist/execution/local.test.d.ts +2 -0
- package/dist/execution/local.test.d.ts.map +1 -0
- package/dist/execution/local.test.js +37 -0
- package/dist/execution/local.test.js.map +1 -0
- package/dist/gateway/__tests__/list-survives-eviction.test.d.ts +2 -0
- package/dist/gateway/__tests__/list-survives-eviction.test.d.ts.map +1 -0
- package/dist/gateway/__tests__/list-survives-eviction.test.js +102 -0
- package/dist/gateway/__tests__/list-survives-eviction.test.js.map +1 -0
- package/dist/gateway/local.d.ts +42 -2
- package/dist/gateway/local.d.ts.map +1 -1
- package/dist/gateway/local.js +110 -3
- package/dist/gateway/local.js.map +1 -1
- package/dist/manager/agent/__tests__/dispose-cancels.test.d.ts +2 -0
- package/dist/manager/agent/__tests__/dispose-cancels.test.d.ts.map +1 -0
- package/dist/manager/agent/__tests__/dispose-cancels.test.js +88 -0
- package/dist/manager/agent/__tests__/dispose-cancels.test.js.map +1 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js +230 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +35 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +117 -7
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +90 -1
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +120 -0
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/plugin/__tests__/enable-contributions.test.js +3 -3
- package/dist/plugin/__tests__/enable-contributions.test.js.map +1 -1
- package/dist/plugin/__tests__/hook-ordering.test.d.ts +2 -0
- package/dist/plugin/__tests__/hook-ordering.test.d.ts.map +1 -0
- package/dist/plugin/__tests__/hook-ordering.test.js +227 -0
- package/dist/plugin/__tests__/hook-ordering.test.js.map +1 -0
- package/dist/plugin/__tests__/install-time-refusal.test.d.ts +2 -0
- package/dist/plugin/__tests__/install-time-refusal.test.d.ts.map +1 -0
- package/dist/plugin/__tests__/install-time-refusal.test.js +49 -0
- package/dist/plugin/__tests__/install-time-refusal.test.js.map +1 -0
- package/dist/plugin/__tests__/lifecycle.test.js +95 -68
- package/dist/plugin/__tests__/lifecycle.test.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +15 -1
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +67 -20
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/loader.d.ts +15 -0
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +33 -1
- package/dist/plugin/loader.js.map +1 -1
- package/dist/probe/registry.d.ts.map +1 -1
- package/dist/probe/registry.js +19 -1
- package/dist/probe/registry.js.map +1 -1
- package/dist/probe/registry.test.d.ts +9 -3
- package/dist/probe/registry.test.d.ts.map +1 -1
- package/dist/probe/registry.test.js +44 -6
- package/dist/probe/registry.test.js.map +1 -1
- package/dist/provider/__tests__/mock-script.test.d.ts +2 -0
- package/dist/provider/__tests__/mock-script.test.d.ts.map +1 -0
- package/dist/provider/__tests__/mock-script.test.js +151 -0
- package/dist/provider/__tests__/mock-script.test.js.map +1 -0
- package/dist/provider/__tests__/retry-visibility.test.d.ts +2 -0
- package/dist/provider/__tests__/retry-visibility.test.d.ts.map +1 -0
- package/dist/provider/__tests__/retry-visibility.test.js +137 -0
- package/dist/provider/__tests__/retry-visibility.test.js.map +1 -0
- package/dist/provider/__tests__/retry.test.d.ts +2 -0
- package/dist/provider/__tests__/retry.test.d.ts.map +1 -0
- package/dist/provider/__tests__/retry.test.js +259 -0
- package/dist/provider/__tests__/retry.test.js.map +1 -0
- package/dist/provider/capabilities.d.ts +1 -0
- package/dist/provider/capabilities.d.ts.map +1 -1
- package/dist/provider/capabilities.js +2 -0
- package/dist/provider/capabilities.js.map +1 -1
- package/dist/provider/collect.d.ts +1 -1
- package/dist/provider/collect.js +1 -1
- package/dist/provider/collect.test.d.ts +1 -1
- package/dist/provider/collect.test.js +1 -1
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +2 -0
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/mock-register.d.ts.map +1 -1
- package/dist/provider/mock-register.js +5 -2
- package/dist/provider/mock-register.js.map +1 -1
- package/dist/provider/mock.d.ts +35 -5
- package/dist/provider/mock.d.ts.map +1 -1
- package/dist/provider/mock.js +104 -32
- package/dist/provider/mock.js.map +1 -1
- package/dist/provider/retry.d.ts +42 -0
- package/dist/provider/retry.d.ts.map +1 -0
- package/dist/provider/retry.js +161 -0
- package/dist/provider/retry.js.map +1 -0
- package/dist/public-runtime.d.ts +26 -7
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +55 -7
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +5 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/rag/__tests__/retrieval-math.test.d.ts +2 -0
- package/dist/rag/__tests__/retrieval-math.test.d.ts.map +1 -0
- package/dist/rag/__tests__/retrieval-math.test.js +46 -0
- package/dist/rag/__tests__/retrieval-math.test.js.map +1 -0
- package/dist/rag/chunking.d.ts +12 -0
- package/dist/rag/chunking.d.ts.map +1 -1
- package/dist/rag/chunking.js +32 -1
- package/dist/rag/chunking.js.map +1 -1
- package/dist/rag/embedding.d.ts +4 -4
- package/dist/rag/embedding.d.ts.map +1 -1
- package/dist/rag/embedding.js +23 -3
- package/dist/rag/embedding.js.map +1 -1
- package/dist/rag/embedding.test.d.ts +1 -1
- package/dist/rag/embedding.test.js +59 -10
- package/dist/rag/embedding.test.js.map +1 -1
- package/dist/rag/index.d.ts +1 -1
- package/dist/rag/index.d.ts.map +1 -1
- package/dist/rag/index.js +1 -1
- package/dist/rag/index.js.map +1 -1
- package/dist/rag/retriever.d.ts +0 -1
- package/dist/rag/retriever.d.ts.map +1 -1
- package/dist/rag/retriever.js +75 -22
- package/dist/rag/retriever.js.map +1 -1
- package/dist/rag/vector-store.test.d.ts +1 -1
- package/dist/rag/vector-store.test.js +2 -2
- package/dist/rag/vector-store.test.js.map +1 -1
- package/dist/registry/ManagedRegistry.test.d.ts +1 -1
- package/dist/registry/ManagedRegistry.test.js +1 -1
- package/dist/registry/Registry.test.d.ts +1 -1
- package/dist/registry/Registry.test.js +1 -1
- package/dist/registry/connector/definitions.test.d.ts +1 -1
- package/dist/registry/connector/definitions.test.js +1 -1
- package/dist/registry/tool/__tests__/schema.test.d.ts +2 -0
- package/dist/registry/tool/__tests__/schema.test.d.ts.map +1 -0
- package/dist/registry/tool/__tests__/schema.test.js +176 -0
- package/dist/registry/tool/__tests__/schema.test.js.map +1 -0
- package/dist/registry/tool/__tests__/tool-name-validation.test.d.ts +2 -0
- package/dist/registry/tool/__tests__/tool-name-validation.test.d.ts.map +1 -0
- package/dist/registry/tool/__tests__/tool-name-validation.test.js +70 -0
- package/dist/registry/tool/__tests__/tool-name-validation.test.js.map +1 -0
- package/dist/registry/tool/execute.d.ts +37 -0
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +91 -21
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/schema.d.ts +26 -0
- package/dist/registry/tool/schema.d.ts.map +1 -0
- package/dist/registry/tool/schema.js +77 -0
- package/dist/registry/tool/schema.js.map +1 -0
- package/dist/registry/toolset/catalog.d.ts.map +1 -1
- package/dist/registry/toolset/catalog.js +0 -1
- package/dist/registry/toolset/catalog.js.map +1 -1
- package/dist/registry/toolset/catalog.test.js +0 -1
- package/dist/registry/toolset/catalog.test.js.map +1 -1
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +76 -0
- package/dist/run/reporter.js.map +1 -1
- package/dist/runtime/bidi/__tests__/session.test.d.ts +2 -0
- package/dist/runtime/bidi/__tests__/session.test.d.ts.map +1 -0
- package/dist/runtime/bidi/__tests__/session.test.js +201 -0
- package/dist/runtime/bidi/__tests__/session.test.js.map +1 -0
- package/dist/runtime/bidi/index.d.ts +5 -0
- package/dist/runtime/bidi/index.d.ts.map +1 -0
- package/dist/runtime/bidi/index.js +3 -0
- package/dist/runtime/bidi/index.js.map +1 -0
- package/dist/runtime/bidi/mock.d.ts +34 -0
- package/dist/runtime/bidi/mock.d.ts.map +1 -0
- package/dist/runtime/bidi/mock.js +60 -0
- package/dist/runtime/bidi/mock.js.map +1 -0
- package/dist/runtime/bidi/session.d.ts +44 -0
- package/dist/runtime/bidi/session.d.ts.map +1 -0
- package/dist/runtime/bidi/session.js +154 -0
- package/dist/runtime/bidi/session.js.map +1 -0
- package/dist/runtime/decision/parser.d.ts.map +1 -1
- package/dist/runtime/decision/parser.js +8 -1
- package/dist/runtime/decision/parser.js.map +1 -1
- package/dist/runtime/decision/parser.test.d.ts +2 -0
- package/dist/runtime/decision/parser.test.d.ts.map +1 -0
- package/dist/runtime/decision/parser.test.js +37 -0
- package/dist/runtime/decision/parser.test.js.map +1 -0
- package/dist/runtime/query/__tests__/answer-review.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/answer-review.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/answer-review.test.js +141 -0
- package/dist/runtime/query/__tests__/answer-review.test.js.map +1 -0
- package/dist/runtime/query/__tests__/capability-negotiation.test.js +77 -105
- package/dist/runtime/query/__tests__/capability-negotiation.test.js.map +1 -1
- package/dist/runtime/query/__tests__/checkpoint-store.test.js +12 -44
- package/dist/runtime/query/__tests__/checkpoint-store.test.js.map +1 -1
- package/dist/runtime/query/__tests__/checkpoint.test.js +2 -10
- package/dist/runtime/query/__tests__/checkpoint.test.js.map +1 -1
- package/dist/runtime/query/__tests__/citations.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/citations.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/citations.test.js +85 -0
- package/dist/runtime/query/__tests__/citations.test.js.map +1 -0
- package/dist/runtime/query/__tests__/content-budget.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/content-budget.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/content-budget.test.js +69 -0
- package/dist/runtime/query/__tests__/content-budget.test.js.map +1 -0
- package/dist/runtime/query/__tests__/context.test.js +3 -2
- package/dist/runtime/query/__tests__/context.test.js.map +1 -1
- package/dist/runtime/query/__tests__/deferred-tools.test.js +21 -130
- package/dist/runtime/query/__tests__/deferred-tools.test.js.map +1 -1
- package/dist/runtime/query/__tests__/delegation-resume.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/delegation-resume.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/delegation-resume.test.js +111 -0
- package/dist/runtime/query/__tests__/delegation-resume.test.js.map +1 -0
- package/dist/runtime/query/__tests__/document-attachments.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/document-attachments.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/document-attachments.test.js +92 -0
- package/dist/runtime/query/__tests__/document-attachments.test.js.map +1 -0
- package/dist/runtime/query/__tests__/durable-park-and-trace.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/durable-park-and-trace.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/durable-park-and-trace.test.js +194 -0
- package/dist/runtime/query/__tests__/durable-park-and-trace.test.js.map +1 -0
- package/dist/runtime/query/__tests__/durable-question-park.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/durable-question-park.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/durable-question-park.test.js +253 -0
- package/dist/runtime/query/__tests__/durable-question-park.test.js.map +1 -0
- package/dist/runtime/query/__tests__/durable-run-state.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/durable-run-state.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/durable-run-state.test.js +158 -0
- package/dist/runtime/query/__tests__/durable-run-state.test.js.map +1 -0
- package/dist/runtime/query/__tests__/executor-plugin-hooks.test.js +24 -20
- package/dist/runtime/query/__tests__/executor-plugin-hooks.test.js.map +1 -1
- package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.js +187 -0
- package/dist/runtime/query/__tests__/finish-reason-vs-tool-calls.test.js.map +1 -0
- package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.js +95 -0
- package/dist/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.js.map +1 -0
- package/dist/runtime/query/__tests__/guardrails-e2e.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/guardrails-e2e.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/guardrails-e2e.test.js +132 -0
- package/dist/runtime/query/__tests__/guardrails-e2e.test.js.map +1 -0
- package/dist/runtime/query/__tests__/guardrails.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/guardrails.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/guardrails.test.js +163 -0
- package/dist/runtime/query/__tests__/guardrails.test.js.map +1 -0
- package/dist/runtime/query/__tests__/hook-model-visibility.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/hook-model-visibility.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/hook-model-visibility.test.js +119 -0
- package/dist/runtime/query/__tests__/hook-model-visibility.test.js.map +1 -0
- package/dist/runtime/query/__tests__/long-document-flow.test.js +9 -2
- package/dist/runtime/query/__tests__/long-document-flow.test.js.map +1 -1
- package/dist/runtime/query/__tests__/memory-promotion.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/memory-promotion.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/memory-promotion.test.js +119 -0
- package/dist/runtime/query/__tests__/memory-promotion.test.js.map +1 -0
- package/dist/runtime/query/__tests__/orphan-task-turn-end.test.js +5 -27
- package/dist/runtime/query/__tests__/orphan-task-turn-end.test.js.map +1 -1
- package/dist/runtime/query/__tests__/overflow-relief.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/overflow-relief.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/overflow-relief.test.js +119 -0
- package/dist/runtime/query/__tests__/overflow-relief.test.js.map +1 -0
- package/dist/runtime/query/__tests__/partial-batch-resume.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/partial-batch-resume.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/partial-batch-resume.test.js +205 -0
- package/dist/runtime/query/__tests__/partial-batch-resume.test.js.map +1 -0
- package/dist/runtime/query/__tests__/plugin-hooks.test.js +0 -1
- package/dist/runtime/query/__tests__/plugin-hooks.test.js.map +1 -1
- package/dist/runtime/query/__tests__/prepare-step-chain.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/prepare-step-chain.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/prepare-step-chain.test.js +104 -0
- package/dist/runtime/query/__tests__/prepare-step-chain.test.js.map +1 -0
- package/dist/runtime/query/__tests__/prepare-step.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/prepare-step.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/prepare-step.test.js +194 -0
- package/dist/runtime/query/__tests__/prepare-step.test.js.map +1 -0
- package/dist/runtime/query/__tests__/probe-veto-is-error.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/probe-veto-is-error.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/probe-veto-is-error.test.js +111 -0
- package/dist/runtime/query/__tests__/probe-veto-is-error.test.js.map +1 -0
- package/dist/runtime/query/__tests__/prompt.test.js +1 -1
- package/dist/runtime/query/__tests__/prompt.test.js.map +1 -1
- package/dist/runtime/query/__tests__/provider-fault-pauses.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/provider-fault-pauses.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/provider-fault-pauses.test.js +86 -0
- package/dist/runtime/query/__tests__/provider-fault-pauses.test.js.map +1 -0
- package/dist/runtime/query/__tests__/reasoning-stream.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/reasoning-stream.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/reasoning-stream.test.js +146 -0
- package/dist/runtime/query/__tests__/reasoning-stream.test.js.map +1 -0
- package/dist/runtime/query/__tests__/recoverable-settle.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/recoverable-settle.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/recoverable-settle.test.js +119 -0
- package/dist/runtime/query/__tests__/recoverable-settle.test.js.map +1 -0
- package/dist/runtime/query/__tests__/resume-budget.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/resume-budget.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/resume-budget.test.js +130 -0
- package/dist/runtime/query/__tests__/resume-budget.test.js.map +1 -0
- package/dist/runtime/query/__tests__/resume-pending.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/resume-pending.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/resume-pending.test.js +226 -0
- package/dist/runtime/query/__tests__/resume-pending.test.js.map +1 -0
- package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.js +89 -0
- package/dist/runtime/query/__tests__/rich-content-budget-wiring.test.js.map +1 -0
- package/dist/runtime/query/__tests__/stop-condition.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/stop-condition.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/stop-condition.test.js +205 -0
- package/dist/runtime/query/__tests__/stop-condition.test.js.map +1 -0
- package/dist/runtime/query/__tests__/structured-output.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/structured-output.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/structured-output.test.js +219 -0
- package/dist/runtime/query/__tests__/structured-output.test.js.map +1 -0
- package/dist/runtime/query/__tests__/structured-run-failure.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/structured-run-failure.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/structured-run-failure.test.js +117 -0
- package/dist/runtime/query/__tests__/structured-run-failure.test.js.map +1 -0
- package/dist/runtime/query/__tests__/terminal-tool.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/terminal-tool.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/terminal-tool.test.js +119 -0
- package/dist/runtime/query/__tests__/terminal-tool.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-grants.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-grants.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-grants.test.js +85 -0
- package/dist/runtime/query/__tests__/tool-grants.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-output-budget.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-output-budget.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-output-budget.test.js +0 -0
- package/dist/runtime/query/__tests__/tool-output-budget.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-pause.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-pause.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-pause.test.js +165 -0
- package/dist/runtime/query/__tests__/tool-pause.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-progress.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-progress.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-progress.test.js +122 -0
- package/dist/runtime/query/__tests__/tool-progress.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-repair-retry.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-repair-retry.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-repair-retry.test.js +196 -0
- package/dist/runtime/query/__tests__/tool-repair-retry.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-result-wire.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-result-wire.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-result-wire.test.js +106 -0
- package/dist/runtime/query/__tests__/tool-result-wire.test.js.map +1 -0
- package/dist/runtime/query/__tests__/tool-timeout.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/tool-timeout.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/tool-timeout.test.js +184 -0
- package/dist/runtime/query/__tests__/tool-timeout.test.js.map +1 -0
- package/dist/runtime/query/__tests__/trace-parenting.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/trace-parenting.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/trace-parenting.test.js +111 -0
- package/dist/runtime/query/__tests__/trace-parenting.test.js.map +1 -0
- package/dist/runtime/query/__tests__/wiring-seams.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/wiring-seams.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/wiring-seams.test.js +237 -0
- package/dist/runtime/query/__tests__/wiring-seams.test.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +124 -6
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +207 -6
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/events.js +2 -2
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +225 -7
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +672 -36
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/guard.d.ts +18 -0
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +16 -1
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/guardrail-presets.d.ts +36 -0
- package/dist/runtime/query/guardrail-presets.d.ts.map +1 -0
- package/dist/runtime/query/guardrail-presets.js +96 -0
- package/dist/runtime/query/guardrail-presets.js.map +1 -0
- package/dist/runtime/query/guardrails.d.ts +35 -0
- package/dist/runtime/query/guardrails.d.ts.map +1 -0
- package/dist/runtime/query/guardrails.js +102 -0
- package/dist/runtime/query/guardrails.js.map +1 -0
- package/dist/runtime/query/index.d.ts +213 -2
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +458 -10
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.d.ts +2 -0
- package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.js +131 -0
- package/dist/runtime/query/iteration/__tests__/cancel-settles-turn.test.js.map +1 -0
- package/dist/runtime/query/iteration/index.d.ts +76 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +594 -29
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +14 -2
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.test.d.ts +1 -1
- package/dist/runtime/query/iteration/phases/advisory.test.js +4 -1
- package/dist/runtime/query/iteration/phases/advisory.test.js.map +1 -1
- package/dist/runtime/query/iteration/phases/checkpoint.js +2 -2
- package/dist/runtime/query/iteration/phases/checkpoint.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.js +1 -1
- package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts +22 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +297 -64
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context-measurement.test.d.ts +21 -0
- package/dist/runtime/query/iteration/phases/context-measurement.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/context-measurement.test.js +161 -0
- package/dist/runtime/query/iteration/phases/context-measurement.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/context.d.ts +62 -2
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +87 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/hitl-answer-question.test.js +3 -1
- package/dist/runtime/query/iteration/phases/hitl-answer-question.test.js.map +1 -1
- package/dist/runtime/query/iteration/phases/overflow-escalation.test.d.ts +15 -0
- package/dist/runtime/query/iteration/phases/overflow-escalation.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/overflow-escalation.test.js +130 -0
- package/dist/runtime/query/iteration/phases/overflow-escalation.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/plan.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/plan.js +8 -2
- package/dist/runtime/query/iteration/phases/plan.js.map +1 -1
- package/dist/runtime/query/iteration/phases/retained-messages.test.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/retained-messages.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/retained-messages.test.js +180 -0
- package/dist/runtime/query/iteration/phases/retained-messages.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/tool-review-denials.test.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/tool-review-denials.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/tool-review-denials.test.js +224 -0
- package/dist/runtime/query/iteration/phases/tool-review-denials.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/tool-review.d.ts +29 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +114 -44
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/working-memory-compaction.test.js +20 -9
- package/dist/runtime/query/iteration/phases/working-memory-compaction.test.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts +2 -26
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +254 -16
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/plugin-hooks.d.ts.map +1 -1
- package/dist/runtime/query/plugin-hooks.js +6 -2
- package/dist/runtime/query/plugin-hooks.js.map +1 -1
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +25 -1
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/question-park.d.ts +85 -0
- package/dist/runtime/query/question-park.d.ts.map +1 -0
- package/dist/runtime/query/question-park.js +71 -0
- package/dist/runtime/query/question-park.js.map +1 -0
- package/dist/runtime/query/result.d.ts +9 -0
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +49 -0
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +106 -0
- package/dist/runtime/query/resume-pending.d.ts.map +1 -0
- package/dist/runtime/query/resume-pending.js +312 -0
- package/dist/runtime/query/resume-pending.js.map +1 -0
- package/dist/runtime/query/run-state.d.ts +52 -0
- package/dist/runtime/query/run-state.d.ts.map +1 -0
- package/dist/runtime/query/run-state.js +87 -0
- package/dist/runtime/query/run-state.js.map +1 -0
- package/dist/runtime/query/tool-grants.d.ts +44 -0
- package/dist/runtime/query/tool-grants.d.ts.map +1 -0
- package/dist/runtime/query/tool-grants.js +63 -0
- package/dist/runtime/query/tool-grants.js.map +1 -0
- package/dist/runtime/query/tool-output-budget.d.ts +83 -0
- package/dist/runtime/query/tool-output-budget.d.ts.map +1 -0
- package/dist/runtime/query/tool-output-budget.js +147 -0
- package/dist/runtime/query/tool-output-budget.js.map +1 -0
- package/dist/runtime/query/tool-pause.d.ts +41 -0
- package/dist/runtime/query/tool-pause.d.ts.map +1 -0
- package/dist/runtime/query/tool-pause.js +94 -0
- package/dist/runtime/query/tool-pause.js.map +1 -0
- package/dist/runtime/query/tooling.d.ts +10 -1
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +13 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/sandbox/__tests__/isolation.test.d.ts +2 -0
- package/dist/sandbox/__tests__/isolation.test.d.ts.map +1 -0
- package/dist/sandbox/__tests__/isolation.test.js +139 -0
- package/dist/sandbox/__tests__/isolation.test.js.map +1 -0
- package/dist/sandbox/__tests__/output-truncation.test.d.ts +2 -0
- package/dist/sandbox/__tests__/output-truncation.test.d.ts.map +1 -0
- package/dist/sandbox/__tests__/output-truncation.test.js +88 -0
- package/dist/sandbox/__tests__/output-truncation.test.js.map +1 -0
- package/dist/sandbox/__tests__/resource-limits.test.d.ts +2 -0
- package/dist/sandbox/__tests__/resource-limits.test.d.ts.map +1 -0
- package/dist/sandbox/__tests__/resource-limits.test.js +86 -0
- package/dist/sandbox/__tests__/resource-limits.test.js.map +1 -0
- package/dist/sandbox/factory.js +1 -1
- package/dist/sandbox/factory.js.map +1 -1
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +1 -0
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/isolation.d.ts +15 -0
- package/dist/sandbox/isolation.d.ts.map +1 -0
- package/dist/sandbox/isolation.js +53 -0
- package/dist/sandbox/isolation.js.map +1 -0
- package/dist/sandbox/provider/local.d.ts +51 -2
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +139 -69
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/session/__tests__/integration/spawn-rollback.test.d.ts +1 -1
- package/dist/session/__tests__/integration/spawn-rollback.test.js +1 -1
- package/dist/session/handoff/broadcast.js +3 -3
- package/dist/session/handoff/broadcast.js.map +1 -1
- package/dist/session/migration/__tests__/filesystem.test.js +5 -1
- package/dist/session/migration/__tests__/filesystem.test.js.map +1 -1
- package/dist/session/migration/filesystem.d.ts.map +1 -1
- package/dist/session/migration/filesystem.js +7 -13
- package/dist/session/migration/filesystem.js.map +1 -1
- package/dist/session/migration/marker.d.ts.map +1 -1
- package/dist/session/migration/marker.js +5 -10
- package/dist/session/migration/marker.js.map +1 -1
- package/dist/session/retention/disk-backend.d.ts.map +1 -1
- package/dist/session/retention/disk-backend.js +5 -12
- package/dist/session/retention/disk-backend.js.map +1 -1
- package/dist/session/workspace/__tests__/git-worktree.test.js +6 -2
- package/dist/session/workspace/__tests__/git-worktree.test.js.map +1 -1
- package/dist/session/workspace/__tests__/shared-run.test.js +15 -0
- package/dist/session/workspace/__tests__/shared-run.test.js.map +1 -1
- package/dist/session/workspace/shared-run.js +8 -1
- package/dist/session/workspace/shared-run.js.map +1 -1
- package/dist/skills/__tests__/frontmatter.test.d.ts +2 -0
- package/dist/skills/__tests__/frontmatter.test.d.ts.map +1 -0
- package/dist/skills/__tests__/frontmatter.test.js +106 -0
- package/dist/skills/__tests__/frontmatter.test.js.map +1 -0
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +42 -3
- package/dist/skills/loader.js.map +1 -1
- package/dist/store/__tests__/checkpoint-integrity.test.d.ts +2 -0
- package/dist/store/__tests__/checkpoint-integrity.test.d.ts.map +1 -0
- package/dist/store/__tests__/checkpoint-integrity.test.js +112 -0
- package/dist/store/__tests__/checkpoint-integrity.test.js.map +1 -0
- package/dist/store/__tests__/checkpoint-versioning.test.d.ts +2 -0
- package/dist/store/__tests__/checkpoint-versioning.test.d.ts.map +1 -0
- package/dist/store/__tests__/checkpoint-versioning.test.js +151 -0
- package/dist/store/__tests__/checkpoint-versioning.test.js.map +1 -0
- package/dist/store/__tests__/schema-adoption.test.d.ts +2 -0
- package/dist/store/__tests__/schema-adoption.test.d.ts.map +1 -0
- package/dist/store/__tests__/schema-adoption.test.js +90 -0
- package/dist/store/__tests__/schema-adoption.test.js.map +1 -0
- package/dist/store/__tests__/schema.test.d.ts +2 -0
- package/dist/store/__tests__/schema.test.d.ts.map +1 -0
- package/dist/store/__tests__/schema.test.js +93 -0
- package/dist/store/__tests__/schema.test.js.map +1 -0
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +16 -16
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/run/disk.d.ts +23 -0
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js +148 -23
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/schema.d.ts +73 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +103 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +25 -13
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/task/__tests__/lookup-across-runs.test.d.ts +2 -0
- package/dist/store/task/__tests__/lookup-across-runs.test.d.ts.map +1 -0
- package/dist/store/task/__tests__/lookup-across-runs.test.js +60 -0
- package/dist/store/task/__tests__/lookup-across-runs.test.js.map +1 -0
- package/dist/store/task/disk.d.ts +18 -0
- package/dist/store/task/disk.d.ts.map +1 -1
- package/dist/store/task/disk.js +61 -16
- package/dist/store/task/disk.js.map +1 -1
- package/dist/store/thread/disk.d.ts.map +1 -1
- package/dist/store/thread/disk.js +20 -11
- package/dist/store/thread/disk.js.map +1 -1
- package/dist/streaming/coalesce.d.ts +1 -1
- package/dist/streaming/coalesce.js +1 -1
- package/dist/telemetry/__tests__/latency-instruments.test.d.ts +2 -0
- package/dist/telemetry/__tests__/latency-instruments.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/latency-instruments.test.js +82 -0
- package/dist/telemetry/__tests__/latency-instruments.test.js.map +1 -0
- package/dist/telemetry/__tests__/metrics.test.d.ts +2 -0
- package/dist/telemetry/__tests__/metrics.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/metrics.test.js +112 -0
- package/dist/telemetry/__tests__/metrics.test.js.map +1 -0
- package/dist/telemetry/__tests__/span-hierarchy.test.d.ts +2 -0
- package/dist/telemetry/__tests__/span-hierarchy.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/span-hierarchy.test.js +84 -0
- package/dist/telemetry/__tests__/span-hierarchy.test.js.map +1 -0
- package/dist/telemetry/attributes.d.ts +44 -0
- package/dist/telemetry/attributes.d.ts.map +1 -1
- package/dist/telemetry/attributes.js +80 -0
- package/dist/telemetry/attributes.js.map +1 -1
- package/dist/telemetry/metrics.d.ts +41 -0
- package/dist/telemetry/metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics.js +160 -0
- package/dist/telemetry/metrics.js.map +1 -0
- package/dist/test-setup.d.ts +3 -3
- package/dist/test-setup.js +3 -3
- package/dist/test-support/paths.d.ts +14 -0
- package/dist/test-support/paths.d.ts.map +1 -0
- package/dist/test-support/paths.js +16 -0
- package/dist/test-support/paths.js.map +1 -0
- package/dist/tools/__tests__/path-containment.test.d.ts +2 -0
- package/dist/tools/__tests__/path-containment.test.d.ts.map +1 -0
- package/dist/tools/__tests__/path-containment.test.js +133 -0
- package/dist/tools/__tests__/path-containment.test.js.map +1 -0
- package/dist/tools/__tests__/posix-path.test.d.ts +2 -0
- package/dist/tools/__tests__/posix-path.test.d.ts.map +1 -0
- package/dist/tools/__tests__/posix-path.test.js +67 -0
- package/dist/tools/__tests__/posix-path.test.js.map +1 -0
- package/dist/tools/__tests__/sandboxed-search.test.d.ts +2 -0
- package/dist/tools/__tests__/sandboxed-search.test.d.ts.map +1 -0
- package/dist/tools/__tests__/sandboxed-search.test.js +114 -0
- package/dist/tools/__tests__/sandboxed-search.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/computer-use.test.js +12 -2
- package/dist/tools/builtins/__tests__/computer-use.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/edit-commits-atomically.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/edit-commits-atomically.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/edit-commits-atomically.test.js +78 -0
- package/dist/tools/builtins/__tests__/edit-commits-atomically.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/edit.test.js +52 -17
- package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/payload-budget.test.js +16 -30
- package/dist/tools/builtins/__tests__/payload-budget.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/read-file.test.js +23 -1
- package/dist/tools/builtins/__tests__/read-file.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/stale-file-refusal.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/stale-file-refusal.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/stale-file-refusal.test.js +187 -0
- package/dist/tools/builtins/__tests__/stale-file-refusal.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/write-file.test.js +13 -37
- package/dist/tools/builtins/__tests__/write-file.test.js.map +1 -1
- package/dist/tools/builtins/atomic-write-file.d.ts +1 -1
- package/dist/tools/builtins/atomic-write-file.d.ts.map +1 -1
- package/dist/tools/builtins/atomic-write-file.js +31 -2
- package/dist/tools/builtins/atomic-write-file.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +33 -4
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +22 -22
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +7 -1
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +23 -0
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -0
- package/dist/tools/builtins/content-fingerprint.js +30 -0
- package/dist/tools/builtins/content-fingerprint.js.map +1 -0
- package/dist/tools/builtins/edit.d.ts +5 -2
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +218 -57
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts +1 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +63 -6
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +61 -8
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/index.js +6 -6
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/ls.d.ts.map +1 -1
- package/dist/tools/builtins/ls.js +4 -2
- package/dist/tools/builtins/ls.js.map +1 -1
- package/dist/tools/builtins/read-file.d.ts +1 -1
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +43 -6
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts +2 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +47 -25
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/__tests__/agent.test.d.ts +1 -1
- package/dist/tools/coordinator/__tests__/agent.test.js +2 -2
- package/dist/tools/coordinator/__tests__/agent.test.js.map +1 -1
- package/dist/tools/coordinator/__tests__/ask-user-question.test.js +55 -0
- package/dist/tools/coordinator/__tests__/ask-user-question.test.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts +20 -9
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +2 -1
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts +20 -0
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +142 -36
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/defineTool.d.ts +16 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +4 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/glob-match.d.ts +18 -0
- package/dist/tools/glob-match.d.ts.map +1 -0
- package/dist/tools/glob-match.js +50 -0
- package/dist/tools/glob-match.js.map +1 -0
- package/dist/tools/paths.d.ts +20 -0
- package/dist/tools/paths.d.ts.map +1 -0
- package/dist/tools/paths.js +41 -0
- package/dist/tools/paths.js.map +1 -0
- package/dist/tools/posix-path.d.ts +24 -0
- package/dist/tools/posix-path.d.ts.map +1 -0
- package/dist/tools/posix-path.js +67 -0
- package/dist/tools/posix-path.js.map +1 -0
- package/dist/types/advisory/config.d.ts +21 -3
- package/dist/types/advisory/config.d.ts.map +1 -1
- package/dist/types/advisory/result.d.ts +12 -10
- package/dist/types/advisory/result.d.ts.map +1 -1
- package/dist/types/agent/base.d.ts +20 -2
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +15 -9
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/dist/types/agent/gateway.d.ts +18 -0
- package/dist/types/agent/gateway.d.ts.map +1 -1
- package/dist/types/agent/manager.d.ts +19 -0
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/reactive.d.ts +48 -0
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/agent/router.d.ts +11 -0
- package/dist/types/agent/router.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +2 -2
- package/dist/types/agent/task.d.ts +24 -0
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/bidi/index.d.ts +140 -0
- package/dist/types/bidi/index.d.ts.map +1 -0
- package/dist/types/bidi/index.js +2 -0
- package/dist/types/bidi/index.js.map +1 -0
- package/dist/types/common/__tests__/numeric-correctness.test.d.ts +2 -0
- package/dist/types/common/__tests__/numeric-correctness.test.d.ts.map +1 -0
- package/dist/types/common/__tests__/numeric-correctness.test.js +108 -0
- package/dist/types/common/__tests__/numeric-correctness.test.js.map +1 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +15 -4
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +29 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/errors/__tests__/catalog.test.d.ts +2 -0
- package/dist/types/errors/__tests__/catalog.test.d.ts.map +1 -0
- package/dist/types/errors/__tests__/catalog.test.js +106 -0
- package/dist/types/errors/__tests__/catalog.test.js.map +1 -0
- package/dist/types/errors/__tests__/errors.test.d.ts +2 -0
- package/dist/types/errors/__tests__/errors.test.d.ts.map +1 -0
- package/dist/types/errors/__tests__/errors.test.js +104 -0
- package/dist/types/errors/__tests__/errors.test.js.map +1 -0
- package/dist/types/errors/catalog.d.ts +83 -0
- package/dist/types/errors/catalog.d.ts.map +1 -0
- package/dist/types/errors/catalog.js +148 -0
- package/dist/types/errors/catalog.js.map +1 -0
- package/dist/types/errors/index.d.ts +73 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/errors/index.js +70 -0
- package/dist/types/errors/index.js.map +1 -0
- package/dist/types/guardrail/index.d.ts +57 -0
- package/dist/types/guardrail/index.d.ts.map +1 -0
- package/dist/types/guardrail/index.js +2 -0
- package/dist/types/guardrail/index.js.map +1 -0
- package/dist/types/hitl/index.d.ts +97 -14
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/ids/index.d.ts +2 -2
- package/dist/types/message/content.d.ts +22 -0
- package/dist/types/message/content.d.ts.map +1 -0
- package/dist/types/message/content.js +49 -0
- package/dist/types/message/content.js.map +1 -0
- package/dist/types/message/index.d.ts +193 -8
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +19 -4
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +78 -3
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +0 -1
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/__tests__/cause-chain.test.d.ts +2 -0
- package/dist/types/provider/__tests__/cause-chain.test.d.ts.map +1 -0
- package/dist/types/provider/__tests__/cause-chain.test.js +108 -0
- package/dist/types/provider/__tests__/cause-chain.test.js.map +1 -0
- package/dist/types/provider/__tests__/declared-retryable.test.d.ts +2 -0
- package/dist/types/provider/__tests__/declared-retryable.test.d.ts.map +1 -0
- package/dist/types/provider/__tests__/declared-retryable.test.js +70 -0
- package/dist/types/provider/__tests__/declared-retryable.test.js.map +1 -0
- package/dist/types/provider/__tests__/overflow-classification.test.d.ts +2 -0
- package/dist/types/provider/__tests__/overflow-classification.test.d.ts.map +1 -0
- package/dist/types/provider/__tests__/overflow-classification.test.js +80 -0
- package/dist/types/provider/__tests__/overflow-classification.test.js.map +1 -0
- package/dist/types/provider/chat.d.ts +27 -1
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +83 -2
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/errors.d.ts +102 -0
- package/dist/types/provider/errors.d.ts.map +1 -0
- package/dist/types/provider/errors.js +393 -0
- package/dist/types/provider/errors.js.map +1 -0
- package/dist/types/provider/index.d.ts +3 -2
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +59 -3
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/rag/embedding.d.ts +11 -2
- package/dist/types/rag/embedding.d.ts.map +1 -1
- package/dist/types/run/__tests__/step.test.d.ts +2 -0
- package/dist/types/run/__tests__/step.test.d.ts.map +1 -0
- package/dist/types/run/__tests__/step.test.js +107 -0
- package/dist/types/run/__tests__/step.test.js.map +1 -0
- package/dist/types/run/answer-review.d.ts +46 -0
- package/dist/types/run/answer-review.d.ts.map +1 -0
- package/dist/types/run/answer-review.js +2 -0
- package/dist/types/run/answer-review.js.map +1 -0
- package/dist/types/run/config.d.ts +33 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/derive-status.d.ts +29 -0
- package/dist/types/run/derive-status.d.ts.map +1 -0
- package/dist/types/run/derive-status.js +49 -0
- package/dist/types/run/derive-status.js.map +1 -0
- package/dist/types/run/entity.d.ts +16 -0
- package/dist/types/run/entity.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +228 -4
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js +7 -0
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/run/index.d.ts +5 -0
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +3 -0
- package/dist/types/run/index.js.map +1 -1
- package/dist/types/run/memory-promotion.d.ts +90 -0
- package/dist/types/run/memory-promotion.d.ts.map +1 -0
- package/dist/types/run/memory-promotion.js +38 -0
- package/dist/types/run/memory-promotion.js.map +1 -0
- package/dist/types/run/prepare-step.d.ts +100 -0
- package/dist/types/run/prepare-step.d.ts.map +1 -0
- package/dist/types/run/prepare-step.js +2 -0
- package/dist/types/run/prepare-step.js.map +1 -0
- package/dist/types/run/state.d.ts +85 -0
- package/dist/types/run/state.d.ts.map +1 -0
- package/dist/types/run/state.js +33 -0
- package/dist/types/run/state.js.map +1 -0
- package/dist/types/run/step.d.ts +77 -0
- package/dist/types/run/step.d.ts.map +1 -0
- package/dist/types/run/step.js +26 -0
- package/dist/types/run/step.js.map +1 -0
- package/dist/types/run/stop-reason.d.ts +31 -3
- package/dist/types/run/stop-reason.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +82 -10
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js +13 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/structured-output/index.d.ts +6 -5
- package/dist/types/structured-output/index.d.ts.map +1 -1
- package/dist/types/thread/entity.d.ts +2 -3
- package/dist/types/thread/entity.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +210 -2
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/repair.d.ts +49 -0
- package/dist/types/tool/repair.d.ts.map +1 -0
- package/dist/types/tool/repair.js +2 -0
- package/dist/types/tool/repair.js.map +1 -0
- package/dist/types/toolset/index.d.ts +2 -5
- package/dist/types/toolset/index.d.ts.map +1 -1
- package/dist/utils/__tests__/atomic-write.test.d.ts +2 -0
- package/dist/utils/__tests__/atomic-write.test.d.ts.map +1 -0
- package/dist/utils/__tests__/atomic-write.test.js +91 -0
- package/dist/utils/__tests__/atomic-write.test.js.map +1 -0
- package/dist/utils/__tests__/shell-compress.test.d.ts +2 -0
- package/dist/utils/__tests__/shell-compress.test.d.ts.map +1 -0
- package/dist/utils/__tests__/shell-compress.test.js +41 -0
- package/dist/utils/__tests__/shell-compress.test.js.map +1 -0
- package/dist/utils/atomic-write.d.ts +10 -0
- package/dist/utils/atomic-write.d.ts.map +1 -0
- package/dist/utils/atomic-write.js +83 -0
- package/dist/utils/atomic-write.js.map +1 -0
- package/dist/utils/shell-compress.d.ts.map +1 -1
- package/dist/utils/shell-compress.js +12 -1
- package/dist/utils/shell-compress.js.map +1 -1
- package/dist/verification/presets.d.ts +6 -3
- package/dist/verification/presets.d.ts.map +1 -1
- package/dist/verification/presets.js +6 -3
- package/dist/verification/presets.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/default-path-conformance.test.ts +306 -0
- package/src/__tests__/shipped-defaults.test.ts +111 -0
- package/src/advisory/__tests__/budget-enforcement.test.ts +208 -0
- package/src/advisory/__tests__/structured-response.test.ts +128 -0
- package/src/advisory/budget.ts +27 -0
- package/src/advisory/context.ts +19 -0
- package/src/advisory/executor.test.ts +12 -8
- package/src/advisory/executor.ts +37 -25
- package/src/advisory/index.ts +2 -0
- package/src/advisory/parse.ts +63 -0
- package/src/agents/AbstractAgent.ts +82 -0
- package/src/agents/PipelineAgent.ts +19 -0
- package/src/agents/ReactiveAgent.ts +47 -0
- package/src/agents/RouterAgent.ts +32 -2
- package/src/agents/SupervisorAgent.ts +31 -1
- package/src/agents/__tests__/idempotency-key.test.ts +177 -0
- package/src/agents/__tests__/invocation-lock.test.ts +154 -0
- package/src/agents/__tests__/reachability.test.ts +224 -0
- package/src/agents/__tests__/supervisor-ledger.test.ts +1 -1
- package/src/agents/index.ts +1 -1
- package/src/agents/lock.ts +0 -2
- package/src/bridge/a2a/late-events.test.ts +84 -0
- package/src/bridge/a2a/mapper.test.ts +1 -1
- package/src/bridge/a2a/mapper.ts +70 -5
- package/src/bridge/a2a/message.ts +5 -1
- package/src/bridge/sse/late-events.test.ts +182 -0
- package/src/bridge/sse/mapper.ts +109 -0
- package/src/compaction/__tests__/cleared-result-recovery.test.ts +118 -0
- package/src/compaction/__tests__/context-window.test.ts +77 -0
- package/src/compaction/__tests__/dangling.test.ts +16 -6
- package/src/compaction/__tests__/lossiness.test.ts +187 -0
- package/src/compaction/__tests__/state-across-resume.test.ts +99 -0
- package/src/compaction/__tests__/tool-result-editing.test.ts +213 -0
- package/src/compaction/__tests__/trim-opens-on-user.test.ts +118 -0
- package/src/compaction/__tests__/verifier-model.test.ts +83 -0
- package/src/compaction/context-window.ts +107 -0
- package/src/compaction/dangling.ts +48 -1
- package/src/compaction/extractor.ts +56 -1
- package/src/compaction/index.ts +16 -0
- package/src/compaction/manager.ts +53 -8
- package/src/compaction/managers/structured.ts +7 -6
- package/src/compaction/retention.ts +89 -0
- package/src/compaction/serializer.ts +42 -11
- package/src/compaction/tool-result-editing.ts +229 -0
- package/src/compaction/types.ts +10 -0
- package/src/compaction/verifier.ts +24 -1
- package/src/compaction/wire.ts +91 -0
- package/src/config/runtime.ts +63 -19
- package/src/connector/builtins/http.test.ts +13 -0
- package/src/connector/builtins/http.ts +15 -1
- package/src/connector/mcp/__tests__/discovery-policy.test.ts +133 -0
- package/src/connector/mcp/__tests__/list-pagination.test.ts +98 -0
- package/src/connector/mcp/__tests__/policy.test.ts +100 -0
- package/src/connector/mcp/__tests__/protocol-negotiation.test.ts +105 -0
- package/src/connector/mcp/__tests__/schema-fidelity.test.ts +250 -0
- package/src/connector/mcp/__tests__/structured-result.test.ts +143 -0
- package/src/connector/mcp/adapter.ts +306 -19
- package/src/connector/mcp/client.test.ts +159 -0
- package/src/connector/mcp/client.ts +160 -13
- package/src/connector/mcp/discovery.ts +74 -5
- package/src/connector/mcp/http-sse.ts +16 -1
- package/src/connector/mcp/index.ts +4 -0
- package/src/connector/mcp/policy.ts +134 -0
- package/src/connector/mcp/schema-refs.ts +126 -0
- package/src/constants/agent/index.ts +3 -0
- package/src/constants/compaction/index.ts +1 -1
- package/src/constants/continuation.ts +4 -4
- package/src/constants/mcp/index.ts +34 -0
- package/src/constants/plugin/index.ts +24 -2
- package/src/constants/sandbox/index.ts +6 -5
- package/src/constants/telemetry/index.ts +8 -0
- package/src/constants/tools/index.ts +20 -0
- package/src/contracts/api.ts +40 -0
- package/src/contracts/run-status.ts +43 -0
- package/src/eval/__tests__/case-deadline.test.ts +147 -0
- package/src/eval/__tests__/end-to-end.test.ts +259 -0
- package/src/eval/__tests__/harness-honesty.test.ts +99 -0
- package/src/eval/__tests__/harness.test.ts +249 -0
- package/src/eval/__tests__/judge.test.ts +306 -0
- package/src/eval/__tests__/scorer-gates.test.ts +156 -0
- package/src/eval/experiment.ts +335 -0
- package/src/eval/from-run.ts +48 -0
- package/src/eval/index.ts +21 -0
- package/src/eval/judge.ts +240 -0
- package/src/eval/scorers.ts +169 -0
- package/src/eval/types.ts +157 -0
- package/src/execution/local.test.ts +46 -0
- package/src/execution/local.ts +6 -1
- package/src/gateway/__tests__/list-survives-eviction.test.ts +124 -0
- package/src/gateway/local.ts +117 -3
- package/src/manager/agent/__tests__/dispose-cancels.test.ts +104 -0
- package/src/manager/agent/__tests__/lifecycle.test.ts +297 -0
- package/src/manager/agent/lifecycle.ts +127 -7
- package/src/manager/run/persistence.ts +132 -1
- package/src/plugin/__tests__/enable-contributions.test.ts +3 -3
- package/src/plugin/__tests__/hook-ordering.test.ts +252 -0
- package/src/plugin/__tests__/install-time-refusal.test.ts +68 -0
- package/src/plugin/__tests__/lifecycle.test.ts +95 -73
- package/src/plugin/lifecycle.ts +76 -22
- package/src/plugin/loader.ts +37 -1
- package/src/probe/registry.test.ts +49 -6
- package/src/probe/registry.ts +21 -1
- package/src/provider/__tests__/mock-script.test.ts +179 -0
- package/src/provider/__tests__/registry.test.ts +1 -1
- package/src/provider/__tests__/retry-visibility.test.ts +160 -0
- package/src/provider/__tests__/retry.test.ts +296 -0
- package/src/provider/capabilities.ts +4 -0
- package/src/provider/collect.test.ts +1 -1
- package/src/provider/collect.ts +1 -1
- package/src/provider/index.ts +8 -0
- package/src/provider/mock-register.ts +5 -2
- package/src/provider/mock.ts +117 -34
- package/src/provider/retry.ts +199 -0
- package/src/public-runtime.ts +118 -7
- package/src/public-types.ts +5 -1
- package/src/rag/__tests__/retrieval-math.test.ts +54 -0
- package/src/rag/chunking.ts +32 -1
- package/src/rag/embedding.test.ts +65 -10
- package/src/rag/embedding.ts +26 -5
- package/src/rag/index.ts +1 -1
- package/src/rag/retriever.ts +92 -21
- package/src/rag/vector-store.test.ts +2 -2
- package/src/registry/ManagedRegistry.test.ts +1 -1
- package/src/registry/Registry.test.ts +1 -1
- package/src/registry/connector/definitions.test.ts +1 -1
- package/src/registry/tool/__tests__/schema.test.ts +208 -0
- package/src/registry/tool/__tests__/tool-name-validation.test.ts +88 -0
- package/src/registry/tool/execute.ts +104 -22
- package/src/registry/tool/schema.ts +80 -0
- package/src/registry/toolset/catalog.test.ts +0 -1
- package/src/registry/toolset/catalog.ts +0 -1
- package/src/run/reporter.ts +84 -0
- package/src/runtime/bidi/__tests__/session.test.ts +232 -0
- package/src/runtime/bidi/index.ts +4 -0
- package/src/runtime/bidi/mock.ts +90 -0
- package/src/runtime/bidi/session.ts +205 -0
- package/src/runtime/decision/parser.test.ts +46 -0
- package/src/runtime/decision/parser.ts +8 -1
- package/src/runtime/query/__tests__/answer-review.test.ts +172 -0
- package/src/runtime/query/__tests__/capability-negotiation.test.ts +88 -123
- package/src/runtime/query/__tests__/checkpoint-store.test.ts +13 -50
- package/src/runtime/query/__tests__/checkpoint.test.ts +2 -10
- package/src/runtime/query/__tests__/citations.test.ts +111 -0
- package/src/runtime/query/__tests__/content-budget.test.ts +83 -0
- package/src/runtime/query/__tests__/context.test.ts +3 -2
- package/src/runtime/query/__tests__/deferred-tools.test.ts +23 -148
- package/src/runtime/query/__tests__/delegation-resume.test.ts +159 -0
- package/src/runtime/query/__tests__/document-attachments.test.ts +125 -0
- package/src/runtime/query/__tests__/durable-park-and-trace.test.ts +245 -0
- package/src/runtime/query/__tests__/durable-question-park.test.ts +305 -0
- package/src/runtime/query/__tests__/durable-run-state.test.ts +194 -0
- package/src/runtime/query/__tests__/executor-plugin-hooks.test.ts +24 -20
- package/src/runtime/query/__tests__/finish-reason-vs-tool-calls.test.ts +206 -0
- package/src/runtime/query/__tests__/grant-cannot-overrule-the-gate.test.ts +115 -0
- package/src/runtime/query/__tests__/guardrails-e2e.test.ts +164 -0
- package/src/runtime/query/__tests__/guardrails.test.ts +236 -0
- package/src/runtime/query/__tests__/hook-model-visibility.test.ts +143 -0
- package/src/runtime/query/__tests__/long-document-flow.test.ts +9 -2
- package/src/runtime/query/__tests__/memory-promotion.test.ts +148 -0
- package/src/runtime/query/__tests__/orphan-task-turn-end.test.ts +5 -31
- package/src/runtime/query/__tests__/overflow-relief.test.ts +139 -0
- package/src/runtime/query/__tests__/partial-batch-resume.test.ts +264 -0
- package/src/runtime/query/__tests__/plugin-hooks.test.ts +0 -1
- package/src/runtime/query/__tests__/prepare-step-chain.test.ts +127 -0
- package/src/runtime/query/__tests__/prepare-step.test.ts +233 -0
- package/src/runtime/query/__tests__/probe-veto-is-error.test.ts +145 -0
- package/src/runtime/query/__tests__/prompt.test.ts +1 -1
- package/src/runtime/query/__tests__/provider-fault-pauses.test.ts +104 -0
- package/src/runtime/query/__tests__/reasoning-stream.test.ts +177 -0
- package/src/runtime/query/__tests__/recoverable-settle.test.ts +145 -0
- package/src/runtime/query/__tests__/resume-budget.test.ts +158 -0
- package/src/runtime/query/__tests__/resume-pending.test.ts +273 -0
- package/src/runtime/query/__tests__/rich-content-budget-wiring.test.ts +109 -0
- package/src/runtime/query/__tests__/stop-condition.test.ts +265 -0
- package/src/runtime/query/__tests__/structured-output.test.ts +268 -0
- package/src/runtime/query/__tests__/structured-run-failure.test.ts +144 -0
- package/src/runtime/query/__tests__/terminal-tool.test.ts +148 -0
- package/src/runtime/query/__tests__/tool-grants.test.ts +102 -0
- package/src/runtime/query/__tests__/tool-output-budget.test.ts +0 -0
- package/src/runtime/query/__tests__/tool-pause.test.ts +209 -0
- package/src/runtime/query/__tests__/tool-progress.test.ts +154 -0
- package/src/runtime/query/__tests__/tool-repair-retry.test.ts +255 -0
- package/src/runtime/query/__tests__/tool-result-wire.test.ts +135 -0
- package/src/runtime/query/__tests__/tool-timeout.test.ts +230 -0
- package/src/runtime/query/__tests__/trace-parenting.test.ts +128 -0
- package/src/runtime/query/__tests__/wiring-seams.test.ts +288 -0
- package/src/runtime/query/checkpoint.ts +242 -10
- package/src/runtime/query/events.ts +2 -2
- package/src/runtime/query/executor.ts +856 -40
- package/src/runtime/query/guard.ts +26 -1
- package/src/runtime/query/guardrail-presets.ts +124 -0
- package/src/runtime/query/guardrails.ts +144 -0
- package/src/runtime/query/index.ts +759 -12
- package/src/runtime/query/iteration/__tests__/cancel-settles-turn.test.ts +177 -0
- package/src/runtime/query/iteration/index.ts +674 -31
- package/src/runtime/query/iteration/phases/advisory.test.ts +4 -1
- package/src/runtime/query/iteration/phases/advisory.ts +14 -2
- package/src/runtime/query/iteration/phases/checkpoint.ts +2 -2
- package/src/runtime/query/iteration/phases/compaction-safe-cut.test.ts +3 -1
- package/src/runtime/query/iteration/phases/compaction.ts +329 -64
- package/src/runtime/query/iteration/phases/context-measurement.test.ts +196 -0
- package/src/runtime/query/iteration/phases/context.ts +155 -2
- package/src/runtime/query/iteration/phases/hitl-answer-question.test.ts +3 -1
- package/src/runtime/query/iteration/phases/overflow-escalation.test.ts +167 -0
- package/src/runtime/query/iteration/phases/plan.ts +10 -2
- package/src/runtime/query/iteration/phases/retained-messages.test.ts +226 -0
- package/src/runtime/query/iteration/phases/tool-review-denials.test.ts +270 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +140 -51
- package/src/runtime/query/iteration/phases/working-memory-compaction.test.ts +21 -9
- package/src/runtime/query/iteration/stream-turn.ts +285 -15
- package/src/runtime/query/plugin-hooks.ts +6 -2
- package/src/runtime/query/prompt.ts +26 -1
- package/src/runtime/query/question-park.ts +120 -0
- package/src/runtime/query/result.ts +64 -0
- package/src/runtime/query/resume-pending.ts +394 -0
- package/src/runtime/query/run-state.ts +124 -0
- package/src/runtime/query/tool-grants.ts +83 -0
- package/src/runtime/query/tool-output-budget.ts +183 -0
- package/src/runtime/query/tool-pause.ts +119 -0
- package/src/runtime/query/tooling.ts +23 -1
- package/src/sandbox/__tests__/isolation.test.ts +164 -0
- package/src/sandbox/__tests__/output-truncation.test.ts +106 -0
- package/src/sandbox/__tests__/resource-limits.test.ts +106 -0
- package/src/sandbox/factory.ts +1 -1
- package/src/sandbox/index.ts +2 -0
- package/src/sandbox/isolation.ts +72 -0
- package/src/sandbox/provider/local.ts +173 -74
- package/src/session/__tests__/integration/spawn-rollback.test.ts +1 -1
- package/src/session/handoff/broadcast.ts +3 -3
- package/src/session/migration/__tests__/filesystem.test.ts +26 -19
- package/src/session/migration/filesystem.ts +7 -12
- package/src/session/migration/marker.ts +5 -9
- package/src/session/retention/disk-backend.ts +5 -11
- package/src/session/workspace/__tests__/git-worktree.test.ts +6 -2
- package/src/session/workspace/__tests__/shared-run.test.ts +18 -0
- package/src/session/workspace/shared-run.ts +7 -1
- package/src/skills/__tests__/frontmatter.test.ts +135 -0
- package/src/skills/loader.ts +47 -3
- package/src/store/__tests__/checkpoint-integrity.test.ts +134 -0
- package/src/store/__tests__/checkpoint-versioning.test.ts +194 -0
- package/src/store/__tests__/schema-adoption.test.ts +118 -0
- package/src/store/__tests__/schema.test.ts +119 -0
- package/src/store/memory/disk.ts +17 -16
- package/src/store/run/disk.ts +169 -22
- package/src/store/schema.ts +135 -0
- package/src/store/session/disk.ts +30 -21
- package/src/store/task/__tests__/lookup-across-runs.test.ts +77 -0
- package/src/store/task/disk.ts +59 -15
- package/src/store/thread/disk.ts +21 -10
- package/src/streaming/coalesce.ts +1 -1
- package/src/telemetry/__tests__/latency-instruments.test.ts +120 -0
- package/src/telemetry/__tests__/metrics.test.ts +160 -0
- package/src/telemetry/__tests__/span-hierarchy.test.ts +94 -0
- package/src/telemetry/attributes.ts +109 -0
- package/src/telemetry/metrics.ts +190 -0
- package/src/test-setup.ts +3 -3
- package/src/test-support/paths.ts +17 -0
- package/src/tools/__tests__/path-containment.test.ts +167 -0
- package/src/tools/__tests__/posix-path.test.ts +83 -0
- package/src/tools/__tests__/sandboxed-search.test.ts +140 -0
- package/src/tools/builtins/__tests__/computer-use.test.ts +15 -2
- package/src/tools/builtins/__tests__/edit-commits-atomically.test.ts +103 -0
- package/src/tools/builtins/__tests__/edit.test.ts +80 -17
- package/src/tools/builtins/__tests__/payload-budget.test.ts +20 -40
- package/src/tools/builtins/__tests__/read-file.test.ts +29 -1
- package/src/tools/builtins/__tests__/stale-file-refusal.test.ts +258 -0
- package/src/tools/builtins/__tests__/write-file.test.ts +13 -52
- package/src/tools/builtins/atomic-write-file.ts +30 -2
- package/src/tools/builtins/bash.ts +34 -4
- package/src/tools/builtins/computer-use.ts +7 -1
- package/src/tools/builtins/content-fingerprint.ts +33 -0
- package/src/tools/builtins/edit.ts +258 -60
- package/src/tools/builtins/glob.ts +71 -6
- package/src/tools/builtins/grep.ts +82 -8
- package/src/tools/builtins/index.ts +6 -6
- package/src/tools/builtins/ls.ts +4 -2
- package/src/tools/builtins/read-file.ts +45 -6
- package/src/tools/builtins/write-file.ts +52 -25
- package/src/tools/coordinator/__tests__/agent.test.ts +2 -2
- package/src/tools/coordinator/__tests__/ask-user-question.test.ts +68 -0
- package/src/tools/coordinator/agent.ts +23 -10
- package/src/tools/coordinator/index.ts +213 -72
- package/src/tools/defineTool.ts +20 -0
- package/src/tools/glob-match.ts +50 -0
- package/src/tools/paths.ts +44 -0
- package/src/tools/posix-path.ts +73 -0
- package/src/types/advisory/config.ts +21 -3
- package/src/types/advisory/result.ts +12 -7
- package/src/types/agent/base.ts +22 -2
- package/src/types/agent/factory.ts +15 -9
- package/src/types/agent/gateway.ts +20 -0
- package/src/types/agent/manager.ts +19 -0
- package/src/types/agent/reactive.ts +50 -0
- package/src/types/agent/router.ts +11 -0
- package/src/types/agent/supervisor.ts +2 -2
- package/src/types/agent/task.ts +26 -0
- package/src/types/bidi/index.ts +119 -0
- package/src/types/common/__tests__/numeric-correctness.test.ts +123 -0
- package/src/types/common/index.ts +16 -4
- package/src/types/computer-use/index.ts +1 -1
- package/src/types/connector/mcp.ts +29 -0
- package/src/types/errors/__tests__/catalog.test.ts +130 -0
- package/src/types/errors/__tests__/errors.test.ts +118 -0
- package/src/types/errors/catalog.ts +211 -0
- package/src/types/errors/index.ts +121 -0
- package/src/types/guardrail/index.ts +62 -0
- package/src/types/hitl/index.ts +102 -20
- package/src/types/ids/index.ts +2 -2
- package/src/types/message/content.ts +50 -0
- package/src/types/message/index.ts +210 -9
- package/src/types/plugin/index.ts +82 -2
- package/src/types/provider/__tests__/cause-chain.test.ts +132 -0
- package/src/types/provider/__tests__/declared-retryable.test.ts +85 -0
- package/src/types/provider/__tests__/overflow-classification.test.ts +113 -0
- package/src/types/provider/chat.ts +29 -1
- package/src/types/provider/config.ts +83 -2
- package/src/types/provider/errors.ts +472 -0
- package/src/types/provider/index.ts +5 -0
- package/src/types/provider/stream.ts +63 -3
- package/src/types/rag/embedding.ts +11 -2
- package/src/types/run/__tests__/step.test.ts +123 -0
- package/src/types/run/answer-review.ts +51 -0
- package/src/types/run/config.ts +35 -0
- package/src/types/run/derive-status.ts +62 -0
- package/src/types/run/entity.ts +18 -0
- package/src/types/run/events.ts +230 -3
- package/src/types/run/index.ts +5 -0
- package/src/types/run/memory-promotion.ts +112 -0
- package/src/types/run/prepare-step.ts +109 -0
- package/src/types/run/state.ts +111 -0
- package/src/types/run/step.ts +95 -0
- package/src/types/run/stop-reason.ts +29 -1
- package/src/types/sandbox/index.ts +93 -12
- package/src/types/structured-output/index.ts +6 -5
- package/src/types/thread/entity.ts +2 -3
- package/src/types/tool/index.ts +221 -2
- package/src/types/tool/repair.ts +54 -0
- package/src/types/toolset/index.ts +2 -6
- package/src/utils/__tests__/atomic-write.test.ts +108 -0
- package/src/utils/__tests__/shell-compress.test.ts +49 -0
- package/src/utils/atomic-write.ts +85 -0
- package/src/utils/shell-compress.ts +12 -1
- package/src/verification/presets.ts +6 -3
|
@@ -1,18 +1,43 @@
|
|
|
1
|
-
import { SpanStatusCode } from '@opentelemetry/api'
|
|
1
|
+
import { type Span, SpanStatusCode } from '@opentelemetry/api'
|
|
2
2
|
import { extractFromAssistantMessage } from '../../../compaction/extractor.js'
|
|
3
3
|
import { AUTO_CONTINUATION_USER_MESSAGE } from '../../../constants/continuation.js'
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_STRUCTURED_OUTPUT_RETRIES,
|
|
6
|
+
STRUCTURED_OUTPUT_REPROMPT,
|
|
7
|
+
} from '../../../constants/tools/index.js'
|
|
4
8
|
import { collect } from '../../../provider/collect.js'
|
|
5
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
GENAI,
|
|
11
|
+
NAMZU,
|
|
12
|
+
agentIterationSpanName,
|
|
13
|
+
parentContext,
|
|
14
|
+
} from '../../../telemetry/attributes.js'
|
|
6
15
|
import { getTracer } from '../../../telemetry/runtime-accessors.js'
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
16
|
+
import { STRUCTURED_OUTPUT_TOOL_NAME } from '../../../tools/builtins/structuredOutput.js'
|
|
17
|
+
import type { CostInfo, TokenUsage } from '../../../types/common/index.js'
|
|
18
|
+
import type { MessageId } from '../../../types/ids/index.js'
|
|
19
|
+
import {
|
|
20
|
+
createAssistantMessage,
|
|
21
|
+
createSystemMessage,
|
|
22
|
+
createUserMessage,
|
|
23
|
+
} from '../../../types/message/index.js'
|
|
24
|
+
import { classifyProviderError } from '../../../types/provider/errors.js'
|
|
25
|
+
import type { ChatCompletionResponse } from '../../../types/provider/index.js'
|
|
26
|
+
import type { AnswerReview } from '../../../types/run/answer-review.js'
|
|
27
|
+
import type {
|
|
28
|
+
PrepareStepResult,
|
|
29
|
+
RunEvent,
|
|
30
|
+
StepResult,
|
|
31
|
+
StopReason,
|
|
32
|
+
} from '../../../types/run/index.js'
|
|
9
33
|
import type { LLMToolSchema, ToolRegistryContract } from '../../../types/tool/index.js'
|
|
10
34
|
import { toErrorMessage } from '../../../utils/error.js'
|
|
11
35
|
import { generateMessageId } from '../../../utils/id.js'
|
|
36
|
+
import type { ToolCallOutcome } from '../executor.js'
|
|
12
37
|
import { applyLifecycleHookResults } from '../plugin-hooks.js'
|
|
13
38
|
import { runAdvisoryPhase } from './phases/advisory.js'
|
|
14
39
|
import { runIterationCheckpoint } from './phases/checkpoint.js'
|
|
15
|
-
import { runCompactionCheck } from './phases/compaction.js'
|
|
40
|
+
import { relieveOverflow, runCompactionCheck } from './phases/compaction.js'
|
|
16
41
|
import type { IterationContext } from './phases/index.js'
|
|
17
42
|
import { runPlanGate } from './phases/plan.js'
|
|
18
43
|
import { runToolReview } from './phases/tool-review.js'
|
|
@@ -23,18 +48,52 @@ export type { IterationContext } from './phases/index.js'
|
|
|
23
48
|
export type { PhaseSignal } from './phases/index.js'
|
|
24
49
|
export type { ToolReviewOutcome } from './phases/index.js'
|
|
25
50
|
|
|
51
|
+
/**
|
|
52
|
+
* How many times an answer may be handed back before the run stops.
|
|
53
|
+
*
|
|
54
|
+
* Bounded for the same reason the structured-output re-prompt is: a judge
|
|
55
|
+
* that never accepts would otherwise spend the whole token budget
|
|
56
|
+
* rediscovering that, and the run would end on a budget error rather than
|
|
57
|
+
* on the thing that actually went wrong.
|
|
58
|
+
*/
|
|
59
|
+
const DEFAULT_ANSWER_REVIEW_LIMIT = 3
|
|
60
|
+
|
|
26
61
|
export class IterationOrchestrator {
|
|
27
62
|
private ctx: IterationContext
|
|
63
|
+
/** Rejections so far. See {@link DEFAULT_ANSWER_REVIEW_LIMIT}. */
|
|
64
|
+
private answerReviewAttempts = 0
|
|
28
65
|
|
|
29
66
|
constructor(ctx: IterationContext) {
|
|
30
67
|
this.ctx = ctx
|
|
31
68
|
}
|
|
32
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Adopt the run's span after construction.
|
|
72
|
+
*
|
|
73
|
+
* The orchestrator is built before `query()` enters its generator body,
|
|
74
|
+
* which is where the run span is created — so the parent cannot be a
|
|
75
|
+
* constructor argument without reordering setup around one field.
|
|
76
|
+
*/
|
|
77
|
+
setRootSpan(span: Span): void {
|
|
78
|
+
this.ctx = { ...this.ctx, rootSpan: span }
|
|
79
|
+
}
|
|
80
|
+
|
|
33
81
|
async *runLoop(): AsyncGenerator<RunEvent> {
|
|
34
82
|
const { runConfig, runMgr } = this.ctx
|
|
35
83
|
const { model } = runConfig
|
|
36
84
|
const tracer = getTracer()
|
|
37
85
|
|
|
86
|
+
// One context-overflow relief per *stuck point*, not per run.
|
|
87
|
+
//
|
|
88
|
+
// The latch exists so that a second overflow immediately after a
|
|
89
|
+
// successful compaction — meaning the prompt is irreducible — stops
|
|
90
|
+
// instead of looping. It was never meant to disarm the mechanism for
|
|
91
|
+
// the rest of the run, which is what a run-scoped flag did: one
|
|
92
|
+
// relief at iteration 3 left iteration 40 to die on an overflow with
|
|
93
|
+
// obvious moves left. It is cleared by a turn that actually
|
|
94
|
+
// succeeded, which is the evidence that the run is no longer stuck.
|
|
95
|
+
let overflowRelieved = false
|
|
96
|
+
|
|
38
97
|
const planSignal = yield* runPlanGate(this.ctx)
|
|
39
98
|
if (planSignal === 'stop') return
|
|
40
99
|
|
|
@@ -81,7 +140,19 @@ export class IterationOrchestrator {
|
|
|
81
140
|
this.ctx.activityStore.start(iterationActivity.id)
|
|
82
141
|
}
|
|
83
142
|
|
|
84
|
-
|
|
143
|
+
// Parent explicitly: this body is an async generator, so the
|
|
144
|
+
// ambient context at resume time belongs to the CONSUMER, not to
|
|
145
|
+
// whoever created the run span. Without this every iteration
|
|
146
|
+
// emits as its own root and a 20-turn run shows up as 21
|
|
147
|
+
// disconnected traces.
|
|
148
|
+
const iterSpan = tracer.startSpan(
|
|
149
|
+
agentIterationSpanName(iterationNum),
|
|
150
|
+
{},
|
|
151
|
+
parentContext(this.ctx.rootSpan),
|
|
152
|
+
)
|
|
153
|
+
// Tool spans for this turn belong under this iteration.
|
|
154
|
+
this.ctx.toolExecutor.setParentSpan(iterSpan)
|
|
155
|
+
|
|
85
156
|
iterSpan.setAttributes({
|
|
86
157
|
[NAMZU.ITERATION]: iterationNum,
|
|
87
158
|
[NAMZU.RUN_ID]: runMgr.id,
|
|
@@ -118,10 +189,22 @@ export class IterationOrchestrator {
|
|
|
118
189
|
// entire prompt-cache prefix (tools render at position 0) and
|
|
119
190
|
// risks a 400 because the history still carries
|
|
120
191
|
// tool_use/tool_result blocks.
|
|
121
|
-
|
|
122
|
-
|
|
192
|
+
// Snapshot the cumulative counters so the step can report ITS
|
|
193
|
+
// own usage rather than the run total.
|
|
194
|
+
const stepStartedAt = Date.now()
|
|
195
|
+
const usageBefore = { ...runMgr.tokenUsage }
|
|
196
|
+
const costBefore = { ...runMgr.costInfo }
|
|
123
197
|
|
|
124
|
-
|
|
198
|
+
// Shape this step before calling the model. `stopWhen` decides
|
|
199
|
+
// whether to keep going; this decides HOW. No-op when the host
|
|
200
|
+
// supplied no hook.
|
|
201
|
+
const step = await this.prepareStep(iterationNum)
|
|
202
|
+
|
|
203
|
+
const llmTools = this.ctx.tools.toLLMTools(step.allowedTools ?? this.ctx.allowedTools)
|
|
204
|
+
const enforceToolInputSchema = enforcedModelInputToolNames(this.ctx.tools, llmTools)
|
|
205
|
+
const stepModel = step.model ?? model
|
|
206
|
+
|
|
207
|
+
const baseMessages = forceFinalize
|
|
125
208
|
? [
|
|
126
209
|
...runMgr.messages,
|
|
127
210
|
createUserMessage(
|
|
@@ -130,10 +213,41 @@ export class IterationOrchestrator {
|
|
|
130
213
|
]
|
|
131
214
|
: runMgr.messages
|
|
132
215
|
|
|
216
|
+
// Step guidance is appended to the REQUEST, never pushed onto
|
|
217
|
+
// the run's history: it applies to this step only, and pushing
|
|
218
|
+
// it would accumulate one stale instruction per iteration.
|
|
219
|
+
// Copy before it crosses the provider boundary. `runMgr.messages`
|
|
220
|
+
// is the LIVE run array, and the loop pushes onto it after the
|
|
221
|
+
// call returns — so a driver that retains what it was handed
|
|
222
|
+
// (to log it, cache it, or replay it on retry) watched its own
|
|
223
|
+
// input grow new turns underneath it. A capture provider in the
|
|
224
|
+
// estate recorded every turn as identical to the last for
|
|
225
|
+
// exactly this reason. Shallow is enough: the defect is array
|
|
226
|
+
// mutation, and per-iteration this is trivial next to the model
|
|
227
|
+
// call it precedes.
|
|
228
|
+
const messages = step.system
|
|
229
|
+
? [...baseMessages, createSystemMessage(step.system)]
|
|
230
|
+
: [...baseMessages]
|
|
231
|
+
|
|
133
232
|
if (this.ctx.pluginManager) {
|
|
134
233
|
const hookResults = await this.ctx.pluginManager.executeHooks(
|
|
135
234
|
'pre_llm_call',
|
|
136
|
-
{
|
|
235
|
+
{
|
|
236
|
+
runId: runMgr.id,
|
|
237
|
+
iteration: iterationNum,
|
|
238
|
+
// Built inside the guard: a run with no plugins installed
|
|
239
|
+
// pays nothing for a projection nobody reads.
|
|
240
|
+
request: Object.freeze({
|
|
241
|
+
model: stepModel,
|
|
242
|
+
// Copied per turn, not handed over live: these are the
|
|
243
|
+
// run's own message objects, and a hook writing into
|
|
244
|
+
// one would edit the history the run is about to send.
|
|
245
|
+
messages: Object.freeze(messages.map((m) => Object.freeze({ ...m }))),
|
|
246
|
+
toolNames: Object.freeze(llmTools.map((t) => t.function.name)),
|
|
247
|
+
temperature: step.temperature ?? runConfig.temperature,
|
|
248
|
+
maxTokens: step.maxResponseTokens ?? runConfig.maxResponseTokens,
|
|
249
|
+
}),
|
|
250
|
+
},
|
|
137
251
|
this.ctx.emitEvent,
|
|
138
252
|
)
|
|
139
253
|
applyLifecycleHookResults('pre_llm_call', hookResults)
|
|
@@ -148,17 +262,18 @@ export class IterationOrchestrator {
|
|
|
148
262
|
// aggregated `ChatCompletionResponse` for the legacy
|
|
149
263
|
// downstream paths (assistantMsg construction, working
|
|
150
264
|
// state extraction, telemetry attribute stamping).
|
|
151
|
-
const { response } = yield* streamProviderTurn(
|
|
265
|
+
const { response, messageId } = yield* streamProviderTurn(
|
|
152
266
|
this.ctx.provider,
|
|
153
267
|
{
|
|
154
|
-
model,
|
|
268
|
+
model: stepModel,
|
|
155
269
|
messages,
|
|
156
|
-
tools:
|
|
157
|
-
enforceToolInputSchema,
|
|
158
|
-
toolChoice: forceFinalize &&
|
|
159
|
-
temperature: runConfig.temperature,
|
|
160
|
-
maxTokens: runConfig.maxResponseTokens,
|
|
270
|
+
tools: llmTools.length > 0 ? llmTools : undefined,
|
|
271
|
+
...(enforceToolInputSchema ? { enforceToolInputSchema } : {}),
|
|
272
|
+
toolChoice: forceFinalize && llmTools.length > 0 ? 'none' : undefined,
|
|
273
|
+
temperature: step.temperature ?? runConfig.temperature,
|
|
274
|
+
maxTokens: step.maxResponseTokens ?? runConfig.maxResponseTokens,
|
|
161
275
|
cacheControl: { type: 'auto' },
|
|
276
|
+
...(runConfig.thinking ? { thinking: runConfig.thinking } : {}),
|
|
162
277
|
// Thread the run abort into the model call so a Stop tears the
|
|
163
278
|
// in-flight turn down (provider passes it to fetch; the consumer
|
|
164
279
|
// also races it). Inert when never aborted.
|
|
@@ -170,14 +285,31 @@ export class IterationOrchestrator {
|
|
|
170
285
|
iterationNum,
|
|
171
286
|
forceFinalize,
|
|
172
287
|
this.ctx.log,
|
|
288
|
+
iterSpan,
|
|
173
289
|
)
|
|
174
290
|
|
|
175
|
-
|
|
291
|
+
// Main-loop turn: also records the prompt size compaction reads.
|
|
292
|
+
runMgr.recordTurnUsage(response.usage)
|
|
293
|
+
|
|
294
|
+
// The turn went through, so the run is not sitting on an
|
|
295
|
+
// irreducible prompt any more. Re-arm relief for the next one.
|
|
296
|
+
overflowRelieved = false
|
|
176
297
|
|
|
177
298
|
if (this.ctx.pluginManager) {
|
|
178
299
|
const hookResults = await this.ctx.pluginManager.executeHooks(
|
|
179
300
|
'post_llm_call',
|
|
180
|
-
{
|
|
301
|
+
{
|
|
302
|
+
runId: runMgr.id,
|
|
303
|
+
iteration: iterationNum,
|
|
304
|
+
response: Object.freeze({
|
|
305
|
+
content: response.message.content,
|
|
306
|
+
toolNames: Object.freeze(
|
|
307
|
+
(response.message.toolCalls ?? []).map((c) => c.function.name),
|
|
308
|
+
),
|
|
309
|
+
finishReason: response.finishReason,
|
|
310
|
+
usage: Object.freeze({ ...response.usage }),
|
|
311
|
+
}),
|
|
312
|
+
},
|
|
181
313
|
this.ctx.emitEvent,
|
|
182
314
|
)
|
|
183
315
|
applyLifecycleHookResults('post_llm_call', hookResults)
|
|
@@ -203,9 +335,18 @@ export class IterationOrchestrator {
|
|
|
203
335
|
cost: runMgr.costInfo,
|
|
204
336
|
})
|
|
205
337
|
|
|
338
|
+
// Reasoning rides along with the turn it belongs to, so the
|
|
339
|
+
// replay contract holds automatically: trimming or compacting
|
|
340
|
+
// the assistant message takes its thinking blocks with it,
|
|
341
|
+
// and no separate atomicity rule is needed.
|
|
206
342
|
const assistantMsg = createAssistantMessage(
|
|
207
343
|
response.message.content,
|
|
208
344
|
forceFinalize ? undefined : response.message.toolCalls,
|
|
345
|
+
response.message.reasoning,
|
|
346
|
+
// Rides with the turn it belongs to, like reasoning does, so
|
|
347
|
+
// trimming or compacting the turn takes its evidence with it
|
|
348
|
+
// rather than leaving citations pointing at prose that is gone.
|
|
349
|
+
response.message.citations,
|
|
209
350
|
)
|
|
210
351
|
runMgr.pushMessage(assistantMsg)
|
|
211
352
|
|
|
@@ -232,12 +373,24 @@ export class IterationOrchestrator {
|
|
|
232
373
|
})
|
|
233
374
|
}
|
|
234
375
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
376
|
+
// Tool calls beat the finish reason. The reason is the
|
|
377
|
+
// provider's SUMMARY of the turn and the tool calls are the
|
|
378
|
+
// turn itself, so when they disagree the calls are the fact.
|
|
379
|
+
// Several function-calling endpoints — gateways and local servers
|
|
380
|
+
// especially — report `stop` alongside a populated
|
|
381
|
+
// `tool_calls`, and three of this repo's drivers pass that
|
|
382
|
+
// value through untouched.
|
|
383
|
+
//
|
|
384
|
+
// Reading `stop` first meant the turn ended with every
|
|
385
|
+
// requested call silently skipped, an assistant message
|
|
386
|
+
// carrying tool_use blocks that were never answered, and a
|
|
387
|
+
// run that settled `end_turn` having done nothing it was
|
|
388
|
+
// asked to do. Checking the calls first costs nothing when
|
|
389
|
+
// the provider is honest and is the only thing that saves the
|
|
390
|
+
// run when it is not.
|
|
391
|
+
const hasToolCalls = (response.message.toolCalls?.length ?? 0) > 0
|
|
392
|
+
|
|
393
|
+
if (forceFinalize || !hasToolCalls) {
|
|
241
394
|
// Every task-dispatch tool (create_task, continue_task, Agent)
|
|
242
395
|
// is BLOCKING: the worker's output returns as the dispatching
|
|
243
396
|
// tool_use's canonical tool_result, so by the time the model
|
|
@@ -268,11 +421,11 @@ export class IterationOrchestrator {
|
|
|
268
421
|
// another turn. The provider receives the partial
|
|
269
422
|
// assistant content + the continue prompt and
|
|
270
423
|
// resumes from where it left off, mirroring the
|
|
271
|
-
//
|
|
424
|
+
// Auto-continuation after an output-ceiling cutoff.
|
|
272
425
|
//
|
|
273
426
|
// Guards:
|
|
274
427
|
// - `hasContent` so we don't loop forever on an
|
|
275
|
-
// empty cutoff (
|
|
428
|
+
// empty cutoff (a provider occasionally emits
|
|
276
429
|
// `stop_reason: max_tokens` with no content
|
|
277
430
|
// when an injected pre-fill blocks the model).
|
|
278
431
|
// - `!forceFinalize` so the forced-finalize path
|
|
@@ -297,6 +450,86 @@ export class IterationOrchestrator {
|
|
|
297
450
|
continue
|
|
298
451
|
}
|
|
299
452
|
|
|
453
|
+
// The model tried to finish in prose while a structured
|
|
454
|
+
// output was demanded. Send it back with the schema error
|
|
455
|
+
// rather than returning an unusable result — this is the
|
|
456
|
+
// re-prompt half, and it is bounded so a model that cannot
|
|
457
|
+
// satisfy the schema fails loudly instead of looping.
|
|
458
|
+
if (!forceFinalize && this.needsStructuredOutput()) {
|
|
459
|
+
const attempt = ++this.structuredOutputAttempts
|
|
460
|
+
const limit = this.structuredOutputRetryLimit()
|
|
461
|
+
if (attempt > limit) {
|
|
462
|
+
this.ctx.log.warn('Structured output not produced within its retries', {
|
|
463
|
+
runId: runMgr.id,
|
|
464
|
+
attempts: attempt - 1,
|
|
465
|
+
})
|
|
466
|
+
runMgr.setStopReason('structured_output_failed')
|
|
467
|
+
iterSpan.end()
|
|
468
|
+
break
|
|
469
|
+
}
|
|
470
|
+
this.ctx.log.info('Re-prompting for structured output', {
|
|
471
|
+
runId: runMgr.id,
|
|
472
|
+
attempt,
|
|
473
|
+
limit,
|
|
474
|
+
})
|
|
475
|
+
runMgr.pushMessage(createUserMessage(STRUCTURED_OUTPUT_REPROMPT))
|
|
476
|
+
await this.ctx.emitEvent({
|
|
477
|
+
type: 'iteration_completed',
|
|
478
|
+
runId: runMgr.id,
|
|
479
|
+
iteration: iterationNum,
|
|
480
|
+
hasToolCalls: false,
|
|
481
|
+
})
|
|
482
|
+
yield* this.ctx.drainPending()
|
|
483
|
+
iterSpan.end()
|
|
484
|
+
continue
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// Let the host judge the ANSWER and hand back work.
|
|
488
|
+
//
|
|
489
|
+
// The stop predicate is only consulted after tools ran, so
|
|
490
|
+
// there was no seam here at all: the moment the model
|
|
491
|
+
// stopped calling tools the run finalized, whatever it had
|
|
492
|
+
// produced. Verify-then-fix — run the build, feed the
|
|
493
|
+
// failure back, let it try again — meant starting a whole
|
|
494
|
+
// new run and re-supplying the context the first one had.
|
|
495
|
+
//
|
|
496
|
+
// Shaped after the structured-output re-prompt directly
|
|
497
|
+
// above, which solves the same problem for one specific
|
|
498
|
+
// judge: bounded attempts, feedback as a user message, and
|
|
499
|
+
// a loud stop rather than a loop.
|
|
500
|
+
if (!forceFinalize && this.ctx.reviewAnswer) {
|
|
501
|
+
const review = await this.reviewAnswer(response.message.content ?? '')
|
|
502
|
+
if (review && !review.accept) {
|
|
503
|
+
const attempt = ++this.answerReviewAttempts
|
|
504
|
+
const limit = this.ctx.maxAnswerReviews ?? DEFAULT_ANSWER_REVIEW_LIMIT
|
|
505
|
+
if (attempt > limit) {
|
|
506
|
+
this.ctx.log.warn('Answer rejected more times than the run allows', {
|
|
507
|
+
runId: runMgr.id,
|
|
508
|
+
attempts: attempt - 1,
|
|
509
|
+
limit,
|
|
510
|
+
})
|
|
511
|
+
runMgr.setStopReason('answer_rejected')
|
|
512
|
+
iterSpan.end()
|
|
513
|
+
break
|
|
514
|
+
}
|
|
515
|
+
this.ctx.log.info('Answer rejected — returning it to the model', {
|
|
516
|
+
runId: runMgr.id,
|
|
517
|
+
attempt,
|
|
518
|
+
limit,
|
|
519
|
+
})
|
|
520
|
+
runMgr.pushMessage(createUserMessage(review.feedback))
|
|
521
|
+
await this.ctx.emitEvent({
|
|
522
|
+
type: 'iteration_completed',
|
|
523
|
+
runId: runMgr.id,
|
|
524
|
+
iteration: iterationNum,
|
|
525
|
+
hasToolCalls: false,
|
|
526
|
+
})
|
|
527
|
+
yield* this.ctx.drainPending()
|
|
528
|
+
iterSpan.end()
|
|
529
|
+
continue
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
300
533
|
if (!hasContent && !forceFinalize) {
|
|
301
534
|
this.ctx.log.warn('Empty completion detected — requesting final summary', {
|
|
302
535
|
iteration: iterationNum,
|
|
@@ -330,16 +563,98 @@ export class IterationOrchestrator {
|
|
|
330
563
|
|
|
331
564
|
const reviewOutcome = yield* runToolReview(this.ctx, response, iterationNum)
|
|
332
565
|
|
|
333
|
-
|
|
566
|
+
// The step record is built even for a rejected batch: a run that
|
|
567
|
+
// spent a turn getting its tools refused still spent the tokens,
|
|
568
|
+
// and a caller reconstructing cost per step must see it.
|
|
569
|
+
this.recordStep({
|
|
570
|
+
stepNumber: iterationNum,
|
|
571
|
+
model,
|
|
572
|
+
messageId,
|
|
573
|
+
response,
|
|
574
|
+
toolResults: reviewOutcome.results,
|
|
575
|
+
toolExecutionMs: reviewOutcome.durationMs,
|
|
576
|
+
startedAt: stepStartedAt,
|
|
577
|
+
usageBefore,
|
|
578
|
+
costBefore,
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
if (reviewOutcome.decision === 'stop') {
|
|
334
582
|
iterSpan.end()
|
|
335
583
|
return
|
|
336
584
|
}
|
|
337
585
|
|
|
338
|
-
if (reviewOutcome === 'rejected') {
|
|
586
|
+
if (reviewOutcome.decision === 'rejected') {
|
|
339
587
|
iterSpan.end()
|
|
340
588
|
continue
|
|
341
589
|
}
|
|
342
590
|
|
|
591
|
+
// A successful `structured_output` call IS the answer, so the
|
|
592
|
+
// run ends here rather than paying for another turn whose only
|
|
593
|
+
// job would be to restate it.
|
|
594
|
+
if (this.captureStructuredOutput(reviewOutcome.results)) {
|
|
595
|
+
this.ctx.log.info('Structured output produced — ending run', {
|
|
596
|
+
runId: runMgr.id,
|
|
597
|
+
iteration: iterationNum,
|
|
598
|
+
})
|
|
599
|
+
runMgr.setStopReason('end_turn')
|
|
600
|
+
await this.ctx.emitEvent({
|
|
601
|
+
type: 'iteration_completed',
|
|
602
|
+
runId: runMgr.id,
|
|
603
|
+
iteration: iterationNum,
|
|
604
|
+
hasToolCalls: true,
|
|
605
|
+
})
|
|
606
|
+
yield* this.ctx.drainPending()
|
|
607
|
+
iterSpan.end()
|
|
608
|
+
break
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// A tool the author declared terminal settles the run with its
|
|
612
|
+
// own output, the same rule `structured_output` has always
|
|
613
|
+
// had. Without it a delegation cost the parent one more model
|
|
614
|
+
// call at full context whose only job was to restate what the
|
|
615
|
+
// worker already said — and to restate it through the parent's
|
|
616
|
+
// compacted view, so the caller did not even receive the
|
|
617
|
+
// worker's words.
|
|
618
|
+
const settled = this.terminalToolOutput(reviewOutcome.results, response)
|
|
619
|
+
if (settled !== undefined) {
|
|
620
|
+
this.ctx.log.info('Terminal tool produced the answer — ending run', {
|
|
621
|
+
runId: runMgr.id,
|
|
622
|
+
iteration: iterationNum,
|
|
623
|
+
tool: settled.toolName,
|
|
624
|
+
})
|
|
625
|
+
runMgr.setResult(settled.output)
|
|
626
|
+
runMgr.setStopReason('end_turn')
|
|
627
|
+
await this.ctx.emitEvent({
|
|
628
|
+
type: 'iteration_completed',
|
|
629
|
+
runId: runMgr.id,
|
|
630
|
+
iteration: iterationNum,
|
|
631
|
+
hasToolCalls: true,
|
|
632
|
+
})
|
|
633
|
+
yield* this.ctx.drainPending()
|
|
634
|
+
iterSpan.end()
|
|
635
|
+
break
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// Evaluated AFTER the tools ran, so a predicate can see what they
|
|
639
|
+
// returned — which is what makes a terminal submit_answer tool
|
|
640
|
+
// usable without discarding its output.
|
|
641
|
+
if (await this.shouldStop()) {
|
|
642
|
+
this.ctx.log.info('Stop condition met', {
|
|
643
|
+
runId: runMgr.id,
|
|
644
|
+
iteration: iterationNum,
|
|
645
|
+
})
|
|
646
|
+
runMgr.setStopReason('stop_condition')
|
|
647
|
+
await this.ctx.emitEvent({
|
|
648
|
+
type: 'iteration_completed',
|
|
649
|
+
runId: runMgr.id,
|
|
650
|
+
iteration: iterationNum,
|
|
651
|
+
hasToolCalls: true,
|
|
652
|
+
})
|
|
653
|
+
yield* this.ctx.drainPending()
|
|
654
|
+
iterSpan.end()
|
|
655
|
+
break
|
|
656
|
+
}
|
|
657
|
+
|
|
343
658
|
const checkpointSignal = yield* runIterationCheckpoint(this.ctx, iterationNum)
|
|
344
659
|
if (checkpointSignal === 'stop') {
|
|
345
660
|
iterSpan.end()
|
|
@@ -381,6 +696,37 @@ export class IterationOrchestrator {
|
|
|
381
696
|
break
|
|
382
697
|
}
|
|
383
698
|
|
|
699
|
+
// The one provider failure the kernel can actually do something
|
|
700
|
+
// about. `context_length_exceeded` is correctly non-retryable —
|
|
701
|
+
// resending the identical prompt cannot help — but the kernel
|
|
702
|
+
// owns a compaction subsystem that can make the prompt smaller.
|
|
703
|
+
// Without this the run died holding the remedy: the threshold
|
|
704
|
+
// path had simply guessed low, which a run carrying images or a
|
|
705
|
+
// language the chars-per-token ratio does not fit will do.
|
|
706
|
+
//
|
|
707
|
+
// Relief is attempted ONCE per iteration and only when it
|
|
708
|
+
// actually shed something. A second overflow after a successful
|
|
709
|
+
// compaction means the prompt is irreducible, and looping on it
|
|
710
|
+
// would burn the budget to arrive at the same error.
|
|
711
|
+
if (
|
|
712
|
+
!overflowRelieved &&
|
|
713
|
+
classifyProviderError(err, this.ctx.provider.id).code === 'context_length_exceeded'
|
|
714
|
+
) {
|
|
715
|
+
overflowRelieved = true
|
|
716
|
+
const shed = await relieveOverflow(this.ctx)
|
|
717
|
+
if (shed) {
|
|
718
|
+
this.ctx.log.info('Retrying the turn after relieving a context overflow', {
|
|
719
|
+
runId: runMgr.id,
|
|
720
|
+
iteration: iterationNum,
|
|
721
|
+
})
|
|
722
|
+
if (iterationActivity) {
|
|
723
|
+
this.ctx.activityStore.complete(iterationActivity.id)
|
|
724
|
+
}
|
|
725
|
+
iterSpan.end()
|
|
726
|
+
continue
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
384
730
|
if (iterationActivity) {
|
|
385
731
|
this.ctx.activityStore.fail(iterationActivity.id, toErrorMessage(err))
|
|
386
732
|
}
|
|
@@ -396,6 +742,274 @@ export class IterationOrchestrator {
|
|
|
396
742
|
}
|
|
397
743
|
}
|
|
398
744
|
|
|
745
|
+
/**
|
|
746
|
+
* Ask the host how to shape this step.
|
|
747
|
+
*
|
|
748
|
+
* Fails OPEN on a throw — same reasoning as `stopWhen` and deliberately
|
|
749
|
+
* opposite to a guardrail: a broken step-shaping hook should not kill an
|
|
750
|
+
* otherwise healthy run, and unlike a safety check, nothing unsafe gets
|
|
751
|
+
* through when it is skipped.
|
|
752
|
+
*/
|
|
753
|
+
private async prepareStep(stepNumber: number): Promise<{
|
|
754
|
+
allowedTools?: string[]
|
|
755
|
+
model?: string
|
|
756
|
+
system?: string
|
|
757
|
+
temperature?: number
|
|
758
|
+
maxResponseTokens?: number
|
|
759
|
+
}> {
|
|
760
|
+
const configured = this.ctx.prepareStep
|
|
761
|
+
if (!configured) return {}
|
|
762
|
+
const stages = Array.isArray(configured) ? configured : [configured]
|
|
763
|
+
|
|
764
|
+
// Folded in DECLARATION order, each stage seeing what the ones
|
|
765
|
+
// before it decided. A later stage overriding a field is last-writer
|
|
766
|
+
// wins — visibly, because the order is a line in the host's code
|
|
767
|
+
// rather than an accident of install history.
|
|
768
|
+
let result: PrepareStepResult = {}
|
|
769
|
+
for (const stage of stages) {
|
|
770
|
+
try {
|
|
771
|
+
const decided = await stage({
|
|
772
|
+
runId: this.ctx.runMgr.id,
|
|
773
|
+
stepNumber,
|
|
774
|
+
messages: this.ctx.runMgr.messages,
|
|
775
|
+
steps: this.steps,
|
|
776
|
+
prepared: result,
|
|
777
|
+
})
|
|
778
|
+
if (decided) result = { ...result, ...decided }
|
|
779
|
+
} catch (err) {
|
|
780
|
+
// Skipped, and the rest still run: one broken concern must
|
|
781
|
+
// not silently disable the others it was declared beside.
|
|
782
|
+
this.ctx.log.error('a prepareStep stage threw — skipping it', {
|
|
783
|
+
runId: this.ctx.runMgr.id,
|
|
784
|
+
stepNumber,
|
|
785
|
+
error: toErrorMessage(err),
|
|
786
|
+
})
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
const prepared: {
|
|
791
|
+
allowedTools?: string[]
|
|
792
|
+
model?: string
|
|
793
|
+
system?: string
|
|
794
|
+
temperature?: number
|
|
795
|
+
maxResponseTokens?: number
|
|
796
|
+
} = {}
|
|
797
|
+
|
|
798
|
+
if (result.activeTools) {
|
|
799
|
+
// A phase list that outlives a tool rename should narrow the
|
|
800
|
+
// surface, not kill the agent mid-run.
|
|
801
|
+
const known = result.activeTools.filter((name: string) => this.ctx.tools.has(name))
|
|
802
|
+
const unknown = result.activeTools.filter((name: string) => !this.ctx.tools.has(name))
|
|
803
|
+
if (unknown.length > 0) {
|
|
804
|
+
this.ctx.log.warn('prepareStep named tools that are not registered — ignoring them', {
|
|
805
|
+
runId: this.ctx.runMgr.id,
|
|
806
|
+
stepNumber,
|
|
807
|
+
unknown,
|
|
808
|
+
})
|
|
809
|
+
}
|
|
810
|
+
prepared.allowedTools = known
|
|
811
|
+
}
|
|
812
|
+
if (result.model !== undefined) prepared.model = result.model
|
|
813
|
+
if (result.system !== undefined) prepared.system = result.system
|
|
814
|
+
if (result.temperature !== undefined) prepared.temperature = result.temperature
|
|
815
|
+
if (result.maxResponseTokens !== undefined) {
|
|
816
|
+
prepared.maxResponseTokens = result.maxResponseTokens
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
return prepared
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** Steps completed so far, exposed on the returned `Run`. */
|
|
823
|
+
private readonly steps: StepResult[] = []
|
|
824
|
+
|
|
825
|
+
getSteps(): readonly StepResult[] {
|
|
826
|
+
return this.steps
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Fold one iteration into a `StepResult`.
|
|
831
|
+
*
|
|
832
|
+
* Every field here was already computed somewhere in the loop; the only
|
|
833
|
+
* new work is subtracting the cumulative counters so the step carries
|
|
834
|
+
* ITS usage rather than the run's running total, which is the number a
|
|
835
|
+
* caller asking "what did this step cost" actually wants.
|
|
836
|
+
*/
|
|
837
|
+
private recordStep(input: {
|
|
838
|
+
stepNumber: number
|
|
839
|
+
model: string
|
|
840
|
+
messageId: MessageId
|
|
841
|
+
response: ChatCompletionResponse
|
|
842
|
+
toolResults: readonly ToolCallOutcome[]
|
|
843
|
+
toolExecutionMs: number
|
|
844
|
+
startedAt: number
|
|
845
|
+
usageBefore: TokenUsage
|
|
846
|
+
costBefore: CostInfo
|
|
847
|
+
}): void {
|
|
848
|
+
const { runMgr } = this.ctx
|
|
849
|
+
const toolCalls = input.response.message.toolCalls ?? []
|
|
850
|
+
const byId = new Map(input.toolResults.map((r) => [r.toolCallId, r]))
|
|
851
|
+
|
|
852
|
+
const step: StepResult = {
|
|
853
|
+
stepNumber: input.stepNumber,
|
|
854
|
+
model: input.model,
|
|
855
|
+
messageId: input.messageId,
|
|
856
|
+
content: input.response.message.content,
|
|
857
|
+
toolCalls,
|
|
858
|
+
// Ordered by the tool CALLS, not by completion, so the record
|
|
859
|
+
// matches what the model asked for.
|
|
860
|
+
toolResults: toolCalls.map((tc) => {
|
|
861
|
+
const outcome = byId.get(tc.id)
|
|
862
|
+
return {
|
|
863
|
+
toolCallId: tc.id,
|
|
864
|
+
toolName: tc.function.name,
|
|
865
|
+
output: outcome?.output ?? '',
|
|
866
|
+
isError: outcome?.isError ?? false,
|
|
867
|
+
durationMs: 0,
|
|
868
|
+
}
|
|
869
|
+
}),
|
|
870
|
+
finishReason: input.response.finishReason,
|
|
871
|
+
usage: subtractUsage(runMgr.tokenUsage, input.usageBefore),
|
|
872
|
+
costDelta: {
|
|
873
|
+
...runMgr.costInfo,
|
|
874
|
+
totalCost: round6(runMgr.costInfo.totalCost - input.costBefore.totalCost),
|
|
875
|
+
},
|
|
876
|
+
startedAt: input.startedAt,
|
|
877
|
+
durationMs: Date.now() - input.startedAt,
|
|
878
|
+
toolExecutionMs: input.toolExecutionMs,
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
this.steps.push(step)
|
|
882
|
+
this.ctx.onStepFinish?.(step)
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/** Turns spent asking the model again for a valid structured output. */
|
|
886
|
+
private structuredOutputAttempts = 0
|
|
887
|
+
private structuredOutputDone = false
|
|
888
|
+
|
|
889
|
+
private structuredOutputRetryLimit(): number {
|
|
890
|
+
return this.ctx.structuredOutput?.maxRetries ?? DEFAULT_STRUCTURED_OUTPUT_RETRIES
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** True while a structured output was demanded and has not arrived. */
|
|
894
|
+
private needsStructuredOutput(): boolean {
|
|
895
|
+
return this.ctx.structuredOutput !== undefined && !this.structuredOutputDone
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Record the structured output if this batch produced one.
|
|
900
|
+
*
|
|
901
|
+
* The tool validates against the Zod schema before its `execute` runs,
|
|
902
|
+
* so reaching here successfully means the value is already valid — a
|
|
903
|
+
* failed parse comes back as an error result and simply does not
|
|
904
|
+
* satisfy the demand, which sends the loop round again.
|
|
905
|
+
*/
|
|
906
|
+
/**
|
|
907
|
+
* The answer a terminal tool produced, or `undefined` to keep looping.
|
|
908
|
+
*
|
|
909
|
+
* Deliberately narrow. A terminal call decides the run only when it is
|
|
910
|
+
* the ONLY call the model made in that turn: a model that asked for
|
|
911
|
+
* other work meant to see those results, and settling here would throw
|
|
912
|
+
* away answers it requested. Same for a failed terminal call — an
|
|
913
|
+
* error is not an answer, and the model is the one that should read
|
|
914
|
+
* it. Both cases fall through to the ordinary path, and both say so in
|
|
915
|
+
* the log rather than quietly costing the relay the flag was set to
|
|
916
|
+
* avoid.
|
|
917
|
+
*/
|
|
918
|
+
private terminalToolOutput(
|
|
919
|
+
results: readonly ToolCallOutcome[],
|
|
920
|
+
response: ChatCompletionResponse,
|
|
921
|
+
): ToolCallOutcome | undefined {
|
|
922
|
+
const terminal = results.filter((r) => this.ctx.tools.get(r.toolName)?.terminal === true)
|
|
923
|
+
if (terminal.length === 0) return undefined
|
|
924
|
+
|
|
925
|
+
const callCount = response.message.toolCalls?.length ?? 0
|
|
926
|
+
if (callCount > 1) {
|
|
927
|
+
this.ctx.log.info('Terminal tool shared its turn — relaying instead of settling', {
|
|
928
|
+
runId: this.ctx.runMgr.id,
|
|
929
|
+
tool: terminal[0]?.toolName,
|
|
930
|
+
callsInTurn: callCount,
|
|
931
|
+
})
|
|
932
|
+
return undefined
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
const hit = terminal[0]
|
|
936
|
+
if (!hit || hit.isError) {
|
|
937
|
+
this.ctx.log.info('Terminal tool failed — returning the error to the model', {
|
|
938
|
+
runId: this.ctx.runMgr.id,
|
|
939
|
+
tool: hit?.toolName,
|
|
940
|
+
})
|
|
941
|
+
return undefined
|
|
942
|
+
}
|
|
943
|
+
return hit
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
private captureStructuredOutput(results: readonly ToolCallOutcome[]): boolean {
|
|
947
|
+
if (!this.needsStructuredOutput()) return false
|
|
948
|
+
const hit = results.find((r) => r.toolName === STRUCTURED_OUTPUT_TOOL_NAME && !r.isError)
|
|
949
|
+
if (!hit) return false
|
|
950
|
+
try {
|
|
951
|
+
this.ctx.runMgr.setStructuredOutput(JSON.parse(hit.output))
|
|
952
|
+
} catch {
|
|
953
|
+
// The tool serializes its own validated input, so this is
|
|
954
|
+
// unreachable in practice; keep the raw text rather than losing it.
|
|
955
|
+
this.ctx.runMgr.setStructuredOutput(hit.output)
|
|
956
|
+
}
|
|
957
|
+
this.structuredOutputDone = true
|
|
958
|
+
return true
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Ask the host whether this answer is good enough.
|
|
963
|
+
*
|
|
964
|
+
* A hook that throws **accepts**, which is the opposite of what the
|
|
965
|
+
* safety gates do, and deliberately so. Those are asked "is this
|
|
966
|
+
* dangerous", where the cost of failing closed is one refused
|
|
967
|
+
* operation. This is asked "is this good enough", where failing closed
|
|
968
|
+
* means handing the answer back forever — so a broken judge would turn
|
|
969
|
+
* every run into a loop that ends on a budget error naming nothing. One
|
|
970
|
+
* unreviewed answer is the cheaper failure, and the throw is logged at
|
|
971
|
+
* `error` so it is not mistaken for approval.
|
|
972
|
+
*/
|
|
973
|
+
private async reviewAnswer(answer: string): Promise<AnswerReview | undefined> {
|
|
974
|
+
if (!this.ctx.reviewAnswer) return undefined
|
|
975
|
+
try {
|
|
976
|
+
return await this.ctx.reviewAnswer(answer, {
|
|
977
|
+
runId: this.ctx.runMgr.id,
|
|
978
|
+
iteration: this.ctx.runMgr.currentIteration,
|
|
979
|
+
messages: this.ctx.runMgr.messages,
|
|
980
|
+
})
|
|
981
|
+
} catch (err) {
|
|
982
|
+
this.ctx.log.error('Answer review threw — accepting the answer unreviewed', {
|
|
983
|
+
runId: this.ctx.runMgr.id,
|
|
984
|
+
error: toErrorMessage(err),
|
|
985
|
+
})
|
|
986
|
+
return { accept: true }
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/** Evaluate the caller's halt predicate, if there is one. */
|
|
991
|
+
private async shouldStop(): Promise<boolean> {
|
|
992
|
+
const stopWhen = this.ctx.stopWhen
|
|
993
|
+
const latestStep = this.steps.at(-1)
|
|
994
|
+
if (!stopWhen || !latestStep) return false
|
|
995
|
+
try {
|
|
996
|
+
return await stopWhen({
|
|
997
|
+
steps: this.steps,
|
|
998
|
+
latestStep,
|
|
999
|
+
totalUsage: this.ctx.runMgr.tokenUsage,
|
|
1000
|
+
totalCost: this.ctx.runMgr.costInfo,
|
|
1001
|
+
})
|
|
1002
|
+
} catch (err) {
|
|
1003
|
+
// A throwing predicate must not kill a run that is otherwise
|
|
1004
|
+
// healthy; failing open keeps the existing budgets in charge.
|
|
1005
|
+
this.ctx.log.error('Stop condition threw — continuing the run', {
|
|
1006
|
+
runId: this.ctx.runMgr.id,
|
|
1007
|
+
error: toErrorMessage(err),
|
|
1008
|
+
})
|
|
1009
|
+
return false
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
399
1013
|
private hasRunningAgentTasks(): boolean {
|
|
400
1014
|
if (!this.ctx.taskGateway) return false
|
|
401
1015
|
return this.ctx.taskGateway
|
|
@@ -431,17 +1045,18 @@ export class IterationOrchestrator {
|
|
|
431
1045
|
// tools param identical to prior iterations (cache prefix intact,
|
|
432
1046
|
// no 400 on tool blocks in history) and forbid use via tool_choice.
|
|
433
1047
|
const finalTools = this.ctx.tools.toLLMTools(this.ctx.allowedTools)
|
|
434
|
-
const
|
|
1048
|
+
const finalEnforced = enforcedModelInputToolNames(this.ctx.tools, finalTools)
|
|
435
1049
|
const response = await collect(
|
|
436
1050
|
this.ctx.provider.chatStream({
|
|
437
1051
|
model,
|
|
438
1052
|
messages: finalMessages,
|
|
439
1053
|
tools: finalTools.length > 0 ? finalTools : undefined,
|
|
440
|
-
enforceToolInputSchema,
|
|
1054
|
+
...(finalEnforced ? { enforceToolInputSchema: finalEnforced } : {}),
|
|
441
1055
|
toolChoice: finalTools.length > 0 ? 'none' : undefined,
|
|
442
1056
|
temperature: this.ctx.runConfig.temperature,
|
|
443
1057
|
maxTokens: this.ctx.runConfig.maxResponseTokens,
|
|
444
1058
|
cacheControl: { type: 'auto' },
|
|
1059
|
+
...(this.ctx.runConfig.thinking ? { thinking: this.ctx.runConfig.thinking } : {}),
|
|
445
1060
|
// Cancellable too: a Stop during the closing summary must not
|
|
446
1061
|
// stream to completion.
|
|
447
1062
|
signal: this.ctx.abortController.signal,
|
|
@@ -477,6 +1092,34 @@ export class IterationOrchestrator {
|
|
|
477
1092
|
}
|
|
478
1093
|
}
|
|
479
1094
|
|
|
1095
|
+
/** Per-step usage: the delta between two cumulative snapshots. */
|
|
1096
|
+
function subtractUsage(after: TokenUsage, before: TokenUsage): TokenUsage {
|
|
1097
|
+
return {
|
|
1098
|
+
promptTokens: after.promptTokens - before.promptTokens,
|
|
1099
|
+
completionTokens: after.completionTokens - before.completionTokens,
|
|
1100
|
+
totalTokens: after.totalTokens - before.totalTokens,
|
|
1101
|
+
cachedTokens: (after.cachedTokens ?? 0) - (before.cachedTokens ?? 0),
|
|
1102
|
+
cacheWriteTokens: (after.cacheWriteTokens ?? 0) - (before.cacheWriteTokens ?? 0),
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
/** Cost deltas are subtractions of floats; keep them presentable. */
|
|
1107
|
+
function round6(n: number): number {
|
|
1108
|
+
return Math.round(n * 1e6) / 1e6
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Which of the tools going out on this request have a closed model schema.
|
|
1113
|
+
*
|
|
1114
|
+
* A driver reads `enforceToolInputSchema` to decide which tool schemas to
|
|
1115
|
+
* constrain generation against. Nothing populated it, so every driver that
|
|
1116
|
+
* consumed it — three of them — was reading a permanently undefined field
|
|
1117
|
+
* and `enforceModelInput: true` on a tool meant nothing end to end.
|
|
1118
|
+
*
|
|
1119
|
+
* Computed per request rather than once, because the allowed set changes:
|
|
1120
|
+
* a deferred tool activated mid-run has to start being enforced from the
|
|
1121
|
+
* next call, not the next process.
|
|
1122
|
+
*/
|
|
480
1123
|
function enforcedModelInputToolNames(
|
|
481
1124
|
registry: ToolRegistryContract,
|
|
482
1125
|
tools: readonly LLMToolSchema[],
|