@humain/terminal 0.0.6 → 0.0.7
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 +52 -0
- package/README.md +10 -4
- package/dist/bundle/chunks/anthropic-messages-GDMGYAZB.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-ZN52D6YC.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +77 -0
- package/dist/bundle/chunks/chunk-3D3G2X5U.js +6 -0
- package/dist/bundle/chunks/chunk-3VI4HD7D.js +31 -0
- package/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
- package/dist/bundle/chunks/chunk-72KO4OMP.js +2 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/dist/bundle/chunks/chunk-ARF4OE6X.js +105 -0
- package/dist/bundle/chunks/chunk-BOW22LW6.js +42 -0
- package/dist/bundle/chunks/chunk-BZQ53VGE.js +70 -0
- package/dist/bundle/chunks/chunk-CBHC6EL7.js +133 -0
- package/dist/bundle/chunks/chunk-D7XAASZM.js +4 -0
- package/dist/bundle/chunks/chunk-ECWELYBH.js +17 -0
- package/dist/bundle/chunks/chunk-GMWCTUPB.js +2 -0
- package/dist/bundle/chunks/chunk-H2O6VOXT.js +11 -0
- package/dist/bundle/chunks/chunk-HNVPY4LZ.js +5995 -0
- package/dist/bundle/chunks/chunk-JUUC5AZY.js +2 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/dist/bundle/chunks/chunk-M2GYSCCG.js +44 -0
- package/dist/bundle/chunks/chunk-MA4UUCYX.js +18 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/dist/bundle/chunks/chunk-SGTGQNNP.js +4 -0
- package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
- package/dist/bundle/chunks/chunk-TXBQIIIO.js +2 -0
- package/dist/bundle/chunks/chunk-WJZ4KLGL.js +2 -0
- package/dist/bundle/chunks/chunk-XNGRGP62.js +2 -0
- package/dist/bundle/chunks/dist-7DSXV2TY.js +9 -0
- package/dist/bundle/chunks/dist-BXEVYJIO.js +7 -0
- package/dist/bundle/chunks/es-P2KNSZYR.js +9 -0
- package/dist/bundle/chunks/es5-FGTJ7ZFW.js +2 -0
- package/dist/bundle/chunks/event-streams-JOSQQSII.js +2 -0
- package/dist/bundle/chunks/extract-2L7ZVN7F.js +106 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-XT7NQJ2E.js +2 -0
- package/dist/bundle/chunks/google-vertex-IDQ6Z53W.js +2 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-HHDZ4FHR.js +5 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/dist/bundle/chunks/node-XY3CBY3C.js +294 -0
- package/dist/bundle/chunks/node-ZHY4LHC7.js +15 -0
- package/dist/bundle/chunks/openai-codex-responses-HRVCDY54.js +8 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-6QBYTBXY.js +7 -0
- package/dist/bundle/chunks/openai-responses-4MWLJHIK.js +2 -0
- package/dist/bundle/chunks/openrouter-images-Y2PCWAQH.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pdfjs-UKQT3OWY.js +107 -0
- package/dist/bundle/chunks/pi-messages-57K43J6J.js +8 -0
- package/dist/bundle/chunks/promise-J5TGSM32.js +2 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/dist/bundle/chunks/undici-D6ABF53Q.js +2 -0
- package/dist/bundle/chunks/webapi-AFS5FDJJ.js +5 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli.js +3 -0
- package/dist/bundle/client.js +2 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +29 -9
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -11
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +50 -14
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +163 -95
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +6 -7
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +4 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +41 -32
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +115 -48
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +38 -9
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +20 -19
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +26 -5
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +5 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +14 -8
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +2 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +22 -14
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +2 -1
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +2 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +10 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +4 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +32 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +9 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +51 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +11 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +16 -3
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +62 -29
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +20 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +19 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +4 -1
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +2 -0
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +6 -2
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/humain/agent-execution-protocol.d.ts +1 -217
- package/dist/humain/agent-execution-protocol.d.ts.map +1 -1
- package/dist/humain/agent-execution-protocol.js +1 -203
- package/dist/humain/agent-execution-protocol.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +107 -16
- package/dist/humain/mcp-adapter/vendor/CHANGELOG.md +82 -0
- package/dist/humain/mcp-adapter/vendor/README.md +47 -15
- package/dist/humain/mcp-adapter/vendor/cli.js +4 -4
- package/dist/humain/mcp-adapter/vendor/commands.ts +5 -3
- package/dist/humain/mcp-adapter/vendor/config.ts +46 -5
- package/dist/humain/mcp-adapter/vendor/direct-tools.ts +103 -92
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.d.ts +10 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.js +63 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.d.ts +8 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js +356 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.d.ts +123 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.js +1088 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.d.ts +24 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.js +336 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.d.ts +19 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js +319 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.d.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js +156 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.d.ts +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.js +15 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.d.ts +566 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.js +287 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.d.ts +6 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.js +37 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.d.ts +104 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.js +59 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.d.ts +4 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.js +27 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.d.ts +32 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.js +338 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/failure-backoff.ts +23 -0
- package/dist/humain/mcp-adapter/vendor/index.bundle.mjs +4870 -3878
- package/dist/humain/mcp-adapter/vendor/index.ts +294 -88
- package/dist/humain/mcp-adapter/vendor/init.ts +41 -30
- package/dist/humain/mcp-adapter/vendor/lifecycle.ts +16 -8
- package/dist/humain/mcp-adapter/vendor/mcp-auth-flow.ts +124 -32
- package/dist/humain/mcp-adapter/vendor/mcp-bearer-store.ts +0 -2
- package/dist/humain/mcp-adapter/vendor/mcp-code.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/mcp-oauth-provider.ts +155 -16
- package/dist/humain/mcp-adapter/vendor/mcp-output-guard.ts +95 -7
- package/dist/humain/mcp-adapter/vendor/mcp-probe.ts +18 -4
- package/dist/humain/mcp-adapter/vendor/mcp-references.ts +376 -0
- package/dist/humain/mcp-adapter/vendor/mcp-status.ts +8 -19
- package/dist/humain/mcp-adapter/vendor/metadata-cache.ts +20 -12
- package/dist/humain/mcp-adapter/vendor/namespace-tools.ts +276 -0
- package/dist/humain/mcp-adapter/vendor/package.json +26 -8
- package/dist/humain/mcp-adapter/vendor/proxy-modes.ts +128 -32
- package/dist/humain/mcp-adapter/vendor/request-headers-command.ts +1 -1
- package/dist/humain/mcp-adapter/vendor/search-ranking.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/server-manager.ts +69 -12
- package/dist/humain/mcp-adapter/vendor/state.ts +1 -3
- package/dist/humain/mcp-adapter/vendor/tool-result-renderer.ts +16 -2
- package/dist/humain/mcp-adapter/vendor/types.ts +51 -2
- package/dist/humain/mcp-adapter/vendor/ui-server.ts +3 -19
- package/dist/humain/mcp-adapter/vendor/ui-session.ts +2 -1
- package/dist/humain/mcp-adapter/vendor/utils.ts +21 -19
- package/dist/humain/mcp-adapter.d.ts.map +1 -1
- package/dist/humain/mcp-adapter.js +4 -0
- package/dist/humain/mcp-adapter.js.map +1 -1
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts +14 -0
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/chrome-cookies.js +85 -33
- package/dist/humain/web-access/vendor/chrome-cookies.js.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.js +3 -1
- package/dist/humain/web-access/vendor/credential-source.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.d.ts +2 -29
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +10 -1
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.d.ts +2 -29
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.js +4 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts +11 -0
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +163 -20
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.d.ts +2 -0
- package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.js +11 -0
- package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-adc.d.ts +10 -0
- package/dist/humain/web-access/vendor/gemini-adc.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-adc.js +268 -0
- package/dist/humain/web-access/vendor/gemini-adc.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-api.d.ts +7 -1
- package/dist/humain/web-access/vendor/gemini-api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-api.js +51 -15
- package/dist/humain/web-access/vendor/gemini-api.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.d.ts +9 -4
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.js +63 -21
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-url-context.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-url-context.js +3 -2
- package/dist/humain/web-access/vendor/gemini-url-context.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts +8 -1
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web-config.js +49 -4
- package/dist/humain/web-access/vendor/gemini-web-config.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web.d.ts +2 -1
- package/dist/humain/web-access/vendor/gemini-web.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web.js +8 -3
- package/dist/humain/web-access/vendor/gemini-web.js.map +1 -1
- package/dist/humain/web-access/vendor/github-api.d.ts +1 -1
- package/dist/humain/web-access/vendor/github-api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/github-api.js +6 -4
- package/dist/humain/web-access/vendor/github-api.js.map +1 -1
- package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/github-extract.js +50 -3
- package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
- package/dist/humain/web-access/vendor/github-issue-pr.d.ts +27 -0
- package/dist/humain/web-access/vendor/github-issue-pr.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/github-issue-pr.js +701 -0
- package/dist/humain/web-access/vendor/github-issue-pr.js.map +1 -0
- package/dist/humain/web-access/vendor/index.d.ts +3 -31
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +643 -530
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/kimi-search.d.ts +5 -0
- package/dist/humain/web-access/vendor/kimi-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/kimi-search.js +228 -0
- package/dist/humain/web-access/vendor/kimi-search.js.map +1 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts +3 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/openai-search.js +89 -16
- package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/page-query.js +56 -8
- package/dist/humain/web-access/vendor/page-query.js.map +1 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js +6 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
- package/dist/humain/web-access/vendor/utils.d.ts +12 -0
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +343 -1
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/xcrawl.d.ts +4 -0
- package/dist/humain/web-access/vendor/xcrawl.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/xcrawl.js +251 -0
- package/dist/humain/web-access/vendor/xcrawl.js.map +1 -0
- package/dist/humain/web-access/vendor/youtube-extract.js +2 -2
- package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -14
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +9 -3
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +53 -10
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -2
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +118 -55
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +151 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +68 -17
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +176 -106
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts +16 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +188 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +6 -5
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +16 -13
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +20 -6
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +3 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -7
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +189 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +12 -2
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +5 -3
- package/dist/utils/management-http.d.ts.map +1 -1
- package/dist/utils/management-http.js +14 -10
- package/dist/utils/management-http.js.map +1 -1
- package/dist/utils/shell.d.ts +3 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +17 -5
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +64 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/version-check.js +4 -4
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +15 -0
- package/docs/custom-provider.md +5 -2
- package/docs/environment-variables.md +7 -7
- package/docs/extensions.md +17 -7
- package/docs/json.md +7 -2
- package/docs/keybindings.md +8 -8
- package/docs/llama-cpp.md +2 -0
- package/docs/models.md +8 -2
- package/docs/packages.md +2 -2
- package/docs/rpc.md +9 -3
- package/docs/sdk.md +7 -2
- package/docs/settings.md +11 -3
- package/docs/skills.md +3 -2
- package/docs/terminal-setup.md +8 -0
- package/docs/usage.md +10 -7
- package/docs/windows.md +15 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +70 -8
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/sandbox/package-lock.json +14 -40
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +4 -4
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +293 -221
- package/package.json +21 -18
- package/src/humain/mcp-adapter/UPSTREAM.md +15 -5
- package/src/humain/mcp-adapter/upstream.json +4 -3
- package/src/humain/mcp-adapter/vendor/CHANGELOG.md +82 -0
- package/src/humain/web-access/UPSTREAM.md +1 -1
- package/src/humain/web-access/upstream.json +6 -4
|
@@ -6,23 +6,32 @@ import { Type } from "typebox";
|
|
|
6
6
|
import type { TSchema } from "typebox";
|
|
7
7
|
import { showStatus, showTools, showPrompts, reconnectServer, reconnectServers, authenticateServer, logoutServer, manageBearerToken, openMcpAuthPanel, openMcpPanel, openMcpSetup } from "./commands.ts";
|
|
8
8
|
import { cloneMcpConfig, loadMcpConfig, writeProjectServerDisabledOverride } from "./config.ts";
|
|
9
|
-
import { buildProxyDescription, createDirectToolExecutor, getMissingConfiguredDirectToolServers, resolveDirectTools } from "./direct-tools.ts";
|
|
9
|
+
import { buildProxyDescription, createDirectToolExecutor, getMissingConfiguredDirectToolServers, prepareDirectToolArguments, resolveDirectTools } from "./direct-tools.ts";
|
|
10
10
|
import { flushMetadataCache, initializeMcp, updateStatusBar } from "./init.ts";
|
|
11
|
-
import {
|
|
11
|
+
import { isServerInActiveFailureBackoff } from "./failure-backoff.ts";
|
|
12
|
+
import { loadMetadataCache, parseDirectToolSelectors, type MetadataCache } from "./metadata-cache.ts";
|
|
12
13
|
import { createPromptCommand, resolveCachedPrompts } from "./prompts.ts";
|
|
13
14
|
import { logger } from "./logger.ts";
|
|
14
15
|
import { executeAuthComplete, executeAuthStart, executeCall, executeConnect, executeDescribe, executeInstructions, executeList, executeSearch, executeStatus, executeUiMessages } from "./proxy-modes.ts";
|
|
15
16
|
import { formatTerminalError, getConfigPathFromArgv, normalizeDirectToolInputSchema, truncateAtWord } from "./utils.ts";
|
|
16
17
|
import { createOAuthRuntime, shutdownOAuth } from "./mcp-auth-flow.ts";
|
|
17
|
-
import { createMcpDirectToolCallRenderer, createMcpProxyToolCallRenderer, createMcpToolResultRenderer, resolveMcpToolRenderOptions } from "./tool-result-renderer.ts";
|
|
18
|
+
import { createMcpDirectToolCallRenderer, createMcpProxyToolCallRenderer, createMcpScriptToolCallRenderer, createMcpToolResultRenderer, resolveMcpToolRenderOptions } from "./tool-result-renderer.ts";
|
|
18
19
|
import { toolErrorOverride } from "./error-signal.ts";
|
|
19
20
|
import { createMcpRuntimeOwner, createOwnedUi, isAbortError, type McpRuntimeOwner } from "./runtime-owner.ts";
|
|
20
21
|
import { publishMcpStatusShutdown } from "./mcp-status.ts";
|
|
21
22
|
import { runMcpScript } from "./mcp-code.ts";
|
|
22
23
|
import { cleanupMaterializedBinaryResources } from "./tool-registrar.ts";
|
|
24
|
+
import { syncNamespaceProxyTools } from "./namespace-tools.ts";
|
|
23
25
|
|
|
24
26
|
export type { McpAdapterOptions } from "./types.ts";
|
|
25
27
|
export type { ServerEntry } from "./types.ts";
|
|
28
|
+
export {
|
|
29
|
+
namespaceProxyName,
|
|
30
|
+
parseMcpReference,
|
|
31
|
+
resolveMcpToolReferences,
|
|
32
|
+
type McpReferenceResolution,
|
|
33
|
+
type ParsedMcpReference,
|
|
34
|
+
} from "./mcp-references.ts";
|
|
26
35
|
export {
|
|
27
36
|
MCP_STATUS_EVENT,
|
|
28
37
|
MCP_STATUS_SNAPSHOT_VERSION,
|
|
@@ -37,15 +46,50 @@ export {
|
|
|
37
46
|
} from "./types.ts";
|
|
38
47
|
|
|
39
48
|
const INIT_WAIT_TIMEOUT_MS = 30_000;
|
|
49
|
+
const INIT_FAILURE_MESSAGE_MAX_CHARS = 1_000;
|
|
40
50
|
const INIT_WAIT_TIMED_OUT: unique symbol = Symbol("init-wait-timed-out");
|
|
41
51
|
|
|
42
52
|
export interface McpServerRegistration {
|
|
43
53
|
dispose(): Promise<void>;
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
export const MCP_RUNTIME_REGISTER_EVENT = "pi-mcp-adapter:runtime-register:v1" as const;
|
|
57
|
+
export const MCP_RUNTIME_REGISTER_VERSION = 1 as const;
|
|
58
|
+
|
|
59
|
+
export const MCP_RUNTIME_SNAPSHOT_EVENT = "pi-mcp-adapter:runtime-snapshot:v1" as const;
|
|
60
|
+
export const MCP_RUNTIME_SNAPSHOT_VERSION = 1 as const;
|
|
61
|
+
|
|
62
|
+
export type McpRuntimeRegistrationResult =
|
|
63
|
+
| { ok: true; registration: McpServerRegistration }
|
|
64
|
+
| { ok: false; error: Error };
|
|
65
|
+
|
|
66
|
+
export interface McpRuntimeRegistrationRequest {
|
|
67
|
+
version: typeof MCP_RUNTIME_REGISTER_VERSION;
|
|
68
|
+
name: string;
|
|
69
|
+
definition: ServerEntry;
|
|
70
|
+
result?: McpRuntimeRegistrationResult;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface McpRuntimeServerSnapshot {
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly definition: ServerEntry;
|
|
76
|
+
readonly runtime: true;
|
|
77
|
+
readonly persisted: false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type McpRuntimeSnapshotResult =
|
|
81
|
+
| { ok: true; snapshot: McpRuntimeServerSnapshot }
|
|
82
|
+
| { ok: false; error: Error };
|
|
83
|
+
|
|
84
|
+
export interface McpRuntimeSnapshotRequest {
|
|
85
|
+
version: typeof MCP_RUNTIME_SNAPSHOT_VERSION;
|
|
86
|
+
name: string;
|
|
87
|
+
result?: McpRuntimeSnapshotResult;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Fast path for callers that share the adapter's module and ExtensionAPI.
|
|
48
91
|
const runtimeRegistrars = new WeakMap<ExtensionAPI, (name: string, definition: ServerEntry) => McpServerRegistration>();
|
|
92
|
+
const runtimeSnapshotters = new WeakMap<ExtensionAPI, (name: string) => McpRuntimeServerSnapshot>();
|
|
49
93
|
|
|
50
94
|
async function awaitWithTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T | typeof INIT_WAIT_TIMED_OUT> {
|
|
51
95
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -74,6 +118,18 @@ function optionalNumber(options: { minimum?: number; description: string }): TSc
|
|
|
74
118
|
: ({ type: "number", ...options } as unknown as TSchema);
|
|
75
119
|
}
|
|
76
120
|
|
|
121
|
+
function parseEnvDirectToolOverride(raw: string | undefined): string[] | undefined {
|
|
122
|
+
return raw?.split(",").map(s => s.trim()).filter(Boolean);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function resolveNamespaceEnvOverride(
|
|
126
|
+
raw: string | undefined,
|
|
127
|
+
selectors: string[] | undefined,
|
|
128
|
+
): ReturnType<typeof parseDirectToolSelectors> | null {
|
|
129
|
+
if (raw === "__none__") return { servers: new Set<string>(), tools: new Map<string, Set<string>>() };
|
|
130
|
+
return selectors ? parseDirectToolSelectors(selectors) : null;
|
|
131
|
+
}
|
|
132
|
+
|
|
77
133
|
function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
78
134
|
const sessionConfig = options.config !== undefined ? cloneMcpConfig(options.config) : undefined;
|
|
79
135
|
const programmaticConfig = sessionConfig !== undefined;
|
|
@@ -82,6 +138,41 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
82
138
|
let currentOwner: McpRuntimeOwner | null = null;
|
|
83
139
|
let currentOAuthRuntime: McpOAuthRuntime | null = null;
|
|
84
140
|
let lifecycleGeneration = 0;
|
|
141
|
+
let retainedInitFailure: string | null = null;
|
|
142
|
+
|
|
143
|
+
function retainInitFailure(error: unknown): string {
|
|
144
|
+
const message = truncateAtWord(formatTerminalError(error), INIT_FAILURE_MESSAGE_MAX_CHARS);
|
|
145
|
+
retainedInitFailure = message;
|
|
146
|
+
return message;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function clearRetainedInitFailure(): void {
|
|
150
|
+
retainedInitFailure = null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function buildInitRetryInstruction(prefix: string, failure: string | null = retainedInitFailure): string {
|
|
154
|
+
const retry = "Fix the MCP server configuration or startup failure, then call mcp(...) again to retry initialization.";
|
|
155
|
+
return failure ? `${prefix}: ${failure}. ${retry}` : `${prefix}. ${retry}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function isOwnerAbortError(error: unknown, owner: McpRuntimeOwner): boolean {
|
|
159
|
+
if (!owner.signal.aborted) return isAbortError(error);
|
|
160
|
+
const reason = owner.signal.reason;
|
|
161
|
+
if (reason instanceof Error && reason.message === "MCP initialization failed" && error !== reason) {
|
|
162
|
+
return isAbortError(error);
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function startGatewayRetryInitialization(ctx: ExtensionContext): void {
|
|
168
|
+
const generation = ++lifecycleGeneration;
|
|
169
|
+
const owner = createMcpRuntimeOwner();
|
|
170
|
+
const oauthRuntime = createOAuthRuntime(owner.signal);
|
|
171
|
+
currentOwner = owner;
|
|
172
|
+
currentOAuthRuntime = oauthRuntime;
|
|
173
|
+
state = null;
|
|
174
|
+
startInitialization(ctx, owner, oauthRuntime, generation, "stale_gateway_retry_initialization");
|
|
175
|
+
}
|
|
85
176
|
|
|
86
177
|
async function shutdownState(currentState: McpExtensionState | null, reason: string): Promise<void> {
|
|
87
178
|
if (!currentState) {
|
|
@@ -130,8 +221,10 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
130
221
|
: loadMcpConfig(earlyConfigPath);
|
|
131
222
|
const earlyCache = loadMetadataCache();
|
|
132
223
|
const envRaw = process.env.MCP_DIRECT_TOOLS;
|
|
133
|
-
const envDirectToolOverride = envRaw
|
|
224
|
+
const envDirectToolOverride = parseEnvDirectToolOverride(envRaw);
|
|
225
|
+
const namespaceEnvOverride = resolveNamespaceEnvOverride(envRaw, envDirectToolOverride);
|
|
134
226
|
const registeredDirectTools = new Map<string, string>();
|
|
227
|
+
const registeredNamespaceProxyTools = new Set<string>();
|
|
135
228
|
const fallbackDeactivatedTools = new Set<string>();
|
|
136
229
|
const toolRenderOptions = resolveMcpToolRenderOptions(earlyConfig.settings);
|
|
137
230
|
const toolRenderShell = toolRenderOptions.resultRendering === "compact" ? "self" : "default";
|
|
@@ -141,7 +234,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
141
234
|
let directToolsFrozen = false;
|
|
142
235
|
// Session/runtime scoped server registrations from other extensions. They
|
|
143
236
|
// survive session restarts within this install and die with the process.
|
|
144
|
-
const runtimeServers = new Map<string, ServerEntry>();
|
|
237
|
+
const runtimeServers = new Map<string, { definition: ServerEntry; entry: ServerEntry }>();
|
|
145
238
|
|
|
146
239
|
// Mirrors init's per-server lifecycle registration so runtime servers get
|
|
147
240
|
// idle cleanup and keep-alive health recovery like configured servers.
|
|
@@ -175,13 +268,16 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
175
268
|
});
|
|
176
269
|
}
|
|
177
270
|
|
|
178
|
-
function registerDirectTool(spec: DirectToolSpec): void {
|
|
271
|
+
function registerDirectTool(spec: DirectToolSpec, config: McpConfig): void {
|
|
179
272
|
(pi.registerTool as (tool: unknown) => unknown)({
|
|
180
273
|
name: spec.prefixedName,
|
|
181
274
|
label: `MCP: ${spec.originalName}`,
|
|
182
275
|
description: spec.description || "(no description)",
|
|
183
276
|
promptSnippet: truncateAtWord(spec.description, 100) || `MCP tool from ${spec.serverName}`,
|
|
184
277
|
parameters: toToolParameters(normalizeDirectToolInputSchema(spec.inputSchema)),
|
|
278
|
+
...(config.settings?.strictDirectToolArguments === true
|
|
279
|
+
? { prepareArguments: (args: unknown) => prepareDirectToolArguments(spec.inputSchema, args) }
|
|
280
|
+
: {}),
|
|
185
281
|
execute: createDirectToolExecutor(() => state, () => initPromise, spec),
|
|
186
282
|
renderShell: toolRenderShell,
|
|
187
283
|
renderCall: createMcpDirectToolCallRenderer(spec.prefixedName, toolRenderOptions),
|
|
@@ -189,10 +285,16 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
189
285
|
});
|
|
190
286
|
}
|
|
191
287
|
|
|
192
|
-
function
|
|
288
|
+
function activeFailureServers(): Set<string> {
|
|
289
|
+
const currentState = state;
|
|
290
|
+
if (!currentState) return new Set();
|
|
291
|
+
return new Set(Object.keys(currentState.config.mcpServers).filter((serverName) => isServerInActiveFailureBackoff(currentState, serverName)));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function resolveCurrentDirectTools(config: McpConfig, cache: MetadataCache | null, reservedNames?: Set<string>): DirectToolSpec[] {
|
|
193
295
|
if (envRaw === "__none__") return [];
|
|
194
296
|
const prefix = config.settings?.toolPrefix ?? "server";
|
|
195
|
-
return resolveDirectTools(config, cache, prefix, envDirectToolOverride);
|
|
297
|
+
return resolveDirectTools(config, cache, prefix, envDirectToolOverride, activeFailureServers(), reservedNames);
|
|
196
298
|
}
|
|
197
299
|
|
|
198
300
|
function getActiveToolsIfReady(): string[] | undefined {
|
|
@@ -226,11 +328,14 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
226
328
|
|
|
227
329
|
function syncDirectTools(config: McpConfig, cache: MetadataCache | null): {
|
|
228
330
|
specs: DirectToolSpec[];
|
|
331
|
+
reservedDirectNames: Set<string>;
|
|
332
|
+
activeDirectNames: Set<string>;
|
|
229
333
|
added: string[];
|
|
230
334
|
updated: string[];
|
|
231
335
|
deactivated: string[];
|
|
232
336
|
} {
|
|
233
|
-
const
|
|
337
|
+
const reservedDirectNames = new Set<string>();
|
|
338
|
+
const specs = resolveCurrentDirectTools(config, cache, reservedDirectNames);
|
|
234
339
|
const nextNames = new Set(specs.map((spec) => spec.prefixedName));
|
|
235
340
|
const added: string[] = [];
|
|
236
341
|
const updated: string[] = [];
|
|
@@ -240,7 +345,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
240
345
|
const fingerprint = directToolFingerprint(spec);
|
|
241
346
|
const previous = registeredDirectTools.get(spec.prefixedName);
|
|
242
347
|
if (previous !== fingerprint) {
|
|
243
|
-
registerDirectTool(spec);
|
|
348
|
+
registerDirectTool(spec, config);
|
|
244
349
|
registeredDirectTools.set(spec.prefixedName, fingerprint);
|
|
245
350
|
if (fallbackDeactivatedTools.delete(spec.prefixedName)) {
|
|
246
351
|
const activeTools = getActiveToolsIfReady();
|
|
@@ -259,7 +364,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
259
364
|
}
|
|
260
365
|
|
|
261
366
|
deactivateTools(deactivated);
|
|
262
|
-
return { specs, added, updated, deactivated };
|
|
367
|
+
return { specs, reservedDirectNames, activeDirectNames: nextNames, added, updated, deactivated };
|
|
263
368
|
}
|
|
264
369
|
|
|
265
370
|
function applyDirectToolConfigChanges(changes: Map<string, true | string[] | false>): void {
|
|
@@ -276,6 +381,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
276
381
|
const cache = loadMetadataCache();
|
|
277
382
|
const result = syncDirectTools(config, cache);
|
|
278
383
|
syncProxyTool(config, cache, result.specs);
|
|
384
|
+
syncNamespaceTools(config, cache, result.reservedDirectNames, result.activeDirectNames);
|
|
279
385
|
const changed = result.added.length + result.updated.length + result.deactivated.length;
|
|
280
386
|
if (changed > 0 && ctx?.hasUI) {
|
|
281
387
|
ctx.ui.notify(
|
|
@@ -285,6 +391,32 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
285
391
|
}
|
|
286
392
|
}
|
|
287
393
|
|
|
394
|
+
function syncNamespaceTools(
|
|
395
|
+
config: McpConfig,
|
|
396
|
+
cache: MetadataCache | null,
|
|
397
|
+
reservedDirectNames: Set<string> = new Set(registeredDirectTools.keys()),
|
|
398
|
+
activeDirectNames: Set<string> = new Set(registeredDirectTools.keys()),
|
|
399
|
+
): void {
|
|
400
|
+
const result = syncNamespaceProxyTools({
|
|
401
|
+
config,
|
|
402
|
+
cache,
|
|
403
|
+
envOverride: namespaceEnvOverride,
|
|
404
|
+
existingDirectNames: reservedDirectNames,
|
|
405
|
+
activeDirectNames,
|
|
406
|
+
existingNamespaceNames: registeredNamespaceProxyTools,
|
|
407
|
+
unavailableServers: activeFailureServers(),
|
|
408
|
+
pi,
|
|
409
|
+
getState: () => state,
|
|
410
|
+
getInitPromise: () => initPromise,
|
|
411
|
+
getPiTools: () => pi.getAllTools(),
|
|
412
|
+
renderOptions: toolRenderOptions,
|
|
413
|
+
renderShell: toolRenderShell,
|
|
414
|
+
renderResult: renderMcpToolResult,
|
|
415
|
+
});
|
|
416
|
+
for (const name of result.added) registeredNamespaceProxyTools.add(name);
|
|
417
|
+
for (const name of result.deactivated) registeredNamespaceProxyTools.delete(name);
|
|
418
|
+
}
|
|
419
|
+
|
|
288
420
|
const registeredPromptCommands = new Set<string>();
|
|
289
421
|
|
|
290
422
|
function registerPromptCommands(specs: Iterable<PromptMetadata>): void {
|
|
@@ -304,7 +436,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
304
436
|
|
|
305
437
|
registerPromptCommands(resolveCachedPrompts(earlyConfig));
|
|
306
438
|
|
|
307
|
-
|
|
439
|
+
const registerRuntimeServer = (name: string, definition: ServerEntry): McpServerRegistration => {
|
|
308
440
|
if (typeof name !== "string" || name.trim() === "") {
|
|
309
441
|
throw new Error("MCP server name must be a non-empty string");
|
|
310
442
|
}
|
|
@@ -317,8 +449,9 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
317
449
|
}
|
|
318
450
|
// Runtime-registered servers are proxy-tool-only: direct tools are frozen
|
|
319
451
|
// at startup and must not be rebuilt for late registrations.
|
|
320
|
-
const
|
|
321
|
-
|
|
452
|
+
const snapshotDefinition = structuredClone(definition);
|
|
453
|
+
const entry: ServerEntry = { ...structuredClone(snapshotDefinition), directTools: false };
|
|
454
|
+
runtimeServers.set(name, { definition: snapshotDefinition, entry });
|
|
322
455
|
const registeredState = state;
|
|
323
456
|
if (registeredState) {
|
|
324
457
|
registeredState.config.mcpServers[name] = entry;
|
|
@@ -341,6 +474,62 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
341
474
|
updateStatusBar(currentState);
|
|
342
475
|
},
|
|
343
476
|
};
|
|
477
|
+
};
|
|
478
|
+
const getRuntimeServerSnapshot = (name: string): McpRuntimeServerSnapshot => {
|
|
479
|
+
if (typeof name !== "string" || name.trim() === "") {
|
|
480
|
+
throw new Error("MCP runtime server name must be a non-empty string");
|
|
481
|
+
}
|
|
482
|
+
const runtimeServer = runtimeServers.get(name);
|
|
483
|
+
if (!runtimeServer) {
|
|
484
|
+
throw new Error(`MCP runtime server "${name}" is not registered or has been disposed`);
|
|
485
|
+
}
|
|
486
|
+
const activeState = state;
|
|
487
|
+
if (!activeState) {
|
|
488
|
+
throw new Error(`MCP runtime server "${name}" is unavailable because the adapter has no active state`);
|
|
489
|
+
}
|
|
490
|
+
const activeEntry = activeState.config.mcpServers[name];
|
|
491
|
+
if (Object.hasOwn(activeState.config.mcpServers, name) && activeEntry !== runtimeServer.entry) {
|
|
492
|
+
throw new Error(`MCP runtime server "${name}" is shadowed by a configured server`);
|
|
493
|
+
}
|
|
494
|
+
if (activeEntry !== runtimeServer.entry) {
|
|
495
|
+
throw new Error(`MCP runtime server "${name}" is unavailable in the active adapter state`);
|
|
496
|
+
}
|
|
497
|
+
return {
|
|
498
|
+
name,
|
|
499
|
+
definition: structuredClone(runtimeServer.definition),
|
|
500
|
+
runtime: true,
|
|
501
|
+
persisted: false,
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
runtimeRegistrars.set(pi, registerRuntimeServer);
|
|
505
|
+
runtimeSnapshotters.set(pi, getRuntimeServerSnapshot);
|
|
506
|
+
pi.events.on(MCP_RUNTIME_REGISTER_EVENT, (rawRequest: unknown) => {
|
|
507
|
+
if (typeof rawRequest !== "object" || rawRequest === null || Array.isArray(rawRequest)) return;
|
|
508
|
+
const request = rawRequest as McpRuntimeRegistrationRequest;
|
|
509
|
+
if (request.result !== undefined) return;
|
|
510
|
+
if (request.version !== MCP_RUNTIME_REGISTER_VERSION) {
|
|
511
|
+
request.result = { ok: false, error: new Error(`Unsupported MCP runtime registration version: ${String(request.version)}`) };
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
try {
|
|
515
|
+
request.result = { ok: true, registration: registerRuntimeServer(request.name, request.definition) };
|
|
516
|
+
} catch (error) {
|
|
517
|
+
request.result = { ok: false, error: error instanceof Error ? error : new Error(String(error)) };
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
pi.events.on(MCP_RUNTIME_SNAPSHOT_EVENT, (rawRequest: unknown) => {
|
|
521
|
+
if (typeof rawRequest !== "object" || rawRequest === null || Array.isArray(rawRequest)) return;
|
|
522
|
+
const request = rawRequest as McpRuntimeSnapshotRequest;
|
|
523
|
+
if (request.result !== undefined) return;
|
|
524
|
+
if (request.version !== MCP_RUNTIME_SNAPSHOT_VERSION) {
|
|
525
|
+
request.result = { ok: false, error: new Error(`Unsupported MCP runtime snapshot version: ${String(request.version)}`) };
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
request.result = { ok: true, snapshot: getRuntimeServerSnapshot(request.name) };
|
|
530
|
+
} catch (error) {
|
|
531
|
+
request.result = { ok: false, error: error instanceof Error ? error : new Error(String(error)) };
|
|
532
|
+
}
|
|
344
533
|
});
|
|
345
534
|
|
|
346
535
|
const getPiTools = (): ToolInfo[] => pi.getAllTools();
|
|
@@ -374,13 +563,14 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
374
563
|
}
|
|
375
564
|
|
|
376
565
|
state = nextState;
|
|
377
|
-
|
|
566
|
+
clearRetainedInitFailure();
|
|
567
|
+
for (const [name, { entry }] of runtimeServers) {
|
|
378
568
|
if (Object.hasOwn(nextState.config.mcpServers, name)) {
|
|
379
569
|
console.error(`MCP: runtime-registered server "${name}" now collides with a configured server; keeping the configured server`);
|
|
380
570
|
continue;
|
|
381
571
|
}
|
|
382
|
-
nextState.config.mcpServers[name] =
|
|
383
|
-
attachRuntimeServerLifecycle(nextState, name,
|
|
572
|
+
nextState.config.mcpServers[name] = entry;
|
|
573
|
+
attachRuntimeServerLifecycle(nextState, name, entry);
|
|
384
574
|
}
|
|
385
575
|
nextState.onToolMetadataUpdated = (_serverName, _reason) => {
|
|
386
576
|
if (state !== nextState || !owner.isActive()) return;
|
|
@@ -409,7 +599,8 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
409
599
|
if (initPromise !== promise && initPromise !== null) {
|
|
410
600
|
return;
|
|
411
601
|
}
|
|
412
|
-
|
|
602
|
+
const message = retainInitFailure(err);
|
|
603
|
+
console.error(`MCP initialization failed: ${message}`);
|
|
413
604
|
initPromise = null;
|
|
414
605
|
if (state) return;
|
|
415
606
|
|
|
@@ -459,6 +650,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
459
650
|
currentOAuthRuntime = oauthRuntime;
|
|
460
651
|
state = null;
|
|
461
652
|
initPromise = null;
|
|
653
|
+
clearRetainedInitFailure();
|
|
462
654
|
|
|
463
655
|
// Abort synchronously before awaiting cleanup so old callbacks and startup
|
|
464
656
|
// work cannot resume into a stale ExtensionContext.
|
|
@@ -520,6 +712,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
520
712
|
currentOAuthRuntime = null;
|
|
521
713
|
state = null;
|
|
522
714
|
initPromise = null;
|
|
715
|
+
clearRetainedInitFailure();
|
|
523
716
|
|
|
524
717
|
// Abort before awaiting cleanup so delayed initialization cannot touch stale
|
|
525
718
|
// Pi context after session shutdown.
|
|
@@ -786,6 +979,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
786
979
|
code: Type.String({ description: "Trusted JavaScript MCP script. Use tools.<prefixedToolName>(args) and emit(value)." }),
|
|
787
980
|
timeoutMs: optionalNumber({ minimum: 1, description: "Execution timeout in milliseconds (default: 30000)" }),
|
|
788
981
|
}),
|
|
982
|
+
renderCall: createMcpScriptToolCallRenderer(toolRenderOptions),
|
|
789
983
|
renderResult: renderMcpToolResult,
|
|
790
984
|
async execute(_toolCallId: string, params: { code: string; timeoutMs?: number }, signal: AbortSignal | undefined) {
|
|
791
985
|
const executeOwner = currentOwner;
|
|
@@ -801,7 +995,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
801
995
|
executeOwner?.throwIfInactive();
|
|
802
996
|
state = initialized;
|
|
803
997
|
} catch (error) {
|
|
804
|
-
if (executeOwner &&
|
|
998
|
+
if (executeOwner && isOwnerAbortError(error, executeOwner)) throw error;
|
|
805
999
|
const message = error instanceof Error ? error.message : String(error);
|
|
806
1000
|
return {
|
|
807
1001
|
content: [{ type: "text" as const, text: `MCP initialization failed: ${message}` }],
|
|
@@ -811,8 +1005,10 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
811
1005
|
}
|
|
812
1006
|
if (!state) {
|
|
813
1007
|
return {
|
|
814
|
-
content: [{ type: "text" as const, text:
|
|
815
|
-
|
|
1008
|
+
content: [{ type: "text" as const, text: retainedInitFailure
|
|
1009
|
+
? buildInitRetryInstruction("MCP is not initialized after an earlier initialization failure")
|
|
1010
|
+
: "MCP not initialized" }],
|
|
1011
|
+
details: { mode: "script", error: "not_initialized", ...(retainedInitFailure ? { message: retainedInitFailure } : {}) },
|
|
816
1012
|
};
|
|
817
1013
|
}
|
|
818
1014
|
executeOwner?.throwIfInactive();
|
|
@@ -864,7 +1060,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
864
1060
|
server?: string;
|
|
865
1061
|
action?: string;
|
|
866
1062
|
}, signal: AbortSignal | undefined, _onUpdate: AgentToolUpdateCallback<Record<string, unknown>> | undefined, _ctx: ExtensionContext) {
|
|
867
|
-
|
|
1063
|
+
let executeOwner = currentOwner;
|
|
868
1064
|
const parseArgs = (value: string | Record<string, unknown> | undefined): Record<string, unknown> | undefined => {
|
|
869
1065
|
if (value === undefined || value === "") return undefined;
|
|
870
1066
|
let args: unknown;
|
|
@@ -887,30 +1083,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
887
1083
|
}
|
|
888
1084
|
return args as Record<string, unknown>;
|
|
889
1085
|
};
|
|
890
|
-
const
|
|
891
|
-
for (const key of ["tool", "connect", "describe", "instructions", "search", "server", "action"] as const) {
|
|
892
|
-
if (value[key] !== undefined && typeof value[key] !== "string") {
|
|
893
|
-
throw new Error(`Invalid nested gateway param \`${key}\`: expected string, got ${Array.isArray(value[key]) ? "array" : typeof value[key]}`);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
for (const key of ["regex", "includeSchemas"] as const) {
|
|
897
|
-
if (value[key] !== undefined && typeof value[key] !== "boolean") {
|
|
898
|
-
throw new Error(`Invalid nested gateway param \`${key}\`: expected boolean, got ${Array.isArray(value[key]) ? "array" : typeof value[key]}`);
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
for (const key of ["limit", "offset"] as const) {
|
|
902
|
-
if (value[key] !== undefined && typeof value[key] !== "number") {
|
|
903
|
-
throw new Error(`Invalid nested gateway param \`${key}\`: expected number, got ${Array.isArray(value[key]) ? "array" : typeof value[key]}`);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
const args = value.args;
|
|
907
|
-
if (args !== undefined && typeof args !== "string" && (typeof args !== "object" || args === null || Array.isArray(args))) {
|
|
908
|
-
throw new Error(`Invalid nested gateway param \`args\`: expected JSON object or JSON string, got ${Array.isArray(args) ? "array" : args === null ? "null" : typeof args}`);
|
|
909
|
-
}
|
|
910
|
-
return value as typeof params;
|
|
911
|
-
};
|
|
912
|
-
let parsedArgs = parseArgs(params.args);
|
|
913
|
-
let dispatchParams = params;
|
|
1086
|
+
const parsedArgs = parseArgs(params.args);
|
|
914
1087
|
const hasGatewayMode = (value: typeof params): boolean =>
|
|
915
1088
|
value.tool !== undefined
|
|
916
1089
|
|| value.connect !== undefined
|
|
@@ -919,18 +1092,15 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
919
1092
|
|| value.search !== undefined
|
|
920
1093
|
|| value.server !== undefined
|
|
921
1094
|
|| value.action !== undefined;
|
|
922
|
-
if (!hasGatewayMode(params) &&
|
|
923
|
-
const nestedParams = validateNestedGatewayParams(parsedArgs);
|
|
924
|
-
if (hasGatewayMode(nestedParams)) {
|
|
925
|
-
dispatchParams = nestedParams;
|
|
926
|
-
parsedArgs = parseArgs(nestedParams.args);
|
|
927
|
-
} else {
|
|
928
|
-
throw new Error("Gateway params were nested inside `args`; pass them top-level (for example, mcp({ search: \"...\" }) or mcp({ tool: \"...\", args: {} })).");
|
|
929
|
-
}
|
|
930
|
-
} else if (!hasGatewayMode(params) && params.args !== undefined) {
|
|
1095
|
+
if (!hasGatewayMode(params) && params.args !== undefined) {
|
|
931
1096
|
throw new Error("Gateway params were nested inside `args`; pass them top-level (for example, mcp({ search: \"...\" }) or mcp({ tool: \"...\", args: {} })).");
|
|
932
1097
|
}
|
|
933
1098
|
|
|
1099
|
+
if (!state && !initPromise && retainedInitFailure) {
|
|
1100
|
+
startGatewayRetryInitialization(_ctx);
|
|
1101
|
+
executeOwner = currentOwner;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
934
1104
|
if (!state && initPromise) {
|
|
935
1105
|
try {
|
|
936
1106
|
const initialized = await awaitWithTimeout(initPromise, INIT_WAIT_TIMEOUT_MS);
|
|
@@ -943,38 +1113,40 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
943
1113
|
executeOwner?.throwIfInactive();
|
|
944
1114
|
state = initialized;
|
|
945
1115
|
} catch (error) {
|
|
946
|
-
if (executeOwner &&
|
|
947
|
-
const message =
|
|
1116
|
+
if (executeOwner && isOwnerAbortError(error, executeOwner)) throw error;
|
|
1117
|
+
const message = retainInitFailure(error);
|
|
948
1118
|
return {
|
|
949
|
-
content: [{ type: "text" as const, text:
|
|
1119
|
+
content: [{ type: "text" as const, text: buildInitRetryInstruction("MCP initialization failed", message) }],
|
|
950
1120
|
details: { error: "init_failed", message },
|
|
951
1121
|
};
|
|
952
1122
|
}
|
|
953
1123
|
}
|
|
954
1124
|
if (!state) {
|
|
955
1125
|
return {
|
|
956
|
-
content: [{ type: "text" as const, text:
|
|
957
|
-
|
|
1126
|
+
content: [{ type: "text" as const, text: retainedInitFailure
|
|
1127
|
+
? buildInitRetryInstruction("MCP is not initialized after an earlier initialization failure")
|
|
1128
|
+
: "MCP not initialized" }],
|
|
1129
|
+
details: { error: "not_initialized", ...(retainedInitFailure ? { message: retainedInitFailure } : {}) },
|
|
958
1130
|
};
|
|
959
1131
|
}
|
|
960
1132
|
executeOwner?.throwIfInactive();
|
|
961
1133
|
|
|
962
|
-
if (
|
|
1134
|
+
if (params.action === "ui-messages") {
|
|
963
1135
|
return executeUiMessages(state);
|
|
964
1136
|
}
|
|
965
|
-
if (
|
|
966
|
-
if (!
|
|
1137
|
+
if (params.action === "auth-start") {
|
|
1138
|
+
if (!params.server) {
|
|
967
1139
|
return {
|
|
968
1140
|
content: [{ type: "text" as const, text: "auth-start requires `server`. Example: mcp({ action: \"auth-start\", server: \"linear-server\" })" }],
|
|
969
1141
|
details: { mode: "auth-start", error: "missing_server" },
|
|
970
1142
|
};
|
|
971
1143
|
}
|
|
972
1144
|
return signal
|
|
973
|
-
? executeAuthStart(state,
|
|
974
|
-
: executeAuthStart(state,
|
|
1145
|
+
? executeAuthStart(state, params.server, signal)
|
|
1146
|
+
: executeAuthStart(state, params.server);
|
|
975
1147
|
}
|
|
976
|
-
if (
|
|
977
|
-
if (!
|
|
1148
|
+
if (params.action === "auth-complete") {
|
|
1149
|
+
if (!params.server) {
|
|
978
1150
|
return {
|
|
979
1151
|
content: [{ type: "text" as const, text: "auth-complete requires `server`." }],
|
|
980
1152
|
details: { mode: "auth-complete", error: "missing_server" },
|
|
@@ -988,28 +1160,28 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
988
1160
|
};
|
|
989
1161
|
}
|
|
990
1162
|
return signal
|
|
991
|
-
? executeAuthComplete(state,
|
|
992
|
-
: executeAuthComplete(state,
|
|
1163
|
+
? executeAuthComplete(state, params.server, input, signal)
|
|
1164
|
+
: executeAuthComplete(state, params.server, input);
|
|
993
1165
|
}
|
|
994
|
-
if (
|
|
995
|
-
return executeCall(state,
|
|
1166
|
+
if (params.tool) {
|
|
1167
|
+
return executeCall(state, params.tool, parsedArgs, params.server, getPiTools, signal);
|
|
996
1168
|
}
|
|
997
|
-
if (
|
|
998
|
-
const result = await executeConnect(state,
|
|
1169
|
+
if (params.connect) {
|
|
1170
|
+
const result = await executeConnect(state, params.connect, signal);
|
|
999
1171
|
syncToolSurface(_ctx as ExtensionContext);
|
|
1000
1172
|
return result;
|
|
1001
1173
|
}
|
|
1002
|
-
if (
|
|
1003
|
-
return executeDescribe(state,
|
|
1174
|
+
if (params.describe) {
|
|
1175
|
+
return executeDescribe(state, params.describe);
|
|
1004
1176
|
}
|
|
1005
|
-
if (
|
|
1006
|
-
return executeInstructions(state,
|
|
1177
|
+
if (params.instructions) {
|
|
1178
|
+
return executeInstructions(state, params.instructions);
|
|
1007
1179
|
}
|
|
1008
|
-
if (
|
|
1009
|
-
return executeSearch(state,
|
|
1180
|
+
if (params.search !== undefined) {
|
|
1181
|
+
return executeSearch(state, params.search, params.regex, params.server, params.includeSchemas, params.limit, params.offset);
|
|
1010
1182
|
}
|
|
1011
|
-
if (
|
|
1012
|
-
return executeList(state,
|
|
1183
|
+
if (params.server) {
|
|
1184
|
+
return executeList(state, params.server);
|
|
1013
1185
|
}
|
|
1014
1186
|
return executeStatus(state);
|
|
1015
1187
|
},
|
|
@@ -1030,7 +1202,7 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
1030
1202
|
|| missingConfiguredDirectToolServers.length > 0;
|
|
1031
1203
|
|
|
1032
1204
|
if (shouldRegisterProxyTool) {
|
|
1033
|
-
const description = buildProxyDescription(config
|
|
1205
|
+
const description = buildProxyDescription(config);
|
|
1034
1206
|
if (!proxyToolRegistered || proxyToolDescription !== description) {
|
|
1035
1207
|
registerProxyTool(description);
|
|
1036
1208
|
return;
|
|
@@ -1051,8 +1223,13 @@ function installMcpAdapter(pi: ExtensionAPI, options: McpAdapterOptions) {
|
|
|
1051
1223
|
}
|
|
1052
1224
|
}
|
|
1053
1225
|
|
|
1054
|
-
const
|
|
1055
|
-
syncProxyTool(earlyConfig, earlyCache,
|
|
1226
|
+
const initialDirectResult = syncDirectTools(earlyConfig, earlyCache);
|
|
1227
|
+
syncProxyTool(earlyConfig, earlyCache, initialDirectResult.specs);
|
|
1228
|
+
// Register namespace-proxy tools eagerly so tool-groups/slow-mode can validate
|
|
1229
|
+
// `mcp:<server>` references on the first session_start turn. Without this
|
|
1230
|
+
// eager call, the tool-groups expansion runs before MCP initialization
|
|
1231
|
+
// completes and emits false `[unknown-tool] mcp__<server>` diagnostics.
|
|
1232
|
+
syncNamespaceTools(earlyConfig, earlyCache, initialDirectResult.reservedDirectNames, initialDirectResult.activeDirectNames);
|
|
1056
1233
|
startLoadTimeInitialization();
|
|
1057
1234
|
}
|
|
1058
1235
|
|
|
@@ -1076,10 +1253,39 @@ export function createMcpAdapter(options: McpAdapterOptions = {}) {
|
|
|
1076
1253
|
export function registerMcpServer(options: { pi: ExtensionAPI; name: string; definition: ServerEntry }): McpServerRegistration {
|
|
1077
1254
|
const { pi, name, definition } = options;
|
|
1078
1255
|
const register = runtimeRegistrars.get(pi);
|
|
1079
|
-
if (
|
|
1256
|
+
if (register) return register(name, definition);
|
|
1257
|
+
const request: McpRuntimeRegistrationRequest = {
|
|
1258
|
+
version: MCP_RUNTIME_REGISTER_VERSION,
|
|
1259
|
+
name,
|
|
1260
|
+
definition,
|
|
1261
|
+
};
|
|
1262
|
+
pi.events.emit(MCP_RUNTIME_REGISTER_EVENT, request);
|
|
1263
|
+
if (!request.result) {
|
|
1264
|
+
throw new Error("pi-mcp-adapter is not installed for this Pi instance");
|
|
1265
|
+
}
|
|
1266
|
+
if (!request.result.ok) throw request.result.error;
|
|
1267
|
+
return request.result.registration;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Return a detached, non-persisted snapshot of one runtime-registered MCP
|
|
1272
|
+
* server. Configured servers and runtime registrations shadowed by config are
|
|
1273
|
+
* never exported through this API.
|
|
1274
|
+
*/
|
|
1275
|
+
export function getRuntimeMcpServerSnapshot(options: { pi: ExtensionAPI; name: string }): McpRuntimeServerSnapshot {
|
|
1276
|
+
const { pi, name } = options;
|
|
1277
|
+
const getSnapshot = runtimeSnapshotters.get(pi);
|
|
1278
|
+
if (getSnapshot) return getSnapshot(name);
|
|
1279
|
+
const request: McpRuntimeSnapshotRequest = {
|
|
1280
|
+
version: MCP_RUNTIME_SNAPSHOT_VERSION,
|
|
1281
|
+
name,
|
|
1282
|
+
};
|
|
1283
|
+
pi.events.emit(MCP_RUNTIME_SNAPSHOT_EVENT, request);
|
|
1284
|
+
if (!request.result) {
|
|
1080
1285
|
throw new Error("pi-mcp-adapter is not installed for this Pi instance");
|
|
1081
1286
|
}
|
|
1082
|
-
|
|
1287
|
+
if (!request.result.ok) throw request.result.error;
|
|
1288
|
+
return request.result.snapshot;
|
|
1083
1289
|
}
|
|
1084
1290
|
|
|
1085
1291
|
export default createMcpAdapter();
|