@namzu/sdk 46.0.0 → 48.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +325 -8
- package/README.md +7 -8
- package/dist/advisory/history.d.ts.map +1 -1
- package/dist/advisory/history.js +21 -1
- package/dist/advisory/history.js.map +1 -1
- package/dist/advisory/index.d.ts +1 -1
- package/dist/advisory/index.d.ts.map +1 -1
- package/dist/advisory/index.js +1 -1
- package/dist/advisory/index.js.map +1 -1
- package/dist/advisory/registry.d.ts +17 -0
- package/dist/advisory/registry.d.ts.map +1 -1
- package/dist/advisory/registry.js +26 -0
- package/dist/advisory/registry.js.map +1 -1
- package/dist/agents/PipelineAgent.d.ts +2 -46
- package/dist/agents/PipelineAgent.d.ts.map +1 -1
- package/dist/agents/PipelineAgent.js +2 -242
- package/dist/agents/PipelineAgent.js.map +1 -1
- package/dist/agents/QueryAgent.d.ts +21 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -0
- package/dist/agents/QueryAgent.js +214 -0
- package/dist/agents/QueryAgent.js.map +1 -0
- package/dist/agents/ReactiveAgent.d.ts +4 -16
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +4 -183
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts +2 -20
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +2 -266
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts +3 -43
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +3 -418
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/defineAgent.d.ts +2 -1
- package/dist/agents/defineAgent.d.ts.map +1 -1
- package/dist/agents/defineAgent.js +6 -1
- package/dist/agents/defineAgent.js.map +1 -1
- package/dist/agents/examples/PipelineAgent.d.ts +46 -0
- package/dist/agents/examples/PipelineAgent.d.ts.map +1 -0
- package/dist/agents/examples/PipelineAgent.js +242 -0
- package/dist/agents/examples/PipelineAgent.js.map +1 -0
- package/dist/agents/examples/RouterAgent.d.ts +22 -0
- package/dist/agents/examples/RouterAgent.d.ts.map +1 -0
- package/dist/agents/examples/RouterAgent.js +268 -0
- package/dist/agents/examples/RouterAgent.js.map +1 -0
- package/dist/agents/examples/SupervisorAgent.d.ts +45 -0
- package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -0
- package/dist/agents/examples/SupervisorAgent.js +406 -0
- package/dist/agents/examples/SupervisorAgent.js.map +1 -0
- package/dist/agents/explore.d.ts +6 -3
- package/dist/agents/explore.d.ts.map +1 -1
- package/dist/agents/explore.js +6 -3
- package/dist/agents/explore.js.map +1 -1
- package/dist/agents/forward-options.d.ts +11 -0
- package/dist/agents/forward-options.d.ts.map +1 -0
- package/dist/agents/forward-options.js +15 -0
- package/dist/agents/forward-options.js.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +2 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/runAgent.d.ts +19 -8
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +99 -29
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/authorization/command-line.d.ts +2 -0
- package/dist/authorization/command-line.d.ts.map +1 -1
- package/dist/authorization/command-line.js +2 -2
- package/dist/authorization/command-line.js.map +1 -1
- package/dist/authorization/gate.d.ts +8 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +12 -1
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/program.d.ts +151 -0
- package/dist/authorization/program.d.ts.map +1 -0
- package/dist/authorization/program.js +713 -0
- package/dist/authorization/program.js.map +1 -0
- package/dist/authorization/reexec-wrapper.d.ts +106 -0
- package/dist/authorization/reexec-wrapper.d.ts.map +1 -0
- package/dist/authorization/reexec-wrapper.js +532 -0
- package/dist/authorization/reexec-wrapper.js.map +1 -0
- package/dist/authorization/rules.d.ts +9 -0
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +8 -1
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +19 -4
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +91 -65
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +6 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/capabilities/index.d.ts +54 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +92 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/config/registry.d.ts +2 -1
- package/dist/config/registry.d.ts.map +1 -1
- package/dist/config/registry.js +3 -2
- package/dist/config/registry.js.map +1 -1
- package/dist/connector/index.d.ts +4 -4
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +3 -3
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/adapter.d.ts +16 -1
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +60 -4
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +13 -4
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +20 -3
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/discovery.d.ts +24 -1
- package/dist/connector/mcp/discovery.d.ts.map +1 -1
- package/dist/connector/mcp/discovery.js +44 -0
- package/dist/connector/mcp/discovery.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +2 -0
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +11 -0
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/mcp-toolset.d.ts +133 -0
- package/dist/connector/mcp/mcp-toolset.d.ts.map +1 -0
- package/dist/connector/mcp/mcp-toolset.js +399 -0
- package/dist/connector/mcp/mcp-toolset.js.map +1 -0
- package/dist/connector/tools/index.d.ts +2 -2
- package/dist/connector/tools/index.d.ts.map +1 -1
- package/dist/connector/tools/index.js +1 -1
- package/dist/connector/tools/index.js.map +1 -1
- package/dist/connector/tools/router.d.ts +15 -13
- package/dist/connector/tools/router.d.ts.map +1 -1
- package/dist/connector/tools/router.js +30 -51
- package/dist/connector/tools/router.js.map +1 -1
- package/dist/contracts/a2a.d.ts +2 -2
- package/dist/directory/derive-supervisor.d.ts +2 -2
- package/dist/directory/derive-supervisor.d.ts.map +1 -1
- package/dist/directory/derive-supervisor.js +6 -7
- package/dist/directory/derive-supervisor.js.map +1 -1
- package/dist/directory/derive.d.ts.map +1 -1
- package/dist/directory/derive.js +5 -5
- package/dist/directory/derive.js.map +1 -1
- package/dist/execution/code-runtime/types.d.ts +2 -2
- package/dist/execution/code-runtime/types.js +1 -1
- package/dist/invariants/index.d.ts +2 -1
- package/dist/invariants/index.d.ts.map +1 -1
- package/dist/invariants/index.js +3 -2
- package/dist/invariants/index.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +9 -0
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/connector/environment.d.ts +6 -0
- package/dist/manager/connector/environment.d.ts.map +1 -1
- package/dist/manager/connector/environment.js +11 -4
- package/dist/manager/connector/environment.js.map +1 -1
- package/dist/manager/connector/index.d.ts +2 -2
- package/dist/manager/connector/index.d.ts.map +1 -1
- package/dist/manager/connector/index.js +2 -2
- package/dist/manager/connector/index.js.map +1 -1
- package/dist/manager/connector/tenant.d.ts +6 -0
- package/dist/manager/connector/tenant.d.ts.map +1 -1
- package/dist/manager/connector/tenant.js +11 -4
- package/dist/manager/connector/tenant.js.map +1 -1
- package/dist/manager/index.d.ts +2 -2
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +2 -2
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/resident/learning-observation.d.ts +4 -4
- package/dist/manager/resident/learning.d.ts +36 -36
- package/dist/manager/session/attribution.d.ts +22 -0
- package/dist/manager/session/attribution.d.ts.map +1 -0
- package/dist/manager/session/attribution.js +64 -0
- package/dist/manager/session/attribution.js.map +1 -0
- package/dist/manager/session/turn-recorder.d.ts +14 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +208 -55
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/peers/address.d.ts +36 -0
- package/dist/peers/address.d.ts.map +1 -0
- package/dist/peers/address.js +52 -0
- package/dist/peers/address.js.map +1 -0
- package/dist/peers/client.d.ts +47 -0
- package/dist/peers/client.d.ts.map +1 -0
- package/dist/peers/client.js +132 -0
- package/dist/peers/client.js.map +1 -0
- package/dist/peers/dir.d.ts +88 -0
- package/dist/peers/dir.d.ts.map +1 -0
- package/dist/peers/dir.js +139 -0
- package/dist/peers/dir.js.map +1 -0
- package/dist/peers/endpoint.d.ts +144 -0
- package/dist/peers/endpoint.d.ts.map +1 -0
- package/dist/peers/endpoint.js +420 -0
- package/dist/peers/endpoint.js.map +1 -0
- package/dist/peers/envelope.d.ts +42 -0
- package/dist/peers/envelope.d.ts.map +1 -0
- package/dist/peers/envelope.js +110 -0
- package/dist/peers/envelope.js.map +1 -0
- package/dist/peers/index.d.ts +30 -0
- package/dist/peers/index.d.ts.map +1 -0
- package/dist/peers/index.js +22 -0
- package/dist/peers/index.js.map +1 -0
- package/dist/peers/protocol.d.ts +645 -0
- package/dist/peers/protocol.d.ts.map +1 -0
- package/dist/peers/protocol.js +151 -0
- package/dist/peers/protocol.js.map +1 -0
- package/dist/peers/record.d.ts +71 -0
- package/dist/peers/record.d.ts.map +1 -0
- package/dist/peers/record.js +45 -0
- package/dist/peers/record.js.map +1 -0
- package/dist/peers/registry.d.ts +54 -0
- package/dist/peers/registry.d.ts.map +1 -0
- package/dist/peers/registry.js +213 -0
- package/dist/peers/registry.js.map +1 -0
- package/dist/plugin/define.d.ts +24 -0
- package/dist/plugin/define.d.ts.map +1 -0
- package/dist/plugin/define.js +42 -0
- package/dist/plugin/define.js.map +1 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1 -0
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +27 -3
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +242 -92
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/resolver.d.ts +2 -2
- package/dist/plugin/resolver.d.ts.map +1 -1
- package/dist/plugin/resolver.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +17 -3
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/probe/errors.d.ts +2 -1
- package/dist/probe/errors.d.ts.map +1 -1
- package/dist/probe/errors.js +3 -2
- package/dist/probe/errors.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +18 -7
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +11 -6
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/prompt/contributions.d.ts +4 -1
- package/dist/prompt/contributions.d.ts.map +1 -1
- package/dist/prompt/contributions.js +7 -2
- package/dist/prompt/contributions.js.map +1 -1
- package/dist/prompt/index.d.ts +1 -1
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/index.js +1 -1
- package/dist/prompt/index.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts +6 -1
- package/dist/provider/collect-chat-completion.d.ts.map +1 -1
- package/dist/provider/collect-chat-completion.js +88 -10
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/mock.d.ts.map +1 -1
- package/dist/provider/mock.js +23 -6
- package/dist/provider/mock.js.map +1 -1
- package/dist/provider/registry.d.ts +2 -1
- package/dist/provider/registry.d.ts.map +1 -1
- package/dist/provider/registry.js +3 -2
- package/dist/provider/registry.js.map +1 -1
- package/dist/provider/tool-call-framing.d.ts +164 -0
- package/dist/provider/tool-call-framing.d.ts.map +1 -0
- package/dist/provider/tool-call-framing.js +163 -0
- package/dist/provider/tool-call-framing.js.map +1 -0
- package/dist/public-runtime.d.ts +24 -11
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +45 -9
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +6 -4
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +8 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +13 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/read-model/registry.d.ts +2 -1
- package/dist/read-model/registry.d.ts.map +1 -1
- package/dist/read-model/registry.js +3 -2
- package/dist/read-model/registry.js.map +1 -1
- package/dist/registry/ManagedRegistry.d.ts +30 -0
- package/dist/registry/ManagedRegistry.d.ts.map +1 -1
- package/dist/registry/ManagedRegistry.js +45 -6
- package/dist/registry/ManagedRegistry.js.map +1 -1
- package/dist/registry/collision.d.ts +57 -0
- package/dist/registry/collision.d.ts.map +1 -0
- package/dist/registry/collision.js +41 -0
- package/dist/registry/collision.js.map +1 -0
- package/dist/registry/command/index.d.ts +5 -3
- package/dist/registry/command/index.d.ts.map +1 -1
- package/dist/registry/command/index.js +6 -4
- package/dist/registry/command/index.js.map +1 -1
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +2 -2
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/plugin/index.d.ts.map +1 -1
- package/dist/registry/plugin/index.js +14 -1
- package/dist/registry/plugin/index.js.map +1 -1
- package/dist/registry/tool/callable.d.ts +7 -7
- package/dist/registry/tool/callable.d.ts.map +1 -1
- package/dist/registry/tool/callable.js +6 -7
- package/dist/registry/tool/callable.js.map +1 -1
- package/dist/registry/tool/execute.d.ts +14 -77
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +15 -727
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/portable.d.ts +25 -0
- package/dist/registry/tool/portable.d.ts.map +1 -1
- package/dist/registry/tool/portable.js +50 -0
- package/dist/registry/tool/portable.js.map +1 -1
- package/dist/registry/tool/presentation.d.ts +6 -5
- package/dist/registry/tool/presentation.d.ts.map +1 -1
- package/dist/registry/tool/presentation.js +3 -3
- package/dist/registry/tool/presentation.js.map +1 -1
- package/dist/runtime/bidi/session.d.ts +5 -4
- package/dist/runtime/bidi/session.d.ts.map +1 -1
- package/dist/runtime/bidi/session.js +18 -1
- package/dist/runtime/bidi/session.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts +45 -2
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +189 -5
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +33 -3
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +86 -10
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-replay.d.ts +1 -1
- package/dist/runtime/query/file-evidence-replay.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-replay.js +8 -7
- package/dist/runtime/query/file-evidence-replay.js.map +1 -1
- package/dist/runtime/query/fork/prepare.d.ts +4 -1
- package/dist/runtime/query/fork/prepare.d.ts.map +1 -1
- package/dist/runtime/query/fork/prepare.js +4 -0
- package/dist/runtime/query/fork/prepare.js.map +1 -1
- package/dist/runtime/query/guardrail-presets.d.ts +4 -3
- package/dist/runtime/query/guardrail-presets.d.ts.map +1 -1
- package/dist/runtime/query/guardrail-presets.js +4 -3
- package/dist/runtime/query/guardrail-presets.js.map +1 -1
- package/dist/runtime/query/index.d.ts +23 -10
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +149 -70
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +8 -1
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +2 -2
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +55 -2
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +342 -116
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/iteration/tool-input.d.ts +79 -0
- package/dist/runtime/query/iteration/tool-input.d.ts.map +1 -0
- package/dist/runtime/query/iteration/tool-input.js +291 -0
- package/dist/runtime/query/iteration/tool-input.js.map +1 -0
- package/dist/runtime/query/observation-context.d.ts +2 -2
- package/dist/runtime/query/observation-context.d.ts.map +1 -1
- package/dist/runtime/query/observation-context.js.map +1 -1
- package/dist/runtime/query/prelude-lease.d.ts +18 -0
- package/dist/runtime/query/prelude-lease.d.ts.map +1 -0
- package/dist/runtime/query/prelude-lease.js +121 -0
- package/dist/runtime/query/prelude-lease.js.map +1 -0
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
- package/dist/runtime/query/prepare-turn.js +386 -187
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/prompt-cache.d.ts +2 -2
- package/dist/runtime/query/prompt-cache.d.ts.map +1 -1
- package/dist/runtime/query/prompt.d.ts +2 -2
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +1 -1
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/resume-session.d.ts.map +1 -1
- package/dist/runtime/query/resume-session.js +37 -2
- package/dist/runtime/query/resume-session.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +22 -3
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +84 -6
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -2
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/query/turn-state.d.ts.map +1 -1
- package/dist/runtime/query/turn-state.js +5 -0
- package/dist/runtime/query/turn-state.js.map +1 -1
- package/dist/runtime/system-events.d.ts +112 -0
- package/dist/runtime/system-events.d.ts.map +1 -0
- package/dist/runtime/system-events.js +183 -0
- package/dist/runtime/system-events.js.map +1 -0
- package/dist/scheduler/delegating.d.ts +2 -1
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +3 -2
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/registry.d.ts +12 -0
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +19 -0
- package/dist/skills/registry.js.map +1 -1
- package/dist/store/evidence/index-page.d.ts +2 -2
- package/dist/store/session-log/conformance.d.ts +1 -1
- package/dist/store/session-log/conformance.d.ts.map +1 -1
- package/dist/store/session-log/conformance.js +49 -8
- package/dist/store/session-log/conformance.js.map +1 -1
- package/dist/store/session-log/core.d.ts +8 -3
- package/dist/store/session-log/core.d.ts.map +1 -1
- package/dist/store/session-log/core.js +2 -1
- package/dist/store/session-log/core.js.map +1 -1
- package/dist/store/session-log/fold.d.ts +12 -0
- package/dist/store/session-log/fold.d.ts.map +1 -1
- package/dist/store/session-log/fold.js +57 -7
- package/dist/store/session-log/fold.js.map +1 -1
- package/dist/store/session-log/index.d.ts +2 -2
- package/dist/store/session-log/index.d.ts.map +1 -1
- package/dist/store/session-log/index.js +1 -1
- package/dist/store/session-log/index.js.map +1 -1
- package/dist/test-support/toolset.d.ts +19 -0
- package/dist/test-support/toolset.d.ts.map +1 -0
- package/dist/test-support/toolset.js +20 -0
- package/dist/test-support/toolset.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts +29 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +19 -9
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-url.d.ts +1 -1
- package/dist/tools/builtins/browser-url.js +1 -1
- package/dist/tools/builtins/browser.d.ts +6 -6
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +19 -11
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +9 -1
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/json-string-hint.d.ts +15 -0
- package/dist/tools/builtins/json-string-hint.d.ts.map +1 -0
- package/dist/tools/builtins/json-string-hint.js +17 -0
- package/dist/tools/builtins/json-string-hint.js.map +1 -0
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +7 -15
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +11 -0
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +10 -0
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +45 -1
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +5 -0
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
- package/dist/tools/coordinator/ask-user-question.js +26 -13
- package/dist/tools/coordinator/ask-user-question.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +5 -0
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/coordinator/question-options.d.ts +78 -0
- package/dist/tools/coordinator/question-options.d.ts.map +1 -0
- package/dist/tools/coordinator/question-options.js +153 -0
- package/dist/tools/coordinator/question-options.js.map +1 -0
- package/dist/tools/defineTool.d.ts +10 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +17 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/memory/search.d.ts.map +1 -1
- package/dist/tools/memory/search.js +4 -1
- package/dist/tools/memory/search.js.map +1 -1
- package/dist/tools/memory/update.d.ts.map +1 -1
- package/dist/tools/memory/update.js +8 -5
- package/dist/tools/memory/update.js.map +1 -1
- package/dist/tools/render-nonce.d.ts +47 -0
- package/dist/tools/render-nonce.d.ts.map +1 -0
- package/dist/tools/render-nonce.js +63 -0
- package/dist/tools/render-nonce.js.map +1 -0
- package/dist/tools/roster.d.ts +46 -19
- package/dist/tools/roster.d.ts.map +1 -1
- package/dist/tools/roster.js +63 -33
- package/dist/tools/roster.js.map +1 -1
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +94 -14
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +52 -6
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/trusted-read-only.d.ts +9 -5
- package/dist/tools/trusted-read-only.d.ts.map +1 -1
- package/dist/tools/trusted-read-only.js +14 -10
- package/dist/tools/trusted-read-only.js.map +1 -1
- package/dist/tools/untrusted-envelope.d.ts +67 -28
- package/dist/tools/untrusted-envelope.d.ts.map +1 -1
- package/dist/tools/untrusted-envelope.js +108 -59
- package/dist/tools/untrusted-envelope.js.map +1 -1
- package/dist/toolsets/combine.d.ts +44 -0
- package/dist/toolsets/combine.d.ts.map +1 -0
- package/dist/toolsets/combine.js +153 -0
- package/dist/toolsets/combine.js.map +1 -0
- package/dist/toolsets/manager.d.ts +201 -0
- package/dist/toolsets/manager.d.ts.map +1 -0
- package/dist/toolsets/manager.js +837 -0
- package/dist/toolsets/manager.js.map +1 -0
- package/dist/toolsets/source-glob.d.ts +15 -0
- package/dist/toolsets/source-glob.d.ts.map +1 -0
- package/dist/toolsets/source-glob.js +23 -0
- package/dist/toolsets/source-glob.js.map +1 -0
- package/dist/toolsets/toolset.d.ts +20 -0
- package/dist/toolsets/toolset.d.ts.map +1 -0
- package/dist/toolsets/toolset.js +28 -0
- package/dist/toolsets/toolset.js.map +1 -0
- package/dist/toolsets/types.d.ts +128 -0
- package/dist/toolsets/types.d.ts.map +1 -0
- package/dist/toolsets/types.js +33 -0
- package/dist/toolsets/types.js.map +1 -0
- package/dist/toolsets/wrappers.d.ts +59 -0
- package/dist/toolsets/wrappers.d.ts.map +1 -0
- package/dist/toolsets/wrappers.js +165 -0
- package/dist/toolsets/wrappers.js.map +1 -0
- package/dist/types/agent/base.d.ts +27 -16
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/index.d.ts +1 -0
- package/dist/types/agent/index.d.ts.map +1 -1
- package/dist/types/agent/index.js +1 -0
- package/dist/types/agent/index.js.map +1 -1
- package/dist/types/agent/pipeline.d.ts +2 -0
- package/dist/types/agent/pipeline.d.ts.map +1 -1
- package/dist/types/agent/query.d.ts +117 -0
- package/dist/types/agent/query.d.ts.map +1 -0
- package/dist/types/agent/query.js +2 -0
- package/dist/types/agent/query.js.map +1 -0
- package/dist/types/agent/reactive.d.ts +2 -129
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/agent/router.d.ts +2 -0
- package/dist/types/agent/router.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +5 -2
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +49 -12
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +6 -0
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +32 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/errors/index.d.ts +15 -0
- package/dist/types/errors/index.d.ts.map +1 -1
- package/dist/types/errors/index.js.map +1 -1
- package/dist/types/hitl/index.d.ts +57 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +130 -9
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +4 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +22 -4
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +1 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +5 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +8 -3
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +39 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +1 -1
- package/dist/types/session/events.d.ts +14 -3
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/tool/index.d.ts +152 -91
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/toolset/index.d.ts +10 -40
- package/dist/types/toolset/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/advisory/history.ts +27 -2
- package/src/advisory/index.ts +1 -1
- package/src/advisory/registry.ts +33 -0
- package/src/agents/AGENTS.md +14 -7
- package/src/agents/PipelineAgent.ts +2 -303
- package/src/agents/QueryAgent.ts +269 -0
- package/src/agents/ReactiveAgent.ts +6 -216
- package/src/agents/RouterAgent.ts +2 -337
- package/src/agents/SupervisorAgent.ts +3 -476
- package/src/agents/defineAgent.ts +13 -2
- package/src/agents/examples/PipelineAgent.ts +302 -0
- package/src/agents/examples/RouterAgent.ts +338 -0
- package/src/agents/examples/SupervisorAgent.ts +472 -0
- package/src/agents/explore.ts +6 -3
- package/src/agents/forward-options.ts +37 -0
- package/src/agents/index.ts +2 -0
- package/src/agents/runAgent.ts +144 -37
- package/src/authorization/command-line.ts +2 -2
- package/src/authorization/gate.ts +21 -1
- package/src/authorization/program.ts +773 -0
- package/src/authorization/reexec-wrapper.ts +589 -0
- package/src/authorization/rules.ts +18 -1
- package/src/authorization/shell-lexer.ts +104 -59
- package/src/bridge/sse/mapper.ts +6 -0
- package/src/capabilities/index.ts +157 -0
- package/src/config/registry.ts +4 -1
- package/src/connector/index.ts +9 -2
- package/src/connector/mcp/adapter.ts +58 -3
- package/src/connector/mcp/client.ts +20 -4
- package/src/connector/mcp/discovery.ts +60 -0
- package/src/connector/mcp/index.ts +13 -0
- package/src/connector/mcp/mcp-toolset.ts +515 -0
- package/src/connector/tools/index.ts +2 -2
- package/src/connector/tools/router.ts +35 -58
- package/src/directory/derive-supervisor.ts +12 -8
- package/src/directory/derive.ts +8 -5
- package/src/execution/code-runtime/types.ts +2 -2
- package/src/invariants/index.ts +4 -1
- package/src/manager/agent/lifecycle.ts +9 -0
- package/src/manager/connector/environment.ts +17 -4
- package/src/manager/connector/index.ts +2 -2
- package/src/manager/connector/tenant.ts +17 -4
- package/src/manager/index.ts +2 -2
- package/src/manager/session/attribution.ts +79 -0
- package/src/manager/session/turn-recorder.ts +211 -55
- package/src/peers/address.ts +58 -0
- package/src/peers/client.ts +202 -0
- package/src/peers/dir.ts +176 -0
- package/src/peers/endpoint.ts +564 -0
- package/src/peers/envelope.ts +121 -0
- package/src/peers/index.ts +96 -0
- package/src/peers/protocol.ts +196 -0
- package/src/peers/record.ts +56 -0
- package/src/peers/registry.ts +241 -0
- package/src/plugin/define.ts +68 -0
- package/src/plugin/index.ts +2 -0
- package/src/plugin/lifecycle.ts +286 -106
- package/src/plugin/resolver.ts +6 -3
- package/src/plugin/shell-hook.ts +21 -5
- package/src/probe/errors.ts +4 -1
- package/src/prompt/coding-agent-doctrine.ts +22 -10
- package/src/prompt/contributions.ts +12 -2
- package/src/prompt/index.ts +1 -0
- package/src/provider/collect-chat-completion.ts +96 -11
- package/src/provider/mock.ts +24 -6
- package/src/provider/registry.ts +4 -1
- package/src/provider/tool-call-framing.ts +226 -0
- package/src/public-runtime.ts +136 -7
- package/src/public-tools.ts +24 -4
- package/src/public-types.ts +60 -6
- package/src/read-model/registry.ts +7 -2
- package/src/registry/ManagedRegistry.ts +57 -6
- package/src/registry/collision.ts +64 -0
- package/src/registry/command/index.ts +7 -3
- package/src/registry/index.ts +3 -9
- package/src/registry/plugin/index.ts +14 -1
- package/src/registry/tool/callable.ts +8 -9
- package/src/registry/tool/execute.ts +16 -846
- package/src/registry/tool/portable.ts +59 -0
- package/src/registry/tool/presentation.ts +6 -5
- package/src/runtime/bidi/session.ts +24 -5
- package/src/runtime/query/executor/tool-call-admission.ts +228 -6
- package/src/runtime/query/executor.ts +110 -12
- package/src/runtime/query/file-evidence-replay.ts +8 -7
- package/src/runtime/query/fork/prepare.ts +6 -1
- package/src/runtime/query/guardrail-presets.ts +4 -3
- package/src/runtime/query/index.ts +199 -101
- package/src/runtime/query/iteration/index.ts +13 -3
- package/src/runtime/query/iteration/phases/compaction.ts +1 -1
- package/src/runtime/query/iteration/phases/context.ts +2 -2
- package/src/runtime/query/iteration/phases/tool-review.ts +59 -2
- package/src/runtime/query/iteration/stream-turn.ts +390 -136
- package/src/runtime/query/iteration/tool-input.ts +284 -0
- package/src/runtime/query/observation-context.ts +2 -2
- package/src/runtime/query/prelude-lease.ts +132 -0
- package/src/runtime/query/prepare-turn.ts +477 -198
- package/src/runtime/query/prompt-cache.ts +2 -2
- package/src/runtime/query/prompt.ts +4 -4
- package/src/runtime/query/resume-session.ts +42 -3
- package/src/runtime/query/review-policy.ts +87 -9
- package/src/runtime/query/tooling.ts +3 -6
- package/src/runtime/query/turn-state.ts +4 -0
- package/src/runtime/system-events.ts +246 -0
- package/src/scheduler/delegating.ts +7 -2
- package/src/skills/index.ts +1 -1
- package/src/skills/registry.ts +25 -0
- package/src/store/session-log/conformance.ts +51 -8
- package/src/store/session-log/core.ts +10 -4
- package/src/store/session-log/fold.ts +33 -7
- package/src/store/session-log/index.ts +2 -0
- package/src/test-support/toolset.ts +23 -0
- package/src/tools/builtins/bash.ts +27 -10
- package/src/tools/builtins/browser-url.ts +1 -1
- package/src/tools/builtins/computer-use.ts +21 -11
- package/src/tools/builtins/edit.ts +12 -2
- package/src/tools/builtins/json-string-hint.ts +16 -0
- package/src/tools/builtins/search-tools.ts +7 -20
- package/src/tools/builtins/write-file.ts +12 -0
- package/src/tools/command-shell.ts +46 -1
- package/src/tools/coordinator/agent.ts +6 -0
- package/src/tools/coordinator/ask-user-question.ts +29 -15
- package/src/tools/coordinator/index.ts +6 -0
- package/src/tools/coordinator/question-options.ts +195 -0
- package/src/tools/defineTool.ts +28 -0
- package/src/tools/memory/search.ts +4 -1
- package/src/tools/memory/update.ts +8 -5
- package/src/tools/render-nonce.ts +69 -0
- package/src/tools/roster.ts +84 -33
- package/src/tools/schedules/schedule-tool.ts +107 -14
- package/src/tools/schedules/types.ts +52 -6
- package/src/tools/trusted-read-only.ts +19 -10
- package/src/tools/untrusted-envelope.ts +121 -57
- package/src/toolsets/combine.ts +181 -0
- package/src/toolsets/manager.ts +996 -0
- package/src/toolsets/source-glob.ts +22 -0
- package/src/toolsets/toolset.ts +31 -0
- package/src/toolsets/types.ts +154 -0
- package/src/toolsets/wrappers.ts +191 -0
- package/src/types/agent/base.ts +29 -16
- package/src/types/agent/index.ts +1 -0
- package/src/types/agent/pipeline.ts +2 -0
- package/src/types/agent/query.ts +129 -0
- package/src/types/agent/reactive.ts +5 -142
- package/src/types/agent/router.ts +2 -0
- package/src/types/agent/supervisor.ts +5 -2
- package/src/types/authorization/index.ts +12 -0
- package/src/types/connector/mcp.ts +32 -0
- package/src/types/errors/index.ts +15 -0
- package/src/types/hitl/index.ts +57 -0
- package/src/types/message/index.ts +135 -7
- package/src/types/plugin/index.ts +44 -21
- package/src/types/provider/chat.ts +5 -0
- package/src/types/provider/config.ts +8 -3
- package/src/types/provider/stream.ts +39 -0
- package/src/types/sandbox/index.ts +1 -1
- package/src/types/session/events.ts +14 -3
- package/src/types/tool/index.ts +154 -105
- package/src/types/toolset/index.ts +10 -47
- package/dist/registry/toolset/catalog.d.ts +0 -42
- package/dist/registry/toolset/catalog.d.ts.map +0 -1
- package/dist/registry/toolset/catalog.js +0 -234
- package/dist/registry/toolset/catalog.js.map +0 -1
- package/src/registry/toolset/catalog.ts +0 -308
|
@@ -134,6 +134,65 @@ export function findPortableSchemaViolations(
|
|
|
134
134
|
return found
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
export interface UndescribedPropertyViolation {
|
|
138
|
+
/** Dotted path to the property missing a description, e.g. `properties.readRange`. */
|
|
139
|
+
readonly path: string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Every named object property, at any depth, whose schema carries no
|
|
144
|
+
* `description`.
|
|
145
|
+
*
|
|
146
|
+
* `defineTool` requires a tool-level `description`, but nothing requires one
|
|
147
|
+
* on each field of its Zod `inputSchema` — a field with no `.describe()`
|
|
148
|
+
* renders with no `description` key, silently, and reaches the model with no
|
|
149
|
+
* account of what it is for. Some other tool-calling frameworks catch the
|
|
150
|
+
* equivalent gap at registration time, behind an opt-in flag, doing the
|
|
151
|
+
* schema derivation themselves; namzu's Zod-first schemas are hand-authored,
|
|
152
|
+
* so the check here is the same shape as {@link findPortableSchemaViolations}
|
|
153
|
+
* — a non-throwing sweep a test runs over a rendered schema, not a
|
|
154
|
+
* registration-time throw. Wiring this into `ToolRegistry.registerOne` as a
|
|
155
|
+
* hard default would break any existing tool, first-party or third-party,
|
|
156
|
+
* that already ships an undescribed field.
|
|
157
|
+
*
|
|
158
|
+
* Only named properties are checked, mirroring that per-parameter
|
|
159
|
+
* granularity: an array's own `.describe()` on the array itself is enough,
|
|
160
|
+
* no per-element description is demanded.
|
|
161
|
+
*/
|
|
162
|
+
export function findUndescribedProperties(
|
|
163
|
+
schema: unknown,
|
|
164
|
+
path = '',
|
|
165
|
+
): UndescribedPropertyViolation[] {
|
|
166
|
+
if (Array.isArray(schema)) {
|
|
167
|
+
return schema.flatMap((item, index) => findUndescribedProperties(item, `${path}[${index}]`))
|
|
168
|
+
}
|
|
169
|
+
if (typeof schema !== 'object' || schema === null) return []
|
|
170
|
+
|
|
171
|
+
const found: UndescribedPropertyViolation[] = []
|
|
172
|
+
const node = schema as Record<string, unknown>
|
|
173
|
+
const props = node.properties
|
|
174
|
+
if (props && typeof props === 'object' && !Array.isArray(props)) {
|
|
175
|
+
for (const [name, value] of Object.entries(props as Record<string, unknown>)) {
|
|
176
|
+
const here = path ? `${path}.properties.${name}` : `properties.${name}`
|
|
177
|
+
const described =
|
|
178
|
+
value !== null &&
|
|
179
|
+
typeof value === 'object' &&
|
|
180
|
+
!Array.isArray(value) &&
|
|
181
|
+
typeof (value as Record<string, unknown>).description === 'string' &&
|
|
182
|
+
(value as Record<string, unknown>).description !== ''
|
|
183
|
+
if (!described) {
|
|
184
|
+
found.push({ path: here })
|
|
185
|
+
}
|
|
186
|
+
found.push(...findUndescribedProperties(value, here))
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const [key, value] of Object.entries(node)) {
|
|
190
|
+
if (key === 'properties') continue
|
|
191
|
+
found.push(...findUndescribedProperties(value, path ? `${path}.${key}` : key))
|
|
192
|
+
}
|
|
193
|
+
return found
|
|
194
|
+
}
|
|
195
|
+
|
|
137
196
|
/**
|
|
138
197
|
* Rewrite what can be rewritten, so a tuple cannot reach a wire.
|
|
139
198
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolManager } from '../../toolsets/manager.js'
|
|
2
|
+
import type { ToolResult } from '../../types/tool/index.js'
|
|
2
3
|
import type { ToolCallView, ToolResultView } from '../../types/tool/presentation.js'
|
|
3
4
|
import { toErrorMessage } from '../../utils/error.js'
|
|
4
5
|
import { SCOPE_ATTRIBUTE } from '../../utils/log/types.js'
|
|
@@ -53,12 +54,12 @@ export function genericLabel(input: unknown): string {
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
|
-
* `registry` is the `
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
* `registry` is the `ToolManager` a turn already holds, so a presenter never
|
|
58
|
+
* needs its own copy of what is resolved — and a tool a live toolset adds is
|
|
59
|
+
* presentable the moment `refresh()` adopts it.
|
|
59
60
|
*/
|
|
60
61
|
export function createToolPresenter(
|
|
61
|
-
registry:
|
|
62
|
+
registry: Pick<ToolManager, 'get'>,
|
|
62
63
|
logger?: Logger,
|
|
63
64
|
): ToolPresenter {
|
|
64
65
|
// `SCOPE_ATTRIBUTE`, not a bare `component` key. The 40 bare ones are a
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { NAMZU } from '../../constants/telemetry/index.js'
|
|
2
|
+
import { ToolManager } from '../../toolsets/manager.js'
|
|
3
|
+
import type { Toolset } from '../../toolsets/types.js'
|
|
2
4
|
import type {
|
|
3
5
|
BidiConnectParams,
|
|
4
6
|
BidiProvider,
|
|
@@ -7,7 +9,7 @@ import type {
|
|
|
7
9
|
} from '../../types/bidi/index.js'
|
|
8
10
|
import type { ToolResultGuardrailSpec } from '../../types/guardrail/index.js'
|
|
9
11
|
import type { SessionId, TurnId } from '../../types/ids/index.js'
|
|
10
|
-
import type { ToolContext
|
|
12
|
+
import type { ToolContext } from '../../types/tool/index.js'
|
|
11
13
|
import { toErrorMessage } from '../../utils/error.js'
|
|
12
14
|
import { generateSessionId, generateTurnId } from '../../utils/id.js'
|
|
13
15
|
import { SCOPE_ATTRIBUTE } from '../../utils/log/types.js'
|
|
@@ -62,7 +64,8 @@ async function waitForProviderClose(pending: Promise<void>, timeoutMs: number):
|
|
|
62
64
|
|
|
63
65
|
export interface BidiTurnParams {
|
|
64
66
|
readonly provider: BidiProvider
|
|
65
|
-
|
|
67
|
+
/** Every tool this duplex turn may see comes from one of these — see `toolsets/types.ts`. */
|
|
68
|
+
readonly toolsets: readonly Toolset[]
|
|
66
69
|
readonly connect: BidiConnectParams
|
|
67
70
|
readonly workingDirectory: string
|
|
68
71
|
readonly env?: Record<string, string>
|
|
@@ -88,8 +91,8 @@ export interface BidiTurnParams {
|
|
|
88
91
|
*
|
|
89
92
|
* Here rather than nowhere because this path builds its OWN tool context:
|
|
90
93
|
* a duplex session executes the tools the model asks for, and its results
|
|
91
|
-
* reach a model just as a turn's do.
|
|
92
|
-
*
|
|
94
|
+
* reach a model just as a turn's do. This duplex path builds its own
|
|
95
|
+
* manager from the supplied toolsets, so this option is its screen policy.
|
|
93
96
|
*/
|
|
94
97
|
readonly toolResultGuardrails?: readonly ToolResultGuardrailSpec[]
|
|
95
98
|
}
|
|
@@ -128,6 +131,20 @@ export async function startBidiTurn(params: BidiTurnParams): Promise<BidiTurn> {
|
|
|
128
131
|
[NAMZU.SESSION_ID]: sessionId,
|
|
129
132
|
[NAMZU.TURN_ID]: turnId,
|
|
130
133
|
})
|
|
134
|
+
// Built once, from a fixed toolset list, like `query()`'s own manager.
|
|
135
|
+
// Nothing here ever calls `refresh()`: a duplex turn has no post-tool
|
|
136
|
+
// iteration boundary to call it at, and no message history for
|
|
137
|
+
// `availability()` to derive a reveal from — a deferred tool never
|
|
138
|
+
// becomes callable mid-session, same as before this existed (nothing in
|
|
139
|
+
// this file ever activated one either).
|
|
140
|
+
// `resultGuardrails` is deliberately left unset on the manager itself
|
|
141
|
+
// (unlike `query()`'s), so the per-call `ToolContext.toolResultGuardrails`
|
|
142
|
+
// below keeps deciding it, exactly as it did when this file called a live
|
|
143
|
+
// `ToolRegistry` directly.
|
|
144
|
+
const toolManager = new ToolManager({
|
|
145
|
+
toolsets: params.toolsets,
|
|
146
|
+
messages: () => [],
|
|
147
|
+
})
|
|
131
148
|
const lifetime = new AbortController()
|
|
132
149
|
const queue: BidiTurnEvent[] = []
|
|
133
150
|
let wake: (() => void) | undefined
|
|
@@ -149,6 +166,7 @@ export async function startBidiTurn(params: BidiTurnParams): Promise<BidiTurn> {
|
|
|
149
166
|
const beginClose = (reason: unknown, closeTransport: boolean): void => {
|
|
150
167
|
if (!closed) {
|
|
151
168
|
closed = true
|
|
169
|
+
toolManager.dispose()
|
|
152
170
|
lifetime.abort(reason)
|
|
153
171
|
wake?.()
|
|
154
172
|
}
|
|
@@ -204,6 +222,7 @@ export async function startBidiTurn(params: BidiTurnParams): Promise<BidiTurn> {
|
|
|
204
222
|
} catch (error) {
|
|
205
223
|
removeConnectAbort?.()
|
|
206
224
|
params.signal?.removeEventListener('abort', onCallerAbort)
|
|
225
|
+
toolManager.dispose()
|
|
207
226
|
if (lifetime.signal.aborted) {
|
|
208
227
|
void connecting.catch(() => undefined)
|
|
209
228
|
throw lifetime.signal.reason
|
|
@@ -252,7 +271,7 @@ export async function startBidiTurn(params: BidiTurnParams): Promise<BidiTurn> {
|
|
|
252
271
|
toolUseId: call.id,
|
|
253
272
|
toolResultGuardrails: params.toolResultGuardrails ?? DEFAULT_TOOL_RESULT_GUARDRAILS,
|
|
254
273
|
}
|
|
255
|
-
const result = await
|
|
274
|
+
const result = await toolManager.execute(call.name, input, context)
|
|
256
275
|
output = result.success ? result.output : (result.error ?? 'the tool failed')
|
|
257
276
|
isError = !result.success
|
|
258
277
|
} catch (err) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GENAI, NAMZU } from '../../../constants/telemetry/index.js'
|
|
2
2
|
import { callableToolNames, formatToolNames } from '../../../registry/tool/callable.js'
|
|
3
3
|
import { renderToolSchema } from '../../../registry/tool/schema.js'
|
|
4
|
-
import type { ToolCall } from '../../../types/message/index.js'
|
|
4
|
+
import type { ToolCall, ToolInputError } from '../../../types/message/index.js'
|
|
5
5
|
import type { PluginHookResult } from '../../../types/plugin/index.js'
|
|
6
|
+
import type { ToolDefinition } from '../../../types/tool/index.js'
|
|
6
7
|
import type { ToolCallRepair, ToolCallRepairReason } from '../../../types/tool/repair.js'
|
|
7
8
|
import { toErrorMessage } from '../../../utils/error.js'
|
|
8
9
|
import type { Logger } from '../../../utils/logger.js'
|
|
@@ -100,7 +101,7 @@ export async function prepareDirectCall(
|
|
|
100
101
|
toolCall,
|
|
101
102
|
toolName,
|
|
102
103
|
input: {},
|
|
103
|
-
message:
|
|
104
|
+
message: unreadableToolCallMessage(host, toolCall, toolName),
|
|
104
105
|
isError: true,
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -392,13 +393,15 @@ export async function repairTruncatedCall(
|
|
|
392
393
|
host,
|
|
393
394
|
{ ...toolCall, function: { ...toolCall.function, arguments: partial } },
|
|
394
395
|
toolName,
|
|
395
|
-
{ reason: 'invalid_json', message:
|
|
396
|
+
{ reason: 'invalid_json', message: unreadableToolCallMessage(host, toolCall, toolName) },
|
|
396
397
|
)
|
|
397
398
|
if (repair) {
|
|
398
|
-
|
|
399
|
+
// Unreadable is not the same as cut off: the reason says which.
|
|
400
|
+
host.log.info('Repaired a tool call whose arguments could not be read', {
|
|
399
401
|
[NAMZU.TURN_ID]: host.config.turnId,
|
|
400
402
|
[GENAI.TOOL_NAME]: toolName,
|
|
401
403
|
'namzu.runtime.partial_length': partial.length,
|
|
404
|
+
'namzu.runtime.input_error_reason': toolCall.metadata?.inputError?.reason ?? 'unknown',
|
|
402
405
|
})
|
|
403
406
|
}
|
|
404
407
|
return repair
|
|
@@ -513,6 +516,225 @@ export function formatFailedToolOutput(
|
|
|
513
516
|
return `${output}\n\n${errorText}`
|
|
514
517
|
}
|
|
515
518
|
|
|
516
|
-
|
|
517
|
-
|
|
519
|
+
/**
|
|
520
|
+
* The message a call with unreadable arguments is answered with, built from
|
|
521
|
+
* why they could not be read and from the tool the call named.
|
|
522
|
+
*/
|
|
523
|
+
export function unreadableToolCallMessage(
|
|
524
|
+
host: ToolAdmissionHost,
|
|
525
|
+
toolCall: ToolCall,
|
|
526
|
+
toolName: string,
|
|
527
|
+
): string {
|
|
528
|
+
return unreadableToolInputMessage(
|
|
529
|
+
toolName,
|
|
530
|
+
toolCall.metadata?.inputError,
|
|
531
|
+
host.config.tools.get?.(toolName),
|
|
532
|
+
)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* The most characters a call cut off after `length` of them should be told to
|
|
537
|
+
* keep under: half of what arrived, rounded down to a figure that reads as a
|
|
538
|
+
* budget, and always less than what arrived. `undefined` when that leaves
|
|
539
|
+
* nothing to state.
|
|
540
|
+
*
|
|
541
|
+
* It used to be at least 100, whatever arrived, so a call the output limit cut
|
|
542
|
+
* after 29 characters was told to keep them under 100: more than it had
|
|
543
|
+
* already sent, which the limit had just refused.
|
|
544
|
+
*/
|
|
545
|
+
function ceilingBelow(length: number): number | undefined {
|
|
546
|
+
const half = Math.floor(length / 2)
|
|
547
|
+
const step = half >= 200 ? 100 : half >= 20 ? 10 : 1
|
|
548
|
+
const ceiling = Math.floor(half / step) * step
|
|
549
|
+
return ceiling >= 2 ? ceiling : undefined
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* How much one call should carry, in the model's words, or `undefined` when
|
|
554
|
+
* there is no number to give: a stream that ended, to a tool that declares no
|
|
555
|
+
* large arguments.
|
|
556
|
+
*
|
|
557
|
+
* A tool that declares large arguments is given a budget for each of them.
|
|
558
|
+
* After an output limit, any tool is told to keep its arguments under half of
|
|
559
|
+
* what arrived ({@link ceilingBelow}): the whole of them for a tool that
|
|
560
|
+
* declares none, and each declared budget lowered to that when it is larger,
|
|
561
|
+
* since a budget the response could not hold would send the model straight
|
|
562
|
+
* back into the cutoff. How to carry less (in parts, in a file) is the tool's
|
|
563
|
+
* own `truncatedInputHint`: splitting is right for a file body and wrong for a
|
|
564
|
+
* delegated prompt.
|
|
565
|
+
*/
|
|
566
|
+
function sizeAdvice(
|
|
567
|
+
largeStringArguments: ToolDefinition['largeStringArguments'],
|
|
568
|
+
error: ToolInputError,
|
|
569
|
+
): string | undefined {
|
|
570
|
+
const lengthCutoff = error.finishReason === 'length'
|
|
571
|
+
const ceiling = lengthCutoff ? ceilingBelow(error.length) : undefined
|
|
572
|
+
// A length cutoff too short to leave any figure worth stating
|
|
573
|
+
// (`ceilingBelow` under 4 characters) gives no budget to any tool,
|
|
574
|
+
// declared or not. Falling through to a tool's full declared budget here
|
|
575
|
+
// would tell a call cut after three characters to keep `content` under
|
|
576
|
+
// 12000 of them: more than a budget, an invitation back into the same
|
|
577
|
+
// cutoff, and a broken invariant (a call is always told less than what
|
|
578
|
+
// arrived). Only a stream that ended for a reason other than the output
|
|
579
|
+
// limit — where no ceiling applies at all — still gets the plain
|
|
580
|
+
// declared budgets below.
|
|
581
|
+
if (lengthCutoff && ceiling === undefined) return undefined
|
|
582
|
+
const declared = Object.entries(largeStringArguments ?? {}).filter(
|
|
583
|
+
([, budget]) => Number.isFinite(budget) && budget > 0,
|
|
584
|
+
)
|
|
585
|
+
if (declared.length === 0) {
|
|
586
|
+
return ceiling === undefined
|
|
587
|
+
? undefined
|
|
588
|
+
: `Send it again with less in one call: keep its arguments under ${ceiling} characters in all.`
|
|
589
|
+
}
|
|
590
|
+
const budgets = declared.map(
|
|
591
|
+
([name, budget]) =>
|
|
592
|
+
`\`${name}\` under ${Math.floor(Math.min(budget, ceiling ?? Number.POSITIVE_INFINITY))} characters`,
|
|
593
|
+
)
|
|
594
|
+
const list =
|
|
595
|
+
budgets.length === 1
|
|
596
|
+
? budgets[0]
|
|
597
|
+
: `${budgets.slice(0, -1).join(', ')} and ${budgets[budgets.length - 1]}`
|
|
598
|
+
return `Send it again with less in one call: keep ${list}.`
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* The most output tokens a character the stream carried can account for.
|
|
603
|
+
* Ordinary text runs well under one token per character; a rare CJK character
|
|
604
|
+
* or an emoji can take two. Output beyond this bound for everything that was
|
|
605
|
+
* streamed went somewhere the stream did not show.
|
|
606
|
+
*/
|
|
607
|
+
const MAX_TOKENS_PER_STREAMED_CHARACTER = 2
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Whether most of the response's output tokens went to output the stream did
|
|
611
|
+
* not carry as text or arguments, and what to say about it, or `undefined`
|
|
612
|
+
* when the usage says nothing of the kind (or there is none).
|
|
613
|
+
*
|
|
614
|
+
* A provider that streams no reasoning, or only an encrypted block or a
|
|
615
|
+
* summary of it, still counts that reasoning against the output limit. Judged
|
|
616
|
+
* by the characters that were streamed alone, a call the reasoning left no
|
|
617
|
+
* room for looked like the call that filled the response, and was told to
|
|
618
|
+
* shrink.
|
|
619
|
+
*
|
|
620
|
+
* The provider's own reasoning count decides when it gives one. Otherwise the
|
|
621
|
+
* streamed characters are given the most tokens they could have taken, and
|
|
622
|
+
* only output beyond that counts as unseen, so text that tokenizes densely is
|
|
623
|
+
* never mistaken for hidden reasoning.
|
|
624
|
+
*/
|
|
625
|
+
function unseenOutput(error: ToolInputError): string | undefined {
|
|
626
|
+
const total = error.outputTokens
|
|
627
|
+
if (total === undefined || total <= 0) return undefined
|
|
628
|
+
if (error.reasoningTokens !== undefined) {
|
|
629
|
+
return error.reasoningTokens * 2 >= total
|
|
630
|
+
? `${error.reasoningTokens} of the response's ${total} output tokens went to reasoning, so little of its limit was left for this call.`
|
|
631
|
+
: undefined
|
|
632
|
+
}
|
|
633
|
+
const streamed = error.precedingLength + error.length
|
|
634
|
+
const unseen = total - streamed * MAX_TOKENS_PER_STREAMED_CHARACTER
|
|
635
|
+
return unseen * 2 >= total
|
|
636
|
+
? `The response used ${total} output tokens, but only ${streamed} characters of text and tool arguments were streamed: most of its output went to reasoning or other output that is not shown, so little of its limit was left for this call.`
|
|
637
|
+
: undefined
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* What to tell the model about a call whose arguments could not be read.
|
|
642
|
+
*
|
|
643
|
+
* Each part answers one question, and a part with no answer is left out:
|
|
644
|
+
* what happened (from `error`, which says cut off or malformed and why), and
|
|
645
|
+
* what to do about it.
|
|
646
|
+
*
|
|
647
|
+
* - Malformed: send one valid JSON object, and the tool's own
|
|
648
|
+
* `malformedInputHint`, or its `validationErrorHint` when it declares no
|
|
649
|
+
* `malformedInputHint`: the required shape is what a model that could not
|
|
650
|
+
* write valid JSON for this tool needs to see, and a tool that states it
|
|
651
|
+
* for a rejected call should not have to state it twice. Never size
|
|
652
|
+
* advice: size does not fix JSON.
|
|
653
|
+
* - Cut off by the output limit: first, which part of the response filled it.
|
|
654
|
+
* When the provider's usage shows that most of the output went to
|
|
655
|
+
* reasoning, or to anything else the stream did not carry
|
|
656
|
+
* ({@link unseenOutput}), the model is told that, and to reason less or
|
|
657
|
+
* split the work: the call did not fill the response. Otherwise the
|
|
658
|
+
* response is what the stream carried: what came before the call
|
|
659
|
+
* (`precedingLength`) and the call itself (`length`). A call that was less
|
|
660
|
+
* than half of that did not fill it; what came before it did, and the model
|
|
661
|
+
* is told to send less before it, with no advice about the call. Otherwise
|
|
662
|
+
* the call itself is to carry less: {@link sizeAdvice}, and the tool's
|
|
663
|
+
* `truncatedInputHint`.
|
|
664
|
+
* - Cut off by the context window (`finishDetail: 'context_window'`): the
|
|
665
|
+
* call is to carry less, {@link sizeAdvice} and the tool's
|
|
666
|
+
* `truncatedInputHint`, with nothing about reasoning or what came before
|
|
667
|
+
* it: the window is the conversation's length, not this response's.
|
|
668
|
+
* - Cut off by the stream ending: the declared budgets, if any, or just to
|
|
669
|
+
* send the call again, and the tool's `truncatedInputHint`.
|
|
670
|
+
* - Stopped by a content filter: no advice. Sending less does not get past a
|
|
671
|
+
* filter.
|
|
672
|
+
*
|
|
673
|
+
* A call recorded before the reason was kept has no `error` and gets the
|
|
674
|
+
* plain statement that its arguments were unreadable, and no hint, since
|
|
675
|
+
* which one applies is not known.
|
|
676
|
+
*/
|
|
677
|
+
export function unreadableToolInputMessage(
|
|
678
|
+
toolName: string,
|
|
679
|
+
error: ToolInputError | undefined,
|
|
680
|
+
tool?: Pick<
|
|
681
|
+
ToolDefinition,
|
|
682
|
+
'truncatedInputHint' | 'malformedInputHint' | 'validationErrorHint' | 'largeStringArguments'
|
|
683
|
+
>,
|
|
684
|
+
): string {
|
|
685
|
+
const parts: string[] = []
|
|
686
|
+
const hint = (text: string | undefined) => {
|
|
687
|
+
const trimmed = text?.trim()
|
|
688
|
+
if (trimmed) parts.push(trimmed)
|
|
689
|
+
}
|
|
690
|
+
if (!error) {
|
|
691
|
+
parts.push(
|
|
692
|
+
`Error: The arguments for "${toolName}" could not be read as JSON. The tool was NOT executed. Send the call again with complete, valid JSON arguments.`,
|
|
693
|
+
)
|
|
694
|
+
} else if (error.reason === 'malformed') {
|
|
695
|
+
const where =
|
|
696
|
+
error.offset !== undefined && !/\bposition \d+/.test(error.parseError)
|
|
697
|
+
? ` at character ${error.offset}`
|
|
698
|
+
: ''
|
|
699
|
+
parts.push(
|
|
700
|
+
`Error: The arguments for "${toolName}" were not valid JSON (${error.parseError}${where}; ${error.length} characters in all). The tool was NOT executed. Send the call again with its arguments as one valid JSON object.`,
|
|
701
|
+
)
|
|
702
|
+
hint(tool?.malformedInputHint?.trim() ? tool.malformedInputHint : tool?.validationErrorHint)
|
|
703
|
+
} else {
|
|
704
|
+
const contextWindow = error.finishReason === 'length' && error.finishDetail === 'context_window'
|
|
705
|
+
const cause = contextWindow
|
|
706
|
+
? "the response filled the model's context window"
|
|
707
|
+
: error.finishReason === 'length'
|
|
708
|
+
? 'the response reached its output token limit'
|
|
709
|
+
: error.finishReason === 'content_filter'
|
|
710
|
+
? "the provider's content filter stopped the response"
|
|
711
|
+
: 'the response stream ended'
|
|
712
|
+
parts.push(
|
|
713
|
+
`Error: The call to "${toolName}" was cut off: ${cause} after ${error.length} characters of its arguments, before they were complete. The tool was NOT executed.`,
|
|
714
|
+
)
|
|
715
|
+
// Only the output limit is shared between reasoning, text and the
|
|
716
|
+
// call. A full context window is the conversation's length: what the
|
|
717
|
+
// response spent on what does not change it, and less in the call is
|
|
718
|
+
// the one thing that helps.
|
|
719
|
+
const unseen =
|
|
720
|
+
error.finishReason === 'length' && !contextWindow ? unseenOutput(error) : undefined
|
|
721
|
+
if (unseen) {
|
|
722
|
+
parts.push(
|
|
723
|
+
unseen,
|
|
724
|
+
'Send the call again after less reasoning, or split the work into smaller steps that each need less of it.',
|
|
725
|
+
)
|
|
726
|
+
} else if (
|
|
727
|
+
error.finishReason === 'length' &&
|
|
728
|
+
!contextWindow &&
|
|
729
|
+
error.length < error.precedingLength
|
|
730
|
+
) {
|
|
731
|
+
parts.push(
|
|
732
|
+
`${error.precedingLength} of the ${error.precedingLength + error.length} characters the response streamed came before this call, so send the call again with less before it in the same response.`,
|
|
733
|
+
)
|
|
734
|
+
} else if (error.finishReason !== 'content_filter') {
|
|
735
|
+
parts.push(sizeAdvice(tool?.largeStringArguments, error) ?? 'Send the call again.')
|
|
736
|
+
hint(tool?.truncatedInputHint)
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return parts.join(' ')
|
|
518
740
|
}
|