@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
package/src/plugin/lifecycle.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { pathToFileURL } from 'node:url'
|
|
2
2
|
import type { ConfigRegistry } from '../config/registry.js'
|
|
3
|
-
import { mcpToolToToolDefinition } from '../connector/mcp/adapter.js'
|
|
4
3
|
import { MCPClient } from '../connector/mcp/client.js'
|
|
5
4
|
import { MCPToolDiscovery } from '../connector/mcp/discovery.js'
|
|
6
5
|
import type { MCPToolDiscoveryOptions } from '../connector/mcp/discovery.js'
|
|
6
|
+
import { mcpToolset } from '../connector/mcp/mcp-toolset.js'
|
|
7
7
|
import type { MCPToolPolicy } from '../connector/mcp/policy.js'
|
|
8
|
-
import {
|
|
9
|
-
import { MCPReconnectOptionsSchema, MCPReconnectSupervisor } from '../connector/mcp/reconnect.js'
|
|
8
|
+
import { MCPReconnectOptionsSchema } from '../connector/mcp/reconnect.js'
|
|
10
9
|
import {
|
|
11
10
|
DEFAULT_HOOK_PRIORITY,
|
|
12
11
|
HOOK_TIMEOUT_MS,
|
|
13
12
|
PLUGIN_NAMESPACE_SEPARATOR,
|
|
14
13
|
} from '../constants/plugin/index.js'
|
|
15
14
|
import { GENAI } from '../constants/telemetry/index.js'
|
|
15
|
+
import { PromptContributionRegistry } from '../prompt/contributions.js'
|
|
16
|
+
import type { PromptContribution } from '../prompt/contributions.js'
|
|
16
17
|
import type { PluginRegistry } from '../registry/plugin/index.js'
|
|
17
18
|
import { loadSkill } from '../skills/loader.js'
|
|
18
19
|
import type { SkillRegistry } from '../skills/registry.js'
|
|
19
20
|
import { resolveWithinReal } from '../tools/paths.js'
|
|
21
|
+
import { wrapUntrusted } from '../tools/untrusted-envelope.js'
|
|
22
|
+
import type { Toolset } from '../toolsets/types.js'
|
|
23
|
+
import { deferred, prefixed } from '../toolsets/wrappers.js'
|
|
20
24
|
import type { PluginId } from '../types/ids/index.js'
|
|
21
25
|
import type {
|
|
22
26
|
PluginDefinition,
|
|
@@ -31,28 +35,22 @@ import type {
|
|
|
31
35
|
} from '../types/plugin/index.js'
|
|
32
36
|
import { assertPluginHookEvent } from '../types/plugin/index.js'
|
|
33
37
|
import type { SessionEvent } from '../types/session/index.js'
|
|
34
|
-
import type { ToolDefinition
|
|
38
|
+
import type { ToolDefinition } from '../types/tool/index.js'
|
|
35
39
|
import { toErrorMessage } from '../utils/error.js'
|
|
36
40
|
import { generatePluginId } from '../utils/id.js'
|
|
37
41
|
import { SCOPE_ATTRIBUTE } from '../utils/log/types.js'
|
|
38
42
|
import type { Logger } from '../utils/logger.js'
|
|
43
|
+
import { type DefinedPlugin, definePlugin } from './define.js'
|
|
39
44
|
import { assertEnableable, loadPluginManifest } from './loader.js'
|
|
40
45
|
|
|
41
46
|
interface PluginContributionRecord {
|
|
42
47
|
toolNames: string[]
|
|
43
48
|
mcpClients: MCPClient[]
|
|
49
|
+
mcpToolsets: Toolset[]
|
|
50
|
+
mcpUnsubscribers: Array<() => void>
|
|
51
|
+
mcpNamesBySource: Map<string, Set<string>>
|
|
44
52
|
/** Namespaced skill names, so rollback and disable can take them back. */
|
|
45
53
|
skillNames: string[]
|
|
46
|
-
/**
|
|
47
|
-
* One per client, held so teardown can stop them.
|
|
48
|
-
*
|
|
49
|
-
* A supervisor still attached when `disconnect()` runs reads the teardown
|
|
50
|
-
* as a fault and reconnects what was just closed — the lifecycle event
|
|
51
|
-
* cannot tell a deliberate disconnect from a dropped transport. Keeping
|
|
52
|
-
* them here is what makes the required stop-then-disconnect ordering
|
|
53
|
-
* possible at all.
|
|
54
|
-
*/
|
|
55
|
-
mcpSupervisors: MCPReconnectSupervisor[]
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
interface PluginAdmission {
|
|
@@ -61,6 +59,38 @@ interface PluginAdmission {
|
|
|
61
59
|
readonly scope: PluginScope
|
|
62
60
|
readonly rootDir: string
|
|
63
61
|
readonly installedAt: number
|
|
62
|
+
readonly inCode?: DefinedPlugin
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Dynamic imports bypass ToolDefinition's TypeScript contract. */
|
|
66
|
+
function assertPluginTool(
|
|
67
|
+
value: unknown,
|
|
68
|
+
pluginName: string,
|
|
69
|
+
origin: string,
|
|
70
|
+
index: number,
|
|
71
|
+
): asserts value is ToolDefinition {
|
|
72
|
+
const tool = value && typeof value === 'object' ? (value as Record<string, unknown>) : null
|
|
73
|
+
const label = `Plugin "${pluginName}" tool #${index} from ${origin}`
|
|
74
|
+
if (
|
|
75
|
+
!tool ||
|
|
76
|
+
typeof tool.name !== 'string' ||
|
|
77
|
+
tool.name.length === 0 ||
|
|
78
|
+
typeof tool.description !== 'string' ||
|
|
79
|
+
typeof tool.execute !== 'function'
|
|
80
|
+
) {
|
|
81
|
+
throw new Error(`${label} must define name, description and execute.`)
|
|
82
|
+
}
|
|
83
|
+
const schema = tool.inputSchema
|
|
84
|
+
if (
|
|
85
|
+
!schema ||
|
|
86
|
+
typeof schema !== 'object' ||
|
|
87
|
+
typeof (schema as { safeParse?: unknown }).safeParse !== 'function' ||
|
|
88
|
+
(!tool.modelInputSchema && typeof (schema as { _def?: unknown })._def !== 'object')
|
|
89
|
+
) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`${label} must define inputSchema as a Zod schema, or as a compatible parser with modelInputSchema.`,
|
|
92
|
+
)
|
|
93
|
+
}
|
|
64
94
|
}
|
|
65
95
|
|
|
66
96
|
function immutableManifest(manifest: PluginDefinition['manifest']): PluginDefinition['manifest'] {
|
|
@@ -77,6 +107,7 @@ function immutableManifest(manifest: PluginDefinition['manifest']): PluginDefini
|
|
|
77
107
|
version: manifest.version,
|
|
78
108
|
description: manifest.description,
|
|
79
109
|
...(manifest.author !== undefined ? { author: manifest.author } : {}),
|
|
110
|
+
...(manifest.instructions !== undefined ? { instructions: manifest.instructions } : {}),
|
|
80
111
|
...(manifest.tools ? { tools: Object.freeze([...manifest.tools]) } : {}),
|
|
81
112
|
...(manifest.skills ? { skills: Object.freeze([...manifest.skills]) } : {}),
|
|
82
113
|
...(manifest.hooks ? { hooks: Object.freeze([...manifest.hooks]) } : {}),
|
|
@@ -88,7 +119,6 @@ function immutableManifest(manifest: PluginDefinition['manifest']): PluginDefini
|
|
|
88
119
|
|
|
89
120
|
export interface PluginLifecycleManagerConfig {
|
|
90
121
|
pluginRegistry: PluginRegistry
|
|
91
|
-
toolRegistry: ToolRegistryContract
|
|
92
122
|
/**
|
|
93
123
|
* Filesystem authorities for each plugin scope.
|
|
94
124
|
*
|
|
@@ -151,13 +181,19 @@ export interface PluginLifecycleManagerConfig {
|
|
|
151
181
|
|
|
152
182
|
export class PluginLifecycleManager {
|
|
153
183
|
private pluginRegistry: PluginRegistry
|
|
154
|
-
|
|
184
|
+
/** Each installed plugin owns its own file source and one source per MCP server. */
|
|
185
|
+
private readonly pluginFileTools = new Map<string, ToolDefinition>()
|
|
186
|
+
private readonly pluginMcpTools = new Map<string, ToolDefinition>()
|
|
187
|
+
private readonly mcpOwnerByName = new Map<string, string>()
|
|
188
|
+
private readonly toolsetsByPlugin = new Map<PluginId, readonly Toolset[]>()
|
|
189
|
+
private readonly instructions = new PromptContributionRegistry()
|
|
190
|
+
private readonly toolsetChangeListeners = new Set<() => void>()
|
|
155
191
|
private listeners: PluginEventListener[] = []
|
|
156
192
|
private hookHandlers: Map<
|
|
157
193
|
PluginHookEvent,
|
|
158
194
|
Array<{
|
|
159
195
|
pluginId: PluginId
|
|
160
|
-
handler:
|
|
196
|
+
handler: (context: PluginHookContext) => Promise<PluginHookResult>
|
|
161
197
|
priority: number
|
|
162
198
|
seq: number
|
|
163
199
|
}>
|
|
@@ -184,16 +220,19 @@ export class PluginLifecycleManager {
|
|
|
184
220
|
* reads.
|
|
185
221
|
*/
|
|
186
222
|
private mcpDiscovery: MCPToolDiscovery
|
|
223
|
+
private readonly mcpToolPolicies?: Readonly<Record<string, MCPToolPolicy>>
|
|
224
|
+
private readonly onMCPToolDrift?: MCPToolDiscoveryOptions['onDrift']
|
|
187
225
|
|
|
188
226
|
private readonly skillRegistry: SkillRegistry | undefined
|
|
189
227
|
|
|
190
228
|
constructor(config: PluginLifecycleManagerConfig) {
|
|
191
229
|
this.pluginRegistry = config.pluginRegistry
|
|
192
|
-
this.toolRegistry = config.toolRegistry
|
|
193
230
|
this.skillRegistry = config.skillRegistry
|
|
194
231
|
this.scopeRoots = Object.freeze({ ...config.scopeRoots })
|
|
195
232
|
this.hookTimeoutMs = config.hookTimeoutMs ?? HOOK_TIMEOUT_MS
|
|
196
233
|
this.configRegistry = config.configRegistry
|
|
234
|
+
this.mcpToolPolicies = config.mcpToolPolicies
|
|
235
|
+
this.onMCPToolDrift = config.onMCPToolDrift
|
|
197
236
|
this.log = config.log.child({ [SCOPE_ATTRIBUTE]: 'plugin/lifecycle' })
|
|
198
237
|
this.mcpDiscovery = new MCPToolDiscovery([], {
|
|
199
238
|
...(config.mcpToolPolicies ? { policies: config.mcpToolPolicies } : {}),
|
|
@@ -202,6 +241,81 @@ export class PluginLifecycleManager {
|
|
|
202
241
|
})
|
|
203
242
|
}
|
|
204
243
|
|
|
244
|
+
/** Stable entries created at install, before a host composes its ToolManager. */
|
|
245
|
+
get toolsets(): readonly Toolset[] {
|
|
246
|
+
return [...this.toolsetsByPlugin.values()].flat()
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Plugin-authored request context from enabled plugins. */
|
|
250
|
+
get promptContributions(): readonly PromptContribution[] {
|
|
251
|
+
return this.instructions.list()
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private registerToolsets(admission: PluginAdmission): void {
|
|
255
|
+
if (this.toolsetsByPlugin.has(admission.id)) return
|
|
256
|
+
const pluginName = admission.manifest.name
|
|
257
|
+
const onChange = (listener: () => void) => {
|
|
258
|
+
this.toolsetChangeListeners.add(listener)
|
|
259
|
+
return () => this.toolsetChangeListeners.delete(listener)
|
|
260
|
+
}
|
|
261
|
+
const fileTools = deferred({
|
|
262
|
+
source: {
|
|
263
|
+
id: `plugin:${pluginName}`,
|
|
264
|
+
kind: 'plugin' as const,
|
|
265
|
+
name: pluginName,
|
|
266
|
+
},
|
|
267
|
+
tools: () =>
|
|
268
|
+
[...this.pluginFileTools.values()].filter((tool) =>
|
|
269
|
+
tool.name.startsWith(`${pluginName}${PLUGIN_NAMESPACE_SEPARATOR}`),
|
|
270
|
+
),
|
|
271
|
+
onChange,
|
|
272
|
+
})
|
|
273
|
+
const mcpTools = (admission.manifest.mcpServers ?? []).map((server) =>
|
|
274
|
+
deferred({
|
|
275
|
+
source: {
|
|
276
|
+
id: `plugin:${pluginName}/mcp:${server.name}`,
|
|
277
|
+
kind: 'mcp_server' as const,
|
|
278
|
+
name: server.name,
|
|
279
|
+
mcpServer: { name: server.name, readOnlyHintTrusted: false },
|
|
280
|
+
},
|
|
281
|
+
tools: () =>
|
|
282
|
+
[...this.pluginMcpTools.values()].filter(
|
|
283
|
+
(tool) =>
|
|
284
|
+
this.mcpOwnerByName.get(tool.name) === `plugin:${pluginName}/mcp:${server.name}`,
|
|
285
|
+
),
|
|
286
|
+
onChange,
|
|
287
|
+
}),
|
|
288
|
+
)
|
|
289
|
+
this.toolsetsByPlugin.set(admission.id, [fileTools, ...mcpTools])
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private notifyToolsetChange(): void {
|
|
293
|
+
for (const listener of this.toolsetChangeListeners) listener()
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** A file-declared plugin tool. Always deferred, like every other tool this manager contributes. */
|
|
297
|
+
private addFileTool(tool: ToolDefinition): void {
|
|
298
|
+
this.pluginFileTools.set(tool.name, tool)
|
|
299
|
+
this.notifyToolsetChange()
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** An MCP-discovered tool or a prompt adapted to one. */
|
|
303
|
+
private addMcpTool(tool: ToolDefinition, sourceId: string): void {
|
|
304
|
+
this.pluginMcpTools.set(tool.name, tool)
|
|
305
|
+
this.mcpOwnerByName.set(tool.name, sourceId)
|
|
306
|
+
this.notifyToolsetChange()
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** Reverses whichever of the two maps above actually holds `name`; a name in neither is a no-op. */
|
|
310
|
+
private removeContributedTool(name: string): void {
|
|
311
|
+
const removedFile = this.pluginFileTools.delete(name)
|
|
312
|
+
const removedMcp = this.pluginMcpTools.delete(name)
|
|
313
|
+
this.mcpOwnerByName.delete(name)
|
|
314
|
+
if (removedFile || removedMcp) {
|
|
315
|
+
this.notifyToolsetChange()
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
205
319
|
/**
|
|
206
320
|
* Attach a hook without installing a plugin from disk.
|
|
207
321
|
*
|
|
@@ -272,6 +386,7 @@ export class PluginLifecycleManager {
|
|
|
272
386
|
|
|
273
387
|
this.pluginRegistry.register(definition)
|
|
274
388
|
this.pluginAdmissions.set(pluginId, admission)
|
|
389
|
+
this.registerToolsets(admission)
|
|
275
390
|
|
|
276
391
|
this.emit({
|
|
277
392
|
type: 'plugin_installed',
|
|
@@ -290,6 +405,42 @@ export class PluginLifecycleManager {
|
|
|
290
405
|
return definition
|
|
291
406
|
}
|
|
292
407
|
|
|
408
|
+
/** Register a host-authored plugin without reading a manifest or importing modules. */
|
|
409
|
+
installDefined(plugin: DefinedPlugin, scope: PluginScope = 'project'): PluginDefinition {
|
|
410
|
+
const defined = definePlugin(plugin)
|
|
411
|
+
const existing = this.pluginRegistry.findByName(defined.name)
|
|
412
|
+
if (existing) {
|
|
413
|
+
throw new Error(`Plugin "${defined.name}" is already installed (id: ${existing.id})`)
|
|
414
|
+
}
|
|
415
|
+
const pluginId = generatePluginId()
|
|
416
|
+
const manifest = immutableManifest({
|
|
417
|
+
name: defined.name,
|
|
418
|
+
version: defined.version,
|
|
419
|
+
description: defined.description,
|
|
420
|
+
...(defined.instructions !== undefined ? { instructions: defined.instructions } : {}),
|
|
421
|
+
mcpServers: defined.mcpServers,
|
|
422
|
+
})
|
|
423
|
+
const admission: PluginAdmission = Object.freeze({
|
|
424
|
+
id: pluginId,
|
|
425
|
+
manifest,
|
|
426
|
+
scope,
|
|
427
|
+
rootDir: this.scopeRoots[scope],
|
|
428
|
+
installedAt: Date.now(),
|
|
429
|
+
inCode: defined,
|
|
430
|
+
})
|
|
431
|
+
const definition = this.definitionFrom(admission, 'installed')
|
|
432
|
+
this.pluginRegistry.register(definition)
|
|
433
|
+
this.pluginAdmissions.set(pluginId, admission)
|
|
434
|
+
this.registerToolsets(admission)
|
|
435
|
+
this.emit({
|
|
436
|
+
type: 'plugin_installed',
|
|
437
|
+
pluginId,
|
|
438
|
+
name: defined.name,
|
|
439
|
+
scope,
|
|
440
|
+
})
|
|
441
|
+
return definition
|
|
442
|
+
}
|
|
443
|
+
|
|
293
444
|
private definitionFrom(
|
|
294
445
|
admission: PluginAdmission,
|
|
295
446
|
status: PluginDefinition['status'],
|
|
@@ -354,6 +505,7 @@ export class PluginLifecycleManager {
|
|
|
354
505
|
try {
|
|
355
506
|
admission = await this.readLegacyAdmission(plugin)
|
|
356
507
|
this.pluginAdmissions.set(pluginId, admission)
|
|
508
|
+
this.registerToolsets(admission)
|
|
357
509
|
} catch (error) {
|
|
358
510
|
this.pluginRegistry.register({
|
|
359
511
|
...plugin,
|
|
@@ -374,7 +526,9 @@ export class PluginLifecycleManager {
|
|
|
374
526
|
// `installed`: a status that says the plugin is fine while it can
|
|
375
527
|
// never enable is how the next reader gets misled.
|
|
376
528
|
try {
|
|
377
|
-
assertEnableable(manifest, {
|
|
529
|
+
assertEnableable(manifest, {
|
|
530
|
+
skillsSupported: Boolean(this.skillRegistry),
|
|
531
|
+
})
|
|
378
532
|
} catch (err) {
|
|
379
533
|
this.pluginRegistry.register({
|
|
380
534
|
...this.definitionFrom(admission, 'error'),
|
|
@@ -386,13 +540,22 @@ export class PluginLifecycleManager {
|
|
|
386
540
|
const contributions: PluginContributionRecord = {
|
|
387
541
|
toolNames: [],
|
|
388
542
|
mcpClients: [],
|
|
543
|
+
mcpToolsets: [],
|
|
544
|
+
mcpUnsubscribers: [],
|
|
545
|
+
mcpNamesBySource: new Map(),
|
|
389
546
|
skillNames: [],
|
|
390
|
-
mcpSupervisors: [],
|
|
391
547
|
}
|
|
392
548
|
|
|
393
549
|
try {
|
|
394
|
-
//
|
|
395
|
-
if (
|
|
550
|
+
// Host-authored definitions have no file path to resolve or module to import.
|
|
551
|
+
if (admission.inCode) {
|
|
552
|
+
for (const [index, tool] of admission.inCode.tools.entries()) {
|
|
553
|
+
assertPluginTool(tool, manifest.name, 'the in-code declaration', index + 1)
|
|
554
|
+
const namespacedName = manifest.name + PLUGIN_NAMESPACE_SEPARATOR + tool.name
|
|
555
|
+
this.addFileTool({ ...tool, name: namespacedName })
|
|
556
|
+
contributions.toolNames.push(namespacedName)
|
|
557
|
+
}
|
|
558
|
+
} else if (manifest.tools && manifest.tools.length > 0) {
|
|
396
559
|
for (const toolPath of manifest.tools) {
|
|
397
560
|
const absolutePath = await resolveWithinReal(admission.rootDir, toolPath)
|
|
398
561
|
const fileUrl = pathToFileURL(absolutePath).href
|
|
@@ -404,10 +567,14 @@ export class PluginLifecycleManager {
|
|
|
404
567
|
)
|
|
405
568
|
}
|
|
406
569
|
|
|
407
|
-
for (const tool of mod.tools) {
|
|
570
|
+
for (const [index, tool] of mod.tools.entries()) {
|
|
571
|
+
assertPluginTool(tool, manifest.name, `"${toolPath}"`, index + 1)
|
|
408
572
|
const namespacedName = manifest.name + PLUGIN_NAMESPACE_SEPARATOR + tool.name
|
|
409
|
-
const namespacedTool: ToolDefinition = {
|
|
410
|
-
|
|
573
|
+
const namespacedTool: ToolDefinition = {
|
|
574
|
+
...tool,
|
|
575
|
+
name: namespacedName,
|
|
576
|
+
}
|
|
577
|
+
this.addFileTool(namespacedTool)
|
|
411
578
|
contributions.toolNames.push(namespacedName)
|
|
412
579
|
}
|
|
413
580
|
}
|
|
@@ -441,11 +608,15 @@ export class PluginLifecycleManager {
|
|
|
441
608
|
}
|
|
442
609
|
|
|
443
610
|
// Load hooks
|
|
444
|
-
if (
|
|
611
|
+
if (admission.inCode) {
|
|
612
|
+
for (const hook of admission.inCode.hooks) this.registerHook(pluginId, hook)
|
|
613
|
+
} else if (manifest.hooks && manifest.hooks.length > 0) {
|
|
445
614
|
for (const hookPath of manifest.hooks) {
|
|
446
615
|
const absolutePath = await resolveWithinReal(admission.rootDir, hookPath)
|
|
447
616
|
const fileUrl = pathToFileURL(absolutePath).href
|
|
448
|
-
const mod = (await import(fileUrl)) as {
|
|
617
|
+
const mod = (await import(fileUrl)) as {
|
|
618
|
+
hooks?: PluginHookDefinition[]
|
|
619
|
+
}
|
|
449
620
|
|
|
450
621
|
if (!mod.hooks || !Array.isArray(mod.hooks)) {
|
|
451
622
|
throw new Error(
|
|
@@ -471,6 +642,24 @@ export class PluginLifecycleManager {
|
|
|
471
642
|
}
|
|
472
643
|
|
|
473
644
|
this.pluginContributions.set(pluginId, contributions)
|
|
645
|
+
const pluginInstructions = manifest.instructions
|
|
646
|
+
if (pluginInstructions?.trim()) {
|
|
647
|
+
this.instructions.register({
|
|
648
|
+
id: `plugin:${manifest.name}:instructions`,
|
|
649
|
+
placement: 'context',
|
|
650
|
+
render: () => {
|
|
651
|
+
if (!this.pluginContributions.has(pluginId)) return null
|
|
652
|
+
return wrapUntrusted(
|
|
653
|
+
{
|
|
654
|
+
kind: 'plugin-instructions',
|
|
655
|
+
attributes: { plugin: manifest.name },
|
|
656
|
+
provenance: `Plugin ${JSON.stringify(manifest.name)} supplied this text; it is plugin-authored context, not operator instructions or tool permissions.`,
|
|
657
|
+
},
|
|
658
|
+
pluginInstructions,
|
|
659
|
+
)
|
|
660
|
+
},
|
|
661
|
+
})
|
|
662
|
+
}
|
|
474
663
|
|
|
475
664
|
const enabled = this.definitionFrom(admission, 'enabled', Date.now())
|
|
476
665
|
this.pluginRegistry.register(enabled)
|
|
@@ -488,7 +677,12 @@ export class PluginLifecycleManager {
|
|
|
488
677
|
// prose that is itself the debt.
|
|
489
678
|
'namzu.plugin.id': pluginId,
|
|
490
679
|
'namzu.plugin.name': manifest.name,
|
|
491
|
-
'namzu.plugin.tool_count':
|
|
680
|
+
'namzu.plugin.tool_count':
|
|
681
|
+
contributions.toolNames.length +
|
|
682
|
+
[...contributions.mcpNamesBySource.values()].reduce(
|
|
683
|
+
(count, names) => count + names.size,
|
|
684
|
+
0,
|
|
685
|
+
),
|
|
492
686
|
'namzu.plugin.skill_count': contributions.skillNames.length,
|
|
493
687
|
'namzu.plugin.mcp_server_count': contributions.mcpClients.length,
|
|
494
688
|
})
|
|
@@ -513,67 +707,52 @@ export class PluginLifecycleManager {
|
|
|
513
707
|
await client.connect()
|
|
514
708
|
contributions.mcpClients.push(client)
|
|
515
709
|
|
|
516
|
-
//
|
|
517
|
-
// made: `transport.onClose` marked the client disconnected and rejected
|
|
518
|
-
// its pending calls, and nothing scheduled another try — so one blip
|
|
519
|
-
// took this plugin's tools out for the life of the process while the
|
|
520
|
-
// plugin went on reporting as enabled.
|
|
521
|
-
// The policy is read from the registry on EVERY attempt, not captured
|
|
522
|
-
// here. That is what makes the seam live: raising `maxAttempts` during
|
|
523
|
-
// an outage takes effect on the retry that is already running, which is
|
|
524
|
-
// the moment an operator actually reaches for it.
|
|
525
|
-
//
|
|
526
|
-
// Namespaced per server rather than globally, because two plugins'
|
|
527
|
-
// servers fail differently — one behind a flaky proxy wants patience,
|
|
528
|
-
// one behind a crash loop wants to give up and say so.
|
|
710
|
+
// The toolset owns reconnection and reads this policy on each attempt.
|
|
529
711
|
const policyScope = this.configRegistry?.register(
|
|
530
712
|
`mcp.${config.name}`,
|
|
531
713
|
MCPReconnectOptionsSchema,
|
|
532
714
|
)
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
715
|
+
// Preserve cross-disable drift detection. The live toolset below owns
|
|
716
|
+
// changes during this enablement; this manager-owned discovery remembers
|
|
717
|
+
// the server's earlier admission across clients and plugin lifetimes.
|
|
718
|
+
await this.mcpDiscovery.discoverFrom(client)
|
|
719
|
+
const sourceId = `plugin:${pluginName}/mcp:${config.name}`
|
|
720
|
+
const policy = this.mcpToolPolicies?.[config.name] ?? this.mcpToolPolicies?.['*']
|
|
721
|
+
const entries = await mcpToolset(client, {
|
|
722
|
+
id: sourceId,
|
|
723
|
+
availability: 'deferred',
|
|
724
|
+
allow: policy?.allow,
|
|
725
|
+
deny: policy?.deny,
|
|
726
|
+
reconnect: policyScope ? () => policyScope.get() : {},
|
|
727
|
+
onDrift: this.onMCPToolDrift,
|
|
728
|
+
logger: this.log,
|
|
729
|
+
})
|
|
730
|
+
contributions.mcpToolsets.push(...entries)
|
|
731
|
+
const wrapped = entries.map((entry) =>
|
|
732
|
+
prefixed(entry, `${pluginName}${PLUGIN_NAMESPACE_SEPARATOR}`),
|
|
536
733
|
)
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const discovered = await this.mcpDiscovery.discoverFrom(client)
|
|
547
|
-
const mcpTools = discovered.map((d) => d.tool)
|
|
548
|
-
for (const mcpTool of mcpTools) {
|
|
549
|
-
const baseDef = mcpToolToToolDefinition(mcpTool, client, config.name)
|
|
550
|
-
// Double-underscore between serverName and toolName so that e.g.
|
|
551
|
-
// (server="fs", tool="read_file") and (server="fs_read", tool="file")
|
|
552
|
-
// produce distinct final names.
|
|
553
|
-
const namespacedName = `${pluginName}${PLUGIN_NAMESPACE_SEPARATOR}mcp__${config.name}__${mcpTool.name}`
|
|
554
|
-
const namespacedTool: ToolDefinition = { ...baseDef, name: namespacedName }
|
|
555
|
-
this.toolRegistry.register(namespacedTool, 'deferred')
|
|
556
|
-
contributions.toolNames.push(namespacedName)
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
// Prompts, through the same gate. A server publishing one is the same
|
|
560
|
-
// trust question as a server publishing a tool.
|
|
561
|
-
const prompts = await this.mcpDiscovery.discoverPromptsFrom(client)
|
|
562
|
-
for (const prompt of prompts) {
|
|
563
|
-
const baseDef = mcpPromptToToolDefinition(prompt, client, config.name)
|
|
564
|
-
const namespacedName = `${pluginName}${PLUGIN_NAMESPACE_SEPARATOR}${baseDef.name}`
|
|
565
|
-
this.toolRegistry.register({ ...baseDef, name: namespacedName }, 'deferred')
|
|
566
|
-
contributions.toolNames.push(namespacedName)
|
|
734
|
+
const sync = () => {
|
|
735
|
+
const previous = contributions.mcpNamesBySource.get(sourceId) ?? new Set<string>()
|
|
736
|
+
const nextTools = wrapped.flatMap((entry) => entry.tools())
|
|
737
|
+
const nextNames = new Set(nextTools.map((tool) => tool.name))
|
|
738
|
+
for (const name of previous) {
|
|
739
|
+
if (!nextNames.has(name)) this.removeContributedTool(name)
|
|
740
|
+
}
|
|
741
|
+
for (const tool of nextTools) this.addMcpTool(tool, sourceId)
|
|
742
|
+
contributions.mcpNamesBySource.set(sourceId, nextNames)
|
|
567
743
|
}
|
|
744
|
+
contributions.mcpUnsubscribers.push(entries[0].onChange?.(sync) ?? (() => {}))
|
|
745
|
+
sync()
|
|
568
746
|
}
|
|
569
747
|
|
|
570
748
|
private async rollbackContributions(
|
|
571
749
|
pluginId: PluginId,
|
|
572
750
|
contributions: PluginContributionRecord,
|
|
573
751
|
): Promise<void> {
|
|
752
|
+
await this.stopMcpContributions(contributions, 'rollback')
|
|
574
753
|
for (const name of contributions.toolNames) {
|
|
575
754
|
try {
|
|
576
|
-
this.
|
|
755
|
+
this.removeContributedTool(name)
|
|
577
756
|
} catch (unregErr) {
|
|
578
757
|
this.log.warn('Rollback: tool unregister failed', {
|
|
579
758
|
[GENAI.TOOL_NAME]: name,
|
|
@@ -586,21 +765,6 @@ export class PluginLifecycleManager {
|
|
|
586
765
|
// Wrapping it would suggest a failure mode that does not exist.
|
|
587
766
|
this.skillRegistry?.unregister(name)
|
|
588
767
|
}
|
|
589
|
-
// Stop supervising BEFORE disconnecting. The lifecycle event a
|
|
590
|
-
// deliberate disconnect emits is the same one a dropped transport
|
|
591
|
-
// emits, so a still-attached supervisor would reconnect what this
|
|
592
|
-
// rollback just closed.
|
|
593
|
-
for (const supervisor of contributions.mcpSupervisors) supervisor.stop()
|
|
594
|
-
for (const client of contributions.mcpClients) {
|
|
595
|
-
try {
|
|
596
|
-
await client.disconnect()
|
|
597
|
-
} catch (discErr) {
|
|
598
|
-
this.log.warn('Rollback: MCP disconnect failed', {
|
|
599
|
-
'namzu.mcp.client_id': client.id,
|
|
600
|
-
'exception.message': toErrorMessage(discErr),
|
|
601
|
-
})
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
768
|
for (const [event, handlers] of this.hookHandlers) {
|
|
605
769
|
const filtered = handlers.filter((h) => h.pluginId !== pluginId)
|
|
606
770
|
if (filtered.length === 0) {
|
|
@@ -611,6 +775,28 @@ export class PluginLifecycleManager {
|
|
|
611
775
|
}
|
|
612
776
|
}
|
|
613
777
|
|
|
778
|
+
private async stopMcpContributions(
|
|
779
|
+
contributions: PluginContributionRecord,
|
|
780
|
+
operation: 'rollback' | 'disable',
|
|
781
|
+
): Promise<void> {
|
|
782
|
+
for (const unsubscribe of contributions.mcpUnsubscribers) unsubscribe()
|
|
783
|
+
for (const entry of contributions.mcpToolsets) await entry.close?.()
|
|
784
|
+
for (const client of contributions.mcpClients) {
|
|
785
|
+
try {
|
|
786
|
+
await client.disconnect()
|
|
787
|
+
} catch (error) {
|
|
788
|
+
this.log.warn('MCP disconnect failed', {
|
|
789
|
+
'namzu.plugin.operation': operation,
|
|
790
|
+
'namzu.mcp.client_id': client.id,
|
|
791
|
+
'exception.message': toErrorMessage(error),
|
|
792
|
+
})
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
for (const names of contributions.mcpNamesBySource.values()) {
|
|
796
|
+
for (const name of names) this.removeContributedTool(name)
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
614
800
|
async disable(pluginId: PluginId): Promise<void> {
|
|
615
801
|
const plugin = this.pluginRegistry.getOrThrow(pluginId)
|
|
616
802
|
const admission = this.pluginAdmissions.get(pluginId)
|
|
@@ -622,24 +808,11 @@ export class PluginLifecycleManager {
|
|
|
622
808
|
)
|
|
623
809
|
}
|
|
624
810
|
|
|
625
|
-
|
|
626
|
-
// disconnect below emits the event the supervisor treats as a fault.
|
|
627
|
-
for (const supervisor of contributions.mcpSupervisors) supervisor.stop()
|
|
628
|
-
// Disconnect MCP clients first so no new tool calls can reach them mid-teardown.
|
|
629
|
-
for (const client of contributions.mcpClients) {
|
|
630
|
-
try {
|
|
631
|
-
await client.disconnect()
|
|
632
|
-
} catch (err) {
|
|
633
|
-
this.log.warn('MCP client disconnect failed during disable', {
|
|
634
|
-
'namzu.mcp.client_id': client.id,
|
|
635
|
-
'exception.message': toErrorMessage(err),
|
|
636
|
-
})
|
|
637
|
-
}
|
|
638
|
-
}
|
|
811
|
+
await this.stopMcpContributions(contributions, 'disable')
|
|
639
812
|
|
|
640
|
-
// Unregister
|
|
813
|
+
// Unregister file-declared tools; MCP entries were removed above.
|
|
641
814
|
for (const name of contributions.toolNames) {
|
|
642
|
-
this.
|
|
815
|
+
this.removeContributedTool(name)
|
|
643
816
|
}
|
|
644
817
|
|
|
645
818
|
// And its skills. A disabled plugin whose skills stayed registered
|
|
@@ -661,6 +834,9 @@ export class PluginLifecycleManager {
|
|
|
661
834
|
}
|
|
662
835
|
|
|
663
836
|
this.pluginContributions.delete(pluginId)
|
|
837
|
+
this.instructions.unregister(
|
|
838
|
+
`plugin:${admission?.manifest.name ?? plugin.manifest.name}:instructions`,
|
|
839
|
+
)
|
|
664
840
|
|
|
665
841
|
// Update status to disabled
|
|
666
842
|
const disabled: PluginDefinition = admission
|
|
@@ -689,7 +865,11 @@ export class PluginLifecycleManager {
|
|
|
689
865
|
}
|
|
690
866
|
|
|
691
867
|
this.pluginRegistry.unregister(pluginId)
|
|
868
|
+
this.instructions.unregister(
|
|
869
|
+
`plugin:${admission?.manifest.name ?? plugin.manifest.name}:instructions`,
|
|
870
|
+
)
|
|
692
871
|
this.pluginAdmissions.delete(pluginId)
|
|
872
|
+
this.toolsetsByPlugin.delete(pluginId)
|
|
693
873
|
|
|
694
874
|
this.emit({
|
|
695
875
|
type: 'plugin_uninstalled',
|
package/src/plugin/resolver.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { PLUGIN_NAMESPACE_SEPARATOR } from '../constants/plugin/index.js'
|
|
2
2
|
import type { PluginRegistry } from '../registry/plugin/index.js'
|
|
3
|
+
import type { ToolManager } from '../toolsets/manager.js'
|
|
3
4
|
import type { PluginId } from '../types/ids/index.js'
|
|
4
5
|
import type { PluginContributionType } from '../types/plugin/index.js'
|
|
5
|
-
import type { ToolRegistryContract } from '../types/tool/index.js'
|
|
6
6
|
|
|
7
7
|
export class PluginResolver {
|
|
8
8
|
private pluginRegistry: PluginRegistry
|
|
9
|
-
private toolRegistry:
|
|
9
|
+
private toolRegistry: Pick<ToolManager, 'listNames' | 'has'>
|
|
10
10
|
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(
|
|
12
|
+
pluginRegistry: PluginRegistry,
|
|
13
|
+
toolRegistry: Pick<ToolManager, 'listNames' | 'has'>,
|
|
14
|
+
) {
|
|
12
15
|
this.pluginRegistry = pluginRegistry
|
|
13
16
|
this.toolRegistry = toolRegistry
|
|
14
17
|
}
|
package/src/plugin/shell-hook.ts
CHANGED
|
@@ -117,7 +117,9 @@ export interface ShellHookEntry {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/** Event → entries, the shape a host's config file carries. */
|
|
120
|
-
export type ShellHooksConfig = {
|
|
120
|
+
export type ShellHooksConfig = {
|
|
121
|
+
readonly [event in ShellHookEvent]?: readonly ShellHookEntry[]
|
|
122
|
+
}
|
|
121
123
|
|
|
122
124
|
/** The plugin id host shell hooks register under when the host names none. */
|
|
123
125
|
export const SHELL_HOOKS_PLUGIN_ID: PluginId = asPluginId('6d6f6bec-9d54-485b-90ca-52edbac1009d')
|
|
@@ -278,7 +280,13 @@ export function runShellHook(
|
|
|
278
280
|
const onAbort = () => killTree()
|
|
279
281
|
signal?.addEventListener('abort', onAbort, { once: true })
|
|
280
282
|
child.on('error', (error) => {
|
|
281
|
-
finish({
|
|
283
|
+
finish({
|
|
284
|
+
exitCode: null,
|
|
285
|
+
timedOut,
|
|
286
|
+
stdout,
|
|
287
|
+
stderr,
|
|
288
|
+
spawnError: error.message,
|
|
289
|
+
})
|
|
282
290
|
})
|
|
283
291
|
child.on('close', (code) => {
|
|
284
292
|
finish({ exitCode: code, timedOut, stdout, stderr })
|
|
@@ -319,9 +327,15 @@ export function shellHookVerdict(
|
|
|
319
327
|
outcome: ShellHookOutcome,
|
|
320
328
|
log: Logger = NOOP_LOGGER,
|
|
321
329
|
): PluginHookResult {
|
|
322
|
-
const attrs = {
|
|
330
|
+
const attrs = {
|
|
331
|
+
'namzu.hook.event': event,
|
|
332
|
+
'namzu.hook.command': entry.command,
|
|
333
|
+
}
|
|
323
334
|
if (outcome.spawnError !== undefined) {
|
|
324
|
-
log.warn('hook could not start', {
|
|
335
|
+
log.warn('hook could not start', {
|
|
336
|
+
...attrs,
|
|
337
|
+
'namzu.hook.error': outcome.spawnError,
|
|
338
|
+
})
|
|
325
339
|
return { action: 'continue' }
|
|
326
340
|
}
|
|
327
341
|
if (outcome.timedOut) {
|
|
@@ -368,6 +382,8 @@ export function createShellHook(
|
|
|
368
382
|
options: ShellHookOptions,
|
|
369
383
|
): PluginHookDefinition {
|
|
370
384
|
const log = options.log ?? NOOP_LOGGER
|
|
385
|
+
// The shell verdict branches on `event`, but TypeScript cannot retain that
|
|
386
|
+
// correlation across the async handler closure and the union of events.
|
|
371
387
|
return {
|
|
372
388
|
event,
|
|
373
389
|
handler: async (context: PluginHookContext) => {
|
|
@@ -405,7 +421,7 @@ export function createShellHook(
|
|
|
405
421
|
)
|
|
406
422
|
return shellHookVerdict(event, entry, outcome, log)
|
|
407
423
|
},
|
|
408
|
-
}
|
|
424
|
+
} as PluginHookDefinition
|
|
409
425
|
}
|
|
410
426
|
|
|
411
427
|
/**
|