@code-yeongyu/senpi 2026.9.26 → 2026.9.27-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 +66 -0
- package/dist/bun-runtime.d.ts +18 -2
- package/dist/bun-runtime.d.ts.map +1 -1
- package/dist/bun-runtime.js +60 -8
- package/dist/bun-runtime.js.map +1 -1
- package/dist/bundle/chunks/anthropic-messages-3FGAXYJS.js +8 -0
- package/dist/bundle/chunks/{app-server-command-ZRCKWY2X.js → app-server-command-ZVB35UIJ.js} +1 -1
- package/dist/bundle/chunks/azure-openai-responses-4SUOOZZ4.js +2 -0
- package/dist/bundle/chunks/bun-extension-importer-R4HXF3GD.js +14 -0
- package/dist/bundle/chunks/{chunk-KMJXSXRX.js → chunk-357I4IUU.js} +2 -2
- package/dist/bundle/chunks/chunk-3SIQIY57.js +8 -0
- package/dist/bundle/chunks/chunk-45SZOLCU.js +2 -0
- package/dist/bundle/chunks/{chunk-77ACEMYL.js → chunk-6J6RDMBY.js} +1 -1
- package/dist/bundle/chunks/{chunk-BSOJHK4W.js → chunk-7FXXRPB3.js} +2 -1
- package/dist/bundle/chunks/{chunk-FD34HSJJ.js → chunk-C6LQNMRB.js} +1 -1
- package/dist/bundle/chunks/chunk-ELM77A26.js +2 -0
- package/dist/bundle/chunks/chunk-GZVCRV7I.js +3 -0
- package/dist/bundle/chunks/{chunk-TTY5BHCG.js → chunk-H2SGCPMD.js} +1 -1
- package/dist/bundle/chunks/chunk-KLBKUBDV.js +2 -0
- package/dist/bundle/chunks/chunk-L6QV7NZI.js +2 -0
- package/dist/bundle/chunks/{chunk-ZKZAATFM.js → chunk-LDB5UMH2.js} +2 -2
- package/dist/bundle/chunks/{chunk-HZAKOVHN.js → chunk-LGKKU4VM.js} +1 -1
- package/dist/bundle/chunks/{chunk-6Q6DGME2.js → chunk-NMDALHXH.js} +1 -1
- package/dist/bundle/chunks/chunk-NNILBBOH.js +18 -0
- package/dist/bundle/chunks/{chunk-SUQDU5KM.js → chunk-OQRUK2DK.js} +1 -1
- package/dist/bundle/chunks/{chunk-OZCB6BP3.js → chunk-OZN2KUPR.js} +7 -7
- package/dist/bundle/chunks/{chunk-X3T45623.js → chunk-QK4QKRTF.js} +1 -1
- package/dist/bundle/chunks/{chunk-WM5FVFAP.js → chunk-QPZVJQC5.js} +1 -1
- package/dist/bundle/chunks/{chunk-Y54V65MS.js → chunk-QYAO24GB.js} +1 -1
- package/dist/bundle/chunks/{chunk-MKAM7IRH.js → chunk-RULGEHQM.js} +1 -1
- package/dist/bundle/chunks/{chunk-QGC46CGK.js → chunk-RYI6XR6Z.js} +63 -58
- package/dist/bundle/chunks/chunk-U3VOXCGP.js +2 -0
- package/dist/bundle/chunks/chunk-W3D3ZYDS.js +2 -0
- package/dist/bundle/chunks/{chunk-UBPMXBOJ.js → chunk-XKLR7C5B.js} +1 -1
- package/dist/bundle/chunks/{chunk-CLZVNQW3.js → chunk-Y7EIVDHZ.js} +1 -1
- package/dist/bundle/chunks/chunk-ZIVYE5YK.js +2 -0
- package/dist/bundle/chunks/cli-main-RONHLFWZ.js +3 -0
- package/dist/bundle/chunks/google-generative-ai-ZTGKZTGU.js +2 -0
- package/dist/bundle/chunks/google-vertex-CCZ376YK.js +2 -0
- package/dist/bundle/chunks/help-fast-path-5LRG6FCG.js +2 -0
- package/dist/bundle/chunks/host-command-JVPGQR74.js +2 -0
- package/dist/bundle/chunks/host-lifecycle-R4HLXLBM.js +3 -0
- package/dist/bundle/chunks/host-lifecycle.js +4 -4
- package/dist/bundle/chunks/interactive-host-runtime-FES2G62G.js +4 -0
- package/dist/bundle/chunks/interactive-mode-45EP2FVL.js +2 -0
- package/dist/bundle/chunks/{list-tips-EBRNBPBM.js → list-tips-XXMRDHN6.js} +1 -1
- package/dist/bundle/chunks/{multi-session-host-7YX2I7UK.js → multi-session-host-EFCMD5OT.js} +6 -6
- package/dist/bundle/chunks/{openai-completions-4CLXDDHJ.js → openai-completions-OP6VFNUR.js} +1 -1
- package/dist/bundle/chunks/openai-images-6U5FCN5S.js +2 -0
- package/dist/bundle/chunks/openai-responses-7PWMBGYX.js +2 -0
- package/dist/bundle/chunks/openrouter-images-QIKWQZUD.js +2 -0
- package/dist/bundle/chunks/{package-manager-cli-3ISYTEL2.js → package-manager-cli-5XJS3TYM.js} +1 -1
- package/dist/bundle/chunks/rotation-stream-KW7PTEC4.js +2 -0
- package/dist/bundle/chunks/rpc-mode-ZHYECU24.js +2 -0
- package/dist/bundle/chunks/session-picker-QHIYVQP4.js +2 -0
- package/dist/bundle/chunks/session-worker.js +281 -270
- package/dist/bundle/chunks/{state-store-Q5EWEAFG.js → state-store-D4GGGT3J.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/continue-moved.d.ts +15 -0
- package/dist/cli/continue-moved.d.ts.map +1 -0
- package/dist/cli/continue-moved.js +26 -0
- package/dist/cli/continue-moved.js.map +1 -0
- package/dist/cli/cross-project-session.d.ts +22 -0
- package/dist/cli/cross-project-session.d.ts.map +1 -0
- package/dist/cli/cross-project-session.js +38 -0
- package/dist/cli/cross-project-session.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +3 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +43 -10
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +19 -5
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/builtin/anthropic-subscription/session-registry-pump.d.ts.map +1 -1
- package/dist/core/extensions/builtin/anthropic-subscription/session-registry-pump.js +5 -1
- package/dist/core/extensions/builtin/anthropic-subscription/session-registry-pump.js.map +1 -1
- package/dist/core/extensions/builtin/anthropic-subscription/session-turn-claim.d.ts +13 -1
- package/dist/core/extensions/builtin/anthropic-subscription/session-turn-claim.d.ts.map +1 -1
- package/dist/core/extensions/builtin/anthropic-subscription/session-turn-claim.js +25 -2
- package/dist/core/extensions/builtin/anthropic-subscription/session-turn-claim.js.map +1 -1
- package/dist/core/extensions/builtin/anthropic-subscription/session-turn-types.d.ts +1 -0
- package/dist/core/extensions/builtin/anthropic-subscription/session-turn-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/anthropic-subscription/session-turn-types.js.map +1 -1
- package/dist/core/extensions/builtin/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/index.js +2 -0
- package/dist/core/extensions/builtin/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/catalog.d.ts +3 -0
- package/dist/core/extensions/builtin/mcp/catalog.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/catalog.js +9 -0
- package/dist/core/extensions/builtin/mcp/catalog.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection-types.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/connection-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection-types.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection.d.ts +1 -1
- package/dist/core/extensions/builtin/mcp/connection.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection.js +3 -2
- package/dist/core/extensions/builtin/mcp/connection.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.d.ts +3 -0
- package/dist/core/extensions/builtin/mcp/expose/session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.js +9 -2
- package/dist/core/extensions/builtin/mcp/expose/session.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.js +7 -1
- package/dist/core/extensions/builtin/mcp/service-register.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-tools-changed.d.ts +18 -0
- package/dist/core/extensions/builtin/mcp/service-tools-changed.d.ts.map +1 -0
- package/dist/core/extensions/builtin/mcp/service-tools-changed.js +61 -0
- package/dist/core/extensions/builtin/mcp/service-tools-changed.js.map +1 -0
- package/dist/core/extensions/builtin/mcp/service-types.d.ts +13 -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.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js +4 -37
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/shared-lease.js +1 -1
- package/dist/core/extensions/builtin/mcp/shared-lease.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/startup-race.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/startup-race.js +11 -1
- package/dist/core/extensions/builtin/mcp/startup-race.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/index.js +5 -2
- package/dist/core/extensions/builtin/permission-system/index.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.d.ts +5 -0
- package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.js +13 -0
- package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
- package/dist/core/extensions/builtin/repository-identity.d.ts +6 -0
- package/dist/core/extensions/builtin/repository-identity.d.ts.map +1 -0
- package/dist/core/extensions/builtin/repository-identity.js +33 -0
- package/dist/core/extensions/builtin/repository-identity.js.map +1 -0
- package/dist/core/extensions/bun-extension-importer.d.ts.map +1 -1
- package/dist/core/extensions/bun-extension-importer.js +10 -4
- package/dist/core/extensions/bun-extension-importer.js.map +1 -1
- package/dist/core/extensions/bun-extension-registry.js +6 -5
- package/dist/core/extensions/bun-extension-registry.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/kernel-prelude.d.ts +13 -0
- package/dist/core/extensions/kernel-prelude.d.ts.map +1 -0
- package/dist/core/extensions/kernel-prelude.js +38 -0
- package/dist/core/extensions/kernel-prelude.js.map +1 -0
- package/dist/core/extensions/types.d.ts +44 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +4 -2
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/moved-sessions.d.ts +10 -0
- package/dist/core/moved-sessions.d.ts.map +1 -0
- package/dist/core/moved-sessions.js +84 -0
- package/dist/core/moved-sessions.js.map +1 -0
- package/dist/core/process-crash-record.d.ts +62 -0
- package/dist/core/process-crash-record.d.ts.map +1 -0
- package/dist/core/process-crash-record.js +216 -0
- package/dist/core/process-crash-record.js.map +1 -0
- package/dist/core/provider-rejected-images.d.ts +18 -0
- package/dist/core/provider-rejected-images.d.ts.map +1 -0
- package/dist/core/provider-rejected-images.js +107 -0
- package/dist/core/provider-rejected-images.js.map +1 -0
- package/dist/core/repository-identity.d.ts +18 -0
- package/dist/core/repository-identity.d.ts.map +1 -0
- package/dist/core/repository-identity.js +75 -0
- package/dist/core/repository-identity.js.map +1 -0
- package/dist/core/resume-target.d.ts +20 -0
- package/dist/core/resume-target.d.ts.map +1 -0
- package/dist/core/resume-target.js +30 -0
- package/dist/core/resume-target.js.map +1 -0
- package/dist/core/session-discovery.d.ts.map +1 -1
- package/dist/core/session-discovery.js +1 -0
- package/dist/core/session-discovery.js.map +1 -1
- package/dist/core/session-hold-errors.d.ts +20 -0
- package/dist/core/session-hold-errors.d.ts.map +1 -0
- package/dist/core/session-hold-errors.js +28 -0
- package/dist/core/session-hold-errors.js.map +1 -0
- package/dist/core/session-holders.d.ts +22 -0
- package/dist/core/session-holders.d.ts.map +1 -0
- package/dist/core/session-holders.js +234 -0
- package/dist/core/session-holders.js.map +1 -0
- package/dist/core/session-manager.d.ts +5 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-rebind.d.ts +23 -0
- package/dist/core/session-rebind.d.ts.map +1 -0
- package/dist/core/session-rebind.js +127 -0
- package/dist/core/session-rebind.js.map +1 -0
- package/dist/core/session-summary-index-file.d.ts.map +1 -1
- package/dist/core/session-summary-index-file.js +5 -2
- package/dist/core/session-summary-index-file.js.map +1 -1
- package/dist/core/session-summary.d.ts +3 -0
- package/dist/core/session-summary.d.ts.map +1 -1
- package/dist/core/session-summary.js +7 -0
- package/dist/core/session-summary.js.map +1 -1
- package/dist/core/session-title-generator.d.ts.map +1 -1
- package/dist/core/session-title-generator.js +21 -3
- package/dist/core/session-title-generator.js.map +1 -1
- package/dist/core/session-title-reasoning.d.ts +14 -0
- package/dist/core/session-title-reasoning.d.ts.map +1 -0
- package/dist/core/session-title-reasoning.js +31 -0
- package/dist/core/session-title-reasoning.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +13 -0
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy-dir-copy.d.ts +9 -0
- package/dist/legacy-dir-copy.d.ts.map +1 -0
- package/dist/legacy-dir-copy.js +69 -0
- package/dist/legacy-dir-copy.js.map +1 -0
- package/dist/legacy-senpi-dir-migration.d.ts.map +1 -1
- package/dist/legacy-senpi-dir-migration.js +64 -48
- package/dist/legacy-senpi-dir-migration.js.map +1 -1
- package/dist/main.d.ts +6 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +129 -22
- package/dist/main.js.map +1 -1
- package/dist/migrations-state.d.ts +1 -1
- package/dist/migrations-state.d.ts.map +1 -1
- package/dist/migrations-state.js +5 -1
- package/dist/migrations-state.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/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +5 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +10 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/resume-rebind.d.ts +12 -0
- package/dist/modes/interactive/resume-rebind.d.ts.map +1 -0
- package/dist/modes/interactive/resume-rebind.js +37 -0
- package/dist/modes/interactive/resume-rebind.js.map +1 -0
- package/dist/modes/interactive/runtime-notice-presenter.d.ts +8 -0
- package/dist/modes/interactive/runtime-notice-presenter.d.ts.map +1 -0
- package/dist/modes/interactive/runtime-notice-presenter.js +69 -0
- package/dist/modes/interactive/runtime-notice-presenter.js.map +1 -0
- package/dist/modes/interactive/runtime-notice.d.ts +50 -0
- package/dist/modes/interactive/runtime-notice.d.ts.map +1 -0
- package/dist/modes/interactive/runtime-notice.js +104 -0
- package/dist/modes/interactive/runtime-notice.js.map +1 -0
- package/dist/modes/interactive/tips/catalog/computer-tips.d.ts +7 -0
- package/dist/modes/interactive/tips/catalog/computer-tips.d.ts.map +1 -0
- package/dist/modes/interactive/tips/catalog/computer-tips.js +36 -0
- package/dist/modes/interactive/tips/catalog/computer-tips.js.map +1 -0
- package/dist/modes/interactive/tips/registry.d.ts.map +1 -1
- package/dist/modes/interactive/tips/registry.js +2 -0
- package/dist/modes/interactive/tips/registry.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +3 -0
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/host-child-exit.d.ts.map +1 -1
- package/dist/modes/rpc/host-child-exit.js +4 -0
- package/dist/modes/rpc/host-child-exit.js.map +1 -1
- package/dist/modes/rpc/host-crash-record.d.ts +8 -0
- package/dist/modes/rpc/host-crash-record.d.ts.map +1 -1
- package/dist/modes/rpc/host-crash-record.js.map +1 -1
- package/dist/modes/rpc/host-crash-record.test.js +11 -0
- package/dist/modes/rpc/host-crash-record.test.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +2 -2
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +14 -6
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-request-deadline.d.ts +17 -0
- package/dist/modes/rpc/rpc-request-deadline.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-request-deadline.js +27 -0
- package/dist/modes/rpc/rpc-request-deadline.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +9 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/rpc/session-command-router.d.ts +3 -6
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +9 -22
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-path-key.d.ts +10 -0
- package/dist/modes/rpc/session-path-key.d.ts.map +1 -0
- package/dist/modes/rpc/session-path-key.js +33 -0
- package/dist/modes/rpc/session-path-key.js.map +1 -0
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +6 -10
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/dist/modes/rpc/session-sweep.d.ts +18 -0
- package/dist/modes/rpc/session-sweep.d.ts.map +1 -0
- package/dist/modes/rpc/session-sweep.js +32 -0
- package/dist/modes/rpc/session-sweep.js.map +1 -0
- package/dist/pi-dir-restore.d.ts +4 -0
- package/dist/pi-dir-restore.d.ts.map +1 -0
- package/dist/pi-dir-restore.js +92 -0
- package/dist/pi-dir-restore.js.map +1 -0
- package/docs/environment-variables.md +2 -0
- package/docs/extensions.md +27 -1
- package/docs/quickstart.md +7 -1
- package/docs/rpc.md +8 -3
- package/docs/sdk.md +29 -0
- package/docs/sessions.md +13 -0
- package/docs/usage.md +1 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +38 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +7 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridge/protocol.ts +9 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridges/schema-bridge.ts +2 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/kernel-preludes.ts +30 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +15 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/context-manager.ts +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/local-module-loader.ts +16 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel.ts +6 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +15 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/transport.ts +7 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/kernel-prelude-plan.ts +19 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt-template.ts +2 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +4 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +11 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +1 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/run-eval-cell.ts +1 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +3 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +2 -2
- 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 +7 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js +3 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +3 -1
- 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 +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +10 -7
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.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 +9 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.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/provider-diagnostic.d.ts +33 -0
- package/node_modules/@earendil-works/pi-ai/dist/provider-diagnostic.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/provider-diagnostic.js +56 -0
- package/node_modules/@earendil-works/pi-ai/dist/provider-diagnostic.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.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/types.d.ts +3 -0
- 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/provider-diagnostic-carrier.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-carrier.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-carrier.js +18 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-carrier.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-sources.d.ts +26 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-sources.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-sources.js +103 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-sources.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-vocabulary.d.ts +36 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-vocabulary.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-vocabulary.js +129 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-vocabulary.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +5 -4
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/native/prebuilds/darwin-arm64/senpi_pty.darwin-arm64.node +0 -0
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
- package/dist/bundle/chunks/anthropic-messages-UYDVRFAS.js +0 -8
- package/dist/bundle/chunks/azure-openai-responses-DODWR4W6.js +0 -2
- package/dist/bundle/chunks/bun-extension-importer-H4IJCWWQ.js +0 -14
- package/dist/bundle/chunks/chunk-34HMVB33.js +0 -2
- package/dist/bundle/chunks/chunk-3WBSBDBX.js +0 -13
- package/dist/bundle/chunks/chunk-L6JO4M6J.js +0 -3
- package/dist/bundle/chunks/chunk-SFYHCFRO.js +0 -2
- package/dist/bundle/chunks/chunk-T3JBT2IK.js +0 -8
- package/dist/bundle/chunks/chunk-TTHMOL5G.js +0 -2
- package/dist/bundle/chunks/chunk-UYCGOK6M.js +0 -2
- package/dist/bundle/chunks/chunk-ZTVQY5V6.js +0 -2
- package/dist/bundle/chunks/cli-main-H6JAXAXV.js +0 -3
- package/dist/bundle/chunks/google-generative-ai-VIEFECKJ.js +0 -2
- package/dist/bundle/chunks/google-vertex-Q64CKFID.js +0 -2
- package/dist/bundle/chunks/help-fast-path-ZGKPSDFO.js +0 -2
- package/dist/bundle/chunks/host-command-BMHJ4YUD.js +0 -2
- package/dist/bundle/chunks/host-lifecycle-2GZAGSGW.js +0 -3
- package/dist/bundle/chunks/interactive-host-runtime-YI75GFD5.js +0 -4
- package/dist/bundle/chunks/interactive-mode-HM7UQYRC.js +0 -2
- package/dist/bundle/chunks/openai-images-JA5N5DUU.js +0 -2
- package/dist/bundle/chunks/openai-responses-IBFGBAJP.js +0 -2
- package/dist/bundle/chunks/openrouter-images-MW5TXV7L.js +0 -2
- package/dist/bundle/chunks/rotation-stream-NATO6IMN.js +0 -2
- package/dist/bundle/chunks/rpc-mode-6PY4TN5F.js +0 -2
- package/dist/bundle/chunks/session-picker-BP7THCWF.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/connection.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iCAAiC,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAElB,oBAAoB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA0B,SAAS,EAAE,MAAM,WAAW,CAAC;AAS9D,MAAM,OAAO,gBAAgB;IAEnB,OAAO,CAAY;IACnB,IAAI,CAAiD;IACrD,OAAO,CAAoC;IAC3C,aAAa,CAA+B;IAC5C,sBAAsB,CAAmD;IAClF,MAAM,CAAwB;IAC9B,WAAW,GAAG,CAAC,CAAC;IAChB,WAAW,CAAqC;IAChD,kBAAkB,CAAqC;IACvD,eAAe,CAA8B;IAC7C,UAAU,CAAoB;IACrB,eAAe,GAAG,IAAI,GAAG,EAA+D,CAAC;IACzF,eAAe,GAAG,IAAI,GAAG,EAA+D,CAAC;IACzF,oBAAoB,GAAG,IAAI,GAAG,EAAyC,CAAC;IAEjF,YAAY,OAAgC;QAC3C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;QACxB,IAAI,CAAC,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;IACJ,CAAC;IAED,KAAK,CAAS,SAAgD,EAAE,KAAa;QAC5E,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YAClC,KAAK,SAAS,CAAC,kBAAkB,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;QACjE,CAAC;IACF,CAAC;IAED,YAAY,CAAC,KAA4B,EAAE,KAAwB;QAClE,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,aAAa,CAAC,OAAe,EAAE,KAAa,EAAE,SAAgB,EAAE,KAAe;QAC9E,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,IAAI,KAAK;QACR,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;CACD","sourcesContent":["import type { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport type { McpOAuthProvider } from \"./auth/oauth-provider.ts\";\nimport type {\n\tServerConnectionListener,\n\tServerConnectionOptions,\n\tServerConnectionState,\n\tServerConnectionStateChangedEvent,\n\tServerConnectionToolsChangedEvent,\n} from \"./connection-types.ts\";\nimport { diagnoseCapturedMcpConnectFailure, diagnoseMcpConnectFailure } from \"./diagnose.ts\";\nimport { ConnectError } from \"./errors.ts\";\nimport type { McpLogger } from \"./log.ts\";\nimport { subscribeMcpServerLogging } from \"./logging.ts\";\nimport { isMcpNeedsAuthError } from \"./needs-auth.ts\";\nimport { subscribeMcpListChanged } from \"./notifications.ts\";\nimport { subscribeMcpResourceUpdated } from \"./resources.ts\";\nimport {\n\tconnectMcpTransport,\n\tcreateMcpTransport,\n\ttype McpTransportConnection,\n\tshutdownMcpTransport,\n} from \"./transport.ts\";\nimport { type McpAsyncErrorSink, wrapAsync } from \"./wrap.ts\";\n\nexport type {\n\tServerConnectionOptions,\n\tServerConnectionState,\n\tServerConnectionStateChangedEvent,\n\tServerConnectionToolsChangedEvent,\n} from \"./connection-types.ts\";\n\nexport class ServerConnection {\n\treadonly serverName: string;\n\treadonly #logger: McpLogger;\n\treadonly #env: Record<string, string | undefined> | undefined;\n\treadonly #config: ServerConnectionOptions[\"config\"];\n\treadonly #authProvider: McpOAuthProvider | undefined;\n\treadonly #elicitationUiProvider: ServerConnectionOptions[\"elicitationUiProvider\"];\n\t#state: ServerConnectionState;\n\t#generation = 0;\n\t#connection: McpTransportConnection | undefined;\n\t#pendingConnection: McpTransportConnection | undefined;\n\t#pendingConnect: Promise<Client> | undefined;\n\t#lastError: Error | undefined;\n\treadonly #stateListeners = new Set<ServerConnectionListener<ServerConnectionStateChangedEvent>>();\n\treadonly #toolsListeners = new Set<ServerConnectionListener<ServerConnectionToolsChangedEvent>>();\n\treadonly #shutdownConnections = new Map<McpTransportConnection, Promise<void>>();\n\n\tconstructor(options: ServerConnectionOptions) {\n\t\tthis.serverName = options.serverName;\n\t\tthis.#config = options.config;\n\t\tthis.#logger = options.logger;\n\t\tthis.#env = options.env;\n\t\tthis.#authProvider = options.authProvider;\n\t\tthis.#elicitationUiProvider = options.elicitationUiProvider;\n\t\tthis.#state = options.config.enabled ? \"idle\" : \"disabled\";\n\t}\n\n\tget state(): ServerConnectionState {\n\t\treturn this.#state;\n\t}\n\tget lastError(): Error | undefined {\n\t\treturn this.#lastError;\n\t}\n\tget generation(): number {\n\t\treturn this.#generation;\n\t}\n\n\trefreshCapturedDiagnostics(): void {\n\t\tconst current = this.#lastError;\n\t\tif (current === undefined) return;\n\t\tconst capturedError = diagnoseCapturedMcpConnectFailure({\n\t\t\tconfig: this.#config,\n\t\t\tcause: current,\n\t\t\tenv: this.#env,\n\t\t\tlogger: this.#logger,\n\t\t\tserverName: this.serverName,\n\t\t});\n\t\tif (capturedError !== null && capturedError.message !== current.message) {\n\t\t\tthis.#lastError = capturedError;\n\t\t}\n\t}\n\n\tget client(): Client {\n\t\tif (this.#connection === undefined) {\n\t\t\tthrow new ConnectError(`MCP server ${this.serverName} is not connected`, {\n\t\t\t\tphase: \"client\",\n\t\t\t\tserverName: this.serverName,\n\t\t\t});\n\t\t}\n\t\treturn this.#connection.client;\n\t}\n\n\tgetRootPid(): number | null {\n\t\treturn this.#connection?.getRootPid() ?? null;\n\t}\n\tconnect(): Promise<Client> {\n\t\tif (this.#state === \"disabled\") {\n\t\t\treturn Promise.reject(this.#connectError(`MCP server ${this.serverName} is disabled`, \"connect\"));\n\t\t}\n\t\tif (this.#state === \"connected\") return Promise.resolve(this.client);\n\t\tif (this.#pendingConnect) return this.#pendingConnect;\n\n\t\tconst generation = this.#generation;\n\t\tthis.#pendingConnect = this.#openConnection(generation).finally(() => {\n\t\t\tif (this.#pendingConnect !== undefined && generation === this.#generation) this.#pendingConnect = undefined;\n\t\t});\n\t\treturn this.#pendingConnect;\n\t}\n\n\t// Building the transport is async (the MCP SDK loads on first use), so the\n\t// single-flight promise is published before it resolves; \"connecting\" is\n\t// entered only once the transport exists and this generation still owns it.\n\tasync #openConnection(generation: number): Promise<Client> {\n\t\tconst connection = await this.#createTransportConnection(generation);\n\t\tthis.#pendingConnection = connection;\n\t\tif (generation === this.#generation && this.#state !== \"disabled\") this.#setState(\"connecting\");\n\t\ttry {\n\t\t\treturn await this.#connectTransport(connection, generation);\n\t\t} finally {\n\t\t\tif (this.#pendingConnection === connection) this.#pendingConnection = undefined;\n\t\t}\n\t}\n\n\tasync renew(): Promise<Client> {\n\t\tif (this.#state === \"disabled\") {\n\t\t\tthrow this.#connectError(`MCP server ${this.serverName} is disabled`, \"renew\");\n\t\t}\n\t\tthis.#generation++;\n\t\tthis.#pendingConnect = undefined;\n\t\tthis.#setState(\"idle\");\n\t\tawait this.#disposeOwnedConnections();\n\t\treturn this.connect();\n\t}\n\n\tbumpGeneration(): Promise<void> {\n\t\tthis.#generation++;\n\t\tthis.#pendingConnect = undefined;\n\t\tthis.#lastError = undefined;\n\t\tif (this.#state !== \"disabled\") this.#setState(\"idle\");\n\t\treturn this.#disposeOwnedConnections();\n\t}\n\n\tdisable(): Promise<void> {\n\t\tthis.#generation++;\n\t\tthis.#pendingConnect = undefined;\n\t\tthis.#lastError = undefined;\n\t\tthis.#setState(\"disabled\");\n\t\treturn this.#disposeOwnedConnections();\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tthis.#generation++;\n\t\tthis.#pendingConnect = undefined;\n\t\tthis.#setState(\"disabled\");\n\t\tawait this.#disposeOwnedConnections();\n\t}\n\n\tmarkDegraded(error: Error): void {\n\t\tthis.#markFailure(\"degraded\", error);\n\t}\n\tmarkSuspended(error?: Error): void {\n\t\tthis.#markFailure(\"suspended\", error);\n\t}\n\tmarkNeedsAuth(error?: Error): void {\n\t\tthis.#markFailure(\"needs_auth\", error);\n\t}\n\tmarkNeedsClientRegistration(error?: Error): void {\n\t\tthis.#markFailure(\"needs_client_registration\", error);\n\t}\n\n\tmarkToolsChanged(): void {\n\t\tthis.#emit(this.#toolsListeners, {\n\t\t\ttype: \"tools_changed\",\n\t\t\tserverName: this.serverName,\n\t\t\tgeneration: this.#generation,\n\t\t});\n\t}\n\n\tonStateChange(listener: ServerConnectionListener<ServerConnectionStateChangedEvent>): () => void {\n\t\tthis.#stateListeners.add(listener);\n\t\treturn () => this.#stateListeners.delete(listener);\n\t}\n\n\tonToolsChanged(listener: ServerConnectionListener<ServerConnectionToolsChangedEvent>): () => void {\n\t\tthis.#toolsListeners.add(listener);\n\t\treturn () => this.#toolsListeners.delete(listener);\n\t}\n\n\tasync #createTransportConnection(generation: number): Promise<McpTransportConnection> {\n\t\tconst connection = createMcpTransport({\n\t\t\tauthProvider: this.#authProvider,\n\t\t\tconfig: this.#config,\n\t\t\tenv: this.#env,\n\t\t\telicitationUiProvider: this.#elicitationUiProvider,\n\t\t\tlogger: this.#logger,\n\t\t\tserverName: this.serverName,\n\t\t});\n\t\tawait connection.materialize();\n\t\tconnection.transport.onclose = wrapAsync(\n\t\t\t\"connection.transport.onclose\",\n\t\t\t() => {\n\t\t\t\tif (this.#shutdownConnections.has(connection)) return;\n\t\t\t\tif (connection === this.#pendingConnection && this.#state === \"connecting\") {\n\t\t\t\t\tconst closeError = this.#connectError(`MCP server ${this.serverName} transport closed`, \"close\", true);\n\t\t\t\t\tconst capturedError = diagnoseCapturedMcpConnectFailure({\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tcause: closeError,\n\t\t\t\t\t\tenv: this.#env,\n\t\t\t\t\t\tlogger: this.#logger,\n\t\t\t\t\t\tserverName: this.serverName,\n\t\t\t\t\t});\n\t\t\t\t\tif (capturedError !== null) this.markDegraded(capturedError);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (connection !== this.#connection && connection !== this.#pendingConnection) return;\n\t\t\t\tif (generation === this.#generation && this.#state !== \"disabled\") {\n\t\t\t\t\tthis.markDegraded(this.#connectError(`MCP server ${this.serverName} transport closed`, \"close\", true));\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.#sink,\n\t\t);\n\t\treturn connection;\n\t}\n\n\tasync #connectTransport(connection: McpTransportConnection, generation: number): Promise<Client> {\n\t\ttry {\n\t\t\tawait connectMcpTransport(connection);\n\t\t} catch (error) {\n\t\t\tif (this.#pendingConnection === connection) this.#pendingConnection = undefined;\n\t\t\tawait this.#shutdown(connection);\n\t\t\tif (generation !== this.#generation || this.#state === \"disabled\") {\n\t\t\t\tthrow this.#connectError(`MCP server ${this.serverName} connect was superseded`, \"connect\", true);\n\t\t\t}\n\t\t\tif (isMcpNeedsAuthError(error)) {\n\t\t\t\tconst authError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tthis.markNeedsAuth(authError);\n\t\t\t\tthrow authError;\n\t\t\t}\n\t\t\tconst connectError = await diagnoseMcpConnectFailure({\n\t\t\t\tconfig: this.#config,\n\t\t\t\tcause: error instanceof Error ? error : new Error(String(error)),\n\t\t\t\tenv: this.#env,\n\t\t\t\tlogger: this.#logger,\n\t\t\t\tserverName: this.serverName,\n\t\t\t});\n\t\t\tthis.markDegraded(connectError);\n\t\t\tthrow connectError;\n\t\t}\n\t\tif (generation !== this.#generation || this.#state === \"disabled\") {\n\t\t\tawait this.#shutdown(connection);\n\t\t\tthrow this.#connectError(`MCP server ${this.serverName} connect was superseded`, \"connect\", true);\n\t\t}\n\t\tif (this.#pendingConnection === connection) this.#pendingConnection = undefined;\n\t\tthis.#connection = connection;\n\t\tthis.#lastError = undefined;\n\t\t// Subscribe to list_changed on the fresh client (even if the server never\n\t\t// declared the capability) so dynamic catalog updates reach the service.\n\t\tsubscribeMcpListChanged(connection.client, () => this.markToolsChanged());\n\t\t// Resource updates ride the same refresh path: the service re-collects the\n\t\t// catalog (tools AND resources) on tools-changed.\n\t\tsubscribeMcpResourceUpdated(connection.client, () => this.markToolsChanged());\n\t\t// Server logging notifications (todo 42): RFC-5424 → the per-server\n\t\t// logger, filtered by config.logLevel, burst-capped.\n\t\tsubscribeMcpServerLogging(connection.client, { logLevel: this.#config.logLevel, logger: this.#logger });\n\t\tthis.#setState(\"connected\");\n\t\tthis.markToolsChanged();\n\t\treturn connection.client;\n\t}\n\n\tasync #disposeOwnedConnections(): Promise<void> {\n\t\tconst connections = new Set<McpTransportConnection>();\n\t\tconst connection = this.#connection;\n\t\tthis.#connection = undefined;\n\t\tif (connection !== undefined) connections.add(connection);\n\t\tconst pendingConnection = this.#pendingConnection;\n\t\tthis.#pendingConnection = undefined;\n\t\tif (pendingConnection !== undefined) connections.add(pendingConnection);\n\t\tawait Promise.all([...connections].map((item) => this.#shutdown(item)));\n\t}\n\n\tasync #shutdown(connection: McpTransportConnection): Promise<void> {\n\t\tconst pending = this.#shutdownConnections.get(connection);\n\t\tif (pending !== undefined) {\n\t\t\tawait pending;\n\t\t\treturn;\n\t\t}\n\t\tconst shutdown = (async () => {\n\t\t\tawait shutdownMcpTransport(connection);\n\t\t})();\n\t\tthis.#shutdownConnections.set(connection, shutdown);\n\t\ttry {\n\t\t\tawait shutdown;\n\t\t} finally {\n\t\t\tthis.#shutdownConnections.delete(connection);\n\t\t}\n\t}\n\n\t#setState(state: ServerConnectionState, error?: Error): void {\n\t\tif (this.#state === state) return;\n\t\tconst previousState = this.#state;\n\t\tthis.#state = state;\n\t\tthis.#emit(this.#stateListeners, {\n\t\t\ttype: \"state_changed\",\n\t\t\tserverName: this.serverName,\n\t\t\tpreviousState,\n\t\t\tstate,\n\t\t\tgeneration: this.#generation,\n\t\t\terror,\n\t\t});\n\t}\n\n\t#emit<TEvent>(listeners: Set<ServerConnectionListener<TEvent>>, event: TEvent): void {\n\t\tfor (const listener of listeners) {\n\t\t\tvoid wrapAsync(\"connection.event\", listener, this.#sink)(event);\n\t\t}\n\t}\n\n\t#markFailure(state: ServerConnectionState, error: Error | undefined): void {\n\t\tthis.#lastError = error;\n\t\tthis.#setState(state, error);\n\t}\n\n\t#connectError(message: string, phase: string, retriable?: true, cause?: unknown): ConnectError {\n\t\treturn new ConnectError(message, { cause, phase, retriable, serverName: this.serverName });\n\t}\n\n\tget #sink(): McpAsyncErrorSink {\n\t\treturn { logger: this.#logger };\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/connection.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iCAAiC,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EACN,mBAAmB,EACnB,kBAA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C9E,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,IAAI,KAAK;QACR,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;CACD","sourcesContent":["import type { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport type { McpOAuthProvider } from \"./auth/oauth-provider.ts\";\nimport type {\n\tServerConnectionListener,\n\tServerConnectionOptions,\n\tServerConnectionState,\n\tServerConnectionStateChangedEvent,\n\tServerConnectionToolsChangedEvent,\n} from \"./connection-types.ts\";\nimport { diagnoseCapturedMcpConnectFailure, diagnoseMcpConnectFailure } from \"./diagnose.ts\";\nimport { ConnectError } from \"./errors.ts\";\nimport type { McpLogger } from \"./log.ts\";\nimport { subscribeMcpServerLogging } from \"./logging.ts\";\nimport { isMcpNeedsAuthError } from \"./needs-auth.ts\";\nimport { subscribeMcpListChanged } from \"./notifications.ts\";\nimport { subscribeMcpResourceUpdated } from \"./resources.ts\";\nimport {\n\tconnectMcpTransport,\n\tcreateMcpTransport,\n\ttype McpTransportConnection,\n\tshutdownMcpTransport,\n} from \"./transport.ts\";\nimport { type McpAsyncErrorSink, wrapAsync } from \"./wrap.ts\";\n\nexport type {\n\tServerConnectionOptions,\n\tServerConnectionState,\n\tServerConnectionStateChangedEvent,\n\tServerConnectionToolsChangedEvent,\n} from \"./connection-types.ts\";\n\nexport class ServerConnection {\n\treadonly serverName: string;\n\treadonly #logger: McpLogger;\n\treadonly #env: Record<string, string | undefined> | undefined;\n\treadonly #config: ServerConnectionOptions[\"config\"];\n\treadonly #authProvider: McpOAuthProvider | undefined;\n\treadonly #elicitationUiProvider: ServerConnectionOptions[\"elicitationUiProvider\"];\n\t#state: ServerConnectionState;\n\t#generation = 0;\n\t#connection: McpTransportConnection | undefined;\n\t#pendingConnection: McpTransportConnection | undefined;\n\t#pendingConnect: Promise<Client> | undefined;\n\t#lastError: Error | undefined;\n\treadonly #stateListeners = new Set<ServerConnectionListener<ServerConnectionStateChangedEvent>>();\n\treadonly #toolsListeners = new Set<ServerConnectionListener<ServerConnectionToolsChangedEvent>>();\n\treadonly #shutdownConnections = new Map<McpTransportConnection, Promise<void>>();\n\n\tconstructor(options: ServerConnectionOptions) {\n\t\tthis.serverName = options.serverName;\n\t\tthis.#config = options.config;\n\t\tthis.#logger = options.logger;\n\t\tthis.#env = options.env;\n\t\tthis.#authProvider = options.authProvider;\n\t\tthis.#elicitationUiProvider = options.elicitationUiProvider;\n\t\tthis.#state = options.config.enabled ? \"idle\" : \"disabled\";\n\t}\n\n\tget state(): ServerConnectionState {\n\t\treturn this.#state;\n\t}\n\tget lastError(): Error | undefined {\n\t\treturn this.#lastError;\n\t}\n\tget generation(): number {\n\t\treturn this.#generation;\n\t}\n\n\trefreshCapturedDiagnostics(): void {\n\t\tconst current = this.#lastError;\n\t\tif (current === undefined) return;\n\t\tconst capturedError = diagnoseCapturedMcpConnectFailure({\n\t\t\tconfig: this.#config,\n\t\t\tcause: current,\n\t\t\tenv: this.#env,\n\t\t\tlogger: this.#logger,\n\t\t\tserverName: this.serverName,\n\t\t});\n\t\tif (capturedError !== null && capturedError.message !== current.message) {\n\t\t\tthis.#lastError = capturedError;\n\t\t}\n\t}\n\n\tget client(): Client {\n\t\tif (this.#connection === undefined) {\n\t\t\tthrow new ConnectError(`MCP server ${this.serverName} is not connected`, {\n\t\t\t\tphase: \"client\",\n\t\t\t\tserverName: this.serverName,\n\t\t\t});\n\t\t}\n\t\treturn this.#connection.client;\n\t}\n\n\tgetRootPid(): number | null {\n\t\treturn this.#connection?.getRootPid() ?? null;\n\t}\n\tconnect(): Promise<Client> {\n\t\tif (this.#state === \"disabled\") {\n\t\t\treturn Promise.reject(this.#connectError(`MCP server ${this.serverName} is disabled`, \"connect\"));\n\t\t}\n\t\tif (this.#state === \"connected\") return Promise.resolve(this.client);\n\t\tif (this.#pendingConnect) return this.#pendingConnect;\n\n\t\tconst generation = this.#generation;\n\t\tthis.#pendingConnect = this.#openConnection(generation).finally(() => {\n\t\t\tif (this.#pendingConnect !== undefined && generation === this.#generation) this.#pendingConnect = undefined;\n\t\t});\n\t\treturn this.#pendingConnect;\n\t}\n\n\t// Building the transport is async (the MCP SDK loads on first use), so the\n\t// single-flight promise is published before it resolves; \"connecting\" is\n\t// entered only once the transport exists and this generation still owns it.\n\tasync #openConnection(generation: number): Promise<Client> {\n\t\tconst connection = await this.#createTransportConnection(generation);\n\t\tthis.#pendingConnection = connection;\n\t\tif (generation === this.#generation && this.#state !== \"disabled\") this.#setState(\"connecting\");\n\t\ttry {\n\t\t\treturn await this.#connectTransport(connection, generation);\n\t\t} finally {\n\t\t\tif (this.#pendingConnection === connection) this.#pendingConnection = undefined;\n\t\t}\n\t}\n\n\tasync renew(): Promise<Client> {\n\t\tif (this.#state === \"disabled\") {\n\t\t\tthrow this.#connectError(`MCP server ${this.serverName} is disabled`, \"renew\");\n\t\t}\n\t\tthis.#generation++;\n\t\tthis.#pendingConnect = undefined;\n\t\tthis.#setState(\"idle\");\n\t\tawait this.#disposeOwnedConnections();\n\t\treturn this.connect();\n\t}\n\n\tbumpGeneration(): Promise<void> {\n\t\tthis.#generation++;\n\t\tthis.#pendingConnect = undefined;\n\t\tthis.#lastError = undefined;\n\t\tif (this.#state !== \"disabled\") this.#setState(\"idle\");\n\t\treturn this.#disposeOwnedConnections();\n\t}\n\n\tdisable(): Promise<void> {\n\t\tthis.#generation++;\n\t\tthis.#pendingConnect = undefined;\n\t\tthis.#lastError = undefined;\n\t\tthis.#setState(\"disabled\");\n\t\treturn this.#disposeOwnedConnections();\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tthis.#generation++;\n\t\tthis.#pendingConnect = undefined;\n\t\tthis.#setState(\"disabled\");\n\t\tawait this.#disposeOwnedConnections();\n\t}\n\n\tmarkDegraded(error: Error): void {\n\t\tthis.#markFailure(\"degraded\", error);\n\t}\n\tmarkSuspended(error?: Error): void {\n\t\tthis.#markFailure(\"suspended\", error);\n\t}\n\tmarkNeedsAuth(error?: Error): void {\n\t\tthis.#markFailure(\"needs_auth\", error);\n\t}\n\tmarkNeedsClientRegistration(error?: Error): void {\n\t\tthis.#markFailure(\"needs_client_registration\", error);\n\t}\n\n\tmarkToolsChanged(cause: ServerConnectionToolsChangedEvent[\"cause\"] = \"notification\"): void {\n\t\tthis.#emit(this.#toolsListeners, {\n\t\t\ttype: \"tools_changed\",\n\t\t\tserverName: this.serverName,\n\t\t\tgeneration: this.#generation,\n\t\t\tcause,\n\t\t});\n\t}\n\n\tonStateChange(listener: ServerConnectionListener<ServerConnectionStateChangedEvent>): () => void {\n\t\tthis.#stateListeners.add(listener);\n\t\treturn () => this.#stateListeners.delete(listener);\n\t}\n\n\tonToolsChanged(listener: ServerConnectionListener<ServerConnectionToolsChangedEvent>): () => void {\n\t\tthis.#toolsListeners.add(listener);\n\t\treturn () => this.#toolsListeners.delete(listener);\n\t}\n\n\tasync #createTransportConnection(generation: number): Promise<McpTransportConnection> {\n\t\tconst connection = createMcpTransport({\n\t\t\tauthProvider: this.#authProvider,\n\t\t\tconfig: this.#config,\n\t\t\tenv: this.#env,\n\t\t\telicitationUiProvider: this.#elicitationUiProvider,\n\t\t\tlogger: this.#logger,\n\t\t\tserverName: this.serverName,\n\t\t});\n\t\tawait connection.materialize();\n\t\tconnection.transport.onclose = wrapAsync(\n\t\t\t\"connection.transport.onclose\",\n\t\t\t() => {\n\t\t\t\tif (this.#shutdownConnections.has(connection)) return;\n\t\t\t\tif (connection === this.#pendingConnection && this.#state === \"connecting\") {\n\t\t\t\t\tconst closeError = this.#connectError(`MCP server ${this.serverName} transport closed`, \"close\", true);\n\t\t\t\t\tconst capturedError = diagnoseCapturedMcpConnectFailure({\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tcause: closeError,\n\t\t\t\t\t\tenv: this.#env,\n\t\t\t\t\t\tlogger: this.#logger,\n\t\t\t\t\t\tserverName: this.serverName,\n\t\t\t\t\t});\n\t\t\t\t\tif (capturedError !== null) this.markDegraded(capturedError);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (connection !== this.#connection && connection !== this.#pendingConnection) return;\n\t\t\t\tif (generation === this.#generation && this.#state !== \"disabled\") {\n\t\t\t\t\tthis.markDegraded(this.#connectError(`MCP server ${this.serverName} transport closed`, \"close\", true));\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.#sink,\n\t\t);\n\t\treturn connection;\n\t}\n\n\tasync #connectTransport(connection: McpTransportConnection, generation: number): Promise<Client> {\n\t\ttry {\n\t\t\tawait connectMcpTransport(connection);\n\t\t} catch (error) {\n\t\t\tif (this.#pendingConnection === connection) this.#pendingConnection = undefined;\n\t\t\tawait this.#shutdown(connection);\n\t\t\tif (generation !== this.#generation || this.#state === \"disabled\") {\n\t\t\t\tthrow this.#connectError(`MCP server ${this.serverName} connect was superseded`, \"connect\", true);\n\t\t\t}\n\t\t\tif (isMcpNeedsAuthError(error)) {\n\t\t\t\tconst authError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tthis.markNeedsAuth(authError);\n\t\t\t\tthrow authError;\n\t\t\t}\n\t\t\tconst connectError = await diagnoseMcpConnectFailure({\n\t\t\t\tconfig: this.#config,\n\t\t\t\tcause: error instanceof Error ? error : new Error(String(error)),\n\t\t\t\tenv: this.#env,\n\t\t\t\tlogger: this.#logger,\n\t\t\t\tserverName: this.serverName,\n\t\t\t});\n\t\t\tthis.markDegraded(connectError);\n\t\t\tthrow connectError;\n\t\t}\n\t\tif (generation !== this.#generation || this.#state === \"disabled\") {\n\t\t\tawait this.#shutdown(connection);\n\t\t\tthrow this.#connectError(`MCP server ${this.serverName} connect was superseded`, \"connect\", true);\n\t\t}\n\t\tif (this.#pendingConnection === connection) this.#pendingConnection = undefined;\n\t\tthis.#connection = connection;\n\t\tthis.#lastError = undefined;\n\t\t// Subscribe to list_changed on the fresh client (even if the server never\n\t\t// declared the capability) so dynamic catalog updates reach the service.\n\t\tsubscribeMcpListChanged(connection.client, () => this.markToolsChanged());\n\t\t// Resource updates ride the same refresh path: the service re-collects the\n\t\t// catalog (tools AND resources) on tools-changed.\n\t\tsubscribeMcpResourceUpdated(connection.client, () => this.markToolsChanged());\n\t\t// Server logging notifications (todo 42): RFC-5424 → the per-server\n\t\t// logger, filtered by config.logLevel, burst-capped.\n\t\tsubscribeMcpServerLogging(connection.client, { logLevel: this.#config.logLevel, logger: this.#logger });\n\t\tthis.#setState(\"connected\");\n\t\tthis.markToolsChanged(\"connect\");\n\t\treturn connection.client;\n\t}\n\n\tasync #disposeOwnedConnections(): Promise<void> {\n\t\tconst connections = new Set<McpTransportConnection>();\n\t\tconst connection = this.#connection;\n\t\tthis.#connection = undefined;\n\t\tif (connection !== undefined) connections.add(connection);\n\t\tconst pendingConnection = this.#pendingConnection;\n\t\tthis.#pendingConnection = undefined;\n\t\tif (pendingConnection !== undefined) connections.add(pendingConnection);\n\t\tawait Promise.all([...connections].map((item) => this.#shutdown(item)));\n\t}\n\n\tasync #shutdown(connection: McpTransportConnection): Promise<void> {\n\t\tconst pending = this.#shutdownConnections.get(connection);\n\t\tif (pending !== undefined) {\n\t\t\tawait pending;\n\t\t\treturn;\n\t\t}\n\t\tconst shutdown = (async () => {\n\t\t\tawait shutdownMcpTransport(connection);\n\t\t})();\n\t\tthis.#shutdownConnections.set(connection, shutdown);\n\t\ttry {\n\t\t\tawait shutdown;\n\t\t} finally {\n\t\t\tthis.#shutdownConnections.delete(connection);\n\t\t}\n\t}\n\n\t#setState(state: ServerConnectionState, error?: Error): void {\n\t\tif (this.#state === state) return;\n\t\tconst previousState = this.#state;\n\t\tthis.#state = state;\n\t\tthis.#emit(this.#stateListeners, {\n\t\t\ttype: \"state_changed\",\n\t\t\tserverName: this.serverName,\n\t\t\tpreviousState,\n\t\t\tstate,\n\t\t\tgeneration: this.#generation,\n\t\t\terror,\n\t\t});\n\t}\n\n\t#emit<TEvent>(listeners: Set<ServerConnectionListener<TEvent>>, event: TEvent): void {\n\t\tfor (const listener of listeners) {\n\t\t\tvoid wrapAsync(\"connection.event\", listener, this.#sink)(event);\n\t\t}\n\t}\n\n\t#markFailure(state: ServerConnectionState, error: Error | undefined): void {\n\t\tthis.#lastError = error;\n\t\tthis.#setState(state, error);\n\t}\n\n\t#connectError(message: string, phase: string, retriable?: true, cause?: unknown): ConnectError {\n\t\treturn new ConnectError(message, { cause, phase, retriable, serverName: this.serverName });\n\t}\n\n\tget #sink(): McpAsyncErrorSink {\n\t\treturn { logger: this.#logger };\n\t}\n}\n"]}
|
|
@@ -22,6 +22,9 @@ export interface McpDirectRegistrationEntry {
|
|
|
22
22
|
readonly cachedCatalog?: McpCachedServerCatalog;
|
|
23
23
|
readonly ensureFresh?: () => Promise<void>;
|
|
24
24
|
readonly ensureCachedToolConnected?: () => Promise<void>;
|
|
25
|
+
/** A startup connect still owns this server's catalog; its refresh registers it. */
|
|
26
|
+
readonly startupCatalogPending?: boolean;
|
|
27
|
+
readonly onRegistered?: (identity: string) => void;
|
|
25
28
|
}
|
|
26
29
|
export declare function registerDirectMcpTools(pi: Pick<ExtensionAPI, "getActiveTools" | "setActiveTools" | "registerTool">, config: ResolvedMcpConfig, entries: Iterable<McpDirectRegistrationEntry>, toolSearchService: ToolSearchService, options?: McpCatalogRegistrationOptions): Promise<McpSessionRegistration | undefined>;
|
|
27
30
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/m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E,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,oFAAoF;IACpF,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACnD;AAED,wBAAsB,sBAAsB,CAC3C,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,CAAC,EAC5E,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EAC7C,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,6BAAkC,GACzC,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAoF7C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cachedToolsToCatalogEntries, collectToolCatalog } from "../catalog.js";
|
|
1
|
+
import { cachedToolsToCatalogEntries, collectToolCatalog, mcpRegistrationIdentity, } from "../catalog.js";
|
|
2
2
|
import { createMcpLogger } from "../log.js";
|
|
3
3
|
import { createMcpResourceTools } from "../resources.js";
|
|
4
4
|
import { computeMcpExposurePolicy } from "./policy.js";
|
|
@@ -10,12 +10,13 @@ export async function registerDirectMcpTools(pi, config, entries, toolSearchServ
|
|
|
10
10
|
const proxyGateways = [];
|
|
11
11
|
const resourceServers = [];
|
|
12
12
|
const promptServers = [];
|
|
13
|
+
const recordRegisteredListings = [];
|
|
13
14
|
for (const entry of entries) {
|
|
14
15
|
const server = config.servers[entry.name];
|
|
15
16
|
if (server?.config === undefined)
|
|
16
17
|
continue;
|
|
17
18
|
const catalog = entry.cachedCatalog === undefined
|
|
18
|
-
? entry.connection.state === "connected"
|
|
19
|
+
? entry.connection.state === "connected" && entry.startupCatalogPending !== true
|
|
19
20
|
? await collectToolCatalog(entry.name, entry.connection, server.config, {
|
|
20
21
|
agentDir: entry.agentDir,
|
|
21
22
|
artifacts: entry.artifacts,
|
|
@@ -29,6 +30,8 @@ export async function registerDirectMcpTools(pi, config, entries, toolSearchServ
|
|
|
29
30
|
ensureFresh: entry.ensureFresh,
|
|
30
31
|
outputGuard: config.settings.outputGuard,
|
|
31
32
|
});
|
|
33
|
+
const identity = mcpRegistrationIdentity(catalog, entry.cachedCatalog);
|
|
34
|
+
recordRegisteredListings.push(() => entry.onRegistered?.(identity));
|
|
32
35
|
const cachedPrompts = entry.cachedCatalog?.prompts ?? [];
|
|
33
36
|
if (cachedPrompts.length > 0) {
|
|
34
37
|
promptServers.push({
|
|
@@ -66,10 +69,14 @@ export async function registerDirectMcpTools(pi, config, entries, toolSearchServ
|
|
|
66
69
|
!searchMode &&
|
|
67
70
|
proxyGateways.length === 0 &&
|
|
68
71
|
options.refreshActiveSetWhenEmpty !== true) {
|
|
72
|
+
for (const record of recordRegisteredListings)
|
|
73
|
+
record();
|
|
69
74
|
return undefined;
|
|
70
75
|
}
|
|
71
76
|
const utilityTools = resourceServers.length > 0 ? createMcpResourceTools(() => resourceServers) : [];
|
|
72
77
|
const registration = registerMcpTierBTools(pi, { activeEntries, proxyGateways, registeredEntries, searchMode, settings: config.settings, utilityTools }, toolSearchService, (message) => createMcpLogger("service").warn(message));
|
|
78
|
+
for (const record of recordRegisteredListings)
|
|
79
|
+
record();
|
|
73
80
|
return { ...registration, promptServers, resourceServers };
|
|
74
81
|
}
|
|
75
82
|
//# sourceMappingURL=session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/session.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/session.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,2BAA2B,EAC3B,kBAAkB,EAElB,uBAAuB,GACvB,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,eAAe,EAAkB,MAAM,WAAW,CAA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E,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACrG,MAAM,YAAY,GAAG,qBAAqB,CACzC,EAAE,EACF,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,EACxG,iBAAiB,EACjB,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CACrD,CAAC;IACF,KAAK,MAAM,MAAM,IAAI,wBAAwB;QAAE,MAAM,EAAE,CAAC;IACxD,OAAO,EAAE,GAAG,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAC5D,CAAC","sourcesContent":["import type { ExtensionAPI } from \"../../../types.ts\";\nimport type { ToolSearchService } from \"../../tool-search/service.ts\";\nimport {\n\tcachedToolsToCatalogEntries,\n\tcollectToolCatalog,\n\ttype McpToolCatalogEntry,\n\tmcpRegistrationIdentity,\n} from \"../catalog.ts\";\nimport type { McpCachedServerCatalog } from \"../catalog-cache.ts\";\nimport type { ResolvedMcpConfig } from \"../config-schema.ts\";\nimport type { ServerConnection } from \"../connection.ts\";\nimport type { McpOutputArtifacts } from \"../guard/output-guard.ts\";\nimport { createMcpLogger, type McpLogger } from \"../log.ts\";\nimport type { McpPromptServer } from \"../prompts.ts\";\nimport { createMcpResourceTools, type McpResourceServer } from \"../resources.ts\";\nimport { computeMcpExposurePolicy } from \"./policy.ts\";\nimport type { McpCatalogRegistrationOptions } from \"./register.ts\";\nimport { type McpTierBRegistration, registerMcpTierBTools } from \"./tier-b.ts\";\n\nexport type McpSessionRegistration = McpTierBRegistration & {\n\tresourceServers: McpResourceServer[];\n\tpromptServers: McpPromptServer[];\n};\n\nexport interface McpDirectRegistrationEntry {\n\treadonly name: string;\n\treadonly connection: ServerConnection;\n\treadonly logger: McpLogger;\n\treadonly agentDir?: string;\n\treadonly artifacts?: McpOutputArtifacts;\n\treadonly cachedCatalog?: McpCachedServerCatalog;\n\treadonly ensureFresh?: () => Promise<void>;\n\treadonly ensureCachedToolConnected?: () => Promise<void>;\n\t/** A startup connect still owns this server's catalog; its refresh registers it. */\n\treadonly startupCatalogPending?: boolean;\n\treadonly onRegistered?: (identity: string) => void;\n}\n\nexport async function registerDirectMcpTools(\n\tpi: Pick<ExtensionAPI, \"getActiveTools\" | \"setActiveTools\" | \"registerTool\">,\n\tconfig: ResolvedMcpConfig,\n\tentries: Iterable<McpDirectRegistrationEntry>,\n\ttoolSearchService: ToolSearchService,\n\toptions: McpCatalogRegistrationOptions = {},\n): Promise<McpSessionRegistration | undefined> {\n\tconst registeredEntries: McpToolCatalogEntry[] = [];\n\tconst activeEntries: McpToolCatalogEntry[] = [];\n\tlet searchMode = false;\n\tconst proxyGateways: { server: string; entries: McpToolCatalogEntry[] }[] = [];\n\tconst resourceServers: McpResourceServer[] = [];\n\tconst promptServers: McpPromptServer[] = [];\n\tconst recordRegisteredListings: Array<() => void> = [];\n\tfor (const entry of entries) {\n\t\tconst server = config.servers[entry.name];\n\t\tif (server?.config === undefined) continue;\n\t\tconst catalog =\n\t\t\tentry.cachedCatalog === undefined\n\t\t\t\t? entry.connection.state === \"connected\" && entry.startupCatalogPending !== true\n\t\t\t\t\t? await collectToolCatalog(entry.name, entry.connection, server.config, {\n\t\t\t\t\t\t\tagentDir: entry.agentDir,\n\t\t\t\t\t\t\tartifacts: entry.artifacts,\n\t\t\t\t\t\t\tensureFresh: entry.ensureFresh,\n\t\t\t\t\t\t\toutputGuard: config.settings.outputGuard,\n\t\t\t\t\t\t})\n\t\t\t\t\t: []\n\t\t\t\t: cachedToolsToCatalogEntries(\n\t\t\t\t\t\tentry.name,\n\t\t\t\t\t\tentry.cachedCatalog,\n\t\t\t\t\t\tentry.connection,\n\t\t\t\t\t\tserver.config.requestTimeoutMs,\n\t\t\t\t\t\tentry.ensureCachedToolConnected ?? (() => entry.connection.connect().then(() => undefined)),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tagentDir: entry.agentDir,\n\t\t\t\t\t\t\tartifacts: entry.artifacts,\n\t\t\t\t\t\t\tensureFresh: entry.ensureFresh,\n\t\t\t\t\t\t\toutputGuard: config.settings.outputGuard,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\tconst identity = mcpRegistrationIdentity(catalog, entry.cachedCatalog);\n\t\trecordRegisteredListings.push(() => entry.onRegistered?.(identity));\n\t\tconst cachedPrompts = entry.cachedCatalog?.prompts ?? [];\n\t\tif (cachedPrompts.length > 0) {\n\t\t\tpromptServers.push({\n\t\t\t\tconnection: entry.connection,\n\t\t\t\tprompts: cachedPrompts,\n\t\t\t\trequestTimeoutMs: server.config.requestTimeoutMs,\n\t\t\t\tserver: entry.name,\n\t\t\t});\n\t\t}\n\t\tconst cachedResources = entry.cachedCatalog?.resources ?? [];\n\t\tif (cachedResources.length > 0) {\n\t\t\tresourceServers.push({\n\t\t\t\tagentDir: entry.agentDir,\n\t\t\t\tartifacts: entry.artifacts,\n\t\t\t\tconnection: entry.connection,\n\t\t\t\toutputGuard: config.settings.outputGuard,\n\t\t\t\trequestTimeoutMs: server.config.requestTimeoutMs,\n\t\t\t\tresources: cachedResources,\n\t\t\t\tserver: entry.name,\n\t\t\t});\n\t\t}\n\t\tconst policy = computeMcpExposurePolicy(catalog, server.config, config.settings);\n\t\tfor (const warning of policy.warnings) entry.logger.warn(warning);\n\t\tif (policy.mode === \"search\") searchMode = true;\n\t\tif (policy.mode === \"proxy\") proxyGateways.push({ entries: [...policy.filteredEntries], server: entry.name });\n\t\tregisteredEntries.push(...policy.registeredEntries);\n\t\tactiveEntries.push(...policy.activeEntries);\n\t}\n\t// Skip touching the active set only when there is genuinely nothing to do.\n\tif (\n\t\tregisteredEntries.length === 0 &&\n\t\tactiveEntries.length === 0 &&\n\t\t!searchMode &&\n\t\tproxyGateways.length === 0 &&\n\t\toptions.refreshActiveSetWhenEmpty !== true\n\t) {\n\t\tfor (const record of recordRegisteredListings) record();\n\t\treturn undefined;\n\t}\n\tconst utilityTools = resourceServers.length > 0 ? createMcpResourceTools(() => resourceServers) : [];\n\tconst registration = registerMcpTierBTools(\n\t\tpi,\n\t\t{ activeEntries, proxyGateways, registeredEntries, searchMode, settings: config.settings, utilityTools },\n\t\ttoolSearchService,\n\t\t(message) => createMcpLogger(\"service\").warn(message),\n\t);\n\tfor (const record of recordRegisteredListings) record();\n\treturn { ...registration, promptServers, resourceServers };\n}\n"]}
|
|
@@ -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,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,
|
|
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,CA0B7C"}
|
|
@@ -3,10 +3,16 @@ import { connectAndRefreshMcpCatalog } from "./startup-race.js";
|
|
|
3
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
|
+
const claim = entry.startupCatalogClaim;
|
|
7
|
+
const startupCatalogPending = claim?.ownsRegistration() === true;
|
|
6
8
|
return {
|
|
7
9
|
agentDir: entry.agentDir,
|
|
8
10
|
artifacts: entry.artifacts,
|
|
9
|
-
cachedCatalog: entry.cachedCatalog,
|
|
11
|
+
cachedCatalog: startupCatalogPending ? claim?.cachedCatalog : entry.cachedCatalog,
|
|
12
|
+
startupCatalogPending,
|
|
13
|
+
onRegistered: (identity) => {
|
|
14
|
+
entry.registeredIdentity = identity;
|
|
15
|
+
},
|
|
10
16
|
connection: entry.connection,
|
|
11
17
|
ensureFresh: () => entry.authPlan?.refresh?.ensureFresh().then(() => undefined) ?? Promise.resolve(),
|
|
12
18
|
ensureCachedToolConnected: () => connectAndRefreshMcpCatalog(entry, serverConfig),
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,MAAM,KAAK,GAAG,KAAK,CAAC,mBAAmB,CAAC;QACxC,MAAM,qBAAqB,GAAG,KAAK,EAAE,gBAAgB,EAAE,KAAK,IAAI,CAAC;QACjE,OAAO;YACN,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,aAAa,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa;YACjF,qBAAqB;YACrB,YAAY,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC1B,KAAK,CAAC,kBAAkB,GAAG,QAAQ,CAAC;YACrC,CAAC;YACD,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\tconst claim = entry.startupCatalogClaim;\n\t\t\tconst startupCatalogPending = claim?.ownsRegistration() === true;\n\t\t\treturn {\n\t\t\t\tagentDir: entry.agentDir,\n\t\t\t\tartifacts: entry.artifacts,\n\t\t\t\tcachedCatalog: startupCatalogPending ? claim?.cachedCatalog : entry.cachedCatalog,\n\t\t\t\tstartupCatalogPending,\n\t\t\t\tonRegistered: (identity) => {\n\t\t\t\t\tentry.registeredIdentity = identity;\n\t\t\t\t},\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"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "../../types.ts";
|
|
2
|
+
import type { ResolvedMcpConfig } from "./config-schema.ts";
|
|
3
|
+
import type { McpConnectionEntry } from "./service-types.ts";
|
|
4
|
+
import type { McpAsyncErrorSink } from "./wrap.ts";
|
|
5
|
+
type McpToolRegistrar = Pick<ExtensionAPI, "getActiveTools" | "setActiveTools" | "registerTool">;
|
|
6
|
+
/** Coalesce a server's tools-changed signals into one refresh. `connectOnly` is true when
|
|
7
|
+
* every merged signal came from a connect rather than from a reported change. */
|
|
8
|
+
export declare function subscribeMcpToolsChanged(entry: McpConnectionEntry, refresh: (connectOnly: boolean) => Promise<void>, sink: McpAsyncErrorSink): () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Re-list a server on a coalesced tools-changed signal and re-register: added
|
|
11
|
+
* tools enter INACTIVE (registerToolsPreservingActiveSet keeps the active set),
|
|
12
|
+
* and removed tools are tombstoned so a stale call fails cleanly. Every connect
|
|
13
|
+
* raises the signal too; a connect-only refresh leaves an unchanged catalog
|
|
14
|
+
* registered, so the catalog lands once per session (#2177).
|
|
15
|
+
*/
|
|
16
|
+
export declare function refreshMcpToolsOnListChanged(entry: McpConnectionEntry, pi: McpToolRegistrar, config: ResolvedMcpConfig, registerDirectTools: (pi: McpToolRegistrar) => Promise<void>, connectOnly: boolean): Promise<void>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=service-tools-changed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-tools-changed.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-tools-changed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAQ5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,KAAK,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,CAAC,CAAC;AAEjG;iFACiF;AACjF,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,EAChD,IAAI,EAAE,iBAAiB,GACrB,MAAM,IAAI,CAmBZ;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CACjD,KAAK,EAAE,kBAAkB,EACzB,EAAE,EAAE,gBAAgB,EACpB,MAAM,EAAE,iBAAiB,EACzB,mBAAmB,EAAE,CAAC,EAAE,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,EAC5D,WAAW,EAAE,OAAO,GAClB,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { collectToolCatalog, mcpRegistrationIdentity } from "./catalog.js";
|
|
2
|
+
import { mapMcpCatalogNames } from "./expose/register.js";
|
|
3
|
+
import { buildMcpTombstoneDefinition, createMcpListChangeCoalescer, diffMcpToolNames, formatMcpListChangedDelta, } from "./notifications.js";
|
|
4
|
+
import { SharedMcpLease } from "./shared-lease.js";
|
|
5
|
+
/** Coalesce a server's tools-changed signals into one refresh. `connectOnly` is true when
|
|
6
|
+
* every merged signal came from a connect rather than from a reported change. */
|
|
7
|
+
export function subscribeMcpToolsChanged(entry, refresh, sink) {
|
|
8
|
+
let changeReported = false;
|
|
9
|
+
const coalescer = createMcpListChangeCoalescer({
|
|
10
|
+
onRefresh: () => {
|
|
11
|
+
const connectOnly = !changeReported;
|
|
12
|
+
changeReported = false;
|
|
13
|
+
return refresh(connectOnly);
|
|
14
|
+
},
|
|
15
|
+
scope: `mcp.list_changed.${entry.name}`,
|
|
16
|
+
sink,
|
|
17
|
+
});
|
|
18
|
+
const unsubscribe = entry.connection.onToolsChanged((event) => {
|
|
19
|
+
if (event.cause !== "connect")
|
|
20
|
+
changeReported = true;
|
|
21
|
+
coalescer.notify();
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
unsubscribe();
|
|
25
|
+
coalescer.dispose();
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Re-list a server on a coalesced tools-changed signal and re-register: added
|
|
30
|
+
* tools enter INACTIVE (registerToolsPreservingActiveSet keeps the active set),
|
|
31
|
+
* and removed tools are tombstoned so a stale call fails cleanly. Every connect
|
|
32
|
+
* raises the signal too; a connect-only refresh leaves an unchanged catalog
|
|
33
|
+
* registered, so the catalog lands once per session (#2177).
|
|
34
|
+
*/
|
|
35
|
+
export async function refreshMcpToolsOnListChanged(entry, pi, config, registerDirectTools, connectOnly) {
|
|
36
|
+
const server = config.servers[entry.name];
|
|
37
|
+
if (server?.config === undefined || entry.connection.state !== "connected")
|
|
38
|
+
return;
|
|
39
|
+
// The startup connect that still owns registration registers its refreshed catalog itself.
|
|
40
|
+
if (connectOnly && entry.startupCatalogClaim?.ownsRegistration() === true)
|
|
41
|
+
return;
|
|
42
|
+
if (entry.connection instanceof SharedMcpLease) {
|
|
43
|
+
entry.cachedCatalog = await entry.connection.catalog();
|
|
44
|
+
}
|
|
45
|
+
const catalog = await collectToolCatalog(entry.name, entry.connection, server.config, {
|
|
46
|
+
agentDir: entry.agentDir,
|
|
47
|
+
outputGuard: config.settings.outputGuard,
|
|
48
|
+
});
|
|
49
|
+
const newNames = mapMcpCatalogNames(catalog).map(({ name }) => name);
|
|
50
|
+
const diff = diffMcpToolNames(entry.knownToolNames ?? newNames, newNames);
|
|
51
|
+
if (!connectOnly || mcpRegistrationIdentity(catalog, entry.cachedCatalog) !== entry.registeredIdentity) {
|
|
52
|
+
// Tombstone removed tools BEFORE re-registration so the subsequent
|
|
53
|
+
// setActiveTools (which excludes them) leaves the tombstones inactive.
|
|
54
|
+
for (const removed of diff.removed)
|
|
55
|
+
pi.registerTool(buildMcpTombstoneDefinition(removed, entry.name));
|
|
56
|
+
await registerDirectTools(pi);
|
|
57
|
+
}
|
|
58
|
+
entry.knownToolNames = newNames;
|
|
59
|
+
entry.lastListChangedDelta = formatMcpListChangedDelta(diff);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=service-tools-changed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-tools-changed.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-tools-changed.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACN,2BAA2B,EAC3B,4BAA4B,EAC5B,gBAAgB,EAChB,yBAAyB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD;iFACiF;AACjF,MAAM,UAAU,wBAAwB,CACvC,KAAyB,EACzB,OAAgD,EAChD,IAAuB;IAEvB,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,MAAM,SAAS,GAAG,4BAA4B,CAAC;QAC9C,SAAS,EAAE,GAAG,EAAE;YACf,MAAM,WAAW,GAAG,CAAC,cAAc,CAAC;YACpC,cAAc,GAAG,KAAK,CAAC;YACvB,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;QAC7B,CAAC;QACD,KAAK,EAAE,oBAAoB,KAAK,CAAC,IAAI,EAAE;QACvC,IAAI;KACJ,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7D,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;YAAE,cAAc,GAAG,IAAI,CAAC;QACrD,SAAS,CAAC,MAAM,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE;QACX,WAAW,EAAE,CAAC;QACd,SAAS,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CACjD,KAAyB,EACzB,EAAoB,E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C,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,cAAc,GAAG,QAAQ,CAAC;IAChC,KAAK,CAAC,oBAAoB,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import type { ExtensionAPI } from \"../../types.ts\";\nimport { collectToolCatalog, mcpRegistrationIdentity } from \"./catalog.ts\";\nimport type { ResolvedMcpConfig } from \"./config-schema.ts\";\nimport { mapMcpCatalogNames } from \"./expose/register.ts\";\nimport {\n\tbuildMcpTombstoneDefinition,\n\tcreateMcpListChangeCoalescer,\n\tdiffMcpToolNames,\n\tformatMcpListChangedDelta,\n} from \"./notifications.ts\";\nimport type { McpConnectionEntry } from \"./service-types.ts\";\nimport { SharedMcpLease } from \"./shared-lease.ts\";\nimport type { McpAsyncErrorSink } from \"./wrap.ts\";\n\ntype McpToolRegistrar = Pick<ExtensionAPI, \"getActiveTools\" | \"setActiveTools\" | \"registerTool\">;\n\n/** Coalesce a server's tools-changed signals into one refresh. `connectOnly` is true when\n * every merged signal came from a connect rather than from a reported change. */\nexport function subscribeMcpToolsChanged(\n\tentry: McpConnectionEntry,\n\trefresh: (connectOnly: boolean) => Promise<void>,\n\tsink: McpAsyncErrorSink,\n): () => void {\n\tlet changeReported = false;\n\tconst coalescer = createMcpListChangeCoalescer({\n\t\tonRefresh: () => {\n\t\t\tconst connectOnly = !changeReported;\n\t\t\tchangeReported = false;\n\t\t\treturn refresh(connectOnly);\n\t\t},\n\t\tscope: `mcp.list_changed.${entry.name}`,\n\t\tsink,\n\t});\n\tconst unsubscribe = entry.connection.onToolsChanged((event) => {\n\t\tif (event.cause !== \"connect\") changeReported = true;\n\t\tcoalescer.notify();\n\t});\n\treturn () => {\n\t\tunsubscribe();\n\t\tcoalescer.dispose();\n\t};\n}\n\n/**\n * Re-list a server on a coalesced tools-changed signal and re-register: added\n * tools enter INACTIVE (registerToolsPreservingActiveSet keeps the active set),\n * and removed tools are tombstoned so a stale call fails cleanly. Every connect\n * raises the signal too; a connect-only refresh leaves an unchanged catalog\n * registered, so the catalog lands once per session (#2177).\n */\nexport async function refreshMcpToolsOnListChanged(\n\tentry: McpConnectionEntry,\n\tpi: McpToolRegistrar,\n\tconfig: ResolvedMcpConfig,\n\tregisterDirectTools: (pi: McpToolRegistrar) => Promise<void>,\n\tconnectOnly: boolean,\n): Promise<void> {\n\tconst server = config.servers[entry.name];\n\tif (server?.config === undefined || entry.connection.state !== \"connected\") return;\n\t// The startup connect that still owns registration registers its refreshed catalog itself.\n\tif (connectOnly && entry.startupCatalogClaim?.ownsRegistration() === true) return;\n\tif (entry.connection instanceof SharedMcpLease) {\n\t\tentry.cachedCatalog = await entry.connection.catalog();\n\t}\n\tconst catalog = await collectToolCatalog(entry.name, entry.connection, server.config, {\n\t\tagentDir: entry.agentDir,\n\t\toutputGuard: config.settings.outputGuard,\n\t});\n\tconst newNames = mapMcpCatalogNames(catalog).map(({ name }) => name);\n\tconst diff = diffMcpToolNames(entry.knownToolNames ?? newNames, newNames);\n\tif (!connectOnly || mcpRegistrationIdentity(catalog, entry.cachedCatalog) !== entry.registeredIdentity) {\n\t\t// Tombstone removed tools BEFORE re-registration so the subsequent\n\t\t// setActiveTools (which excludes them) leaves the tombstones inactive.\n\t\tfor (const removed of diff.removed) pi.registerTool(buildMcpTombstoneDefinition(removed, entry.name));\n\t\tawait registerDirectTools(pi);\n\t}\n\tentry.knownToolNames = newNames;\n\tentry.lastListChangedDelta = formatMcpListChangedDelta(diff);\n}\n"]}
|
|
@@ -118,6 +118,16 @@ export interface McpServerCounters {
|
|
|
118
118
|
totalLatencyMs: number;
|
|
119
119
|
reconnectCount: number;
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Held by a startup connect from its start until it hands the server's catalog
|
|
123
|
+
* to a registration pass. While it owns registration, other passes register the
|
|
124
|
+
* catalog known when the connect began, never the in-flight one, so the catalog
|
|
125
|
+
* lands exactly once (#2177).
|
|
126
|
+
*/
|
|
127
|
+
export interface McpStartupCatalogClaim {
|
|
128
|
+
readonly cachedCatalog: McpCachedServerCatalog | undefined;
|
|
129
|
+
readonly ownsRegistration: () => boolean;
|
|
130
|
+
}
|
|
121
131
|
export interface McpConnectionEntry {
|
|
122
132
|
readonly key: string;
|
|
123
133
|
readonly name: string;
|
|
@@ -131,6 +141,9 @@ export interface McpConnectionEntry {
|
|
|
131
141
|
readonly authPlan?: ServerAuthPlan;
|
|
132
142
|
cachedCatalog?: McpCachedServerCatalog;
|
|
133
143
|
cacheRefreshedAfterConnect: boolean;
|
|
144
|
+
startupCatalogClaim?: McpStartupCatalogClaim;
|
|
145
|
+
/** `mcpRegistrationIdentity` of what the session last registered for this server. */
|
|
146
|
+
registeredIdentity?: string;
|
|
134
147
|
/** Full mcp tool names last registered for this server (list_changed diffing). */
|
|
135
148
|
knownToolNames?: string[];
|
|
136
149
|
/** Latest `/mcp status` list_changed delta line, e.g. "2 added (inactive), 1 removed". */
|
|
@@ -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,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,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,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IACnC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,0BAA0B,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,sBAAsB,CAAC;IAC7C,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,0FAA0F;IAC1F,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B"}
|
|
@@ -1 +1 @@
|
|
|
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 { HostMcpRegistry } from \"./host-registry.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 mcpRegistry?: HostMcpRegistry;\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"]}
|
|
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 { HostMcpRegistry } from \"./host-registry.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 mcpRegistry?: HostMcpRegistry;\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\n/**\n * Held by a startup connect from its start until it hands the server's catalog\n * to a registration pass. While it owns registration, other passes register the\n * catalog known when the connect began, never the in-flight one, so the catalog\n * lands exactly once (#2177).\n */\nexport interface McpStartupCatalogClaim {\n\treadonly cachedCatalog: McpCachedServerCatalog | undefined;\n\treadonly ownsRegistration: () => boolean;\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\tstartupCatalogClaim?: McpStartupCatalogClaim;\n\t/** `mcpRegistrationIdentity` of what the session last registered for this server. */\n\tregisteredIdentity?: string;\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service.ts"],"names":[],"mappings":"AAEA,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":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAQhH,OAAO,EAA2C,qBAAqB,EAA4B,MAAM,aAAa,CAAC;AACvH,OAAO,KAAK,EAAE,eAAe,EAAwC,MAAM,oBAAoB,CAAC;AAChG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAA6B,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMxD,OAAO,KAAK,EAEX,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAOjB,qBAAqB,EAErB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGN,KAAK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
|
2
2
|
import { getToolSearchService, resetToolSearchServiceForTests, } from "../tool-search/service.js";
|
|
3
3
|
import { resolveAuthMode } from "./auth/context.js";
|
|
4
|
-
import { collectToolCatalog } from "./catalog.js";
|
|
5
4
|
import { getValidCachedServer, readMcpCatalogCache } from "./catalog-cache.js";
|
|
6
5
|
import { loadMcpConfig, mergeExtensionMcpServers, resolveSkillMcpServer, visitSpawnableMcpServers } from "./config.js";
|
|
7
6
|
import { collectAllPages } from "./expose/pagination.js";
|
|
8
|
-
import { mapMcpCatalogNames } from "./expose/register.js";
|
|
9
7
|
import { cleanupMcpOutputArtifacts, McpOutputArtifacts } from "./guard/output-guard.js";
|
|
10
8
|
import { HostMcpRegistry } from "./host-registry.js";
|
|
11
9
|
import { refreshMcpInstructionsForSession } from "./instructions.js";
|
|
12
|
-
import { buildMcpTombstoneDefinition, createMcpListChangeCoalescer, diffMcpToolNames, formatMcpListChangedDelta, } from "./notifications.js";
|
|
13
10
|
import { reconnectMcpNow } from "./reconnect.js";
|
|
14
11
|
import { createMcpSessionConnection, disposeEntryConnection } from "./service-connection.js";
|
|
15
12
|
import { getMcpServiceExposureStatus } from "./service-exposure.js";
|
|
16
13
|
import { registerMcpServiceDirectTools } from "./service-register.js";
|
|
17
14
|
import { buildMcpServerSnapshot } from "./service-snapshot.js";
|
|
18
|
-
import {
|
|
15
|
+
import { refreshMcpToolsOnListChanged, subscribeMcpToolsChanged } from "./service-tools-changed.js";
|
|
19
16
|
import { MCP_ATTACH_SETTLE_TIMEOUT_MS, McpDeferredAttach, raceMcpStartupConnect, resolveMcpStartupTimeoutMs, shouldRaceMcpStartup, } from "./startup-race.js";
|
|
20
17
|
export { registerToolsPreservingActiveSet } from "./active-set.js";
|
|
21
18
|
export class McpService {
|
|
@@ -365,12 +362,7 @@ export class McpService {
|
|
|
365
362
|
}
|
|
366
363
|
#wireListChanged(entry) {
|
|
367
364
|
const sink = { logger: { error: (message, data) => entry.logger.error(message, data) } };
|
|
368
|
-
|
|
369
|
-
onRefresh: () => this.#handleServerToolsChanged(entry),
|
|
370
|
-
scope: `mcp.list_changed.${entry.name}`,
|
|
371
|
-
sink,
|
|
372
|
-
});
|
|
373
|
-
const unsubscribe = entry.connection.onToolsChanged(() => coalescer.notify());
|
|
365
|
+
entry.disposeListChanged = subscribeMcpToolsChanged(entry, (connectOnly) => this.#handleServerToolsChanged(entry, connectOnly), sink);
|
|
374
366
|
const unsubscribeState = entry.connection.onStateChange(() => {
|
|
375
367
|
const ctx = this.#sessionContext;
|
|
376
368
|
if (ctx?.mode !== "rpc")
|
|
@@ -379,39 +371,14 @@ export class McpService {
|
|
|
379
371
|
entry.logger.error("Failed to refresh MCP control inventory", error);
|
|
380
372
|
});
|
|
381
373
|
});
|
|
382
|
-
entry.disposeListChanged = () => {
|
|
383
|
-
unsubscribe();
|
|
384
|
-
coalescer.dispose();
|
|
385
|
-
};
|
|
386
374
|
entry.disposeWireStatus = unsubscribeState;
|
|
387
375
|
}
|
|
388
|
-
|
|
389
|
-
// enter INACTIVE (registerToolsPreservingActiveSet keeps the active set), and
|
|
390
|
-
// removed tools are tombstoned so a stale call fails cleanly.
|
|
391
|
-
async #handleServerToolsChanged(entry) {
|
|
376
|
+
async #handleServerToolsChanged(entry, connectOnly) {
|
|
392
377
|
const pi = this.#pi;
|
|
393
378
|
const config = this.#config;
|
|
394
379
|
if (pi === undefined || config === null)
|
|
395
380
|
return;
|
|
396
|
-
|
|
397
|
-
if (server?.config === undefined || entry.connection.state !== "connected")
|
|
398
|
-
return;
|
|
399
|
-
if (entry.connection instanceof SharedMcpLease) {
|
|
400
|
-
entry.cachedCatalog = await entry.connection.catalog();
|
|
401
|
-
}
|
|
402
|
-
const catalog = await collectToolCatalog(entry.name, entry.connection, server.config, {
|
|
403
|
-
agentDir: entry.agentDir,
|
|
404
|
-
outputGuard: config.settings.outputGuard,
|
|
405
|
-
});
|
|
406
|
-
const newNames = mapMcpCatalogNames(catalog).map(({ name }) => name);
|
|
407
|
-
const diff = diffMcpToolNames(entry.knownToolNames ?? newNames, newNames);
|
|
408
|
-
// Tombstone removed tools BEFORE re-registration so the subsequent
|
|
409
|
-
// setActiveTools (which excludes them) leaves the tombstones inactive.
|
|
410
|
-
for (const removed of diff.removed)
|
|
411
|
-
pi.registerTool(buildMcpTombstoneDefinition(removed, entry.name));
|
|
412
|
-
await this.#registerDirectTools(pi);
|
|
413
|
-
entry.knownToolNames = newNames;
|
|
414
|
-
entry.lastListChangedDelta = formatMcpListChangedDelta(diff);
|
|
381
|
+
await refreshMcpToolsOnListChanged(entry, pi, config, (target) => this.#registerDirectTools(target), connectOnly);
|
|
415
382
|
}
|
|
416
383
|
async #registerDirectTools(pi) {
|
|
417
384
|
const config = this.#config;
|