@namzu/sdk 46.0.0 → 48.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +325 -8
- package/README.md +7 -8
- package/dist/advisory/history.d.ts.map +1 -1
- package/dist/advisory/history.js +21 -1
- package/dist/advisory/history.js.map +1 -1
- package/dist/advisory/index.d.ts +1 -1
- package/dist/advisory/index.d.ts.map +1 -1
- package/dist/advisory/index.js +1 -1
- package/dist/advisory/index.js.map +1 -1
- package/dist/advisory/registry.d.ts +17 -0
- package/dist/advisory/registry.d.ts.map +1 -1
- package/dist/advisory/registry.js +26 -0
- package/dist/advisory/registry.js.map +1 -1
- package/dist/agents/PipelineAgent.d.ts +2 -46
- package/dist/agents/PipelineAgent.d.ts.map +1 -1
- package/dist/agents/PipelineAgent.js +2 -242
- package/dist/agents/PipelineAgent.js.map +1 -1
- package/dist/agents/QueryAgent.d.ts +21 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -0
- package/dist/agents/QueryAgent.js +214 -0
- package/dist/agents/QueryAgent.js.map +1 -0
- package/dist/agents/ReactiveAgent.d.ts +4 -16
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +4 -183
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts +2 -20
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +2 -266
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts +3 -43
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +3 -418
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/defineAgent.d.ts +2 -1
- package/dist/agents/defineAgent.d.ts.map +1 -1
- package/dist/agents/defineAgent.js +6 -1
- package/dist/agents/defineAgent.js.map +1 -1
- package/dist/agents/examples/PipelineAgent.d.ts +46 -0
- package/dist/agents/examples/PipelineAgent.d.ts.map +1 -0
- package/dist/agents/examples/PipelineAgent.js +242 -0
- package/dist/agents/examples/PipelineAgent.js.map +1 -0
- package/dist/agents/examples/RouterAgent.d.ts +22 -0
- package/dist/agents/examples/RouterAgent.d.ts.map +1 -0
- package/dist/agents/examples/RouterAgent.js +268 -0
- package/dist/agents/examples/RouterAgent.js.map +1 -0
- package/dist/agents/examples/SupervisorAgent.d.ts +45 -0
- package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -0
- package/dist/agents/examples/SupervisorAgent.js +406 -0
- package/dist/agents/examples/SupervisorAgent.js.map +1 -0
- package/dist/agents/explore.d.ts +6 -3
- package/dist/agents/explore.d.ts.map +1 -1
- package/dist/agents/explore.js +6 -3
- package/dist/agents/explore.js.map +1 -1
- package/dist/agents/forward-options.d.ts +11 -0
- package/dist/agents/forward-options.d.ts.map +1 -0
- package/dist/agents/forward-options.js +15 -0
- package/dist/agents/forward-options.js.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +2 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/runAgent.d.ts +19 -8
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +99 -29
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/authorization/command-line.d.ts +2 -0
- package/dist/authorization/command-line.d.ts.map +1 -1
- package/dist/authorization/command-line.js +2 -2
- package/dist/authorization/command-line.js.map +1 -1
- package/dist/authorization/gate.d.ts +8 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +12 -1
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/program.d.ts +151 -0
- package/dist/authorization/program.d.ts.map +1 -0
- package/dist/authorization/program.js +713 -0
- package/dist/authorization/program.js.map +1 -0
- package/dist/authorization/reexec-wrapper.d.ts +106 -0
- package/dist/authorization/reexec-wrapper.d.ts.map +1 -0
- package/dist/authorization/reexec-wrapper.js +532 -0
- package/dist/authorization/reexec-wrapper.js.map +1 -0
- package/dist/authorization/rules.d.ts +9 -0
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +8 -1
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +19 -4
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +91 -65
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +6 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/capabilities/index.d.ts +54 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +92 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/config/registry.d.ts +2 -1
- package/dist/config/registry.d.ts.map +1 -1
- package/dist/config/registry.js +3 -2
- package/dist/config/registry.js.map +1 -1
- package/dist/connector/index.d.ts +4 -4
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +3 -3
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/adapter.d.ts +16 -1
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +60 -4
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +13 -4
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +20 -3
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/discovery.d.ts +24 -1
- package/dist/connector/mcp/discovery.d.ts.map +1 -1
- package/dist/connector/mcp/discovery.js +44 -0
- package/dist/connector/mcp/discovery.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +2 -0
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +11 -0
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/mcp-toolset.d.ts +133 -0
- package/dist/connector/mcp/mcp-toolset.d.ts.map +1 -0
- package/dist/connector/mcp/mcp-toolset.js +399 -0
- package/dist/connector/mcp/mcp-toolset.js.map +1 -0
- package/dist/connector/tools/index.d.ts +2 -2
- package/dist/connector/tools/index.d.ts.map +1 -1
- package/dist/connector/tools/index.js +1 -1
- package/dist/connector/tools/index.js.map +1 -1
- package/dist/connector/tools/router.d.ts +15 -13
- package/dist/connector/tools/router.d.ts.map +1 -1
- package/dist/connector/tools/router.js +30 -51
- package/dist/connector/tools/router.js.map +1 -1
- package/dist/contracts/a2a.d.ts +2 -2
- package/dist/directory/derive-supervisor.d.ts +2 -2
- package/dist/directory/derive-supervisor.d.ts.map +1 -1
- package/dist/directory/derive-supervisor.js +6 -7
- package/dist/directory/derive-supervisor.js.map +1 -1
- package/dist/directory/derive.d.ts.map +1 -1
- package/dist/directory/derive.js +5 -5
- package/dist/directory/derive.js.map +1 -1
- package/dist/execution/code-runtime/types.d.ts +2 -2
- package/dist/execution/code-runtime/types.js +1 -1
- package/dist/invariants/index.d.ts +2 -1
- package/dist/invariants/index.d.ts.map +1 -1
- package/dist/invariants/index.js +3 -2
- package/dist/invariants/index.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +9 -0
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/connector/environment.d.ts +6 -0
- package/dist/manager/connector/environment.d.ts.map +1 -1
- package/dist/manager/connector/environment.js +11 -4
- package/dist/manager/connector/environment.js.map +1 -1
- package/dist/manager/connector/index.d.ts +2 -2
- package/dist/manager/connector/index.d.ts.map +1 -1
- package/dist/manager/connector/index.js +2 -2
- package/dist/manager/connector/index.js.map +1 -1
- package/dist/manager/connector/tenant.d.ts +6 -0
- package/dist/manager/connector/tenant.d.ts.map +1 -1
- package/dist/manager/connector/tenant.js +11 -4
- package/dist/manager/connector/tenant.js.map +1 -1
- package/dist/manager/index.d.ts +2 -2
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +2 -2
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/resident/learning-observation.d.ts +4 -4
- package/dist/manager/resident/learning.d.ts +36 -36
- package/dist/manager/session/attribution.d.ts +22 -0
- package/dist/manager/session/attribution.d.ts.map +1 -0
- package/dist/manager/session/attribution.js +64 -0
- package/dist/manager/session/attribution.js.map +1 -0
- package/dist/manager/session/turn-recorder.d.ts +14 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +208 -55
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/peers/address.d.ts +36 -0
- package/dist/peers/address.d.ts.map +1 -0
- package/dist/peers/address.js +52 -0
- package/dist/peers/address.js.map +1 -0
- package/dist/peers/client.d.ts +47 -0
- package/dist/peers/client.d.ts.map +1 -0
- package/dist/peers/client.js +132 -0
- package/dist/peers/client.js.map +1 -0
- package/dist/peers/dir.d.ts +88 -0
- package/dist/peers/dir.d.ts.map +1 -0
- package/dist/peers/dir.js +139 -0
- package/dist/peers/dir.js.map +1 -0
- package/dist/peers/endpoint.d.ts +144 -0
- package/dist/peers/endpoint.d.ts.map +1 -0
- package/dist/peers/endpoint.js +420 -0
- package/dist/peers/endpoint.js.map +1 -0
- package/dist/peers/envelope.d.ts +42 -0
- package/dist/peers/envelope.d.ts.map +1 -0
- package/dist/peers/envelope.js +110 -0
- package/dist/peers/envelope.js.map +1 -0
- package/dist/peers/index.d.ts +30 -0
- package/dist/peers/index.d.ts.map +1 -0
- package/dist/peers/index.js +22 -0
- package/dist/peers/index.js.map +1 -0
- package/dist/peers/protocol.d.ts +645 -0
- package/dist/peers/protocol.d.ts.map +1 -0
- package/dist/peers/protocol.js +151 -0
- package/dist/peers/protocol.js.map +1 -0
- package/dist/peers/record.d.ts +71 -0
- package/dist/peers/record.d.ts.map +1 -0
- package/dist/peers/record.js +45 -0
- package/dist/peers/record.js.map +1 -0
- package/dist/peers/registry.d.ts +54 -0
- package/dist/peers/registry.d.ts.map +1 -0
- package/dist/peers/registry.js +213 -0
- package/dist/peers/registry.js.map +1 -0
- package/dist/plugin/define.d.ts +24 -0
- package/dist/plugin/define.d.ts.map +1 -0
- package/dist/plugin/define.js +42 -0
- package/dist/plugin/define.js.map +1 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1 -0
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +27 -3
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +242 -92
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/resolver.d.ts +2 -2
- package/dist/plugin/resolver.d.ts.map +1 -1
- package/dist/plugin/resolver.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +17 -3
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/probe/errors.d.ts +2 -1
- package/dist/probe/errors.d.ts.map +1 -1
- package/dist/probe/errors.js +3 -2
- package/dist/probe/errors.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +18 -7
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +11 -6
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/prompt/contributions.d.ts +4 -1
- package/dist/prompt/contributions.d.ts.map +1 -1
- package/dist/prompt/contributions.js +7 -2
- package/dist/prompt/contributions.js.map +1 -1
- package/dist/prompt/index.d.ts +1 -1
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/index.js +1 -1
- package/dist/prompt/index.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts +6 -1
- package/dist/provider/collect-chat-completion.d.ts.map +1 -1
- package/dist/provider/collect-chat-completion.js +88 -10
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/mock.d.ts.map +1 -1
- package/dist/provider/mock.js +23 -6
- package/dist/provider/mock.js.map +1 -1
- package/dist/provider/registry.d.ts +2 -1
- package/dist/provider/registry.d.ts.map +1 -1
- package/dist/provider/registry.js +3 -2
- package/dist/provider/registry.js.map +1 -1
- package/dist/provider/tool-call-framing.d.ts +164 -0
- package/dist/provider/tool-call-framing.d.ts.map +1 -0
- package/dist/provider/tool-call-framing.js +163 -0
- package/dist/provider/tool-call-framing.js.map +1 -0
- package/dist/public-runtime.d.ts +24 -11
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +45 -9
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +6 -4
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +8 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +13 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/read-model/registry.d.ts +2 -1
- package/dist/read-model/registry.d.ts.map +1 -1
- package/dist/read-model/registry.js +3 -2
- package/dist/read-model/registry.js.map +1 -1
- package/dist/registry/ManagedRegistry.d.ts +30 -0
- package/dist/registry/ManagedRegistry.d.ts.map +1 -1
- package/dist/registry/ManagedRegistry.js +45 -6
- package/dist/registry/ManagedRegistry.js.map +1 -1
- package/dist/registry/collision.d.ts +57 -0
- package/dist/registry/collision.d.ts.map +1 -0
- package/dist/registry/collision.js +41 -0
- package/dist/registry/collision.js.map +1 -0
- package/dist/registry/command/index.d.ts +5 -3
- package/dist/registry/command/index.d.ts.map +1 -1
- package/dist/registry/command/index.js +6 -4
- package/dist/registry/command/index.js.map +1 -1
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +2 -2
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/plugin/index.d.ts.map +1 -1
- package/dist/registry/plugin/index.js +14 -1
- package/dist/registry/plugin/index.js.map +1 -1
- package/dist/registry/tool/callable.d.ts +7 -7
- package/dist/registry/tool/callable.d.ts.map +1 -1
- package/dist/registry/tool/callable.js +6 -7
- package/dist/registry/tool/callable.js.map +1 -1
- package/dist/registry/tool/execute.d.ts +14 -77
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +15 -727
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/portable.d.ts +25 -0
- package/dist/registry/tool/portable.d.ts.map +1 -1
- package/dist/registry/tool/portable.js +50 -0
- package/dist/registry/tool/portable.js.map +1 -1
- package/dist/registry/tool/presentation.d.ts +6 -5
- package/dist/registry/tool/presentation.d.ts.map +1 -1
- package/dist/registry/tool/presentation.js +3 -3
- package/dist/registry/tool/presentation.js.map +1 -1
- package/dist/runtime/bidi/session.d.ts +5 -4
- package/dist/runtime/bidi/session.d.ts.map +1 -1
- package/dist/runtime/bidi/session.js +18 -1
- package/dist/runtime/bidi/session.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts +45 -2
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +189 -5
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +33 -3
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +86 -10
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-replay.d.ts +1 -1
- package/dist/runtime/query/file-evidence-replay.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-replay.js +8 -7
- package/dist/runtime/query/file-evidence-replay.js.map +1 -1
- package/dist/runtime/query/fork/prepare.d.ts +4 -1
- package/dist/runtime/query/fork/prepare.d.ts.map +1 -1
- package/dist/runtime/query/fork/prepare.js +4 -0
- package/dist/runtime/query/fork/prepare.js.map +1 -1
- package/dist/runtime/query/guardrail-presets.d.ts +4 -3
- package/dist/runtime/query/guardrail-presets.d.ts.map +1 -1
- package/dist/runtime/query/guardrail-presets.js +4 -3
- package/dist/runtime/query/guardrail-presets.js.map +1 -1
- package/dist/runtime/query/index.d.ts +23 -10
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +149 -70
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +8 -1
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +2 -2
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +55 -2
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +342 -116
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/iteration/tool-input.d.ts +79 -0
- package/dist/runtime/query/iteration/tool-input.d.ts.map +1 -0
- package/dist/runtime/query/iteration/tool-input.js +291 -0
- package/dist/runtime/query/iteration/tool-input.js.map +1 -0
- package/dist/runtime/query/observation-context.d.ts +2 -2
- package/dist/runtime/query/observation-context.d.ts.map +1 -1
- package/dist/runtime/query/observation-context.js.map +1 -1
- package/dist/runtime/query/prelude-lease.d.ts +18 -0
- package/dist/runtime/query/prelude-lease.d.ts.map +1 -0
- package/dist/runtime/query/prelude-lease.js +121 -0
- package/dist/runtime/query/prelude-lease.js.map +1 -0
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
- package/dist/runtime/query/prepare-turn.js +386 -187
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/prompt-cache.d.ts +2 -2
- package/dist/runtime/query/prompt-cache.d.ts.map +1 -1
- package/dist/runtime/query/prompt.d.ts +2 -2
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +1 -1
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/resume-session.d.ts.map +1 -1
- package/dist/runtime/query/resume-session.js +37 -2
- package/dist/runtime/query/resume-session.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +22 -3
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +84 -6
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -2
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/query/turn-state.d.ts.map +1 -1
- package/dist/runtime/query/turn-state.js +5 -0
- package/dist/runtime/query/turn-state.js.map +1 -1
- package/dist/runtime/system-events.d.ts +112 -0
- package/dist/runtime/system-events.d.ts.map +1 -0
- package/dist/runtime/system-events.js +183 -0
- package/dist/runtime/system-events.js.map +1 -0
- package/dist/scheduler/delegating.d.ts +2 -1
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +3 -2
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/registry.d.ts +12 -0
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +19 -0
- package/dist/skills/registry.js.map +1 -1
- package/dist/store/evidence/index-page.d.ts +2 -2
- package/dist/store/session-log/conformance.d.ts +1 -1
- package/dist/store/session-log/conformance.d.ts.map +1 -1
- package/dist/store/session-log/conformance.js +49 -8
- package/dist/store/session-log/conformance.js.map +1 -1
- package/dist/store/session-log/core.d.ts +8 -3
- package/dist/store/session-log/core.d.ts.map +1 -1
- package/dist/store/session-log/core.js +2 -1
- package/dist/store/session-log/core.js.map +1 -1
- package/dist/store/session-log/fold.d.ts +12 -0
- package/dist/store/session-log/fold.d.ts.map +1 -1
- package/dist/store/session-log/fold.js +57 -7
- package/dist/store/session-log/fold.js.map +1 -1
- package/dist/store/session-log/index.d.ts +2 -2
- package/dist/store/session-log/index.d.ts.map +1 -1
- package/dist/store/session-log/index.js +1 -1
- package/dist/store/session-log/index.js.map +1 -1
- package/dist/test-support/toolset.d.ts +19 -0
- package/dist/test-support/toolset.d.ts.map +1 -0
- package/dist/test-support/toolset.js +20 -0
- package/dist/test-support/toolset.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts +29 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +19 -9
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-url.d.ts +1 -1
- package/dist/tools/builtins/browser-url.js +1 -1
- package/dist/tools/builtins/browser.d.ts +6 -6
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +19 -11
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +9 -1
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/json-string-hint.d.ts +15 -0
- package/dist/tools/builtins/json-string-hint.d.ts.map +1 -0
- package/dist/tools/builtins/json-string-hint.js +17 -0
- package/dist/tools/builtins/json-string-hint.js.map +1 -0
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +7 -15
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +11 -0
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +10 -0
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +45 -1
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +5 -0
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
- package/dist/tools/coordinator/ask-user-question.js +26 -13
- package/dist/tools/coordinator/ask-user-question.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +5 -0
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/coordinator/question-options.d.ts +78 -0
- package/dist/tools/coordinator/question-options.d.ts.map +1 -0
- package/dist/tools/coordinator/question-options.js +153 -0
- package/dist/tools/coordinator/question-options.js.map +1 -0
- package/dist/tools/defineTool.d.ts +10 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +17 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/memory/search.d.ts.map +1 -1
- package/dist/tools/memory/search.js +4 -1
- package/dist/tools/memory/search.js.map +1 -1
- package/dist/tools/memory/update.d.ts.map +1 -1
- package/dist/tools/memory/update.js +8 -5
- package/dist/tools/memory/update.js.map +1 -1
- package/dist/tools/render-nonce.d.ts +47 -0
- package/dist/tools/render-nonce.d.ts.map +1 -0
- package/dist/tools/render-nonce.js +63 -0
- package/dist/tools/render-nonce.js.map +1 -0
- package/dist/tools/roster.d.ts +46 -19
- package/dist/tools/roster.d.ts.map +1 -1
- package/dist/tools/roster.js +63 -33
- package/dist/tools/roster.js.map +1 -1
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +94 -14
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +52 -6
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/trusted-read-only.d.ts +9 -5
- package/dist/tools/trusted-read-only.d.ts.map +1 -1
- package/dist/tools/trusted-read-only.js +14 -10
- package/dist/tools/trusted-read-only.js.map +1 -1
- package/dist/tools/untrusted-envelope.d.ts +67 -28
- package/dist/tools/untrusted-envelope.d.ts.map +1 -1
- package/dist/tools/untrusted-envelope.js +108 -59
- package/dist/tools/untrusted-envelope.js.map +1 -1
- package/dist/toolsets/combine.d.ts +44 -0
- package/dist/toolsets/combine.d.ts.map +1 -0
- package/dist/toolsets/combine.js +153 -0
- package/dist/toolsets/combine.js.map +1 -0
- package/dist/toolsets/manager.d.ts +201 -0
- package/dist/toolsets/manager.d.ts.map +1 -0
- package/dist/toolsets/manager.js +837 -0
- package/dist/toolsets/manager.js.map +1 -0
- package/dist/toolsets/source-glob.d.ts +15 -0
- package/dist/toolsets/source-glob.d.ts.map +1 -0
- package/dist/toolsets/source-glob.js +23 -0
- package/dist/toolsets/source-glob.js.map +1 -0
- package/dist/toolsets/toolset.d.ts +20 -0
- package/dist/toolsets/toolset.d.ts.map +1 -0
- package/dist/toolsets/toolset.js +28 -0
- package/dist/toolsets/toolset.js.map +1 -0
- package/dist/toolsets/types.d.ts +128 -0
- package/dist/toolsets/types.d.ts.map +1 -0
- package/dist/toolsets/types.js +33 -0
- package/dist/toolsets/types.js.map +1 -0
- package/dist/toolsets/wrappers.d.ts +59 -0
- package/dist/toolsets/wrappers.d.ts.map +1 -0
- package/dist/toolsets/wrappers.js +165 -0
- package/dist/toolsets/wrappers.js.map +1 -0
- package/dist/types/agent/base.d.ts +27 -16
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/index.d.ts +1 -0
- package/dist/types/agent/index.d.ts.map +1 -1
- package/dist/types/agent/index.js +1 -0
- package/dist/types/agent/index.js.map +1 -1
- package/dist/types/agent/pipeline.d.ts +2 -0
- package/dist/types/agent/pipeline.d.ts.map +1 -1
- package/dist/types/agent/query.d.ts +117 -0
- package/dist/types/agent/query.d.ts.map +1 -0
- package/dist/types/agent/query.js +2 -0
- package/dist/types/agent/query.js.map +1 -0
- package/dist/types/agent/reactive.d.ts +2 -129
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/agent/router.d.ts +2 -0
- package/dist/types/agent/router.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +5 -2
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +49 -12
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +6 -0
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +32 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/errors/index.d.ts +15 -0
- package/dist/types/errors/index.d.ts.map +1 -1
- package/dist/types/errors/index.js.map +1 -1
- package/dist/types/hitl/index.d.ts +57 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +130 -9
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +4 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +22 -4
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +1 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +5 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +8 -3
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +39 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +1 -1
- package/dist/types/session/events.d.ts +14 -3
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/tool/index.d.ts +152 -91
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/toolset/index.d.ts +10 -40
- package/dist/types/toolset/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/advisory/history.ts +27 -2
- package/src/advisory/index.ts +1 -1
- package/src/advisory/registry.ts +33 -0
- package/src/agents/AGENTS.md +14 -7
- package/src/agents/PipelineAgent.ts +2 -303
- package/src/agents/QueryAgent.ts +269 -0
- package/src/agents/ReactiveAgent.ts +6 -216
- package/src/agents/RouterAgent.ts +2 -337
- package/src/agents/SupervisorAgent.ts +3 -476
- package/src/agents/defineAgent.ts +13 -2
- package/src/agents/examples/PipelineAgent.ts +302 -0
- package/src/agents/examples/RouterAgent.ts +338 -0
- package/src/agents/examples/SupervisorAgent.ts +472 -0
- package/src/agents/explore.ts +6 -3
- package/src/agents/forward-options.ts +37 -0
- package/src/agents/index.ts +2 -0
- package/src/agents/runAgent.ts +144 -37
- package/src/authorization/command-line.ts +2 -2
- package/src/authorization/gate.ts +21 -1
- package/src/authorization/program.ts +773 -0
- package/src/authorization/reexec-wrapper.ts +589 -0
- package/src/authorization/rules.ts +18 -1
- package/src/authorization/shell-lexer.ts +104 -59
- package/src/bridge/sse/mapper.ts +6 -0
- package/src/capabilities/index.ts +157 -0
- package/src/config/registry.ts +4 -1
- package/src/connector/index.ts +9 -2
- package/src/connector/mcp/adapter.ts +58 -3
- package/src/connector/mcp/client.ts +20 -4
- package/src/connector/mcp/discovery.ts +60 -0
- package/src/connector/mcp/index.ts +13 -0
- package/src/connector/mcp/mcp-toolset.ts +515 -0
- package/src/connector/tools/index.ts +2 -2
- package/src/connector/tools/router.ts +35 -58
- package/src/directory/derive-supervisor.ts +12 -8
- package/src/directory/derive.ts +8 -5
- package/src/execution/code-runtime/types.ts +2 -2
- package/src/invariants/index.ts +4 -1
- package/src/manager/agent/lifecycle.ts +9 -0
- package/src/manager/connector/environment.ts +17 -4
- package/src/manager/connector/index.ts +2 -2
- package/src/manager/connector/tenant.ts +17 -4
- package/src/manager/index.ts +2 -2
- package/src/manager/session/attribution.ts +79 -0
- package/src/manager/session/turn-recorder.ts +211 -55
- package/src/peers/address.ts +58 -0
- package/src/peers/client.ts +202 -0
- package/src/peers/dir.ts +176 -0
- package/src/peers/endpoint.ts +564 -0
- package/src/peers/envelope.ts +121 -0
- package/src/peers/index.ts +96 -0
- package/src/peers/protocol.ts +196 -0
- package/src/peers/record.ts +56 -0
- package/src/peers/registry.ts +241 -0
- package/src/plugin/define.ts +68 -0
- package/src/plugin/index.ts +2 -0
- package/src/plugin/lifecycle.ts +286 -106
- package/src/plugin/resolver.ts +6 -3
- package/src/plugin/shell-hook.ts +21 -5
- package/src/probe/errors.ts +4 -1
- package/src/prompt/coding-agent-doctrine.ts +22 -10
- package/src/prompt/contributions.ts +12 -2
- package/src/prompt/index.ts +1 -0
- package/src/provider/collect-chat-completion.ts +96 -11
- package/src/provider/mock.ts +24 -6
- package/src/provider/registry.ts +4 -1
- package/src/provider/tool-call-framing.ts +226 -0
- package/src/public-runtime.ts +136 -7
- package/src/public-tools.ts +24 -4
- package/src/public-types.ts +60 -6
- package/src/read-model/registry.ts +7 -2
- package/src/registry/ManagedRegistry.ts +57 -6
- package/src/registry/collision.ts +64 -0
- package/src/registry/command/index.ts +7 -3
- package/src/registry/index.ts +3 -9
- package/src/registry/plugin/index.ts +14 -1
- package/src/registry/tool/callable.ts +8 -9
- package/src/registry/tool/execute.ts +16 -846
- package/src/registry/tool/portable.ts +59 -0
- package/src/registry/tool/presentation.ts +6 -5
- package/src/runtime/bidi/session.ts +24 -5
- package/src/runtime/query/executor/tool-call-admission.ts +228 -6
- package/src/runtime/query/executor.ts +110 -12
- package/src/runtime/query/file-evidence-replay.ts +8 -7
- package/src/runtime/query/fork/prepare.ts +6 -1
- package/src/runtime/query/guardrail-presets.ts +4 -3
- package/src/runtime/query/index.ts +199 -101
- package/src/runtime/query/iteration/index.ts +13 -3
- package/src/runtime/query/iteration/phases/compaction.ts +1 -1
- package/src/runtime/query/iteration/phases/context.ts +2 -2
- package/src/runtime/query/iteration/phases/tool-review.ts +59 -2
- package/src/runtime/query/iteration/stream-turn.ts +390 -136
- package/src/runtime/query/iteration/tool-input.ts +284 -0
- package/src/runtime/query/observation-context.ts +2 -2
- package/src/runtime/query/prelude-lease.ts +132 -0
- package/src/runtime/query/prepare-turn.ts +477 -198
- package/src/runtime/query/prompt-cache.ts +2 -2
- package/src/runtime/query/prompt.ts +4 -4
- package/src/runtime/query/resume-session.ts +42 -3
- package/src/runtime/query/review-policy.ts +87 -9
- package/src/runtime/query/tooling.ts +3 -6
- package/src/runtime/query/turn-state.ts +4 -0
- package/src/runtime/system-events.ts +246 -0
- package/src/scheduler/delegating.ts +7 -2
- package/src/skills/index.ts +1 -1
- package/src/skills/registry.ts +25 -0
- package/src/store/session-log/conformance.ts +51 -8
- package/src/store/session-log/core.ts +10 -4
- package/src/store/session-log/fold.ts +33 -7
- package/src/store/session-log/index.ts +2 -0
- package/src/test-support/toolset.ts +23 -0
- package/src/tools/builtins/bash.ts +27 -10
- package/src/tools/builtins/browser-url.ts +1 -1
- package/src/tools/builtins/computer-use.ts +21 -11
- package/src/tools/builtins/edit.ts +12 -2
- package/src/tools/builtins/json-string-hint.ts +16 -0
- package/src/tools/builtins/search-tools.ts +7 -20
- package/src/tools/builtins/write-file.ts +12 -0
- package/src/tools/command-shell.ts +46 -1
- package/src/tools/coordinator/agent.ts +6 -0
- package/src/tools/coordinator/ask-user-question.ts +29 -15
- package/src/tools/coordinator/index.ts +6 -0
- package/src/tools/coordinator/question-options.ts +195 -0
- package/src/tools/defineTool.ts +28 -0
- package/src/tools/memory/search.ts +4 -1
- package/src/tools/memory/update.ts +8 -5
- package/src/tools/render-nonce.ts +69 -0
- package/src/tools/roster.ts +84 -33
- package/src/tools/schedules/schedule-tool.ts +107 -14
- package/src/tools/schedules/types.ts +52 -6
- package/src/tools/trusted-read-only.ts +19 -10
- package/src/tools/untrusted-envelope.ts +121 -57
- package/src/toolsets/combine.ts +181 -0
- package/src/toolsets/manager.ts +996 -0
- package/src/toolsets/source-glob.ts +22 -0
- package/src/toolsets/toolset.ts +31 -0
- package/src/toolsets/types.ts +154 -0
- package/src/toolsets/wrappers.ts +191 -0
- package/src/types/agent/base.ts +29 -16
- package/src/types/agent/index.ts +1 -0
- package/src/types/agent/pipeline.ts +2 -0
- package/src/types/agent/query.ts +129 -0
- package/src/types/agent/reactive.ts +5 -142
- package/src/types/agent/router.ts +2 -0
- package/src/types/agent/supervisor.ts +5 -2
- package/src/types/authorization/index.ts +12 -0
- package/src/types/connector/mcp.ts +32 -0
- package/src/types/errors/index.ts +15 -0
- package/src/types/hitl/index.ts +57 -0
- package/src/types/message/index.ts +135 -7
- package/src/types/plugin/index.ts +44 -21
- package/src/types/provider/chat.ts +5 -0
- package/src/types/provider/config.ts +8 -3
- package/src/types/provider/stream.ts +39 -0
- package/src/types/sandbox/index.ts +1 -1
- package/src/types/session/events.ts +14 -3
- package/src/types/tool/index.ts +154 -105
- package/src/types/toolset/index.ts +10 -47
- package/dist/registry/toolset/catalog.d.ts +0 -42
- package/dist/registry/toolset/catalog.d.ts.map +0 -1
- package/dist/registry/toolset/catalog.js +0 -234
- package/dist/registry/toolset/catalog.js.map +0 -1
- package/src/registry/toolset/catalog.ts +0 -308
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxF,YAAY,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACrE,YAAY,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,iBAAiB,CAAA"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { discoverPlugins, loadPluginManifest, discoverAllPluginDirs } from './loader.js';
|
|
2
|
+
export { definePlugin } from './define.js';
|
|
2
3
|
export { PluginLifecycleManager } from './lifecycle.js';
|
|
3
4
|
export { PluginResolver } from './resolver.js';
|
|
4
5
|
export { attachShellHooks, createShellHook, DEFAULT_SHELL_HOOK_TIMEOUT_MS, MAX_SHELL_HOOK_TIMEOUT_MS, runShellHook, SHELL_HOOK_EVENTS, SHELL_HOOKS_PLUGIN_ID, shellHookMatches, shellHookVerdict, } from './shell-hook.js';
|
package/dist/plugin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,iBAAiB,CAAA"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { ConfigRegistry } from '../config/registry.js';
|
|
2
2
|
import type { MCPToolDiscoveryOptions } from '../connector/mcp/discovery.js';
|
|
3
3
|
import type { MCPToolPolicy } from '../connector/mcp/policy.js';
|
|
4
|
+
import type { PromptContribution } from '../prompt/contributions.js';
|
|
4
5
|
import type { PluginRegistry } from '../registry/plugin/index.js';
|
|
5
6
|
import type { SkillRegistry } from '../skills/registry.js';
|
|
7
|
+
import type { Toolset } from '../toolsets/types.js';
|
|
6
8
|
import type { PluginId } from '../types/ids/index.js';
|
|
7
9
|
import type { PluginDefinition, PluginEventListener, PluginHookContext, PluginHookDefinition, PluginHookEvent, PluginHookResult, PluginScope } from '../types/plugin/index.js';
|
|
8
10
|
import type { SessionEvent } from '../types/session/index.js';
|
|
9
|
-
import type { ToolRegistryContract } from '../types/tool/index.js';
|
|
10
11
|
import type { Logger } from '../utils/logger.js';
|
|
12
|
+
import { type DefinedPlugin } from './define.js';
|
|
11
13
|
export interface PluginLifecycleManagerConfig {
|
|
12
14
|
pluginRegistry: PluginRegistry;
|
|
13
|
-
toolRegistry: ToolRegistryContract;
|
|
14
15
|
/**
|
|
15
16
|
* Filesystem authorities for each plugin scope.
|
|
16
17
|
*
|
|
@@ -70,7 +71,13 @@ export interface PluginLifecycleManagerConfig {
|
|
|
70
71
|
}
|
|
71
72
|
export declare class PluginLifecycleManager {
|
|
72
73
|
private pluginRegistry;
|
|
73
|
-
|
|
74
|
+
/** Each installed plugin owns its own file source and one source per MCP server. */
|
|
75
|
+
private readonly pluginFileTools;
|
|
76
|
+
private readonly pluginMcpTools;
|
|
77
|
+
private readonly mcpOwnerByName;
|
|
78
|
+
private readonly toolsetsByPlugin;
|
|
79
|
+
private readonly instructions;
|
|
80
|
+
private readonly toolsetChangeListeners;
|
|
74
81
|
private listeners;
|
|
75
82
|
private hookHandlers;
|
|
76
83
|
private pluginContributions;
|
|
@@ -95,8 +102,22 @@ export declare class PluginLifecycleManager {
|
|
|
95
102
|
* reads.
|
|
96
103
|
*/
|
|
97
104
|
private mcpDiscovery;
|
|
105
|
+
private readonly mcpToolPolicies?;
|
|
106
|
+
private readonly onMCPToolDrift?;
|
|
98
107
|
private readonly skillRegistry;
|
|
99
108
|
constructor(config: PluginLifecycleManagerConfig);
|
|
109
|
+
/** Stable entries created at install, before a host composes its ToolManager. */
|
|
110
|
+
get toolsets(): readonly Toolset[];
|
|
111
|
+
/** Plugin-authored request context from enabled plugins. */
|
|
112
|
+
get promptContributions(): readonly PromptContribution[];
|
|
113
|
+
private registerToolsets;
|
|
114
|
+
private notifyToolsetChange;
|
|
115
|
+
/** A file-declared plugin tool. Always deferred, like every other tool this manager contributes. */
|
|
116
|
+
private addFileTool;
|
|
117
|
+
/** An MCP-discovered tool or a prompt adapted to one. */
|
|
118
|
+
private addMcpTool;
|
|
119
|
+
/** Reverses whichever of the two maps above actually holds `name`; a name in neither is a no-op. */
|
|
120
|
+
private removeContributedTool;
|
|
100
121
|
/**
|
|
101
122
|
* Attach a hook without installing a plugin from disk.
|
|
102
123
|
*
|
|
@@ -114,11 +135,14 @@ export declare class PluginLifecycleManager {
|
|
|
114
135
|
on(listener: PluginEventListener): void;
|
|
115
136
|
off(listener: PluginEventListener): void;
|
|
116
137
|
install(pluginDir: string, scope: PluginScope): Promise<PluginDefinition>;
|
|
138
|
+
/** Register a host-authored plugin without reading a manifest or importing modules. */
|
|
139
|
+
installDefined(plugin: DefinedPlugin, scope?: PluginScope): PluginDefinition;
|
|
117
140
|
private definitionFrom;
|
|
118
141
|
private readLegacyAdmission;
|
|
119
142
|
enable(pluginId: PluginId): Promise<void>;
|
|
120
143
|
private attachMCPServer;
|
|
121
144
|
private rollbackContributions;
|
|
145
|
+
private stopMcpContributions;
|
|
122
146
|
disable(pluginId: PluginId): Promise<void>;
|
|
123
147
|
uninstall(pluginId: PluginId): Promise<void>;
|
|
124
148
|
executeHooks(event: PluginHookEvent, context: Omit<PluginHookContext, 'pluginId' | 'event'>, emitSessionEvent?: (event: SessionEvent) => Promise<void>): Promise<PluginHookResult[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/plugin/lifecycle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/plugin/lifecycle.ts"],"names":[],"mappings":"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"}
|
package/dist/plugin/lifecycle.js
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { mcpToolToToolDefinition } from '../connector/mcp/adapter.js';
|
|
3
2
|
import { MCPClient } from '../connector/mcp/client.js';
|
|
4
3
|
import { MCPToolDiscovery } from '../connector/mcp/discovery.js';
|
|
5
|
-
import {
|
|
6
|
-
import { MCPReconnectOptionsSchema
|
|
4
|
+
import { mcpToolset } from '../connector/mcp/mcp-toolset.js';
|
|
5
|
+
import { MCPReconnectOptionsSchema } from '../connector/mcp/reconnect.js';
|
|
7
6
|
import { DEFAULT_HOOK_PRIORITY, HOOK_TIMEOUT_MS, PLUGIN_NAMESPACE_SEPARATOR, } from '../constants/plugin/index.js';
|
|
8
7
|
import { GENAI } from '../constants/telemetry/index.js';
|
|
8
|
+
import { PromptContributionRegistry } from '../prompt/contributions.js';
|
|
9
9
|
import { loadSkill } from '../skills/loader.js';
|
|
10
10
|
import { resolveWithinReal } from '../tools/paths.js';
|
|
11
|
+
import { wrapUntrusted } from '../tools/untrusted-envelope.js';
|
|
12
|
+
import { deferred, prefixed } from '../toolsets/wrappers.js';
|
|
11
13
|
import { assertPluginHookEvent } from '../types/plugin/index.js';
|
|
12
14
|
import { toErrorMessage } from '../utils/error.js';
|
|
13
15
|
import { generatePluginId } from '../utils/id.js';
|
|
14
16
|
import { SCOPE_ATTRIBUTE } from '../utils/log/types.js';
|
|
17
|
+
import { definePlugin } from './define.js';
|
|
15
18
|
import { assertEnableable, loadPluginManifest } from './loader.js';
|
|
19
|
+
/** Dynamic imports bypass ToolDefinition's TypeScript contract. */
|
|
20
|
+
function assertPluginTool(value, pluginName, origin, index) {
|
|
21
|
+
const tool = value && typeof value === 'object' ? value : null;
|
|
22
|
+
const label = `Plugin "${pluginName}" tool #${index} from ${origin}`;
|
|
23
|
+
if (!tool ||
|
|
24
|
+
typeof tool.name !== 'string' ||
|
|
25
|
+
tool.name.length === 0 ||
|
|
26
|
+
typeof tool.description !== 'string' ||
|
|
27
|
+
typeof tool.execute !== 'function') {
|
|
28
|
+
throw new Error(`${label} must define name, description and execute.`);
|
|
29
|
+
}
|
|
30
|
+
const schema = tool.inputSchema;
|
|
31
|
+
if (!schema ||
|
|
32
|
+
typeof schema !== 'object' ||
|
|
33
|
+
typeof schema.safeParse !== 'function' ||
|
|
34
|
+
(!tool.modelInputSchema && typeof schema._def !== 'object')) {
|
|
35
|
+
throw new Error(`${label} must define inputSchema as a Zod schema, or as a compatible parser with modelInputSchema.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
16
38
|
function immutableManifest(manifest) {
|
|
17
39
|
const mcpServers = manifest.mcpServers?.map((server) => Object.freeze({
|
|
18
40
|
name: server.name,
|
|
@@ -25,6 +47,7 @@ function immutableManifest(manifest) {
|
|
|
25
47
|
version: manifest.version,
|
|
26
48
|
description: manifest.description,
|
|
27
49
|
...(manifest.author !== undefined ? { author: manifest.author } : {}),
|
|
50
|
+
...(manifest.instructions !== undefined ? { instructions: manifest.instructions } : {}),
|
|
28
51
|
...(manifest.tools ? { tools: Object.freeze([...manifest.tools]) } : {}),
|
|
29
52
|
...(manifest.skills ? { skills: Object.freeze([...manifest.skills]) } : {}),
|
|
30
53
|
...(manifest.hooks ? { hooks: Object.freeze([...manifest.hooks]) } : {}),
|
|
@@ -35,7 +58,13 @@ function immutableManifest(manifest) {
|
|
|
35
58
|
}
|
|
36
59
|
export class PluginLifecycleManager {
|
|
37
60
|
pluginRegistry;
|
|
38
|
-
|
|
61
|
+
/** Each installed plugin owns its own file source and one source per MCP server. */
|
|
62
|
+
pluginFileTools = new Map();
|
|
63
|
+
pluginMcpTools = new Map();
|
|
64
|
+
mcpOwnerByName = new Map();
|
|
65
|
+
toolsetsByPlugin = new Map();
|
|
66
|
+
instructions = new PromptContributionRegistry();
|
|
67
|
+
toolsetChangeListeners = new Set();
|
|
39
68
|
listeners = [];
|
|
40
69
|
hookHandlers = new Map();
|
|
41
70
|
pluginContributions = new Map();
|
|
@@ -60,14 +89,17 @@ export class PluginLifecycleManager {
|
|
|
60
89
|
* reads.
|
|
61
90
|
*/
|
|
62
91
|
mcpDiscovery;
|
|
92
|
+
mcpToolPolicies;
|
|
93
|
+
onMCPToolDrift;
|
|
63
94
|
skillRegistry;
|
|
64
95
|
constructor(config) {
|
|
65
96
|
this.pluginRegistry = config.pluginRegistry;
|
|
66
|
-
this.toolRegistry = config.toolRegistry;
|
|
67
97
|
this.skillRegistry = config.skillRegistry;
|
|
68
98
|
this.scopeRoots = Object.freeze({ ...config.scopeRoots });
|
|
69
99
|
this.hookTimeoutMs = config.hookTimeoutMs ?? HOOK_TIMEOUT_MS;
|
|
70
100
|
this.configRegistry = config.configRegistry;
|
|
101
|
+
this.mcpToolPolicies = config.mcpToolPolicies;
|
|
102
|
+
this.onMCPToolDrift = config.onMCPToolDrift;
|
|
71
103
|
this.log = config.log.child({ [SCOPE_ATTRIBUTE]: 'plugin/lifecycle' });
|
|
72
104
|
this.mcpDiscovery = new MCPToolDiscovery([], {
|
|
73
105
|
...(config.mcpToolPolicies ? { policies: config.mcpToolPolicies } : {}),
|
|
@@ -75,6 +107,67 @@ export class PluginLifecycleManager {
|
|
|
75
107
|
logger: this.log,
|
|
76
108
|
});
|
|
77
109
|
}
|
|
110
|
+
/** Stable entries created at install, before a host composes its ToolManager. */
|
|
111
|
+
get toolsets() {
|
|
112
|
+
return [...this.toolsetsByPlugin.values()].flat();
|
|
113
|
+
}
|
|
114
|
+
/** Plugin-authored request context from enabled plugins. */
|
|
115
|
+
get promptContributions() {
|
|
116
|
+
return this.instructions.list();
|
|
117
|
+
}
|
|
118
|
+
registerToolsets(admission) {
|
|
119
|
+
if (this.toolsetsByPlugin.has(admission.id))
|
|
120
|
+
return;
|
|
121
|
+
const pluginName = admission.manifest.name;
|
|
122
|
+
const onChange = (listener) => {
|
|
123
|
+
this.toolsetChangeListeners.add(listener);
|
|
124
|
+
return () => this.toolsetChangeListeners.delete(listener);
|
|
125
|
+
};
|
|
126
|
+
const fileTools = deferred({
|
|
127
|
+
source: {
|
|
128
|
+
id: `plugin:${pluginName}`,
|
|
129
|
+
kind: 'plugin',
|
|
130
|
+
name: pluginName,
|
|
131
|
+
},
|
|
132
|
+
tools: () => [...this.pluginFileTools.values()].filter((tool) => tool.name.startsWith(`${pluginName}${PLUGIN_NAMESPACE_SEPARATOR}`)),
|
|
133
|
+
onChange,
|
|
134
|
+
});
|
|
135
|
+
const mcpTools = (admission.manifest.mcpServers ?? []).map((server) => deferred({
|
|
136
|
+
source: {
|
|
137
|
+
id: `plugin:${pluginName}/mcp:${server.name}`,
|
|
138
|
+
kind: 'mcp_server',
|
|
139
|
+
name: server.name,
|
|
140
|
+
mcpServer: { name: server.name, readOnlyHintTrusted: false },
|
|
141
|
+
},
|
|
142
|
+
tools: () => [...this.pluginMcpTools.values()].filter((tool) => this.mcpOwnerByName.get(tool.name) === `plugin:${pluginName}/mcp:${server.name}`),
|
|
143
|
+
onChange,
|
|
144
|
+
}));
|
|
145
|
+
this.toolsetsByPlugin.set(admission.id, [fileTools, ...mcpTools]);
|
|
146
|
+
}
|
|
147
|
+
notifyToolsetChange() {
|
|
148
|
+
for (const listener of this.toolsetChangeListeners)
|
|
149
|
+
listener();
|
|
150
|
+
}
|
|
151
|
+
/** A file-declared plugin tool. Always deferred, like every other tool this manager contributes. */
|
|
152
|
+
addFileTool(tool) {
|
|
153
|
+
this.pluginFileTools.set(tool.name, tool);
|
|
154
|
+
this.notifyToolsetChange();
|
|
155
|
+
}
|
|
156
|
+
/** An MCP-discovered tool or a prompt adapted to one. */
|
|
157
|
+
addMcpTool(tool, sourceId) {
|
|
158
|
+
this.pluginMcpTools.set(tool.name, tool);
|
|
159
|
+
this.mcpOwnerByName.set(tool.name, sourceId);
|
|
160
|
+
this.notifyToolsetChange();
|
|
161
|
+
}
|
|
162
|
+
/** Reverses whichever of the two maps above actually holds `name`; a name in neither is a no-op. */
|
|
163
|
+
removeContributedTool(name) {
|
|
164
|
+
const removedFile = this.pluginFileTools.delete(name);
|
|
165
|
+
const removedMcp = this.pluginMcpTools.delete(name);
|
|
166
|
+
this.mcpOwnerByName.delete(name);
|
|
167
|
+
if (removedFile || removedMcp) {
|
|
168
|
+
this.notifyToolsetChange();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
78
171
|
/**
|
|
79
172
|
* Attach a hook without installing a plugin from disk.
|
|
80
173
|
*
|
|
@@ -138,6 +231,7 @@ export class PluginLifecycleManager {
|
|
|
138
231
|
const definition = this.definitionFrom(admission, 'installed');
|
|
139
232
|
this.pluginRegistry.register(definition);
|
|
140
233
|
this.pluginAdmissions.set(pluginId, admission);
|
|
234
|
+
this.registerToolsets(admission);
|
|
141
235
|
this.emit({
|
|
142
236
|
type: 'plugin_installed',
|
|
143
237
|
pluginId,
|
|
@@ -152,6 +246,41 @@ export class PluginLifecycleManager {
|
|
|
152
246
|
});
|
|
153
247
|
return definition;
|
|
154
248
|
}
|
|
249
|
+
/** Register a host-authored plugin without reading a manifest or importing modules. */
|
|
250
|
+
installDefined(plugin, scope = 'project') {
|
|
251
|
+
const defined = definePlugin(plugin);
|
|
252
|
+
const existing = this.pluginRegistry.findByName(defined.name);
|
|
253
|
+
if (existing) {
|
|
254
|
+
throw new Error(`Plugin "${defined.name}" is already installed (id: ${existing.id})`);
|
|
255
|
+
}
|
|
256
|
+
const pluginId = generatePluginId();
|
|
257
|
+
const manifest = immutableManifest({
|
|
258
|
+
name: defined.name,
|
|
259
|
+
version: defined.version,
|
|
260
|
+
description: defined.description,
|
|
261
|
+
...(defined.instructions !== undefined ? { instructions: defined.instructions } : {}),
|
|
262
|
+
mcpServers: defined.mcpServers,
|
|
263
|
+
});
|
|
264
|
+
const admission = Object.freeze({
|
|
265
|
+
id: pluginId,
|
|
266
|
+
manifest,
|
|
267
|
+
scope,
|
|
268
|
+
rootDir: this.scopeRoots[scope],
|
|
269
|
+
installedAt: Date.now(),
|
|
270
|
+
inCode: defined,
|
|
271
|
+
});
|
|
272
|
+
const definition = this.definitionFrom(admission, 'installed');
|
|
273
|
+
this.pluginRegistry.register(definition);
|
|
274
|
+
this.pluginAdmissions.set(pluginId, admission);
|
|
275
|
+
this.registerToolsets(admission);
|
|
276
|
+
this.emit({
|
|
277
|
+
type: 'plugin_installed',
|
|
278
|
+
pluginId,
|
|
279
|
+
name: defined.name,
|
|
280
|
+
scope,
|
|
281
|
+
});
|
|
282
|
+
return definition;
|
|
283
|
+
}
|
|
155
284
|
definitionFrom(admission, status, enabledAt) {
|
|
156
285
|
return Object.freeze({
|
|
157
286
|
...admission,
|
|
@@ -198,6 +327,7 @@ export class PluginLifecycleManager {
|
|
|
198
327
|
try {
|
|
199
328
|
admission = await this.readLegacyAdmission(plugin);
|
|
200
329
|
this.pluginAdmissions.set(pluginId, admission);
|
|
330
|
+
this.registerToolsets(admission);
|
|
201
331
|
}
|
|
202
332
|
catch (error) {
|
|
203
333
|
this.pluginRegistry.register({
|
|
@@ -217,7 +347,9 @@ export class PluginLifecycleManager {
|
|
|
217
347
|
// `installed`: a status that says the plugin is fine while it can
|
|
218
348
|
// never enable is how the next reader gets misled.
|
|
219
349
|
try {
|
|
220
|
-
assertEnableable(manifest, {
|
|
350
|
+
assertEnableable(manifest, {
|
|
351
|
+
skillsSupported: Boolean(this.skillRegistry),
|
|
352
|
+
});
|
|
221
353
|
}
|
|
222
354
|
catch (err) {
|
|
223
355
|
this.pluginRegistry.register({
|
|
@@ -229,12 +361,22 @@ export class PluginLifecycleManager {
|
|
|
229
361
|
const contributions = {
|
|
230
362
|
toolNames: [],
|
|
231
363
|
mcpClients: [],
|
|
364
|
+
mcpToolsets: [],
|
|
365
|
+
mcpUnsubscribers: [],
|
|
366
|
+
mcpNamesBySource: new Map(),
|
|
232
367
|
skillNames: [],
|
|
233
|
-
mcpSupervisors: [],
|
|
234
368
|
};
|
|
235
369
|
try {
|
|
236
|
-
//
|
|
237
|
-
if (
|
|
370
|
+
// Host-authored definitions have no file path to resolve or module to import.
|
|
371
|
+
if (admission.inCode) {
|
|
372
|
+
for (const [index, tool] of admission.inCode.tools.entries()) {
|
|
373
|
+
assertPluginTool(tool, manifest.name, 'the in-code declaration', index + 1);
|
|
374
|
+
const namespacedName = manifest.name + PLUGIN_NAMESPACE_SEPARATOR + tool.name;
|
|
375
|
+
this.addFileTool({ ...tool, name: namespacedName });
|
|
376
|
+
contributions.toolNames.push(namespacedName);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else if (manifest.tools && manifest.tools.length > 0) {
|
|
238
380
|
for (const toolPath of manifest.tools) {
|
|
239
381
|
const absolutePath = await resolveWithinReal(admission.rootDir, toolPath);
|
|
240
382
|
const fileUrl = pathToFileURL(absolutePath).href;
|
|
@@ -242,10 +384,14 @@ export class PluginLifecycleManager {
|
|
|
242
384
|
if (!mod.tools || !Array.isArray(mod.tools)) {
|
|
243
385
|
throw new Error(`Plugin "${manifest.name}": tool module "${toolPath}" must export a "tools" array`);
|
|
244
386
|
}
|
|
245
|
-
for (const tool of mod.tools) {
|
|
387
|
+
for (const [index, tool] of mod.tools.entries()) {
|
|
388
|
+
assertPluginTool(tool, manifest.name, `"${toolPath}"`, index + 1);
|
|
246
389
|
const namespacedName = manifest.name + PLUGIN_NAMESPACE_SEPARATOR + tool.name;
|
|
247
|
-
const namespacedTool = {
|
|
248
|
-
|
|
390
|
+
const namespacedTool = {
|
|
391
|
+
...tool,
|
|
392
|
+
name: namespacedName,
|
|
393
|
+
};
|
|
394
|
+
this.addFileTool(namespacedTool);
|
|
249
395
|
contributions.toolNames.push(namespacedName);
|
|
250
396
|
}
|
|
251
397
|
}
|
|
@@ -275,7 +421,11 @@ export class PluginLifecycleManager {
|
|
|
275
421
|
}
|
|
276
422
|
}
|
|
277
423
|
// Load hooks
|
|
278
|
-
if (
|
|
424
|
+
if (admission.inCode) {
|
|
425
|
+
for (const hook of admission.inCode.hooks)
|
|
426
|
+
this.registerHook(pluginId, hook);
|
|
427
|
+
}
|
|
428
|
+
else if (manifest.hooks && manifest.hooks.length > 0) {
|
|
279
429
|
for (const hookPath of manifest.hooks) {
|
|
280
430
|
const absolutePath = await resolveWithinReal(admission.rootDir, hookPath);
|
|
281
431
|
const fileUrl = pathToFileURL(absolutePath).href;
|
|
@@ -300,6 +450,22 @@ export class PluginLifecycleManager {
|
|
|
300
450
|
throw err;
|
|
301
451
|
}
|
|
302
452
|
this.pluginContributions.set(pluginId, contributions);
|
|
453
|
+
const pluginInstructions = manifest.instructions;
|
|
454
|
+
if (pluginInstructions?.trim()) {
|
|
455
|
+
this.instructions.register({
|
|
456
|
+
id: `plugin:${manifest.name}:instructions`,
|
|
457
|
+
placement: 'context',
|
|
458
|
+
render: () => {
|
|
459
|
+
if (!this.pluginContributions.has(pluginId))
|
|
460
|
+
return null;
|
|
461
|
+
return wrapUntrusted({
|
|
462
|
+
kind: 'plugin-instructions',
|
|
463
|
+
attributes: { plugin: manifest.name },
|
|
464
|
+
provenance: `Plugin ${JSON.stringify(manifest.name)} supplied this text; it is plugin-authored context, not operator instructions or tool permissions.`,
|
|
465
|
+
}, pluginInstructions);
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
}
|
|
303
469
|
const enabled = this.definitionFrom(admission, 'enabled', Date.now());
|
|
304
470
|
this.pluginRegistry.register(enabled);
|
|
305
471
|
this.emit({
|
|
@@ -314,7 +480,8 @@ export class PluginLifecycleManager {
|
|
|
314
480
|
// prose that is itself the debt.
|
|
315
481
|
'namzu.plugin.id': pluginId,
|
|
316
482
|
'namzu.plugin.name': manifest.name,
|
|
317
|
-
'namzu.plugin.tool_count': contributions.toolNames.length
|
|
483
|
+
'namzu.plugin.tool_count': contributions.toolNames.length +
|
|
484
|
+
[...contributions.mcpNamesBySource.values()].reduce((count, names) => count + names.size, 0),
|
|
318
485
|
'namzu.plugin.skill_count': contributions.skillNames.length,
|
|
319
486
|
'namzu.plugin.mcp_server_count': contributions.mcpClients.length,
|
|
320
487
|
});
|
|
@@ -332,55 +499,45 @@ export class PluginLifecycleManager {
|
|
|
332
499
|
});
|
|
333
500
|
await client.connect();
|
|
334
501
|
contributions.mcpClients.push(client);
|
|
335
|
-
//
|
|
336
|
-
// made: `transport.onClose` marked the client disconnected and rejected
|
|
337
|
-
// its pending calls, and nothing scheduled another try — so one blip
|
|
338
|
-
// took this plugin's tools out for the life of the process while the
|
|
339
|
-
// plugin went on reporting as enabled.
|
|
340
|
-
// The policy is read from the registry on EVERY attempt, not captured
|
|
341
|
-
// here. That is what makes the seam live: raising `maxAttempts` during
|
|
342
|
-
// an outage takes effect on the retry that is already running, which is
|
|
343
|
-
// the moment an operator actually reaches for it.
|
|
344
|
-
//
|
|
345
|
-
// Namespaced per server rather than globally, because two plugins'
|
|
346
|
-
// servers fail differently — one behind a flaky proxy wants patience,
|
|
347
|
-
// one behind a crash loop wants to give up and say so.
|
|
502
|
+
// The toolset owns reconnection and reads this policy on each attempt.
|
|
348
503
|
const policyScope = this.configRegistry?.register(`mcp.${config.name}`, MCPReconnectOptionsSchema);
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
504
|
+
// Preserve cross-disable drift detection. The live toolset below owns
|
|
505
|
+
// changes during this enablement; this manager-owned discovery remembers
|
|
506
|
+
// the server's earlier admission across clients and plugin lifetimes.
|
|
507
|
+
await this.mcpDiscovery.discoverFrom(client);
|
|
508
|
+
const sourceId = `plugin:${pluginName}/mcp:${config.name}`;
|
|
509
|
+
const policy = this.mcpToolPolicies?.[config.name] ?? this.mcpToolPolicies?.['*'];
|
|
510
|
+
const entries = await mcpToolset(client, {
|
|
511
|
+
id: sourceId,
|
|
512
|
+
availability: 'deferred',
|
|
513
|
+
allow: policy?.allow,
|
|
514
|
+
deny: policy?.deny,
|
|
515
|
+
reconnect: policyScope ? () => policyScope.get() : {},
|
|
516
|
+
onDrift: this.onMCPToolDrift,
|
|
517
|
+
logger: this.log,
|
|
518
|
+
});
|
|
519
|
+
contributions.mcpToolsets.push(...entries);
|
|
520
|
+
const wrapped = entries.map((entry) => prefixed(entry, `${pluginName}${PLUGIN_NAMESPACE_SEPARATOR}`));
|
|
521
|
+
const sync = () => {
|
|
522
|
+
const previous = contributions.mcpNamesBySource.get(sourceId) ?? new Set();
|
|
523
|
+
const nextTools = wrapped.flatMap((entry) => entry.tools());
|
|
524
|
+
const nextNames = new Set(nextTools.map((tool) => tool.name));
|
|
525
|
+
for (const name of previous) {
|
|
526
|
+
if (!nextNames.has(name))
|
|
527
|
+
this.removeContributedTool(name);
|
|
528
|
+
}
|
|
529
|
+
for (const tool of nextTools)
|
|
530
|
+
this.addMcpTool(tool, sourceId);
|
|
531
|
+
contributions.mcpNamesBySource.set(sourceId, nextNames);
|
|
532
|
+
};
|
|
533
|
+
contributions.mcpUnsubscribers.push(entries[0].onChange?.(sync) ?? (() => { }));
|
|
534
|
+
sync();
|
|
379
535
|
}
|
|
380
536
|
async rollbackContributions(pluginId, contributions) {
|
|
537
|
+
await this.stopMcpContributions(contributions, 'rollback');
|
|
381
538
|
for (const name of contributions.toolNames) {
|
|
382
539
|
try {
|
|
383
|
-
this.
|
|
540
|
+
this.removeContributedTool(name);
|
|
384
541
|
}
|
|
385
542
|
catch (unregErr) {
|
|
386
543
|
this.log.warn('Rollback: tool unregister failed', {
|
|
@@ -394,23 +551,6 @@ export class PluginLifecycleManager {
|
|
|
394
551
|
// Wrapping it would suggest a failure mode that does not exist.
|
|
395
552
|
this.skillRegistry?.unregister(name);
|
|
396
553
|
}
|
|
397
|
-
// Stop supervising BEFORE disconnecting. The lifecycle event a
|
|
398
|
-
// deliberate disconnect emits is the same one a dropped transport
|
|
399
|
-
// emits, so a still-attached supervisor would reconnect what this
|
|
400
|
-
// rollback just closed.
|
|
401
|
-
for (const supervisor of contributions.mcpSupervisors)
|
|
402
|
-
supervisor.stop();
|
|
403
|
-
for (const client of contributions.mcpClients) {
|
|
404
|
-
try {
|
|
405
|
-
await client.disconnect();
|
|
406
|
-
}
|
|
407
|
-
catch (discErr) {
|
|
408
|
-
this.log.warn('Rollback: MCP disconnect failed', {
|
|
409
|
-
'namzu.mcp.client_id': client.id,
|
|
410
|
-
'exception.message': toErrorMessage(discErr),
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
554
|
for (const [event, handlers] of this.hookHandlers) {
|
|
415
555
|
const filtered = handlers.filter((h) => h.pluginId !== pluginId);
|
|
416
556
|
if (filtered.length === 0) {
|
|
@@ -421,32 +561,39 @@ export class PluginLifecycleManager {
|
|
|
421
561
|
}
|
|
422
562
|
}
|
|
423
563
|
}
|
|
424
|
-
async
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
throw new Error(`Cannot disable plugin "${admission?.manifest.name ?? plugin.manifest.name}": status is not "enabled"`);
|
|
430
|
-
}
|
|
431
|
-
// Stop supervising first, for the same reason as the rollback path: the
|
|
432
|
-
// disconnect below emits the event the supervisor treats as a fault.
|
|
433
|
-
for (const supervisor of contributions.mcpSupervisors)
|
|
434
|
-
supervisor.stop();
|
|
435
|
-
// Disconnect MCP clients first so no new tool calls can reach them mid-teardown.
|
|
564
|
+
async stopMcpContributions(contributions, operation) {
|
|
565
|
+
for (const unsubscribe of contributions.mcpUnsubscribers)
|
|
566
|
+
unsubscribe();
|
|
567
|
+
for (const entry of contributions.mcpToolsets)
|
|
568
|
+
await entry.close?.();
|
|
436
569
|
for (const client of contributions.mcpClients) {
|
|
437
570
|
try {
|
|
438
571
|
await client.disconnect();
|
|
439
572
|
}
|
|
440
|
-
catch (
|
|
441
|
-
this.log.warn('MCP
|
|
573
|
+
catch (error) {
|
|
574
|
+
this.log.warn('MCP disconnect failed', {
|
|
575
|
+
'namzu.plugin.operation': operation,
|
|
442
576
|
'namzu.mcp.client_id': client.id,
|
|
443
|
-
'exception.message': toErrorMessage(
|
|
577
|
+
'exception.message': toErrorMessage(error),
|
|
444
578
|
});
|
|
445
579
|
}
|
|
446
580
|
}
|
|
447
|
-
|
|
581
|
+
for (const names of contributions.mcpNamesBySource.values()) {
|
|
582
|
+
for (const name of names)
|
|
583
|
+
this.removeContributedTool(name);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
async disable(pluginId) {
|
|
587
|
+
const plugin = this.pluginRegistry.getOrThrow(pluginId);
|
|
588
|
+
const admission = this.pluginAdmissions.get(pluginId);
|
|
589
|
+
const contributions = this.pluginContributions.get(pluginId);
|
|
590
|
+
if (!contributions) {
|
|
591
|
+
throw new Error(`Cannot disable plugin "${admission?.manifest.name ?? plugin.manifest.name}": status is not "enabled"`);
|
|
592
|
+
}
|
|
593
|
+
await this.stopMcpContributions(contributions, 'disable');
|
|
594
|
+
// Unregister file-declared tools; MCP entries were removed above.
|
|
448
595
|
for (const name of contributions.toolNames) {
|
|
449
|
-
this.
|
|
596
|
+
this.removeContributedTool(name);
|
|
450
597
|
}
|
|
451
598
|
// And its skills. A disabled plugin whose skills stayed registered
|
|
452
599
|
// would keep offering the model instructions from something the
|
|
@@ -466,6 +613,7 @@ export class PluginLifecycleManager {
|
|
|
466
613
|
}
|
|
467
614
|
}
|
|
468
615
|
this.pluginContributions.delete(pluginId);
|
|
616
|
+
this.instructions.unregister(`plugin:${admission?.manifest.name ?? plugin.manifest.name}:instructions`);
|
|
469
617
|
// Update status to disabled
|
|
470
618
|
const disabled = admission
|
|
471
619
|
? this.definitionFrom(admission, 'disabled')
|
|
@@ -488,7 +636,9 @@ export class PluginLifecycleManager {
|
|
|
488
636
|
await this.disable(pluginId);
|
|
489
637
|
}
|
|
490
638
|
this.pluginRegistry.unregister(pluginId);
|
|
639
|
+
this.instructions.unregister(`plugin:${admission?.manifest.name ?? plugin.manifest.name}:instructions`);
|
|
491
640
|
this.pluginAdmissions.delete(pluginId);
|
|
641
|
+
this.toolsetsByPlugin.delete(pluginId);
|
|
492
642
|
this.emit({
|
|
493
643
|
type: 'plugin_uninstalled',
|
|
494
644
|
pluginId,
|