@namzu/sdk 45.1.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 +436 -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 +13 -2
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +37 -5
- 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 +27 -1
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +39 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +113 -69
- 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/pricing/catalogue.generated.d.ts.map +1 -1
- package/dist/pricing/catalogue.generated.js +28 -4
- package/dist/pricing/catalogue.generated.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 +27 -14
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +49 -11
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +9 -6
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +13 -5
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +16 -5
- 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 +22 -0
- package/dist/registry/tool/callable.d.ts.map +1 -0
- package/dist/registry/tool/callable.js +28 -0
- package/dist/registry/tool/callable.js.map +1 -0
- 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 -720
- 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 +82 -13
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +227 -17
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +37 -5
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +103 -14
- 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 +65 -3
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +143 -22
- 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 +18 -0
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +20 -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-coordinates.d.ts +65 -0
- package/dist/tools/builtins/computer-use-coordinates.d.ts.map +1 -0
- package/dist/tools/builtins/computer-use-coordinates.js +123 -0
- package/dist/tools/builtins/computer-use-coordinates.js.map +1 -0
- package/dist/tools/builtins/computer-use-image.d.ts +77 -0
- package/dist/tools/builtins/computer-use-image.d.ts.map +1 -0
- package/dist/tools/builtins/computer-use-image.js +223 -0
- package/dist/tools/builtins/computer-use-image.js.map +1 -0
- package/dist/tools/builtins/computer-use.d.ts +519 -14
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +1196 -183
- 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/index.d.ts +2 -1
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js +1 -1
- package/dist/tools/builtins/index.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/skill.d.ts +74 -0
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +214 -174
- package/dist/tools/builtins/skill.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 +12 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +24 -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/present.d.ts.map +1 -1
- package/dist/tools/schedules/present.js +2 -0
- package/dist/tools/schedules/present.js.map +1 -1
- package/dist/tools/schedules/schedule-tool.d.ts +6 -5
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +208 -37
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +120 -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 +70 -12
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +11 -0
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/computer-use/index.d.ts +176 -0
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/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 +171 -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 +3 -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 +46 -5
- package/src/authorization/program.ts +773 -0
- package/src/authorization/reexec-wrapper.ts +589 -0
- package/src/authorization/rules.ts +36 -1
- package/src/authorization/shell-lexer.ts +136 -63
- 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/pricing/catalogue.generated.ts +28 -4
- package/src/pricing/rates.source.json +27 -6
- 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 +152 -9
- package/src/public-tools.ts +43 -5
- package/src/public-types.ts +65 -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 +36 -0
- package/src/registry/tool/execute.ts +16 -839
- 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 +288 -22
- package/src/runtime/query/executor.ts +129 -16
- 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 +190 -24
- 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 +33 -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-coordinates.ts +144 -0
- package/src/tools/builtins/computer-use-image.ts +278 -0
- package/src/tools/builtins/computer-use.ts +1495 -191
- package/src/tools/builtins/edit.ts +12 -2
- package/src/tools/builtins/index.ts +7 -1
- package/src/tools/builtins/json-string-hint.ts +16 -0
- package/src/tools/builtins/search-tools.ts +7 -20
- package/src/tools/builtins/skill.ts +304 -174
- 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 +38 -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/present.ts +2 -0
- package/src/tools/schedules/schedule-tool.ts +238 -39
- package/src/tools/schedules/types.ts +120 -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 +33 -0
- package/src/types/computer-use/index.ts +202 -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 +173 -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
|
@@ -70,6 +70,14 @@ export interface ShellWord {
|
|
|
70
70
|
readonly expands: boolean
|
|
71
71
|
/** True when any part of the word was quoted or escaped. */
|
|
72
72
|
readonly quoted: boolean
|
|
73
|
+
/**
|
|
74
|
+
* True when the word reads a `$(…)` or backtick substitution. Read by
|
|
75
|
+
* `redirectionTarget()`: an unquoted substitution used as a `<`/`>`
|
|
76
|
+
* redirection target can run twice (measured, bash 5.2.21 and 5.3.15,
|
|
77
|
+
* for a `${var:-…}`-style default value that turns out ambiguous), so
|
|
78
|
+
* such a target is opaque rather than trusted to run once.
|
|
79
|
+
*/
|
|
80
|
+
readonly substitutes: boolean
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
/** A redirection: `2>&1`, `> file`, `<<EOF` and the rest. */
|
|
@@ -145,15 +153,53 @@ export interface ShellLexResult {
|
|
|
145
153
|
* payload is decoded as bash reads it; for `dash` and friends the bash reading
|
|
146
154
|
* is a close approximation, and the line is only as exact as that.
|
|
147
155
|
*/
|
|
148
|
-
export const NESTED_SHELLS: ReadonlySet<string> =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
export const NESTED_SHELLS: ReadonlySet<string> = PLAIN_SHELL_NAMES
|
|
157
|
+
|
|
158
|
+
/** What {@link nestedShellCommand} found: the payload the lexer reads, or why it could not. */
|
|
159
|
+
export type NestedShellCommand =
|
|
160
|
+
| {
|
|
161
|
+
/** The shell's basename, one of {@link NESTED_SHELLS}. */
|
|
162
|
+
readonly shell: string
|
|
163
|
+
/** The `-c` argument, read as a command line of its own. */
|
|
164
|
+
readonly payload: ShellWord
|
|
165
|
+
}
|
|
166
|
+
| {
|
|
167
|
+
/** Why the lexer calls the line opaque instead (`nested shell option` …). */
|
|
168
|
+
readonly opaque: string
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether the lexer reads a simple command's payload as a command line of
|
|
173
|
+
* its own: `words` are the command's words without its leading assignments.
|
|
174
|
+
* The command must, after unwrapping a chain of re-exec wrappers this
|
|
175
|
+
* recognises (`sudo`, `env`, `nice`, `timeout`, … — {@link unwrapReexecChain}
|
|
176
|
+
* in `reexec-wrapper.ts`, shared with `program.ts` so the two can never
|
|
177
|
+
* quietly disagree about where one ends), start a shell in
|
|
178
|
+
* {@link NESTED_SHELLS} by basename, exactly as written (`bash`, `/bin/sh`;
|
|
179
|
+
* not `bash.exe`, `BASH` or `fish`), or `busybox`/`toybox` running one, with
|
|
180
|
+
* `-c` among its options (clustered short forms included, `-ec`, `-lc`); the
|
|
181
|
+
* payload is the first argument that is not an option. `null` when it reads
|
|
182
|
+
* no payload — including when a wrapper consumed the whole line (`chroot
|
|
183
|
+
* /mnt` alone) or hit an option it does not recognise, in which case the
|
|
184
|
+
* whole line is opaque instead (below), not silently read as unremarkable.
|
|
185
|
+
*
|
|
186
|
+
* A host deciding on {@link lexShellCommandLine}'s reading uses this to know
|
|
187
|
+
* which text that reading already includes. Every other text a program runs
|
|
188
|
+
* as code — `powershell -c '…'`, `fish -c '…'`, `bash.exe -c '…'`, a script
|
|
189
|
+
* — is not in it.
|
|
190
|
+
*/
|
|
191
|
+
export function nestedShellCommand(words: readonly ShellWord[]): NestedShellCommand | null {
|
|
192
|
+
if (words.length === 0) return null
|
|
193
|
+
const chained = unwrapReexecChain(words)
|
|
194
|
+
if ('unknown' in chained) return { opaque: chained.unknown }
|
|
195
|
+
if ('none' in chained) return null
|
|
196
|
+
const invocation = shellInvocation(chained.rest)
|
|
197
|
+
if (invocation === null) return null
|
|
198
|
+
const found = shellDashC(invocation.rest)
|
|
199
|
+
if ('unknown' in found) return { opaque: found.unknown }
|
|
200
|
+
if ('none' in found) return null
|
|
201
|
+
return { shell: invocation.shell, payload: found.payload }
|
|
202
|
+
}
|
|
157
203
|
|
|
158
204
|
/** How many `bash -c` payloads deep the lexer follows before it gives up. */
|
|
159
205
|
const MAX_SHELL_DEPTH = 4
|
|
@@ -161,6 +207,13 @@ const MAX_SHELL_DEPTH = 4
|
|
|
161
207
|
const MAX_NESTING = 100
|
|
162
208
|
|
|
163
209
|
import type { ShellDialect } from '../types/tool/index.js'
|
|
210
|
+
import {
|
|
211
|
+
PLAIN_SHELL_NAMES,
|
|
212
|
+
REEXEC_WRAPPER_NAMES,
|
|
213
|
+
shellDashC,
|
|
214
|
+
shellInvocation,
|
|
215
|
+
unwrapReexecChain,
|
|
216
|
+
} from './reexec-wrapper.js'
|
|
164
217
|
|
|
165
218
|
export type { ShellDialect }
|
|
166
219
|
|
|
@@ -390,6 +443,14 @@ class WordBuilder {
|
|
|
390
443
|
quoted = false
|
|
391
444
|
/** A brace expansion, which POSIX shells do not perform. */
|
|
392
445
|
brace = false
|
|
446
|
+
/**
|
|
447
|
+
* A `$(…)` or backtick substitution read in this word. Brace expansion
|
|
448
|
+
* happens on the word's raw text BEFORE any expansion runs, so `{a,b}`
|
|
449
|
+
* beside one duplicates it — `$(cmd){a,b}` runs `cmd` once per brace
|
|
450
|
+
* alternative, not once — which the recursive read below does not
|
|
451
|
+
* model; `brace && substitutes` together are opaque instead of trusted.
|
|
452
|
+
*/
|
|
453
|
+
substitutes = false
|
|
393
454
|
/** Unquoted `{` seen, and whether a `,` or `..` followed it: brace expansion. */
|
|
394
455
|
private braceOpen = false
|
|
395
456
|
private braceSeparator = false
|
|
@@ -435,6 +496,12 @@ class WordBuilder {
|
|
|
435
496
|
this.value += text
|
|
436
497
|
this.empty = false
|
|
437
498
|
}
|
|
499
|
+
|
|
500
|
+
/** A `$(…)` or backtick substitution, kept as written. */
|
|
501
|
+
substitution(text: string): void {
|
|
502
|
+
this.substitutes = true
|
|
503
|
+
this.expansion(text)
|
|
504
|
+
}
|
|
438
505
|
}
|
|
439
506
|
|
|
440
507
|
// ---------------------------------------------------------------------------
|
|
@@ -1138,6 +1205,21 @@ class Parser {
|
|
|
1138
1205
|
// Ubuntu ship).
|
|
1139
1206
|
this.context.opaque('quoted or expanding target of >& or <&')
|
|
1140
1207
|
}
|
|
1208
|
+
if (
|
|
1209
|
+
['<', '>', '<>', '>>', '>|'].includes(operator.op) &&
|
|
1210
|
+
!target.word.quoted &&
|
|
1211
|
+
target.word.substitutes
|
|
1212
|
+
) {
|
|
1213
|
+
// A `<`/`>`-family target must be exactly one word; when it is not
|
|
1214
|
+
// (empty, or several), bash reports "ambiguous redirect" — and for
|
|
1215
|
+
// a `${var:-…}`-style default value, running that check evaluates
|
|
1216
|
+
// the substitution in it a SECOND time (measured, bash 5.2.21 and
|
|
1217
|
+
// 5.3.15: `<${a:-$(a)}` and `>${a:-$(a)}` both run `a` twice, a
|
|
1218
|
+
// bare `<$(a)` or `<a$(a)` only once). Whether the default branch
|
|
1219
|
+
// even runs depends on whether the variable is set at runtime, so
|
|
1220
|
+
// this is opaque rather than trusted to run once.
|
|
1221
|
+
this.context.opaque('unquoted substitution in a redirection target')
|
|
1222
|
+
}
|
|
1141
1223
|
const redirection: { -readonly [K in keyof ShellRedirection]: ShellRedirection[K] } = {
|
|
1142
1224
|
operator: operator.op,
|
|
1143
1225
|
...(operator.fd !== undefined ? { fd: operator.fd } : {}),
|
|
@@ -1178,8 +1260,8 @@ class Parser {
|
|
|
1178
1260
|
name !== 'shopt' &&
|
|
1179
1261
|
name !== 'enable' &&
|
|
1180
1262
|
name !== 'set' &&
|
|
1181
|
-
name
|
|
1182
|
-
!
|
|
1263
|
+
!NESTED_SHELLS.has(name) &&
|
|
1264
|
+
!REEXEC_WRAPPER_NAMES.has(name)
|
|
1183
1265
|
)
|
|
1184
1266
|
return
|
|
1185
1267
|
const words = command.words.slice(command.assignments)
|
|
@@ -1202,55 +1284,17 @@ class Parser {
|
|
|
1202
1284
|
}
|
|
1203
1285
|
return
|
|
1204
1286
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1287
|
+
const nested = nestedShellCommand(words)
|
|
1288
|
+
if (nested === null) return
|
|
1289
|
+
if ('opaque' in nested) {
|
|
1290
|
+
this.context.opaque(nested.opaque)
|
|
1207
1291
|
return
|
|
1208
1292
|
}
|
|
1209
|
-
|
|
1210
|
-
this.nestedShell(words)
|
|
1293
|
+
this.nestedShell(nested.shell, nested.payload)
|
|
1211
1294
|
}
|
|
1212
1295
|
|
|
1213
|
-
/**
|
|
1214
|
-
|
|
1215
|
-
* non-option argument once `-c` has been seen among the options.
|
|
1216
|
-
*/
|
|
1217
|
-
private nestedShell(words: readonly ShellWord[]): void {
|
|
1218
|
-
const shell = basename(words[0]?.value ?? '')
|
|
1219
|
-
let command = false
|
|
1220
|
-
let payload: ShellWord | undefined
|
|
1221
|
-
for (let i = 1; i < words.length; i += 1) {
|
|
1222
|
-
const word = words[i] as ShellWord
|
|
1223
|
-
if (word.expands) {
|
|
1224
|
-
this.context.opaque('nested shell option')
|
|
1225
|
-
return
|
|
1226
|
-
}
|
|
1227
|
-
const value = word.value
|
|
1228
|
-
if (value === '--' || value === '-') {
|
|
1229
|
-
payload = words[i + 1]
|
|
1230
|
-
break
|
|
1231
|
-
}
|
|
1232
|
-
if (value.startsWith('--')) {
|
|
1233
|
-
if (value === '--rcfile' || value === '--init-file') i += 1
|
|
1234
|
-
continue
|
|
1235
|
-
}
|
|
1236
|
-
if (/^[-+][A-Za-z]+$/.test(value)) {
|
|
1237
|
-
if (value.startsWith('-') && value.includes('c')) command = true
|
|
1238
|
-
// `-o name`, `-O name`: the option takes the next word.
|
|
1239
|
-
if (/[oO]$/.test(value)) i += 1
|
|
1240
|
-
continue
|
|
1241
|
-
}
|
|
1242
|
-
payload = word
|
|
1243
|
-
break
|
|
1244
|
-
}
|
|
1245
|
-
if (!command) return
|
|
1246
|
-
if (payload === undefined) {
|
|
1247
|
-
this.context.opaque('nested shell without a command')
|
|
1248
|
-
return
|
|
1249
|
-
}
|
|
1250
|
-
if (payload.expands) {
|
|
1251
|
-
this.context.opaque('nested shell command is expanded at runtime')
|
|
1252
|
-
return
|
|
1253
|
-
}
|
|
1296
|
+
/** Read the payload of `bash -c payload` as a command line of its own. */
|
|
1297
|
+
private nestedShell(shell: string, payload: ShellWord): void {
|
|
1254
1298
|
if (this.depth + 1 >= MAX_SHELL_DEPTH) {
|
|
1255
1299
|
this.context.opaque('nested shells too deep')
|
|
1256
1300
|
return
|
|
@@ -1426,7 +1470,7 @@ class Parser {
|
|
|
1426
1470
|
kind: 'word',
|
|
1427
1471
|
start,
|
|
1428
1472
|
end: start + 1,
|
|
1429
|
-
word: { text: '-', value: '-', expands: false, quoted: false },
|
|
1473
|
+
word: { text: '-', value: '-', expands: false, quoted: false, substitutes: false },
|
|
1430
1474
|
reservedOk: false,
|
|
1431
1475
|
}
|
|
1432
1476
|
}
|
|
@@ -1814,11 +1858,19 @@ class Parser {
|
|
|
1814
1858
|
}
|
|
1815
1859
|
this.pos = i
|
|
1816
1860
|
if (builder.brace) this.bashOnly('brace expansion')
|
|
1861
|
+
// Brace expansion runs on the word's raw text before any substitution
|
|
1862
|
+
// does, so `$(cmd){a,b}` duplicates `$(cmd)` into two copies that
|
|
1863
|
+
// each run `cmd` — the commands pushed while reading this word are
|
|
1864
|
+
// not the one-time account the recursive read otherwise gives.
|
|
1865
|
+
if (builder.brace && builder.substitutes) {
|
|
1866
|
+
this.context.opaque('command substitution duplicated by brace expansion')
|
|
1867
|
+
}
|
|
1817
1868
|
const word: ShellWord = {
|
|
1818
1869
|
text: src.slice(start, i),
|
|
1819
1870
|
value: builder.value,
|
|
1820
1871
|
expands: builder.expands,
|
|
1821
1872
|
quoted: builder.quoted,
|
|
1873
|
+
substitutes: builder.substitutes,
|
|
1822
1874
|
}
|
|
1823
1875
|
// A descriptor before a redirection operator: `2>`, `{fd}>`.
|
|
1824
1876
|
const next = src[i]
|
|
@@ -1991,7 +2043,7 @@ class Parser {
|
|
|
1991
2043
|
builder.expansion(src.slice(at, end))
|
|
1992
2044
|
return end
|
|
1993
2045
|
}
|
|
1994
|
-
const end = this.parameterBraces(n + 1, inDouble)
|
|
2046
|
+
const end = this.parameterBraces(n + 1, inDouble, builder)
|
|
1995
2047
|
builder.expansion(src.slice(at, end))
|
|
1996
2048
|
return end
|
|
1997
2049
|
}
|
|
@@ -2005,7 +2057,18 @@ class Parser {
|
|
|
2005
2057
|
return end
|
|
2006
2058
|
}
|
|
2007
2059
|
}
|
|
2008
|
-
|
|
2060
|
+
// `$(…)`'s body is read as a command list of its own, the same
|
|
2061
|
+
// way `nestedShell()` reads a `bash -c` payload: each command
|
|
2062
|
+
// found inside it is pushed to the shared `context.commands`
|
|
2063
|
+
// (marked `origin: 'substitution'`), checked by the same deny
|
|
2064
|
+
// rules, instead of the containing line being called opaque
|
|
2065
|
+
// outright. Finding the matching `)` requires the parse to
|
|
2066
|
+
// succeed — a `)` inside a quoted string or a `case` pattern is
|
|
2067
|
+
// not it — so a substitution that does not parse throws all the
|
|
2068
|
+
// way to `lexShellCommandLine`'s own catch, which is the only
|
|
2069
|
+
// sound way to be wrong about its extent, and marks the whole
|
|
2070
|
+
// line opaque (`internal error`) exactly as any other
|
|
2071
|
+
// unmodeled construct does.
|
|
2009
2072
|
const inner = new Parser(
|
|
2010
2073
|
src,
|
|
2011
2074
|
n + 1,
|
|
@@ -2015,7 +2078,7 @@ class Parser {
|
|
|
2015
2078
|
this.nestingNow + 1,
|
|
2016
2079
|
)
|
|
2017
2080
|
const end = inner.substitution()
|
|
2018
|
-
builder.
|
|
2081
|
+
builder.substitution(src.slice(at, end))
|
|
2019
2082
|
return end
|
|
2020
2083
|
}
|
|
2021
2084
|
if (next === '[') {
|
|
@@ -2084,7 +2147,7 @@ class Parser {
|
|
|
2084
2147
|
* (indirection, a subscript or offset evaluated as arithmetic, a
|
|
2085
2148
|
* transformation) is opaque.
|
|
2086
2149
|
*/
|
|
2087
|
-
private parameterBraces(from: number, inDouble: boolean): number {
|
|
2150
|
+
private parameterBraces(from: number, inDouble: boolean, builder: WordBuilder): number {
|
|
2088
2151
|
const src = this.src
|
|
2089
2152
|
let i = from
|
|
2090
2153
|
const scratch = new WordBuilder()
|
|
@@ -2134,6 +2197,11 @@ class Parser {
|
|
|
2134
2197
|
const content = src.slice(from, i).replace(/\\\n/g, '')
|
|
2135
2198
|
if (!SAFE_PARAMETER.test(content)) this.context.opaque('parameter expansion')
|
|
2136
2199
|
else if (!POSIX_PARAMETER.test(content)) this.bashOnly('parameter expansion')
|
|
2200
|
+
// A substitution inside the default-value expression (`${a:-$(cmd)}`)
|
|
2201
|
+
// is read into a scratch builder discarded above; propagate whether
|
|
2202
|
+
// it happened onto the enclosing word, which is what the caller's
|
|
2203
|
+
// own brace-expansion check reads.
|
|
2204
|
+
if (scratch.substitutes) builder.substitutes = true
|
|
2137
2205
|
return i + 1
|
|
2138
2206
|
}
|
|
2139
2207
|
|
|
@@ -2268,8 +2336,12 @@ class Parser {
|
|
|
2268
2336
|
body += char
|
|
2269
2337
|
i += 1
|
|
2270
2338
|
}
|
|
2271
|
-
|
|
2272
|
-
|
|
2339
|
+
// Backtick's extent is found lexically, above — unlike `$(…)`, its
|
|
2340
|
+
// boundary does not depend on the body parsing as commands. So a
|
|
2341
|
+
// body that fails to parse is caught here, the same way a `bash -c`
|
|
2342
|
+
// payload's own failure is (`nestedShell()`): the rest of the LINE
|
|
2343
|
+
// is still read, only this substitution's own commands are unknown.
|
|
2344
|
+
builder.substitution(src.slice(at, i + 1))
|
|
2273
2345
|
this.context.rescan(body.length)
|
|
2274
2346
|
this.inherit(body)
|
|
2275
2347
|
const inner = new Parser(body, 0, this.context, 'substitution', this.depth, this.nestingNow + 1)
|
|
@@ -2277,6 +2349,7 @@ class Parser {
|
|
|
2277
2349
|
inner.program()
|
|
2278
2350
|
} catch (error) {
|
|
2279
2351
|
if (!(error instanceof Stop)) throw error
|
|
2352
|
+
this.context.opaque(`command substitution: ${error.reason}`)
|
|
2280
2353
|
}
|
|
2281
2354
|
return i + 1
|
|
2282
2355
|
}
|
package/src/bridge/sse/mapper.ts
CHANGED
|
@@ -572,6 +572,12 @@ const MAPPING: {
|
|
|
572
572
|
transform: (e) => ({
|
|
573
573
|
tool_use_id: e.toolUseId,
|
|
574
574
|
input: e.input,
|
|
575
|
+
// Arguments that could not be read: that they were not, why, and
|
|
576
|
+
// what arrived. Dropped here before, so a wire client saw `{}` as
|
|
577
|
+
// the call's input with nothing to say it was not the model's.
|
|
578
|
+
...(e.inputTruncated ? { input_truncated: true } : {}),
|
|
579
|
+
...(e.inputError ? { input_error: e.inputError } : {}),
|
|
580
|
+
...(e.partialArguments !== undefined ? { partial_arguments: e.partialArguments } : {}),
|
|
575
581
|
}),
|
|
576
582
|
},
|
|
577
583
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { PromptContributionRegistry } from '../prompt/contributions.js'
|
|
2
|
+
import type { PromptContribution } from '../prompt/contributions.js'
|
|
3
|
+
import type { Toolset } from '../toolsets/types.js'
|
|
4
|
+
import type { InputGuardrailSpec, OutputGuardrailSpec } from '../types/guardrail/index.js'
|
|
5
|
+
import type { ProjectId, SessionId, TenantId, TopicId } from '../types/ids/index.js'
|
|
6
|
+
import type { Message } from '../types/message/index.js'
|
|
7
|
+
import type { ReasoningEffort, ThinkingConfig } from '../types/provider/index.js'
|
|
8
|
+
|
|
9
|
+
export interface CapabilityModelSettings {
|
|
10
|
+
readonly temperature?: number
|
|
11
|
+
readonly thinking?: ThinkingConfig
|
|
12
|
+
readonly effort?: ReasoningEffort
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Host-authored behavior assembled for one agent invocation. */
|
|
16
|
+
export interface Capability {
|
|
17
|
+
/** Stable across invocations; duplicate ids are refused. */
|
|
18
|
+
readonly id: string
|
|
19
|
+
readonly instructions?: string
|
|
20
|
+
readonly toolsets?: readonly Toolset[]
|
|
21
|
+
readonly promptContributions?: readonly PromptContribution[]
|
|
22
|
+
readonly inputGuardrails?: readonly InputGuardrailSpec[]
|
|
23
|
+
readonly outputGuardrails?: readonly OutputGuardrailSpec[]
|
|
24
|
+
/** Later capabilities override earlier ones; explicit run options win. */
|
|
25
|
+
readonly modelSettings?: CapabilityModelSettings
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CapabilityRunContext {
|
|
29
|
+
readonly workingDirectory: string
|
|
30
|
+
readonly model: string
|
|
31
|
+
readonly prompt: string | readonly Message[]
|
|
32
|
+
readonly sessionId: SessionId
|
|
33
|
+
readonly topicId: TopicId
|
|
34
|
+
readonly projectId: ProjectId
|
|
35
|
+
readonly tenantId: TenantId
|
|
36
|
+
readonly signal?: AbortSignal
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A factory receives a fresh context on every invocation, including repeated session turns. */
|
|
40
|
+
export interface DynamicCapability {
|
|
41
|
+
readonly id: string
|
|
42
|
+
readonly forRun: (context: CapabilityRunContext) => Capability | null | Promise<Capability | null>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type AgentCapability = Capability | DynamicCapability
|
|
46
|
+
|
|
47
|
+
function assertCapabilityId(id: string): void {
|
|
48
|
+
if (typeof id !== 'string' || id.trim() !== id || id.length === 0) {
|
|
49
|
+
throw new Error('Capability id must be a nonempty, trimmed string.')
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Snapshot a reusable host declaration. Toolsets retain their own source ownership. */
|
|
54
|
+
export function defineCapability(value: Capability): Capability {
|
|
55
|
+
assertCapabilityId(value.id)
|
|
56
|
+
return Object.freeze({
|
|
57
|
+
...value,
|
|
58
|
+
...(value.toolsets ? { toolsets: Object.freeze([...value.toolsets]) } : {}),
|
|
59
|
+
...(value.promptContributions
|
|
60
|
+
? { promptContributions: Object.freeze([...value.promptContributions]) }
|
|
61
|
+
: {}),
|
|
62
|
+
...(value.inputGuardrails
|
|
63
|
+
? { inputGuardrails: Object.freeze([...value.inputGuardrails]) }
|
|
64
|
+
: {}),
|
|
65
|
+
...(value.outputGuardrails
|
|
66
|
+
? { outputGuardrails: Object.freeze([...value.outputGuardrails]) }
|
|
67
|
+
: {}),
|
|
68
|
+
...(value.modelSettings ? { modelSettings: Object.freeze({ ...value.modelSettings }) } : {}),
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Make the factory's stable identity explicit before it sees a run. */
|
|
73
|
+
export function dynamicCapability(
|
|
74
|
+
id: string,
|
|
75
|
+
forRun: DynamicCapability['forRun'],
|
|
76
|
+
): DynamicCapability {
|
|
77
|
+
assertCapabilityId(id)
|
|
78
|
+
return Object.freeze({ id, forRun })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ResolvedCapabilities {
|
|
82
|
+
readonly toolsets: readonly Toolset[]
|
|
83
|
+
readonly promptContributions: PromptContributionRegistry
|
|
84
|
+
readonly modelSettings: CapabilityModelSettings
|
|
85
|
+
readonly inputGuardrails: readonly InputGuardrailSpec[]
|
|
86
|
+
readonly outputGuardrails: readonly OutputGuardrailSpec[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function resolveForRun(
|
|
90
|
+
entry: DynamicCapability,
|
|
91
|
+
context: CapabilityRunContext,
|
|
92
|
+
): Promise<Capability | null> {
|
|
93
|
+
if (!context.signal) return await entry.forRun(context)
|
|
94
|
+
const signal = context.signal
|
|
95
|
+
return await new Promise<Capability | null>((resolve, reject) => {
|
|
96
|
+
const onAbort = () => {
|
|
97
|
+
signal.removeEventListener('abort', onAbort)
|
|
98
|
+
reject(signal.reason)
|
|
99
|
+
}
|
|
100
|
+
signal.addEventListener('abort', onAbort, { once: true })
|
|
101
|
+
if (signal.aborted) {
|
|
102
|
+
onAbort()
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
Promise.resolve()
|
|
106
|
+
.then(() => entry.forRun(context))
|
|
107
|
+
.then(resolve, reject)
|
|
108
|
+
.finally(() => signal.removeEventListener('abort', onAbort))
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Resolve each factory exactly once, in declaration order, before the first model call. */
|
|
113
|
+
export async function resolveCapabilities(
|
|
114
|
+
capabilities: readonly AgentCapability[],
|
|
115
|
+
context: CapabilityRunContext,
|
|
116
|
+
): Promise<ResolvedCapabilities> {
|
|
117
|
+
const seen = new Set<string>()
|
|
118
|
+
const toolsets: Toolset[] = []
|
|
119
|
+
const promptContributions = new PromptContributionRegistry()
|
|
120
|
+
const inputGuardrails: InputGuardrailSpec[] = []
|
|
121
|
+
const outputGuardrails: OutputGuardrailSpec[] = []
|
|
122
|
+
let modelSettings: CapabilityModelSettings = {}
|
|
123
|
+
|
|
124
|
+
for (const entry of capabilities) {
|
|
125
|
+
context.signal?.throwIfAborted()
|
|
126
|
+
assertCapabilityId(entry.id)
|
|
127
|
+
if (seen.has(entry.id)) throw new Error(`Capability "${entry.id}" is declared twice.`)
|
|
128
|
+
seen.add(entry.id)
|
|
129
|
+
|
|
130
|
+
const resolved = 'forRun' in entry ? await resolveForRun(entry, context) : entry
|
|
131
|
+
context.signal?.throwIfAborted()
|
|
132
|
+
if (resolved === null) continue
|
|
133
|
+
if (!resolved) throw new Error(`Capability "${entry.id}" returned no declaration.`)
|
|
134
|
+
if (resolved.id !== entry.id) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
`Capability "${entry.id}" returned id "${resolved.id}"; a run factory must keep its declared id.`,
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
const capability = defineCapability(resolved)
|
|
140
|
+
toolsets.push(...(capability.toolsets ?? []))
|
|
141
|
+
if (capability.instructions?.trim()) {
|
|
142
|
+
const instructions = capability.instructions
|
|
143
|
+
promptContributions.register({
|
|
144
|
+
id: `capability:${capability.id}:instructions`,
|
|
145
|
+
placement: 'dynamic',
|
|
146
|
+
render: () => instructions,
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
for (const contribution of capability.promptContributions ?? []) {
|
|
150
|
+
promptContributions.register(contribution)
|
|
151
|
+
}
|
|
152
|
+
inputGuardrails.push(...(capability.inputGuardrails ?? []))
|
|
153
|
+
outputGuardrails.push(...(capability.outputGuardrails ?? []))
|
|
154
|
+
modelSettings = { ...modelSettings, ...capability.modelSettings }
|
|
155
|
+
}
|
|
156
|
+
return { toolsets, promptContributions, modelSettings, inputGuardrails, outputGuardrails }
|
|
157
|
+
}
|
package/src/config/registry.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ZodType, ZodTypeDef } from 'zod'
|
|
2
2
|
|
|
3
|
+
import { RegistryCollisionError } from '../registry/collision.js'
|
|
3
4
|
import { type ConfigOverrideStore, InMemoryConfigOverrideStore } from '../store/config/index.js'
|
|
4
5
|
import { type Logger, resolveLogger } from '../utils/logger.js'
|
|
5
6
|
|
|
@@ -49,9 +50,11 @@ export interface ConfigScope<T> {
|
|
|
49
50
|
watch(listener: (next: T, previous: T) => void): () => void
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
export class ConfigNamespaceCollisionError extends
|
|
53
|
+
export class ConfigNamespaceCollisionError extends RegistryCollisionError {
|
|
53
54
|
constructor(readonly namespace: string) {
|
|
54
55
|
super(
|
|
56
|
+
'ConfigRegistry',
|
|
57
|
+
namespace,
|
|
55
58
|
`Configuration namespace "${namespace}" is already registered. Two owners of one namespace means whichever registered second silently decides the schema, so this refuses instead.`,
|
|
56
59
|
)
|
|
57
60
|
this.name = 'ConfigNamespaceCollisionError'
|
package/src/connector/index.ts
CHANGED
|
@@ -6,10 +6,13 @@ export { ScopedConnectorRegistry } from '../registry/connector/scoped.js'
|
|
|
6
6
|
export { ConnectorManager } from '../manager/connector/lifecycle.js'
|
|
7
7
|
export type { ConnectorManagerConfig } from '../manager/connector/lifecycle.js'
|
|
8
8
|
|
|
9
|
-
export { TenantConnectorManager } from '../manager/connector/tenant.js'
|
|
9
|
+
export { TenantCollisionError, TenantConnectorManager } from '../manager/connector/tenant.js'
|
|
10
10
|
export type { TenantConnectorManagerConfig } from '../manager/connector/tenant.js'
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export {
|
|
13
|
+
EnvironmentCollisionError,
|
|
14
|
+
EnvironmentConnectorManager,
|
|
15
|
+
} from '../manager/connector/environment.js'
|
|
13
16
|
export type {
|
|
14
17
|
EnvironmentConnectorSetup,
|
|
15
18
|
EnvironmentConnectorManagerConfig,
|
|
@@ -73,6 +76,8 @@ export {
|
|
|
73
76
|
mcpJsonSchemaToZod,
|
|
74
77
|
mcpPromptToToolDefinition,
|
|
75
78
|
mcpToolResultToToolResult,
|
|
79
|
+
mcpToolset,
|
|
80
|
+
mcpToolsetName,
|
|
76
81
|
mcpToolToToolDefinition,
|
|
77
82
|
renderPromptMessages,
|
|
78
83
|
resolveMcpEra,
|
|
@@ -102,4 +107,6 @@ export type {
|
|
|
102
107
|
MCPToolDrift,
|
|
103
108
|
MCPToolPolicy,
|
|
104
109
|
MCPToolPolicyDecision,
|
|
110
|
+
MCPToolsetOptions,
|
|
111
|
+
MCPToolsets,
|
|
105
112
|
} from './mcp/index.js'
|
|
@@ -469,10 +469,48 @@ export function mcpToolToToolDefinition(
|
|
|
469
469
|
* never lowers it. See `isTrustedReadOnly`.
|
|
470
470
|
*/
|
|
471
471
|
readOnlyHintTrusted = false,
|
|
472
|
+
/**
|
|
473
|
+
* In-loop retry budget for every tool this server contributes. Unset
|
|
474
|
+
* (the default) keeps today's behaviour byte-for-byte: `maxRetries`
|
|
475
|
+
* absent on the returned `ToolDefinition`, so the executor's own
|
|
476
|
+
* default (0) applies.
|
|
477
|
+
*
|
|
478
|
+
* Even with this set, a failure is only retried if `execute` also
|
|
479
|
+
* marked it {@link ToolResult.retryable}, which below is true only for
|
|
480
|
+
* the two outcomes this adapter already knows never reached the
|
|
481
|
+
* server's side effect (`mcp_tool_input_required`,
|
|
482
|
+
* `mcp_tool_missing_client_capability`) — never for
|
|
483
|
+
* `mcp_tool_outcome_unknown` or a raw transport error, where whether
|
|
484
|
+
* the call landed is exactly what is not known.
|
|
485
|
+
*/
|
|
486
|
+
maxRetries?: number,
|
|
472
487
|
): ToolDefinition {
|
|
473
488
|
const inputSchema = mcpJsonSchemaToZod(tool.inputSchema)
|
|
474
489
|
const toolName = `mcp_${serverName}_${tool.name}`
|
|
475
490
|
|
|
491
|
+
// Everything the server's own annotations carry that `isReadOnly`/
|
|
492
|
+
// `isDestructive` do not already have a typed home for — `title`,
|
|
493
|
+
// `idempotentHint`, `openWorldHint` — plus any `_meta` on the listing
|
|
494
|
+
// entry itself. Never sent back to the model (ToolDefinition.metadata is
|
|
495
|
+
// wire-excluded); a host, capability or toolset wrapper reads it with
|
|
496
|
+
// `matchesToolSelector` or by hand.
|
|
497
|
+
const mcpMetadata: Record<string, unknown> = {}
|
|
498
|
+
if (tool.annotations?.title !== undefined) mcpMetadata.title = tool.annotations.title
|
|
499
|
+
if (tool.annotations?.idempotentHint !== undefined) {
|
|
500
|
+
mcpMetadata.idempotentHint = tool.annotations.idempotentHint
|
|
501
|
+
}
|
|
502
|
+
if (tool.annotations?.openWorldHint !== undefined) {
|
|
503
|
+
mcpMetadata.openWorldHint = tool.annotations.openWorldHint
|
|
504
|
+
}
|
|
505
|
+
if (tool._meta !== undefined) mcpMetadata._meta = tool._meta
|
|
506
|
+
// Advisory only, NOT a security boundary: the gate that actually decides
|
|
507
|
+
// (`isTrustedReadOnly`, `tools/trusted-read-only.ts`) reads the OWNING
|
|
508
|
+
// TOOLSET's source (`ToolManager.sourceOf`), which whoever wraps this
|
|
509
|
+
// definition sets — `plugin/lifecycle.ts` or `mcpToolset`. Kept here too so a definition inspected on its
|
|
510
|
+
// own (a probe, a test, `matchesToolSelector`) can still see what the
|
|
511
|
+
// caller passed, now that `ToolDefinition.provenance` is gone.
|
|
512
|
+
mcpMetadata.readOnlyHintTrusted = readOnlyHintTrusted
|
|
513
|
+
|
|
476
514
|
return {
|
|
477
515
|
name: toolName,
|
|
478
516
|
description: tool.description
|
|
@@ -488,14 +526,21 @@ export function mcpToolToToolDefinition(
|
|
|
488
526
|
: {}),
|
|
489
527
|
category: 'network',
|
|
490
528
|
permissions: ['network_access'],
|
|
529
|
+
...(maxRetries === undefined ? {} : { maxRetries }),
|
|
491
530
|
// Reports what the SERVER said, faithfully. The outbound re-export
|
|
492
531
|
// and the destructive label a human is shown both need the server's
|
|
493
|
-
// own answer; whether a gate may act on it is decided separately,
|
|
494
|
-
//
|
|
532
|
+
// own answer; whether a gate may act on it is decided separately,
|
|
533
|
+
// from the OWNING TOOLSET's source (`ToolManager.sourceOf`,
|
|
534
|
+
// `toolsets/manager.ts`) — a definition cannot claim its own source,
|
|
535
|
+
// so `readOnlyHintTrusted` is carried only as advisory metadata here.
|
|
536
|
+
// See `tools/trusted-read-only.ts`. Whoever wraps this definition into a
|
|
537
|
+
// toolset (`plugin/lifecycle.ts` or `mcpToolset`)
|
|
538
|
+
// gives it `source.kind: 'mcp_server'`, `source.mcpServer.name:
|
|
539
|
+
// serverName` and this same `readOnlyHintTrusted`.
|
|
495
540
|
isReadOnly: () => tool.annotations?.readOnlyHint ?? false,
|
|
496
541
|
isDestructive: () => tool.annotations?.destructiveHint ?? false,
|
|
497
542
|
isConcurrencySafe: () => true,
|
|
498
|
-
|
|
543
|
+
...(Object.keys(mcpMetadata).length > 0 ? { metadata: mcpMetadata } : {}),
|
|
499
544
|
|
|
500
545
|
async execute(input: unknown, context: ToolContext): Promise<ToolResult> {
|
|
501
546
|
try {
|
|
@@ -533,6 +578,12 @@ export function mcpToolToToolDefinition(
|
|
|
533
578
|
success: false,
|
|
534
579
|
output: '',
|
|
535
580
|
error: `MCP tool "${tool.name}" on server "${serverName}" asked for input this client has no way to supply${requested.length > 0 ? ` (${requested.join(', ')})` : ''}.`,
|
|
581
|
+
// No side effect is known to have happened (see the
|
|
582
|
+
// comment above), so a retry — of this tool, or a
|
|
583
|
+
// different approach entirely — is safe. Only
|
|
584
|
+
// meaningful when the definition also opted into
|
|
585
|
+
// `maxRetries`; see this function's parameter.
|
|
586
|
+
retryable: true,
|
|
536
587
|
data: {
|
|
537
588
|
code: 'mcp_tool_input_required',
|
|
538
589
|
server: serverName,
|
|
@@ -555,6 +606,10 @@ export function mcpToolToToolDefinition(
|
|
|
555
606
|
success: false,
|
|
556
607
|
output: '',
|
|
557
608
|
error: `MCP tool "${tool.name}" on server "${serverName}" requires client capabilities this client did not declare${requiredCapabilities.length > 0 ? ` (${requiredCapabilities.join(', ')})` : ''}.`,
|
|
609
|
+
// The server refused before running the tool, so
|
|
610
|
+
// nothing ran; safe to retry the same way
|
|
611
|
+
// `mcp_tool_input_required` above is.
|
|
612
|
+
retryable: true,
|
|
558
613
|
data: {
|
|
559
614
|
code: 'mcp_tool_missing_client_capability',
|
|
560
615
|
server: serverName,
|