@code-yeongyu/senpi 2026.8.10 → 2026.8.11-3
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 +119 -0
- package/dist/brand-dir-migration.d.ts +28 -0
- package/dist/brand-dir-migration.d.ts.map +1 -0
- package/dist/brand-dir-migration.js +77 -0
- package/dist/brand-dir-migration.js.map +1 -0
- package/dist/cli/grok-neo-gate.d.ts +0 -8
- package/dist/cli/grok-neo-gate.d.ts.map +1 -1
- package/dist/cli/grok-neo-gate.js +4 -2
- package/dist/cli/grok-neo-gate.js.map +1 -1
- package/dist/cli-main.d.ts +1 -1
- package/dist/cli-main.d.ts.map +1 -1
- package/dist/cli-main.js +4 -0
- package/dist/cli-main.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +27 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +41 -9
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +8 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +65 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/brand.d.ts +79 -0
- package/dist/core/brand.d.ts.map +1 -0
- package/dist/core/brand.js +141 -0
- package/dist/core/brand.js.map +1 -0
- package/dist/core/dynamic-prompt/identity.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/identity.js +2 -1
- package/dist/core/dynamic-prompt/identity.js.map +1 -1
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +2 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts +2 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js +24 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.d.ts +4 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.js +5 -2
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.d.ts +6 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js +16 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js +10 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.js +2 -1
- package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
- package/dist/core/extensions/builtin/config-reload/generated-shim-filter.d.ts.map +1 -1
- package/dist/core/extensions/builtin/config-reload/generated-shim-filter.js +4 -4
- package/dist/core/extensions/builtin/config-reload/generated-shim-filter.js.map +1 -1
- package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/index.js +5 -0
- package/dist/core/extensions/builtin/goal/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts +2 -2
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js +3 -3
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +6 -0
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/store.d.ts +3 -2
- package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/store.js +128 -101
- package/dist/core/extensions/builtin/goal/store.js.map +1 -1
- package/dist/core/extensions/builtin/goal/transitions.js +2 -1
- package/dist/core/extensions/builtin/goal/transitions.js.map +1 -1
- package/dist/core/extensions/builtin/help/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/help/index.js +3 -2
- package/dist/core/extensions/builtin/help/index.js.map +1 -1
- package/dist/core/extensions/builtin/imagegen/auth.d.ts +45 -0
- package/dist/core/extensions/builtin/imagegen/auth.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/auth.js +137 -0
- package/dist/core/extensions/builtin/imagegen/auth.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/index.d.ts +5 -0
- package/dist/core/extensions/builtin/imagegen/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/index.js +46 -0
- package/dist/core/extensions/builtin/imagegen/index.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/paths.d.ts +26 -0
- package/dist/core/extensions/builtin/imagegen/paths.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/paths.js +52 -0
- package/dist/core/extensions/builtin/imagegen/paths.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/skill/SKILL.md +67 -0
- package/dist/core/extensions/builtin/imagegen/state.d.ts +26 -0
- package/dist/core/extensions/builtin/imagegen/state.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/state.js +35 -0
- package/dist/core/extensions/builtin/imagegen/state.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/tool.d.ts +31 -0
- package/dist/core/extensions/builtin/imagegen/tool.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/tool.js +174 -0
- package/dist/core/extensions/builtin/imagegen/tool.js.map +1 -0
- package/dist/core/extensions/builtin/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/index.js +9 -1
- package/dist/core/extensions/builtin/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/control-inventory.d.ts +14 -0
- package/dist/core/extensions/builtin/mcp/control-inventory.d.ts.map +1 -0
- package/dist/core/extensions/builtin/mcp/control-inventory.js +22 -0
- package/dist/core/extensions/builtin/mcp/control-inventory.js.map +1 -0
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts +2 -44
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.js +3 -97
- package/dist/core/extensions/builtin/mcp/expose/native-search.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/proxy.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/proxy.js +15 -4
- package/dist/core/extensions/builtin/mcp/expose/proxy.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.d.ts +2 -1
- package/dist/core/extensions/builtin/mcp/expose/session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.js +2 -2
- package/dist/core/extensions/builtin/mcp/expose/session.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts +13 -11
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js +58 -59
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.js +28 -36
- package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.d.ts +2 -1
- package/dist/core/extensions/builtin/mcp/service-register.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.js +2 -2
- package/dist/core/extensions/builtin/mcp/service-register.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.d.ts +4 -0
- package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts +6 -11
- package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js +79 -41
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/wrap.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/wrap.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/wrap.js +3 -0
- package/dist/core/extensions/builtin/mcp/wrap.js.map +1 -1
- package/dist/core/extensions/builtin/openai-image-gen/externalize.d.ts +27 -0
- package/dist/core/extensions/builtin/openai-image-gen/externalize.d.ts.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/externalize.js +133 -0
- package/dist/core/extensions/builtin/openai-image-gen/externalize.js.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/gate.d.ts +21 -0
- package/dist/core/extensions/builtin/openai-image-gen/gate.d.ts.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/gate.js +63 -0
- package/dist/core/extensions/builtin/openai-image-gen/gate.js.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/index.d.ts +14 -0
- package/dist/core/extensions/builtin/openai-image-gen/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/index.js +77 -0
- package/dist/core/extensions/builtin/openai-image-gen/index.js.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/inject.d.ts +15 -0
- package/dist/core/extensions/builtin/openai-image-gen/inject.d.ts.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/inject.js +42 -0
- package/dist/core/extensions/builtin/openai-image-gen/inject.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js +6 -5
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.js +8 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.d.ts +3 -1
- package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.js +4 -1
- package/dist/core/extensions/builtin/terminal/notify.js.map +1 -1
- package/dist/core/extensions/builtin/tool-search/engine/bm25.d.ts +22 -0
- package/dist/core/extensions/builtin/tool-search/engine/bm25.d.ts.map +1 -0
- package/dist/core/extensions/builtin/{mcp/expose → tool-search/engine}/bm25.js +16 -31
- package/dist/core/extensions/builtin/tool-search/engine/bm25.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/engine/document.d.ts +14 -0
- package/dist/core/extensions/builtin/tool-search/engine/document.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/engine/document.js +2 -0
- package/dist/core/extensions/builtin/tool-search/engine/document.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/engine/marker.d.ts +55 -0
- package/dist/core/extensions/builtin/tool-search/engine/marker.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/engine/marker.js +189 -0
- package/dist/core/extensions/builtin/tool-search/engine/marker.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/index.d.ts +7 -0
- package/dist/core/extensions/builtin/tool-search/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/index.js +71 -0
- package/dist/core/extensions/builtin/tool-search/index.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/native-search.d.ts +52 -0
- package/dist/core/extensions/builtin/tool-search/native-search.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/native-search.js +116 -0
- package/dist/core/extensions/builtin/tool-search/native-search.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/service.d.ts +38 -0
- package/dist/core/extensions/builtin/tool-search/service.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/service.js +200 -0
- package/dist/core/extensions/builtin/tool-search/service.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/tool.d.ts +21 -0
- package/dist/core/extensions/builtin/tool-search/tool.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/tool.js +95 -0
- package/dist/core/extensions/builtin/tool-search/tool.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +44 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +11 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -4
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +0 -7
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/generated-shim-banner.d.ts +15 -0
- package/dist/core/generated-shim-banner.d.ts.map +1 -0
- package/dist/core/generated-shim-banner.js +26 -0
- package/dist/core/generated-shim-banner.js.map +1 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +7 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +2 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/provider-composer.d.ts +10 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +9 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -5
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/session-log.d.ts.map +1 -1
- package/dist/core/session-log.js +4 -2
- package/dist/core/session-log.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +3 -2
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/telemetry.d.ts.map +1 -1
- package/dist/core/telemetry.js +2 -1
- package/dist/core/telemetry.js.map +1 -1
- package/dist/core/timings.d.ts +0 -4
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +2 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/inspector-policy.d.ts.map +1 -1
- package/dist/inspector-policy.js +2 -1
- package/dist/inspector-policy.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -4
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -0
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -8
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +6 -7
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/cli-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/cli-tips.js +2 -1
- package/dist/modes/interactive/tips/catalog/cli-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/ethos-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/ethos-tips.js +4 -3
- package/dist/modes/interactive/tips/catalog/ethos-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/model-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/model-tips.js +2 -1
- package/dist/modes/interactive/tips/catalog/model-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/session-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/session-tips.js +2 -1
- package/dist/modes/interactive/tips/catalog/session-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/settings-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/settings-tips.js +3 -2
- package/dist/modes/interactive/tips/catalog/settings-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/workspace-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/workspace-tips.js +4 -3
- package/dist/modes/interactive/tips/catalog/workspace-tips.js.map +1 -1
- package/dist/modes/provider-native-rendering.d.ts.map +1 -1
- package/dist/modes/provider-native-rendering.js +33 -0
- package/dist/modes/provider-native-rendering.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +130 -4
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +31 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/nearest-parent-config.d.ts +6 -1
- package/dist/nearest-parent-config.d.ts.map +1 -1
- package/dist/nearest-parent-config.js +18 -2
- package/dist/nearest-parent-config.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +13 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/rpc-entry.js +2 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/self-update-bootstrap.d.ts.map +1 -1
- package/dist/self-update-bootstrap.js +6 -0
- package/dist/self-update-bootstrap.js.map +1 -1
- package/dist/senpi +3 -2
- package/dist/utils/pi-user-agent.d.ts +1 -1
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +4 -3
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +2 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +37 -6
- package/dist/utils/version-check.js.map +1 -1
- package/dist/valid-cwd.d.ts +2 -0
- package/dist/valid-cwd.d.ts.map +1 -0
- package/dist/valid-cwd.js +14 -0
- package/dist/valid-cwd.js.map +1 -0
- package/docs/environment-variables.md +7 -0
- package/docs/extensions.md +50 -13
- package/docs/mcp.md +2 -0
- package/docs/rpc.md +54 -0
- package/docs/skills.md +8 -0
- package/examples/extensions/searchable-tools.ts +49 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +36 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +5 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +4 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +2 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +9 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +7 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js +222 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.lazy.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.lazy.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.lazy.js +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.lazy.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +113 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +32 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +32 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +36 -13
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js +18 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-images.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-images.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-images.js +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-images.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +7 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/wire-identity.d.ts +14 -0
- package/node_modules/@earendil-works/pi-ai/dist/wire-identity.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/wire-identity.js +24 -0
- package/node_modules/@earendil-works/pi-ai/dist/wire-identity.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.js +11 -3
- package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +8 -8
- package/dist/core/extensions/builtin/mcp/expose/bm25.d.ts +0 -30
- package/dist/core/extensions/builtin/mcp/expose/bm25.d.ts.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/bm25.js.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/lazy-activate.d.ts +0 -15
- package/dist/core/extensions/builtin/mcp/expose/lazy-activate.d.ts.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/lazy-activate.js +0 -33
- package/dist/core/extensions/builtin/mcp/expose/lazy-activate.js.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts +0 -43
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js +0 -125
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js.map +0 -1
- package/dist/core/omo-native-detect.d.ts +0 -3
- package/dist/core/omo-native-detect.d.ts.map +0 -1
- package/dist/core/omo-native-detect.js +0 -64
- package/dist/core/omo-native-detect.js.map +0 -1
- package/dist/core/omo-native-detect.test.d.ts +0 -2
- package/dist/core/omo-native-detect.test.d.ts.map +0 -1
- package/dist/core/omo-native-detect.test.js +0 -47
- package/dist/core/omo-native-detect.test.js.map +0 -1
- package/dist/modes/interactive/components/footer-omo-native-badge.test.d.ts +0 -2
- package/dist/modes/interactive/components/footer-omo-native-badge.test.d.ts.map +0 -1
- package/dist/modes/interactive/components/footer-omo-native-badge.test.js +0 -52
- package/dist/modes/interactive/components/footer-omo-native-badge.test.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EACN,yBAAyB,EAGzB,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,0BAA0B,GAAG,eAAe,CAAC;AAEnD,MAAM,UAAU,kBAAkB,CAAC,OAAmB,EAAE,YAAY,GAAG,IAAI;IAC1E,OAAO,CAAC,EAAgB,EAAQ,EAAE;QACjC,IAAI,aAAwC,CAAC;QAC7C,MAAM,IAAI,GAAG;YACZ,MAAM,EAAE;gBACP,KAAK,CAAC,OAAe,EAAE,IAAc;oBACpC,eAAe,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;g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CAAC,CAAC,CAAC;QACH,EAAE,CAAC,EAAE,CACJ,kBAAkB,EAClB,SAAS,CACR,sBAAsB,EACtB,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,YAAY;gBAAE,OAAO;YACvD,MAAM,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC,EACD,IAAI,CACJ,CACD,CAAC;QACF,EAAE,CAAC,EAAE,CACJ,4BAA4B,EAC5B,SAAS,CACR,gCAAgC,EAChC,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,0BAA0B,CAAC,EAAE,CAAC;gBACtF,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACjC,CAAC;QACF,CAAC,EACD,IAAI,CACJ,CACD,CAAC;IACH,CAAC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB;IACxB,IAAI,CAAC;QACJ,mBAAmB,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAgB;IACpD,MAAM,YAAY,GAAG,gBAAgB,EAAE,CAAC;IACxC,OAAO,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;AAChG,CAAC","sourcesContent":["import { bindToProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport type { ExtensionAPI, ExtensionContext, ExtensionFactory, SessionStartEvent } from \"../../types.ts\";\nimport { registerMcpCommands } from \"./commands.ts\";\nimport { createLazyToolActivator } from \"./expose/lazy-activate.ts\";\nimport { AnthropicNativeToolSearchAdapter } from \"./expose/native-search.ts\";\nimport { TOOL_SEARCH_TOOL_NAME } from \"./expose/tool-search.ts\";\nimport { injectMcpInstructions, refreshMcpInstructionsForSession } from \"./instructions.ts\";\nimport { createMcpLogger } from \"./log.ts\";\nimport { registerMcpPromptCommands } from \"./prompts.ts\";\nimport { expandMcpResourceMentions } from \"./resources.ts\";\nimport { getMcpService, McpService } from \"./service.ts\";\nimport {\n\tparseSkillMcpDeclarations,\n\ttype SkillLike,\n\ttype SkillMcpDeclarations,\n\tskillActivationTargets,\n} from \"./skills.ts\";\nimport { reportMcpAsyncError, wrapAsync } from \"./wrap.ts\";\n\nconst MCP_BUILTIN_EXTENSION_PATH = \"<builtin:mcp>\";\n\nexport function createMcpExtension(service: McpService, sessionOwned = true): ExtensionFactory {\n\treturn (pi: ExtensionAPI): void => {\n\t\tlet attachPromise: Promise<void> | undefined;\n\t\tconst sink = {\n\t\t\tlogger: {\n\t\t\t\terror(message: string, data?: unknown): void {\n\t\t\t\t\tcreateMcpLogger(\"service\").error(message, data);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tregisterMcpCommands(pi, service);\n\n\t\t// Native provider tool-search adapter (todo 33 — Anthropic, spike = GO).\n\t\t// Runs on every request but is a no-op unless settings.nativeToolSearch is\n\t\t// auto|true and the model is anthropic-messages; a 400 disables it for the\n\t\t// session and falls back to the always-registered local tool_search.\n\t\tconst nativeAdapter = new AnthropicNativeToolSearchAdapter({\n\t\t\tenabled: () => {\n\t\t\t\tconst setting = service.getNativeToolSearchSetting();\n\t\t\t\treturn setting === true || setting === \"auto\";\n\t\t\t},\n\t\t\tisDeferrable: (name) => name.startsWith(\"mcp_\") && name !== TOOL_SEARCH_TOOL_NAME,\n\t\t\tonFallback: (reason) => createMcpLogger(\"service\").warn(reason),\n\t\t\tsearchToolName: TOOL_SEARCH_TOOL_NAME,\n\t\t});\n\t\tpi.on(\"before_provider_request\", (event, ctx) => nativeAdapter.applyBeforeRequest(ctx.model?.api, event.payload));\n\t\tpi.on(\"after_provider_response\", (event) => nativeAdapter.noteResponseStatus(event.status));\n\t\t// Resumed/compacted sessions carry tool_search activation markers in their\n\t\t// history but re-enter search mode with only directTools active. The context\n\t\t// event (fired before each LLM call, with the full message history) replays\n\t\t// the markers as a safety net; the primary replay happens at attach time so\n\t\t// the FIRST turn's payload already carries previously promoted tools. Scans\n\t\t// once per registration (see McpService.maybeRehydrateFromHistory).\n\t\tpi.on(\"context\", (event) => {\n\t\t\tservice.maybeRehydrateFromHistory(event.messages);\n\t\t});\n\n\t\t// A code-mode (eval) cell may name a search-mode tool that tool_search would\n\t\t// promote but that is not active yet. Activating it here keeps the catalog the\n\t\t// only eligible set, so permission-denied, tombstoned, and capability-gated\n\t\t// tools stay inactive, and routes through tier-B activate() for stub swapping.\n\t\tpi.registerLazyToolActivator(\n\t\t\tcreateLazyToolActivator({\n\t\t\t\tgetSearchable: () => service.getTierBSearchable(),\n\t\t\t\tgetActiveTools: () => pi.getActiveTools(),\n\t\t\t\tactivate: (names) => service.activateSkillMcpTools(names),\n\t\t\t}),\n\t\t);\n\n\t\t// skills-carry-MCP (todo 37): skills declaring MCP servers (mcp.json\n\t\t// sidecar or SKILL.md frontmatter) register lazily with tools hidden;\n\t\t// loading a skill — /skill:<name> input or the model reading its SKILL.md —\n\t\t// reveals that skill's includeTools matches for the rest of the session.\n\t\tlet skillDecls: SkillMcpDeclarations = { servers: new Map(), warnings: [] };\n\t\tlet skillsByName = new Map<string, SkillLike>();\n\t\tconst loadedSkills = new Set<string>();\n\t\tconst revealSkill = (skillName: string): void => {\n\t\t\tif (loadedSkills.has(skillName) || !skillsByName.has(skillName)) return;\n\t\t\tloadedSkills.add(skillName);\n\t\t\tconst registered = service.getTierBSearchable();\n\t\t\tconst targets = skillActivationTargets(skillDecls, skillName, registered);\n\t\t\tif (targets.length > 0) service.activateSkillMcpTools(targets);\n\t\t};\n\t\tpi.on(\"input\", async (event, ctx) => {\n\t\t\tconst match = /^\\s*\\/skill:([A-Za-z0-9._-]+)/.exec(event.text);\n\t\t\tif (match) revealSkill(match[1]);\n\t\t\t// @mcp:<server>/<uri> mention expansion (todo 39): recognized mentions are\n\t\t\t// inlined via the sanctioned input transform; failures pass through\n\t\t\t// untouched with a one-line notice so submission is never blocked.\n\t\t\tif (event.text.includes(\"@mcp:\")) {\n\t\t\t\tconst expansion = await expandMcpResourceMentions(event.text, () => service.getMcpResourceServers());\n\t\t\t\tfor (const notice of expansion.notices) {\n\t\t\t\t\tcreateMcpLogger(\"resources\").warn(notice);\n\t\t\t\t\tvoid ctx.ui?.notify?.(notice, \"warning\");\n\t\t\t\t}\n\t\t\t\tif (expansion.changed) return { action: \"transform\", text: expansion.text };\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t\tpi.on(\"tool_call\", (event) => {\n\t\t\tif (event.toolName !== \"read\") return undefined;\n\t\t\tconst path = (event.input as { path?: string }).path;\n\t\t\tif (path === undefined) return undefined;\n\t\t\tfor (const [name, skill] of skillsByName) {\n\t\t\t\tif (path === skill.filePath || path.endsWith(skill.filePath)) revealSkill(name);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\n\t\t// Attach is SINGLE-FLIGHT. session_start handlers are dispatched\n\t\t// fire-and-forget, so a slow attach (a cold MCP server's boot + catalog\n\t\t// collection is awaited inside attachSession) can still be in flight when\n\t\t// before_agent_start fires. The old `attached` boolean was only set on\n\t\t// completion, so before_agent_start would start a SECOND concurrent attach —\n\t\t// which found the connection entries already created (still \"connecting\"),\n\t\t// collected an empty catalog, and registered no MCP tools for turn 1; the\n\t\t// first attach then landed the real registration turns later. Memoizing the\n\t\t// in-flight promise makes before_agent_start await the ORIGINAL attach, so\n\t\t// the first turn's payload deterministically carries the MCP tool set.\n\t\t// session_start always starts a fresh attach (reloads must re-sync config).\n\t\tconst attach = (event: SessionStartEvent, ctx: ExtensionContext): Promise<void> => {\n\t\t\tattachPromise = (async () => {\n\t\t\t\tawait service.attachSession(event, ctx, pi);\n\t\t\t\trefreshMcpInstructionsForSession(service);\n\t\t\t\tif (sessionOwned) registerMcpPromptCommands(service, pi, service.getMcpPromptServers());\n\t\t\t\telse registerMcpPromptCommands(pi, service.getMcpPromptServers());\n\t\t\t})();\n\t\t\treturn attachPromise;\n\t\t};\n\t\tpi.on(\n\t\t\t\"session_start\",\n\t\t\twrapAsync(\"mcp.session_start\", (event, ctx) => attach(event, ctx), sink),\n\t\t);\n\t\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\t\ttry {\n\t\t\t\t// Elicitation (todo 41): point mid-call forms at this session's UI.\n\t\t\t\tservice.setMcpElicitationUiProvider(() => ctx.ui);\n\t\t\t\tawait (attachPromise ?? attach({ type: \"session_start\", reason: \"startup\" }, ctx));\n\t\t\t\tconst skills = (event.systemPromptOptions.skills ?? []) as readonly SkillLike[];\n\t\t\t\tif (skills.length > 0) {\n\t\t\t\t\tskillsByName = new Map(skills.map((skill) => [skill.name, skill]));\n\t\t\t\t\tskillDecls = parseSkillMcpDeclarations(skills);\n\t\t\t\t\tconst declared = new Map(\n\t\t\t\t\t\t[...skillDecls.servers].map(([name, decl]) => [name, { raw: decl.raw, sourcePath: decl.sourcePath }]),\n\t\t\t\t\t);\n\t\t\t\t\tconst warnings = [\n\t\t\t\t\t\t...skillDecls.warnings,\n\t\t\t\t\t\t...(declared.size > 0 ? await service.attachSkillMcpServers(declared) : []),\n\t\t\t\t\t];\n\t\t\t\t\tfor (const warning of warnings) createMcpLogger(\"skills\").warn(warning);\n\t\t\t\t}\n\t\t\t\tconst systemPrompt = injectMcpInstructions(service, event.systemPrompt);\n\t\t\t\treturn systemPrompt === undefined ? undefined : { systemPrompt };\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof Error)) throw error;\n\t\t\t\tawait reportMcpAsyncError(\"mcp.before_agent_start\", error, sink);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t});\n\t\tpi.on(\n\t\t\t\"session_shutdown\",\n\t\t\twrapAsync(\n\t\t\t\t\"mcp.session_shutdown\",\n\t\t\t\tasync (event) => {\n\t\t\t\t\tif (event.reason === \"reload\" && !sessionOwned) return;\n\t\t\t\t\tawait service.handleSessionShutdown(event);\n\t\t\t\t},\n\t\t\t\tsink,\n\t\t\t),\n\t\t);\n\t\tpi.on(\n\t\t\t\"session_extensions_removed\",\n\t\t\twrapAsync(\n\t\t\t\t\"mcp.session_extensions_removed\",\n\t\t\t\tasync (event) => {\n\t\t\t\t\tif (event.removed.some((extension) => extension.path === MCP_BUILTIN_EXTENSION_PATH)) {\n\t\t\t\t\t\tawait service.dispose(\"reload\");\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsink,\n\t\t\t),\n\t\t);\n\t};\n}\n\nfunction hasProviderScope(): boolean {\n\ttry {\n\t\tbindToProviderScope(() => undefined);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport default function mcpExtension(pi: ExtensionAPI): void | Promise<void> {\n\tconst sessionOwned = hasProviderScope();\n\treturn createMcpExtension(sessionOwned ? new McpService() : getMcpService(), sessionOwned)(pi);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACN,4BAA4B,EAC5B,mCAAmC,EACnC,mCAAmC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAC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AC,YAAY,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;AAChG,CAAC","sourcesContent":["import { bindToProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport type { ExtensionAPI, ExtensionContext, ExtensionFactory, SessionStartEvent } from \"../../types.ts\";\nimport { installMcpNativeToolSearchGate } from \"../tool-search/native-search.ts\";\nimport { registerMcpCommands } from \"./commands.ts\";\nimport {\n\tisMcpControlInventoryRequest,\n\tMCP_CONTROL_INVENTORY_CHANGED_EVENT,\n\tMCP_CONTROL_INVENTORY_REQUEST_EVENT,\n} from \"./control-inventory.ts\";\nimport { injectMcpInstructions, refreshMcpInstructionsForSession } from \"./instructions.ts\";\nimport { createMcpLogger } from \"./log.ts\";\nimport { registerMcpPromptCommands } from \"./prompts.ts\";\nimport { expandMcpResourceMentions } from \"./resources.ts\";\nimport { getMcpService, McpService } from \"./service.ts\";\nimport {\n\tparseSkillMcpDeclarations,\n\ttype SkillLike,\n\ttype SkillMcpDeclarations,\n\tskillActivationTargets,\n} from \"./skills.ts\";\nimport { reportMcpAsyncError, safeEventBusOn, wrapAsync } from \"./wrap.ts\";\n\nconst MCP_BUILTIN_EXTENSION_PATH = \"<builtin:mcp>\";\n\nexport function createMcpExtension(service: McpService, sessionOwned = true): ExtensionFactory {\n\treturn (pi: ExtensionAPI): void => {\n\t\tlet attachPromise: Promise<void> | undefined;\n\t\tlet attachedSessionId: string | undefined;\n\t\tlet controlInventoryDisposed = false;\n\t\tconst unsubscribeControlInventoryRequest = safeEventBusOn(\n\t\t\tpi.events,\n\t\t\tMCP_CONTROL_INVENTORY_REQUEST_EVENT,\n\t\t\t(data) => {\n\t\t\t\tif (!isMcpControlInventoryRequest(data) || data.sessionId !== attachedSessionId) return;\n\t\t\t\tdata.respond(service.refreshWireStatusSnapshot(data.sessionId));\n\t\t\t},\n\t\t);\n\t\tconst unsubscribeWireStatus = service.onWireStatusChanged((sessionId, snapshot) => {\n\t\t\tif (sessionId === undefined || sessionId !== attachedSessionId) return;\n\t\t\tpi.events.emit(MCP_CONTROL_INVENTORY_CHANGED_EVENT, { sessionId, snapshot });\n\t\t});\n\t\tconst disposeControlInventory = (): void => {\n\t\t\tif (controlInventoryDisposed) return;\n\t\t\tcontrolInventoryDisposed = true;\n\t\t\tunsubscribeControlInventoryRequest();\n\t\t\tunsubscribeWireStatus();\n\t\t};\n\t\tconst sink = {\n\t\t\tlogger: {\n\t\t\t\terror(message: string, data?: unknown): void {\n\t\t\t\t\tcreateMcpLogger(\"service\").error(message, data);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tregisterMcpCommands(pi, service);\n\n\t\tinstallMcpNativeToolSearchGate(() => {\n\t\t\tconst setting = service.getNativeToolSearchSetting();\n\t\t\treturn setting === true || setting === \"auto\";\n\t\t});\n\t\t// skills-carry-MCP (todo 37): skills declaring MCP servers (mcp.json\n\t\t// sidecar or SKILL.md frontmatter) register lazily with tools hidden;\n\t\t// loading a skill — /skill:<name> input or the model reading its SKILL.md —\n\t\t// reveals that skill's includeTools matches for the rest of the session.\n\t\tlet skillDecls: SkillMcpDeclarations = { servers: new Map(), warnings: [] };\n\t\tlet skillsByName = new Map<string, SkillLike>();\n\t\tconst loadedSkills = new Set<string>();\n\t\tconst revealSkill = (skillName: string): void => {\n\t\t\tif (loadedSkills.has(skillName) || !skillsByName.has(skillName)) return;\n\t\t\tloadedSkills.add(skillName);\n\t\t\tconst registered = service.getTierBSearchable();\n\t\t\tconst targets = skillActivationTargets(skillDecls, skillName, registered);\n\t\t\tif (targets.length > 0) service.activateSkillMcpTools(targets);\n\t\t};\n\t\tpi.on(\"input\", async (event, ctx) => {\n\t\t\tconst match = /^\\s*\\/skill:([A-Za-z0-9._-]+)/.exec(event.text);\n\t\t\tif (match) revealSkill(match[1]);\n\t\t\t// @mcp:<server>/<uri> mention expansion (todo 39): recognized mentions are\n\t\t\t// inlined via the sanctioned input transform; failures pass through\n\t\t\t// untouched with a one-line notice so submission is never blocked.\n\t\t\tif (event.text.includes(\"@mcp:\")) {\n\t\t\t\tconst expansion = await expandMcpResourceMentions(event.text, () => service.getMcpResourceServers());\n\t\t\t\tfor (const notice of expansion.notices) {\n\t\t\t\t\tcreateMcpLogger(\"resources\").warn(notice);\n\t\t\t\t\tvoid ctx.ui?.notify?.(notice, \"warning\");\n\t\t\t\t}\n\t\t\t\tif (expansion.changed) return { action: \"transform\", text: expansion.text };\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t\tpi.on(\"tool_call\", (event) => {\n\t\t\tif (event.toolName !== \"read\") return undefined;\n\t\t\tconst path = (event.input as { path?: string }).path;\n\t\t\tif (path === undefined) return undefined;\n\t\t\tfor (const [name, skill] of skillsByName) {\n\t\t\t\tif (path === skill.filePath || path.endsWith(skill.filePath)) revealSkill(name);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\n\t\t// Attach is SINGLE-FLIGHT. session_start handlers are dispatched\n\t\t// fire-and-forget, so a slow attach (a cold MCP server's boot + catalog\n\t\t// collection is awaited inside attachSession) can still be in flight when\n\t\t// before_agent_start fires. The old `attached` boolean was only set on\n\t\t// completion, so before_agent_start would start a SECOND concurrent attach —\n\t\t// which found the connection entries already created (still \"connecting\"),\n\t\t// collected an empty catalog, and registered no MCP tools for turn 1; the\n\t\t// first attach then landed the real registration turns later. Memoizing the\n\t\t// in-flight promise makes before_agent_start await the ORIGINAL attach, so\n\t\t// the first turn's payload deterministically carries the MCP tool set.\n\t\t// session_start always starts a fresh attach (reloads must re-sync config).\n\t\tconst attach = (event: SessionStartEvent, ctx: ExtensionContext): Promise<void> => {\n\t\t\tattachedSessionId = ctx.sessionManager?.getSessionId?.();\n\t\t\tattachPromise = (async () => {\n\t\t\t\tawait service.attachSession(event, ctx, pi);\n\t\t\t\trefreshMcpInstructionsForSession(service);\n\t\t\t\tif (sessionOwned) registerMcpPromptCommands(service, pi, service.getMcpPromptServers());\n\t\t\t\telse registerMcpPromptCommands(pi, service.getMcpPromptServers());\n\t\t\t})();\n\t\t\treturn attachPromise;\n\t\t};\n\t\tpi.on(\n\t\t\t\"session_start\",\n\t\t\twrapAsync(\"mcp.session_start\", (event, ctx) => attach(event, ctx), sink),\n\t\t);\n\t\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\t\ttry {\n\t\t\t\t// Elicitation (todo 41): point mid-call forms at this session's UI.\n\t\t\t\tservice.setMcpElicitationUiProvider(() => ctx.ui);\n\t\t\t\tawait (attachPromise ?? attach({ type: \"session_start\", reason: \"startup\" }, ctx));\n\t\t\t\tconst skills = (event.systemPromptOptions.skills ?? []) as readonly SkillLike[];\n\t\t\t\tif (skills.length > 0) {\n\t\t\t\t\tskillsByName = new Map(skills.map((skill) => [skill.name, skill]));\n\t\t\t\t\tskillDecls = parseSkillMcpDeclarations(skills);\n\t\t\t\t\tconst declared = new Map(\n\t\t\t\t\t\t[...skillDecls.servers].map(([name, decl]) => [name, { raw: decl.raw, sourcePath: decl.sourcePath }]),\n\t\t\t\t\t);\n\t\t\t\t\tconst warnings = [\n\t\t\t\t\t\t...skillDecls.warnings,\n\t\t\t\t\t\t...(declared.size > 0 ? await service.attachSkillMcpServers(declared) : []),\n\t\t\t\t\t];\n\t\t\t\t\tfor (const warning of warnings) createMcpLogger(\"skills\").warn(warning);\n\t\t\t\t}\n\t\t\t\tconst systemPrompt = injectMcpInstructions(service, event.systemPrompt);\n\t\t\t\treturn systemPrompt === undefined ? undefined : { systemPrompt };\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof Error)) throw error;\n\t\t\t\tawait reportMcpAsyncError(\"mcp.before_agent_start\", error, sink);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t});\n\t\tpi.on(\n\t\t\t\"session_shutdown\",\n\t\t\twrapAsync(\n\t\t\t\t\"mcp.session_shutdown\",\n\t\t\t\tasync (event) => {\n\t\t\t\t\tif (event.reason === \"reload\" && !sessionOwned) return;\n\t\t\t\t\tdisposeControlInventory();\n\t\t\t\t\tawait service.handleSessionShutdown(event);\n\t\t\t\t},\n\t\t\t\tsink,\n\t\t\t),\n\t\t);\n\t\tpi.on(\n\t\t\t\"session_extensions_removed\",\n\t\t\twrapAsync(\n\t\t\t\t\"mcp.session_extensions_removed\",\n\t\t\t\tasync (event) => {\n\t\t\t\t\tif (event.removed.some((extension) => extension.path === MCP_BUILTIN_EXTENSION_PATH)) {\n\t\t\t\t\t\tdisposeControlInventory();\n\t\t\t\t\t\tawait service.dispose(\"reload\");\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsink,\n\t\t\t),\n\t\t);\n\t};\n}\n\nfunction hasProviderScope(): boolean {\n\ttry {\n\t\tbindToProviderScope(() => undefined);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport default function mcpExtension(pi: ExtensionAPI): void | Promise<void> {\n\tconst sessionOwned = hasProviderScope();\n\treturn createMcpExtension(sessionOwned ? new McpService() : getMcpService(), sessionOwned)(pi);\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "../../types.ts";
|
|
2
|
+
import type { ToolSearchService } from "../tool-search/service.ts";
|
|
2
3
|
import type { ResolvedMcpConfig } from "./config-schema.ts";
|
|
3
4
|
import type { McpSessionRegistration } from "./expose/session.ts";
|
|
4
5
|
import type { McpConnectionEntry } from "./service-types.ts";
|
|
@@ -6,6 +7,6 @@ type McpToolRegistrar = Pick<ExtensionAPI, "getActiveTools" | "setActiveTools" |
|
|
|
6
7
|
export interface McpServiceDirectToolRegistrationOptions {
|
|
7
8
|
readonly refreshActiveSetWhenEmpty?: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare function registerMcpServiceDirectTools(pi: McpToolRegistrar, config: ResolvedMcpConfig, entries: Iterable<McpConnectionEntry>, options?: McpServiceDirectToolRegistrationOptions): Promise<McpSessionRegistration | undefined>;
|
|
10
|
+
export declare function registerMcpServiceDirectTools(pi: McpToolRegistrar, config: ResolvedMcpConfig, entries: Iterable<McpConnectionEntry>, toolSearchService: ToolSearchService, options?: McpServiceDirectToolRegistrationOptions): Promise<McpSessionRegistration | undefined>;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=service-register.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-register.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,KAAK,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,CAAC,CAAC;AAEjG,MAAM,WAAW,uCAAuC;IACvD,QAAQ,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CAC7C;AAED,wBAAsB,6BAA6B,CAClD,EAAE,EAAE,gBAAgB,EACpB,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACrC,OAAO,GAAE,uCAA4C,GACnD,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"service-register.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,KAAK,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,CAAC,CAAC;AAEjG,MAAM,WAAW,uCAAuC;IACvD,QAAQ,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CAC7C;AAED,wBAAsB,6BAA6B,CAClD,EAAE,EAAE,gBAAgB,EACpB,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACrC,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,uCAA4C,GACnD,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAoB7C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { registerDirectMcpTools } from "./expose/session.js";
|
|
2
2
|
import { connectAndRefreshMcpCatalog } from "./startup-race.js";
|
|
3
|
-
export async function registerMcpServiceDirectTools(pi, config, entries, options = {}) {
|
|
3
|
+
export async function registerMcpServiceDirectTools(pi, config, entries, toolSearchService, options = {}) {
|
|
4
4
|
return await registerDirectMcpTools(pi, config, [...entries].map((entry) => {
|
|
5
5
|
const serverConfig = config.servers[entry.name]?.config;
|
|
6
6
|
return {
|
|
@@ -13,6 +13,6 @@ export async function registerMcpServiceDirectTools(pi, config, entries, options
|
|
|
13
13
|
logger: entry.logger,
|
|
14
14
|
name: entry.name,
|
|
15
15
|
};
|
|
16
|
-
}), options);
|
|
16
|
+
}), toolSearchService, options);
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=service-register.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-register.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-register.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-register.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-register.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAQhE,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAClD,EAAoB,EACpB,MAAyB,EACzB,OAAqC,EACrC,iBAAoC,EACpC,OAAO,GAA4C,EAAE;IAErD,OAAO,MAAM,sBAAsB,CAClC,EAAE,EACF,MAAM,EACN,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACxD,OAAO;YACN,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE;YACpG,yBAAyB,EAAE,GAAG,EAAE,CAAC,2BAA2B,CAAC,KAAK,EAAE,YAAY,CAAC;YACjF,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI;SAChB,CAAC;IACH,CAAC,CAAC,EACF,iBAAiB,EACjB,OAAO,CACP,CAAC;AACH,CAAC","sourcesContent":["import type { ExtensionAPI } from \"../../types.ts\";\nimport type { ToolSearchService } from \"../tool-search/service.ts\";\nimport type { ResolvedMcpConfig } from \"./config-schema.ts\";\nimport type { McpSessionRegistration } from \"./expose/session.ts\";\nimport { registerDirectMcpTools } from \"./expose/session.ts\";\nimport type { McpConnectionEntry } from \"./service-types.ts\";\nimport { connectAndRefreshMcpCatalog } from \"./startup-race.ts\";\n\ntype McpToolRegistrar = Pick<ExtensionAPI, \"getActiveTools\" | \"setActiveTools\" | \"registerTool\">;\n\nexport interface McpServiceDirectToolRegistrationOptions {\n\treadonly refreshActiveSetWhenEmpty?: boolean;\n}\n\nexport async function registerMcpServiceDirectTools(\n\tpi: McpToolRegistrar,\n\tconfig: ResolvedMcpConfig,\n\tentries: Iterable<McpConnectionEntry>,\n\ttoolSearchService: ToolSearchService,\n\toptions: McpServiceDirectToolRegistrationOptions = {},\n): Promise<McpSessionRegistration | undefined> {\n\treturn await registerDirectMcpTools(\n\t\tpi,\n\t\tconfig,\n\t\t[...entries].map((entry) => {\n\t\t\tconst serverConfig = config.servers[entry.name]?.config;\n\t\t\treturn {\n\t\t\t\tagentDir: entry.agentDir,\n\t\t\t\tartifacts: entry.artifacts,\n\t\t\t\tcachedCatalog: entry.cachedCatalog,\n\t\t\t\tconnection: entry.connection,\n\t\t\t\tensureFresh: () => entry.authPlan?.refresh?.ensureFresh().then(() => undefined) ?? Promise.resolve(),\n\t\t\t\tensureCachedToolConnected: () => connectAndRefreshMcpCatalog(entry, serverConfig),\n\t\t\t\tlogger: entry.logger,\n\t\t\t\tname: entry.name,\n\t\t\t};\n\t\t}),\n\t\ttoolSearchService,\n\t\toptions,\n\t);\n}\n"]}
|
|
@@ -10,6 +10,7 @@ export type McpWireJsonValue = null | boolean | number | string | readonly McpWi
|
|
|
10
10
|
readonly [key: string]: McpWireJsonValue | undefined;
|
|
11
11
|
};
|
|
12
12
|
export type McpWireAuthStatus = "unsupported" | "notLoggedIn" | "bearerToken" | "oAuth";
|
|
13
|
+
export type McpWireServerStatus = ServerConnectionState | ResolvedMcpServer["state"];
|
|
13
14
|
export type McpWireServerInfo = {
|
|
14
15
|
readonly name: string;
|
|
15
16
|
readonly title: string | null;
|
|
@@ -56,6 +57,7 @@ export type McpWireStatusServer = {
|
|
|
56
57
|
readonly resources: readonly McpWireResource[];
|
|
57
58
|
readonly resourceTemplates: readonly McpWireResourceTemplate[];
|
|
58
59
|
readonly authStatus: McpWireAuthStatus;
|
|
60
|
+
readonly status?: McpWireServerStatus;
|
|
59
61
|
};
|
|
60
62
|
export type McpWireStatusSnapshot = {
|
|
61
63
|
readonly servers: readonly McpWireStatusServer[];
|
|
@@ -133,5 +135,7 @@ export interface McpConnectionEntry {
|
|
|
133
135
|
lastListChangedDelta?: string;
|
|
134
136
|
/** Teardown for the list_changed coalescer + subscription. */
|
|
135
137
|
disposeListChanged?: () => void;
|
|
138
|
+
/** Teardown for the control-inventory connection-state subscription. */
|
|
139
|
+
disposeWireStatus?: () => void;
|
|
136
140
|
}
|
|
137
141
|
//# sourceMappingURL=service-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;AAE1F,MAAM,MAAM,gBAAgB,GACzB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,gBAAgB,EAAE,GAC3B;IAAE,Q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":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtensionContext, SessionShutdownEvent, SessionStartEvent } from \"../../types.ts\";\nimport type { ServerAuthPlan } from \"./auth/context.ts\";\nimport type { McpCachedServerCatalog } from \"./catalog-cache.ts\";\nimport type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection, ServerConnectionState } from \"./connection.ts\";\nimport type { McpOutputArtifacts } from \"./guard/output-guard.ts\";\nimport type { McpLogger } from \"./log.ts\";\n\nexport type McpDisposeReason = Extract<SessionShutdownEvent[\"reason\"], \"quit\" | \"reload\">;\n\nexport type McpWireJsonValue =\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| readonly McpWireJsonValue[]\n\t| { readonly [key: string]: McpWireJsonValue | undefined };\n\nexport type McpWireAuthStatus = \"unsupported\" | \"notLoggedIn\" | \"bearerToken\" | \"oAuth\";\n\nexport type McpWireServerInfo = {\n\treadonly name: string;\n\treadonly title: string | null;\n\treadonly version: string;\n\treadonly description: string | null;\n\treadonly icons: readonly McpWireJsonValue[] | null;\n\treadonly websiteUrl: string | null;\n};\n\nexport type McpWireTool = {\n\treadonly name: string;\n\treadonly title?: string;\n\treadonly description?: string;\n\treadonly inputSchema: McpWireJsonValue;\n\treadonly outputSchema?: McpWireJsonValue;\n\treadonly annotations?: McpWireJsonValue;\n\treadonly icons?: readonly McpWireJsonValue[];\n\treadonly _meta?: McpWireJsonValue;\n};\n\nexport type McpWireResource = {\n\treadonly annotations?: McpWireJsonValue;\n\treadonly description?: string;\n\treadonly mimeType?: string;\n\treadonly name: string;\n\treadonly size?: number;\n\treadonly title?: string;\n\treadonly uri: string;\n\treadonly icons?: readonly McpWireJsonValue[];\n\treadonly _meta?: McpWireJsonValue;\n};\n\nexport type McpWireResourceTemplate = {\n\treadonly annotations?: McpWireJsonValue;\n\treadonly uriTemplate: string;\n\treadonly name: string;\n\treadonly title?: string;\n\treadonly description?: string;\n\treadonly mimeType?: string;\n\treadonly icons?: readonly McpWireJsonValue[];\n\treadonly _meta?: McpWireJsonValue;\n};\n\nexport type McpWireStatusServer = {\n\treadonly name: string;\n\treadonly serverInfo: McpWireServerInfo | null;\n\treadonly tools: readonly McpWireTool[];\n\treadonly resources: readonly McpWireResource[];\n\treadonly resourceTemplates: readonly McpWireResourceTemplate[];\n\treadonly authStatus: McpWireAuthStatus;\n};\n\nexport type McpWireStatusSnapshot = {\n\treadonly servers: readonly McpWireStatusServer[];\n};\n\nexport type McpSessionContext = Pick<ExtensionContext, \"cwd\" | \"isProjectTrusted\"> & {\n\tmode?: ExtensionContext[\"mode\"];\n\t/**\n\t * Session history access, present on the real ExtensionContext. Only\n\t * getEntries is needed (attach-time promotion rehydration); keeping the\n\t * requirement narrow lets tests pass a two-line fake.\n\t */\n\tsessionManager?: Pick<ExtensionContext[\"sessionManager\"], \"getEntries\"> &\n\t\tPartial<Pick<ExtensionContext[\"sessionManager\"], \"getSessionId\">>;\n\t/**\n\t * Extension-declared MCP servers. Read on every attach so reattach/reload\n\t * paths pick up the current declarations without caching them in the MCP\n\t * builtin.\n\t */\n\tgetRegisteredMcpServers?: () => readonly {\n\t\tname: string;\n\t\tconfig: Record<string, unknown>;\n\t\textensionPath: string;\n\t\tregistrationCwd: string;\n\t}[];\n};\n\nexport interface McpSessionOptions {\n\treadonly agentDir?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly logDir?: string;\n\treadonly projectTrusted?: boolean;\n}\n\nexport interface McpServiceSnapshot {\n\tdisposed: boolean;\n\tdisposeCount: number;\n\tlastDisposeReason: McpDisposeReason | null;\n\tsessionStartCount: number;\n\tlastSessionStartReason: SessionStartEvent[\"reason\"] | null;\n\thasSessionContext: boolean;\n\tconnectionCount: number;\n}\n\nexport interface McpServerSnapshot {\n\tname: string;\n\tconfigState: ResolvedMcpServer[\"state\"] | \"removed\";\n\tconfigHash: string | null;\n\tsource: ResolvedMcpServer[\"source\"] | null;\n\tsourcePath: string | null;\n\tlifecycleState: ServerConnectionState | \"cached\" | \"not_spawned\";\n\tgeneration: number | null;\n\tpid: number | null;\n\tlastError: string | null;\n\tuptimeMs: number | null;\n\tcounters: McpServerCounters;\n}\n\nexport interface McpServerCounters {\n\tcallCount: number;\n\terrorCount: number;\n\ttotalLatencyMs: number;\n\treconnectCount: number;\n}\n\nexport interface McpConnectionEntry {\n\treadonly key: string;\n\treadonly name: string;\n\treadonly configHash: string;\n\treadonly connection: ServerConnection;\n\treadonly logger: McpLogger;\n\treadonly createdAtMs: number;\n\treadonly counters: McpServerCounters;\n\treadonly agentDir?: string;\n\treadonly artifacts?: McpOutputArtifacts;\n\treadonly authPlan?: ServerAuthPlan;\n\tcachedCatalog?: McpCachedServerCatalog;\n\tcacheRefreshedAfterConnect: boolean;\n\t/** Full mcp tool names last registered for this server (list_changed diffing). */\n\tknownToolNames?: string[];\n\t/** Latest `/mcp status` list_changed delta line, e.g. \"2 added (inactive), 1 removed\". */\n\tlastListChangedDelta?: string;\n\t/** Teardown for the list_changed coalescer + subscription. */\n\tdisposeListChanged?: () => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"service-types.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtensionContext, SessionShutdownEvent, SessionStartEvent } from \"../../types.ts\";\nimport type { ServerAuthPlan } from \"./auth/context.ts\";\nimport type { McpCachedServerCatalog } from \"./catalog-cache.ts\";\nimport type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection, ServerConnectionState } from \"./connection.ts\";\nimport type { McpOutputArtifacts } from \"./guard/output-guard.ts\";\nimport type { McpLogger } from \"./log.ts\";\n\nexport type McpDisposeReason = Extract<SessionShutdownEvent[\"reason\"], \"quit\" | \"reload\">;\n\nexport type McpWireJsonValue =\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| readonly McpWireJsonValue[]\n\t| { readonly [key: string]: McpWireJsonValue | undefined };\n\nexport type McpWireAuthStatus = \"unsupported\" | \"notLoggedIn\" | \"bearerToken\" | \"oAuth\";\nexport type McpWireServerStatus = ServerConnectionState | ResolvedMcpServer[\"state\"];\n\nexport type McpWireServerInfo = {\n\treadonly name: string;\n\treadonly title: string | null;\n\treadonly version: string;\n\treadonly description: string | null;\n\treadonly icons: readonly McpWireJsonValue[] | null;\n\treadonly websiteUrl: string | null;\n};\n\nexport type McpWireTool = {\n\treadonly name: string;\n\treadonly title?: string;\n\treadonly description?: string;\n\treadonly inputSchema: McpWireJsonValue;\n\treadonly outputSchema?: McpWireJsonValue;\n\treadonly annotations?: McpWireJsonValue;\n\treadonly icons?: readonly McpWireJsonValue[];\n\treadonly _meta?: McpWireJsonValue;\n};\n\nexport type McpWireResource = {\n\treadonly annotations?: McpWireJsonValue;\n\treadonly description?: string;\n\treadonly mimeType?: string;\n\treadonly name: string;\n\treadonly size?: number;\n\treadonly title?: string;\n\treadonly uri: string;\n\treadonly icons?: readonly McpWireJsonValue[];\n\treadonly _meta?: McpWireJsonValue;\n};\n\nexport type McpWireResourceTemplate = {\n\treadonly annotations?: McpWireJsonValue;\n\treadonly uriTemplate: string;\n\treadonly name: string;\n\treadonly title?: string;\n\treadonly description?: string;\n\treadonly mimeType?: string;\n\treadonly icons?: readonly McpWireJsonValue[];\n\treadonly _meta?: McpWireJsonValue;\n};\n\nexport type McpWireStatusServer = {\n\treadonly name: string;\n\treadonly serverInfo: McpWireServerInfo | null;\n\treadonly tools: readonly McpWireTool[];\n\treadonly resources: readonly McpWireResource[];\n\treadonly resourceTemplates: readonly McpWireResourceTemplate[];\n\treadonly authStatus: McpWireAuthStatus;\n\treadonly status?: McpWireServerStatus;\n};\n\nexport type McpWireStatusSnapshot = {\n\treadonly servers: readonly McpWireStatusServer[];\n};\n\nexport type McpSessionContext = Pick<ExtensionContext, \"cwd\" | \"isProjectTrusted\"> & {\n\tmode?: ExtensionContext[\"mode\"];\n\t/**\n\t * Session history access, present on the real ExtensionContext. Only\n\t * getEntries is needed (attach-time promotion rehydration); keeping the\n\t * requirement narrow lets tests pass a two-line fake.\n\t */\n\tsessionManager?: Pick<ExtensionContext[\"sessionManager\"], \"getEntries\"> &\n\t\tPartial<Pick<ExtensionContext[\"sessionManager\"], \"getSessionId\">>;\n\t/**\n\t * Extension-declared MCP servers. Read on every attach so reattach/reload\n\t * paths pick up the current declarations without caching them in the MCP\n\t * builtin.\n\t */\n\tgetRegisteredMcpServers?: () => readonly {\n\t\tname: string;\n\t\tconfig: Record<string, unknown>;\n\t\textensionPath: string;\n\t\tregistrationCwd: string;\n\t}[];\n};\n\nexport interface McpSessionOptions {\n\treadonly agentDir?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly logDir?: string;\n\treadonly projectTrusted?: boolean;\n}\n\nexport interface McpServiceSnapshot {\n\tdisposed: boolean;\n\tdisposeCount: number;\n\tlastDisposeReason: McpDisposeReason | null;\n\tsessionStartCount: number;\n\tlastSessionStartReason: SessionStartEvent[\"reason\"] | null;\n\thasSessionContext: boolean;\n\tconnectionCount: number;\n}\n\nexport interface McpServerSnapshot {\n\tname: string;\n\tconfigState: ResolvedMcpServer[\"state\"] | \"removed\";\n\tconfigHash: string | null;\n\tsource: ResolvedMcpServer[\"source\"] | null;\n\tsourcePath: string | null;\n\tlifecycleState: ServerConnectionState | \"cached\" | \"not_spawned\";\n\tgeneration: number | null;\n\tpid: number | null;\n\tlastError: string | null;\n\tuptimeMs: number | null;\n\tcounters: McpServerCounters;\n}\n\nexport interface McpServerCounters {\n\tcallCount: number;\n\terrorCount: number;\n\ttotalLatencyMs: number;\n\treconnectCount: number;\n}\n\nexport interface McpConnectionEntry {\n\treadonly key: string;\n\treadonly name: string;\n\treadonly configHash: string;\n\treadonly connection: ServerConnection;\n\treadonly logger: McpLogger;\n\treadonly createdAtMs: number;\n\treadonly counters: McpServerCounters;\n\treadonly agentDir?: string;\n\treadonly artifacts?: McpOutputArtifacts;\n\treadonly authPlan?: ServerAuthPlan;\n\tcachedCatalog?: McpCachedServerCatalog;\n\tcacheRefreshedAfterConnect: boolean;\n\t/** Full mcp tool names last registered for this server (list_changed diffing). */\n\tknownToolNames?: string[];\n\t/** Latest `/mcp status` list_changed delta line, e.g. \"2 added (inactive), 1 removed\". */\n\tlastListChangedDelta?: string;\n\t/** Teardown for the list_changed coalescer + subscription. */\n\tdisposeListChanged?: () => void;\n\t/** Teardown for the control-inventory connection-state subscription. */\n\tdisposeWireStatus?: () => void;\n}\n"]}
|
|
@@ -37,6 +37,10 @@ export declare class McpService {
|
|
|
37
37
|
* resulting snapshot because tool, resource, and prompt catalogs can become
|
|
38
38
|
* available in different startup-race generations. */
|
|
39
39
|
onMcpRegistrationChanged(listener: () => void): () => void;
|
|
40
|
+
/** Subscribe to live MCP inventory transitions for session-scoped hosts. */
|
|
41
|
+
onWireStatusChanged(listener: (sessionId: string | undefined, snapshot: McpWireStatusSnapshot) => void): () => void;
|
|
42
|
+
/** Refresh and return the current session-owned MCP wire inventory. */
|
|
43
|
+
refreshWireStatusSnapshot(sessionId?: string): Promise<McpWireStatusSnapshot>;
|
|
40
44
|
/** Reveal skill-owned tools (todo 37): activation is effective the next
|
|
41
45
|
* turn, exactly like an tool_search promotion. Unknown names are ignored. */
|
|
42
46
|
activateSkillMcpTools(names: readonly string[]): void;
|
|
@@ -57,18 +61,9 @@ export declare class McpService {
|
|
|
57
61
|
* does not expose or derive from the lifecycle-only server snapshots.
|
|
58
62
|
*/
|
|
59
63
|
getWireStatusSnapshot(sessionId?: string): McpWireStatusSnapshot;
|
|
60
|
-
/**
|
|
61
|
-
* Replay tool_search activation markers from session history through the
|
|
62
|
-
* live tier-B activation path (see tool-search.ts). Returns newly activated
|
|
63
|
-
* names; safe to call repeatedly (already-active names are skipped).
|
|
64
|
-
*/
|
|
64
|
+
/** Route compatibility callers through the shared ownership-aware scanner. */
|
|
65
65
|
rehydrateActiveToolsFromHistory(messages: readonly unknown[]): string[];
|
|
66
|
-
/**
|
|
67
|
-
* Once-per-registration variant for per-turn context events: scanning the
|
|
68
|
-
* full history each turn would cost O(history) JSON serialization, and a
|
|
69
|
-
* live session's active set only drifts from history when a (re-)registration
|
|
70
|
-
* rebuilt it — so scan once after each registration and skip otherwise.
|
|
71
|
-
*/
|
|
66
|
+
/** Shared service memoization keeps this scan once-per-catalog-generation. */
|
|
72
67
|
maybeRehydrateFromHistory(messages: readonly unknown[]): string[];
|
|
73
68
|
setMcpInstructions(instructions: string): void;
|
|
74
69
|
getMcpInstructions(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAShH,OAAO,EAA2C,qBAAqB,EAA4B,MAAM,aAAa,CAAC;AACvH,OAAO,KAAK,EAAE,eAAe,EAAwC,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAInD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAA6B,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAYxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,OAAO,KAAK,EAEX,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAOjB,qBAAqB,EAErB,MAAM,oBAAoB,CAAC;AAW5B,KAAK,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,EAA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AmB,IAAI,gBAAgB,GAAG,SAAS,CAElD;IAED,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;IAED,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEjD;IAED,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAIhD;IAED,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE3C;IAED,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,0BAA0B,EAAE,gBAAgB,CAAC,CAEjF;IAED,aAAa,CACZ,IAAI,EAAE,MAAM,GAEV;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9G,SAAS,CASX;IAED,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEtD;IAED;8DAC0D;IAC1D,0BAA0B,IAAI,MAAM,GAAG,OAAO,GAAG,SAAS,CAEzD;CACD;AAiGD,wBAAgB,aAAa,IAAI,UAAU,CAK1C;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,gBAAgB,CAE1G;AAUD,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getToolSearchService, resetToolSearchServiceForTests, } from "../tool-search/service.js";
|
|
1
2
|
import { detectLiteralBearerWarnings, resolveAuthMode, resolveServerAuth } from "./auth/context.js";
|
|
2
3
|
import { collectToolCatalog } from "./catalog.js";
|
|
3
4
|
import { getValidCachedServer, readMcpCatalogCache } from "./catalog-cache.js";
|
|
@@ -34,9 +35,11 @@ export class McpService {
|
|
|
34
35
|
#interactiveAuthServers = new Set();
|
|
35
36
|
#promptCommandNames = new Set();
|
|
36
37
|
#registrationListeners = new Set();
|
|
38
|
+
#wireStatusListeners = new Set();
|
|
39
|
+
#wireStatusRefreshQueue = Promise.resolve();
|
|
37
40
|
#refreshActiveSetWhenNoTools = false;
|
|
38
41
|
#tierBRegistration;
|
|
39
|
-
#
|
|
42
|
+
#toolSearchService;
|
|
40
43
|
#sessionOptions = {};
|
|
41
44
|
#pi;
|
|
42
45
|
#attachQueue = Promise.resolve();
|
|
@@ -59,6 +62,19 @@ export class McpService {
|
|
|
59
62
|
mergeExtensionMcpServers(config, ctx.getRegisteredMcpServers?.() ?? []);
|
|
60
63
|
this.#config = config;
|
|
61
64
|
this.#pi = _pi;
|
|
65
|
+
if (_pi !== undefined) {
|
|
66
|
+
const activationRuntime = {
|
|
67
|
+
getActiveTools: () => _pi.getActiveTools(),
|
|
68
|
+
setActiveTools: (names) => _pi.setActiveTools([...names]),
|
|
69
|
+
};
|
|
70
|
+
try {
|
|
71
|
+
this.#toolSearchService = getToolSearchService();
|
|
72
|
+
this.#toolSearchService.bindActivationRuntime(activationRuntime);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
this.#toolSearchService = getToolSearchService({ getAllTools: () => [], ...activationRuntime });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
62
78
|
this.#authAgentDir = options.agentDir;
|
|
63
79
|
this.#authEnv = options.env;
|
|
64
80
|
this.#sessionOptions = options;
|
|
@@ -75,7 +91,7 @@ export class McpService {
|
|
|
75
91
|
if (_pi !== undefined)
|
|
76
92
|
this.#rehydrateFromSessionHistory(ctx);
|
|
77
93
|
if (shouldCaptureWireStatus(ctx))
|
|
78
|
-
await this
|
|
94
|
+
await this.refreshWireStatusSnapshot(ctx.sessionManager?.getSessionId?.());
|
|
79
95
|
});
|
|
80
96
|
this.#attachQueue = attach.then(() => undefined, () => undefined);
|
|
81
97
|
await attach;
|
|
@@ -112,7 +128,7 @@ export class McpService {
|
|
|
112
128
|
await this.#syncFromConfig(config, this.#sessionOptions, false, pi, toolRefreshGeneration);
|
|
113
129
|
await this.#registerDirectTools(pi);
|
|
114
130
|
if (this.#sessionContext !== null && shouldCaptureWireStatus(this.#sessionContext)) {
|
|
115
|
-
await this
|
|
131
|
+
await this.refreshWireStatusSnapshot(this.#sessionContext.sessionManager?.getSessionId?.());
|
|
116
132
|
}
|
|
117
133
|
}
|
|
118
134
|
return warnings;
|
|
@@ -137,6 +153,18 @@ export class McpService {
|
|
|
137
153
|
this.#registrationListeners.add(listener);
|
|
138
154
|
return () => this.#registrationListeners.delete(listener);
|
|
139
155
|
}
|
|
156
|
+
/** Subscribe to live MCP inventory transitions for session-scoped hosts. */
|
|
157
|
+
onWireStatusChanged(listener) {
|
|
158
|
+
this.#wireStatusListeners.add(listener);
|
|
159
|
+
return () => this.#wireStatusListeners.delete(listener);
|
|
160
|
+
}
|
|
161
|
+
/** Refresh and return the current session-owned MCP wire inventory. */
|
|
162
|
+
async refreshWireStatusSnapshot(sessionId) {
|
|
163
|
+
const refresh = this.#wireStatusRefreshQueue.then(() => this.#captureWireStatus(sessionId));
|
|
164
|
+
this.#wireStatusRefreshQueue = refresh.then(() => undefined, () => undefined);
|
|
165
|
+
await refresh;
|
|
166
|
+
return this.getWireStatusSnapshot(sessionId);
|
|
167
|
+
}
|
|
140
168
|
/** Reveal skill-owned tools (todo 37): activation is effective the next
|
|
141
169
|
* turn, exactly like an tool_search promotion. Unknown names are ignored. */
|
|
142
170
|
activateSkillMcpTools(names) {
|
|
@@ -166,6 +194,7 @@ export class McpService {
|
|
|
166
194
|
this.#interactiveAuthServers.clear();
|
|
167
195
|
this.#promptCommandNames.clear();
|
|
168
196
|
this.#registrationListeners.clear();
|
|
197
|
+
this.#wireStatusListeners.clear();
|
|
169
198
|
this.#wireStatusBySession.clear();
|
|
170
199
|
this.#latestWireStatus = { servers: [] };
|
|
171
200
|
const entries = [...this.#connections.values()];
|
|
@@ -358,10 +387,19 @@ export class McpService {
|
|
|
358
387
|
sink,
|
|
359
388
|
});
|
|
360
389
|
const unsubscribe = entry.connection.onToolsChanged(() => coalescer.notify());
|
|
390
|
+
const unsubscribeState = entry.connection.onStateChange(() => {
|
|
391
|
+
const ctx = this.#sessionContext;
|
|
392
|
+
if (ctx?.mode !== "rpc")
|
|
393
|
+
return;
|
|
394
|
+
void this.refreshWireStatusSnapshot(ctx.sessionManager?.getSessionId?.()).catch((error) => {
|
|
395
|
+
entry.logger.error("Failed to refresh MCP control inventory", error);
|
|
396
|
+
});
|
|
397
|
+
});
|
|
361
398
|
entry.disposeListChanged = () => {
|
|
362
399
|
unsubscribe();
|
|
363
400
|
coalescer.dispose();
|
|
364
401
|
};
|
|
402
|
+
entry.disposeWireStatus = unsubscribeState;
|
|
365
403
|
}
|
|
366
404
|
// Re-list a server on a coalesced list_changed and re-register: added tools
|
|
367
405
|
// enter INACTIVE (registerToolsPreservingActiveSet keeps the active set), and
|
|
@@ -392,34 +430,26 @@ export class McpService {
|
|
|
392
430
|
const config = this.#config;
|
|
393
431
|
if (config === null)
|
|
394
432
|
return;
|
|
395
|
-
|
|
433
|
+
const toolSearchService = this.#toolSearchService;
|
|
434
|
+
if (toolSearchService === undefined)
|
|
435
|
+
return;
|
|
436
|
+
this.#tierBRegistration = await registerMcpServiceDirectTools(pi, config, this.#connections.values(), toolSearchService, {
|
|
396
437
|
refreshActiveSetWhenEmpty: this.#refreshActiveSetWhenNoTools,
|
|
397
438
|
});
|
|
439
|
+
const ctx = this.#sessionContext;
|
|
440
|
+
if (ctx?.mode === "rpc") {
|
|
441
|
+
await this.refreshWireStatusSnapshot(ctx.sessionManager?.getSessionId?.());
|
|
442
|
+
}
|
|
398
443
|
for (const listener of this.#registrationListeners)
|
|
399
444
|
listener();
|
|
400
|
-
// A (re-)registration recomputes the active set from config alone, so any
|
|
401
|
-
// promotions recorded in history are worth replaying on the next scan.
|
|
402
|
-
this.#historyScanned = false;
|
|
403
445
|
}
|
|
404
|
-
/**
|
|
405
|
-
* Replay tool_search activation markers from session history through the
|
|
406
|
-
* live tier-B activation path (see tool-search.ts). Returns newly activated
|
|
407
|
-
* names; safe to call repeatedly (already-active names are skipped).
|
|
408
|
-
*/
|
|
446
|
+
/** Route compatibility callers through the shared ownership-aware scanner. */
|
|
409
447
|
rehydrateActiveToolsFromHistory(messages) {
|
|
410
|
-
this.#
|
|
411
|
-
return this.#tierBRegistration?.rehydrateFromHistory(messages) ?? [];
|
|
448
|
+
return this.#toolSearchService?.maybeRehydrateFromHistory(messages) ?? [];
|
|
412
449
|
}
|
|
413
|
-
/**
|
|
414
|
-
* Once-per-registration variant for per-turn context events: scanning the
|
|
415
|
-
* full history each turn would cost O(history) JSON serialization, and a
|
|
416
|
-
* live session's active set only drifts from history when a (re-)registration
|
|
417
|
-
* rebuilt it — so scan once after each registration and skip otherwise.
|
|
418
|
-
*/
|
|
450
|
+
/** Shared service memoization keeps this scan once-per-catalog-generation. */
|
|
419
451
|
maybeRehydrateFromHistory(messages) {
|
|
420
|
-
|
|
421
|
-
return [];
|
|
422
|
-
return this.rehydrateActiveToolsFromHistory(messages);
|
|
452
|
+
return this.#toolSearchService?.maybeRehydrateFromHistory(messages) ?? [];
|
|
423
453
|
}
|
|
424
454
|
#serverSnapshot(name) {
|
|
425
455
|
const connection = this.getConnection(name);
|
|
@@ -434,9 +464,14 @@ export class McpService {
|
|
|
434
464
|
.sort()
|
|
435
465
|
.map((name) => this.#captureWireStatusServer(name, config.servers[name])));
|
|
436
466
|
const snapshot = { servers };
|
|
467
|
+
const previous = this.getWireStatusSnapshot(sessionId);
|
|
437
468
|
this.#latestWireStatus = snapshot;
|
|
438
469
|
if (sessionId !== undefined)
|
|
439
470
|
this.#wireStatusBySession.set(sessionId, snapshot);
|
|
471
|
+
if (JSON.stringify(previous) === JSON.stringify(snapshot))
|
|
472
|
+
return;
|
|
473
|
+
for (const listener of this.#wireStatusListeners)
|
|
474
|
+
listener(sessionId, snapshot);
|
|
440
475
|
}
|
|
441
476
|
async #captureWireStatusServer(name, server) {
|
|
442
477
|
const entry = this.#entryForName(name);
|
|
@@ -452,23 +487,21 @@ export class McpService {
|
|
|
452
487
|
const version = client.getServerVersion();
|
|
453
488
|
if (version !== undefined)
|
|
454
489
|
serverInfo = mapWireServerInfo(version);
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
resources = [];
|
|
471
|
-
}
|
|
490
|
+
try {
|
|
491
|
+
tools = (await collectAllPages((cursor) => client.listTools(cursor === undefined ? {} : { cursor }))).items;
|
|
492
|
+
}
|
|
493
|
+
catch (error) {
|
|
494
|
+
if (!(error instanceof Error))
|
|
495
|
+
throw error;
|
|
496
|
+
tools = cached?.tools ?? [];
|
|
497
|
+
}
|
|
498
|
+
try {
|
|
499
|
+
resources = (await collectAllPages((cursor) => client.listResources(cursor === undefined ? {} : { cursor }))).items;
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
if (!(error instanceof Error))
|
|
503
|
+
throw error;
|
|
504
|
+
resources = cached?.resources ?? [];
|
|
472
505
|
}
|
|
473
506
|
try {
|
|
474
507
|
resourceTemplates = (await collectAllPages((cursor) => client.listResourceTemplates(cursor === undefined ? {} : { cursor }))).items;
|
|
@@ -486,6 +519,9 @@ export class McpService {
|
|
|
486
519
|
resources: resources.map(mapWireResource),
|
|
487
520
|
resourceTemplates: resourceTemplates.map(mapWireResourceTemplate),
|
|
488
521
|
authStatus: wireAuthStatus(entry, server),
|
|
522
|
+
...(connection?.state === undefined && server?.state === undefined
|
|
523
|
+
? {}
|
|
524
|
+
: { status: connection?.state ?? server?.state }),
|
|
489
525
|
};
|
|
490
526
|
}
|
|
491
527
|
#entryForName(name) {
|
|
@@ -556,7 +592,7 @@ function wireAuthStatus(entry, server) {
|
|
|
556
592
|
}
|
|
557
593
|
}
|
|
558
594
|
function shouldCaptureWireStatus(ctx) {
|
|
559
|
-
return ctx.mode === "app-server";
|
|
595
|
+
return ctx.mode === "app-server" || ctx.mode === "rpc";
|
|
560
596
|
}
|
|
561
597
|
function mapWireServerInfo(info) {
|
|
562
598
|
return {
|
|
@@ -637,11 +673,13 @@ export function shouldDisposeMcpService(reason) {
|
|
|
637
673
|
}
|
|
638
674
|
async function disposeEntryConnection(entry) {
|
|
639
675
|
entry.disposeListChanged?.();
|
|
676
|
+
entry.disposeWireStatus?.();
|
|
640
677
|
disposeMcpReconnect(entry.connection);
|
|
641
678
|
disposeMcpConnectionLifecycle(entry.connection);
|
|
642
679
|
await entry.connection.dispose();
|
|
643
680
|
}
|
|
644
681
|
export function resetMcpServiceForTests() {
|
|
645
682
|
service = null;
|
|
683
|
+
resetToolSearchServiceForTests();
|
|
646
684
|
}
|
|
647
685
|
//# sourceMappingURL=service.js.map
|