@ashx-j/lunr 0.2.17 → 0.2.18
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 +19 -1
- package/README.md +2 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +44 -19
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +2 -2
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +8 -11
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +2 -1
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts +4 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +172 -171
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts +50 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js +131 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts +7 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js +211 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts +0 -5
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +0 -202
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +276 -109
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts +4 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js +10 -3
- package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js +6 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts +6 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +33 -8
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +2 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +68 -15
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +5 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +72 -31
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +2 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.js +105 -54
- package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.js +82 -65
- package/dist/builtin-extensions/pi-web-access/gemini-search.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.js +2 -0
- package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +259 -168
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/lazy.d.ts +18 -0
- package/dist/builtin-extensions/pi-web-access/lazy.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/lazy.js +19 -0
- package/dist/builtin-extensions/pi-web-access/lazy.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts +6 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js +17 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js.map +1 -0
- package/dist/cli-runtime.d.ts +3 -0
- package/dist/cli-runtime.d.ts.map +1 -0
- package/dist/cli-runtime.js +72 -0
- package/dist/cli-runtime.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -60
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -3
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/host-static.d.ts.map +1 -1
- package/dist/core/extensions/host-static.js +34 -12
- package/dist/core/extensions/host-static.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -2
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -64
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/timings.d.ts +2 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +17 -2
- package/dist/core/timings.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +6 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +23 -6
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/cron.d.ts +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +3 -1
- package/dist/gateway/cron.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -14
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/injected-context.d.ts +2 -0
- package/dist/modes/interactive/injected-context.d.ts.map +1 -0
- package/dist/modes/interactive/injected-context.js +7 -0
- package/dist/modes/interactive/injected-context.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +32 -8
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/thinking-level-slash.d.ts +4 -0
- package/dist/modes/interactive/thinking-level-slash.d.ts.map +1 -0
- package/dist/modes/interactive/thinking-level-slash.js +23 -0
- package/dist/modes/interactive/thinking-level-slash.js.map +1 -0
- package/dist/node-runtime/agent-session-services-35WNVGMR.js +36 -0
- package/dist/node-runtime/benchmark-request-UC7PD3V3.js +57 -0
- package/dist/node-runtime/brave-UWDA3I22.js +143 -0
- package/dist/node-runtime/builtin-extensions-QATGXENO.js +28 -0
- package/dist/node-runtime/chunk-2SJB2AWP.js +47 -0
- package/dist/node-runtime/chunk-3NMWLTPV.js +64 -0
- package/dist/node-runtime/chunk-3WFAEVKS.js +115 -0
- package/dist/node-runtime/chunk-3X3KZKMI.js +49 -0
- package/dist/node-runtime/chunk-4CSFRBCN.js +7558 -0
- package/dist/node-runtime/chunk-4DJ6HEGH.js +296 -0
- package/dist/node-runtime/chunk-4HXHDDCF.js +16 -0
- package/dist/node-runtime/chunk-4I23VTC4.js +429 -0
- package/dist/node-runtime/chunk-4TLO4PO2.js +3427 -0
- package/dist/node-runtime/chunk-4ZWGEEAS.js +69 -0
- package/dist/node-runtime/chunk-53YJI7JU.js +137 -0
- package/dist/node-runtime/chunk-5EFIU3OM.js +295 -0
- package/dist/node-runtime/chunk-6BEIBLQ3.js +53 -0
- package/dist/node-runtime/chunk-6KDIOJL3.js +72 -0
- package/dist/node-runtime/chunk-7N3YHTYF.js +26 -0
- package/dist/node-runtime/chunk-7NBZ5P7I.js +24 -0
- package/dist/node-runtime/chunk-AD6VXAO7.js +342 -0
- package/dist/node-runtime/chunk-ARC4KOTI.js +11178 -0
- package/dist/node-runtime/chunk-AROOY4BB.js +173 -0
- package/dist/node-runtime/chunk-ATGA2WLC.js +5646 -0
- package/dist/node-runtime/chunk-AUXVGBO4.js +19 -0
- package/dist/node-runtime/chunk-AY6CAJSL.js +30 -0
- package/dist/node-runtime/chunk-BHO7O6E5.js +296 -0
- package/dist/node-runtime/chunk-BI3DHYCN.js +8845 -0
- package/dist/node-runtime/chunk-BOHIDQT4.js +21 -0
- package/dist/node-runtime/chunk-BRJX2PRC.js +53 -0
- package/dist/node-runtime/chunk-CBGB57XT.js +20211 -0
- package/dist/node-runtime/chunk-CCZJ3PYY.js +17 -0
- package/dist/node-runtime/chunk-CGBXPL3E.js +1171 -0
- package/dist/node-runtime/chunk-CJECDQKP.js +19 -0
- package/dist/node-runtime/chunk-CSFI6YXL.js +130 -0
- package/dist/node-runtime/chunk-DAPBPCBP.js +53 -0
- package/dist/node-runtime/chunk-DDWHZ633.js +37 -0
- package/dist/node-runtime/chunk-DMMTJQMQ.js +43 -0
- package/dist/node-runtime/chunk-DVGWF6A2.js +1180 -0
- package/dist/node-runtime/chunk-EBF6COVM.js +1734 -0
- package/dist/node-runtime/chunk-FQMM2EZ2.js +248 -0
- package/dist/node-runtime/chunk-FVDOXRUD.js +96 -0
- package/dist/node-runtime/chunk-G4P75AIS.js +9471 -0
- package/dist/node-runtime/chunk-G6LRAP36.js +105 -0
- package/dist/node-runtime/chunk-GKLEQ3I4.js +860 -0
- package/dist/node-runtime/chunk-H2EOZYMP.js +57 -0
- package/dist/node-runtime/chunk-HQCKFM2O.js +56 -0
- package/dist/node-runtime/chunk-HYHJIRDW.js +19 -0
- package/dist/node-runtime/chunk-I6R76AG7.js +22 -0
- package/dist/node-runtime/chunk-IRPJXI6U.js +1269 -0
- package/dist/node-runtime/chunk-J26TSGDL.js +633 -0
- package/dist/node-runtime/chunk-JZQ7F36T.js +610 -0
- package/dist/node-runtime/chunk-KBKMCJDU.js +126 -0
- package/dist/node-runtime/chunk-KWA4OC2J.js +100 -0
- package/dist/node-runtime/chunk-M3LZLQW2.js +98 -0
- package/dist/node-runtime/chunk-MCUNIRD5.js +8388 -0
- package/dist/node-runtime/chunk-NI6OTSBH.js +966 -0
- package/dist/node-runtime/chunk-NUIFPZWX.js +209 -0
- package/dist/node-runtime/chunk-OBMWP3I5.js +68 -0
- package/dist/node-runtime/chunk-OCVIXVTZ.js +88 -0
- package/dist/node-runtime/chunk-OPEK5RRY.js +466 -0
- package/dist/node-runtime/chunk-OR4L3IB2.js +42 -0
- package/dist/node-runtime/chunk-PL6JKXWI.js +3622 -0
- package/dist/node-runtime/chunk-PNJSG3IZ.js +807 -0
- package/dist/node-runtime/chunk-PVCDKGR6.js +55 -0
- package/dist/node-runtime/chunk-Q4Q6D4IY.js +364 -0
- package/dist/node-runtime/chunk-Q5ZU2VRT.js +83 -0
- package/dist/node-runtime/chunk-QFWG2RVL.js +5477 -0
- package/dist/node-runtime/chunk-QZMODZQ2.js +305 -0
- package/dist/node-runtime/chunk-R5EDISSV.js +375 -0
- package/dist/node-runtime/chunk-RNBHABBA.js +986 -0
- package/dist/node-runtime/chunk-RQ2Q5IYR.js +72 -0
- package/dist/node-runtime/chunk-RRIZE6QQ.js +17 -0
- package/dist/node-runtime/chunk-SN6G4OU6.js +4753 -0
- package/dist/node-runtime/chunk-STERBGUB.js +949 -0
- package/dist/node-runtime/chunk-UWQYRSYQ.js +8973 -0
- package/dist/node-runtime/chunk-VRB2IYGG.js +53 -0
- package/dist/node-runtime/chunk-VSELYKWU.js +772 -0
- package/dist/node-runtime/chunk-W3CVH5RX.js +62 -0
- package/dist/node-runtime/chunk-WJVFOIB5.js +24921 -0
- package/dist/node-runtime/chunk-WKDK4C5P.js +2834 -0
- package/dist/node-runtime/chunk-XATUM2HK.js +46 -0
- package/dist/node-runtime/chunk-XBWPBZBN.js +125 -0
- package/dist/node-runtime/chunk-XTHQ7XR7.js +509 -0
- package/dist/node-runtime/chunk-ZBV7FAHG.js +1345 -0
- package/dist/node-runtime/cli-runtime.js +80 -0
- package/dist/node-runtime/clipboard-OZ63BBC6.js +12 -0
- package/dist/node-runtime/clipboard-image-7QR6GXVA.js +13 -0
- package/dist/node-runtime/command-AAV3YRR5.js +13 -0
- package/dist/node-runtime/commands-MV5KOZ64.js +291 -0
- package/dist/node-runtime/config-QDD5PUE2.js +73 -0
- package/dist/node-runtime/curator-server-XCM43VEF.js +3816 -0
- package/dist/node-runtime/customize-XEXL2DGQ.js +12 -0
- package/dist/node-runtime/direct-tool-executor-BK7CLEBX.js +188 -0
- package/dist/node-runtime/exa-LL64QZR2.js +329 -0
- package/dist/node-runtime/export-html-TEXVV5RP.js +150 -0
- package/dist/node-runtime/extension-input-O4HSAEM4.js +14 -0
- package/dist/node-runtime/extension-selector-X5FCX43D.js +14 -0
- package/dist/node-runtime/extract-XLQSJN4V.js +17 -0
- package/dist/node-runtime/file-sync-HCOP2QVF.js +117 -0
- package/dist/node-runtime/gateway-OAC4OBBL.js +2137 -0
- package/dist/node-runtime/gemini-api-QE7ANVDZ.js +29 -0
- package/dist/node-runtime/gemini-search-U7SUMPQA.js +330 -0
- package/dist/node-runtime/gemini-url-context-PXWCBQHK.js +103 -0
- package/dist/node-runtime/gemini-web-MM446SEH.js +14 -0
- package/dist/node-runtime/github-extract-F64RZOEA.js +619 -0
- package/dist/node-runtime/goal-NJEE5CTU.js +1831 -0
- package/dist/node-runtime/index.js +859 -0
- package/dist/node-runtime/init-3C7Z24OI.js +28 -0
- package/dist/node-runtime/install-cli-EXMJQESX.js +308 -0
- package/dist/node-runtime/interactive-mode-2SZUO53H.js +56 -0
- package/dist/node-runtime/interactive-view-S6J3QHEF.js +247 -0
- package/dist/node-runtime/lsp-manager-3ASUSO4T.js +1104 -0
- package/dist/node-runtime/lunr-cron-AUUYP4N4.js +272 -0
- package/dist/node-runtime/main.js +54 -0
- package/dist/node-runtime/mcp-auth-flow-QIXHW6QN.js +32 -0
- package/dist/node-runtime/mcp-panel-IIGMXQGP.js +501 -0
- package/dist/node-runtime/mcp-setup-panel-FEK7663I.js +355 -0
- package/dist/node-runtime/memory-cap-3S4XRLNP.js +20 -0
- package/dist/node-runtime/model-tiers-NJLHUEGK.js +20 -0
- package/dist/node-runtime/openai-search-B3MSNCQA.js +288 -0
- package/dist/node-runtime/package-manager-cli-7RKSZGEN.js +749 -0
- package/dist/node-runtime/parallel-AI2MNSCU.js +265 -0
- package/dist/node-runtime/parser-manager-TQHWYDH7.js +152 -0
- package/dist/node-runtime/pdf-extract-IPE6H4HP.js +57 -0
- package/dist/node-runtime/perplexity-QVJW3I35.js +12 -0
- package/dist/node-runtime/pi-intercom-EEMBGQID.js +2215 -0
- package/dist/node-runtime/pi-mcp-adapter-GUFZWW54.js +428 -0
- package/dist/node-runtime/pi-ollama-cloud-2F3Y2QNM.js +1440 -0
- package/dist/node-runtime/pi-prompt-template-model-QWTCGLJU.js +3946 -0
- package/dist/node-runtime/pi-subagents-7YJ3I4VE.js +6048 -0
- package/dist/node-runtime/pi-web-access-2CQGFLT2.js +1867 -0
- package/dist/node-runtime/print-mode-XSFM26EL.js +12 -0
- package/dist/node-runtime/proxy-modes-V6YVFH3C.js +685 -0
- package/dist/node-runtime/rpc-entry.js +62 -0
- package/dist/node-runtime/rpc-mode-W5ZTLTMZ.js +13 -0
- package/dist/node-runtime/runtime-bridges-3RKBDLNA.js +14 -0
- package/dist/node-runtime/session-manager-E7AREDTV.js +33 -0
- package/dist/node-runtime/session-selector-FJ7M2AIX.js +14 -0
- package/dist/node-runtime/settings-manager-GHPTUN7R.js +21 -0
- package/dist/node-runtime/src-BPQFJR76.js +2427 -0
- package/dist/node-runtime/subagent-executor-5Q5A4HJ2.js +8499 -0
- package/dist/node-runtime/summary-review-YSMXKITO.js +228 -0
- package/dist/node-runtime/tavily-WEZFVFP7.js +154 -0
- package/dist/node-runtime/timings-UAD5BEAS.js +16 -0
- package/dist/node-runtime/tool-renderer-MV5O452K.js +204 -0
- package/dist/node-runtime/update-cli-L3JIBH2U.js +70 -0
- package/dist/node-runtime/v4-5MNC3H7G.js +424 -0
- package/dist/node-runtime/video-extract-OYT5WKS5.js +304 -0
- package/dist/node-runtime/workspace-index-6DBXSTJ6.js +163 -0
- package/dist/node-runtime/youtube-extract-TQYKGFGS.js +264 -0
- package/dist/rpc.d.ts +3 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +18 -0
- package/dist/rpc.js.map +1 -0
- package/dist/startup/benchmark-request.d.ts +3 -0
- package/dist/startup/benchmark-request.d.ts.map +1 -0
- package/dist/startup/benchmark-request.js +65 -0
- package/dist/startup/benchmark-request.js.map +1 -0
- package/dist/startup/interactive-view.d.ts.map +1 -1
- package/dist/startup/interactive-view.js +1 -2
- package/dist/startup/interactive-view.js.map +1 -1
- package/dist/startup/startup-milestones.d.ts +1 -1
- package/dist/startup/startup-milestones.d.ts.map +1 -1
- package/dist/startup/startup-milestones.js.map +1 -1
- package/dist/utils/await-with-abort.d.ts +2 -0
- package/dist/utils/await-with-abort.d.ts.map +1 -0
- package/dist/utils/await-with-abort.js +19 -0
- package/dist/utils/await-with-abort.js.map +1 -0
- package/docs/development.md +5 -1
- package/docs/features.md +2 -2
- package/docs/interactive-startup.md +95 -48
- package/docs/keybindings.md +2 -2
- package/docs/terminal-setup.md +1 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +8 -8
|
@@ -1,46 +1,238 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { Type } from "typebox";
|
|
2
|
-
import { showStatus, showTools, reconnectServers, authenticateServer, logoutServer, openMcpAuthPanel, openMcpPanel, openMcpSetup } from "./commands.js";
|
|
3
3
|
import { loadMcpConfig } from "./config.js";
|
|
4
|
-
import { buildProxyDescription,
|
|
5
|
-
import {
|
|
6
|
-
import { loadMetadataCache } from "./metadata-cache.js";
|
|
7
|
-
import { executeAuthComplete, executeAuthStart, executeCall, executeConnect, executeDescribe, executeList, executeSearch, executeStatus, executeUiMessages } from "./proxy-modes.js";
|
|
4
|
+
import { buildProxyDescription, getMissingConfiguredDirectToolServers, resolveDirectTools } from "./direct-tools.js";
|
|
5
|
+
import { getMetadataCachePath, loadMetadataCache } from "./metadata-cache.js";
|
|
8
6
|
import { getConfigPathFromArgv, normalizeDirectToolInputSchema, truncateAtWord } from "./utils.js";
|
|
9
|
-
import { initializeOAuth, shutdownOAuth } from "./mcp-auth-flow.js";
|
|
10
7
|
import { createMcpDirectToolCallRenderer, renderMcpProxyToolCall, renderMcpToolResult } from "./tool-result-renderer.js";
|
|
11
8
|
import { toolErrorOverride } from "./error-signal.js";
|
|
9
|
+
import { abortable, throwIfAborted } from "./abort.js";
|
|
10
|
+
function shouldBackgroundAutostart(config, cache) {
|
|
11
|
+
const serverEntries = Object.entries(config.mcpServers);
|
|
12
|
+
if (serverEntries.length === 0)
|
|
13
|
+
return false;
|
|
14
|
+
if (!existsSync(getMetadataCachePath()))
|
|
15
|
+
return true;
|
|
16
|
+
for (const [, definition] of serverEntries) {
|
|
17
|
+
const mode = definition.lifecycle ?? "lazy";
|
|
18
|
+
if (mode === "keep-alive" || mode === "eager")
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
if (process.env.MCP_DIRECT_TOOLS === "__none__")
|
|
22
|
+
return false;
|
|
23
|
+
return getMissingConfiguredDirectToolServers(config, cache).length > 0;
|
|
24
|
+
}
|
|
12
25
|
export default function mcpAdapter(pi) {
|
|
13
26
|
let state = null;
|
|
14
27
|
let initPromise = null;
|
|
15
28
|
let lifecycleGeneration = 0;
|
|
16
|
-
|
|
29
|
+
let sessionAbort = new AbortController();
|
|
30
|
+
const initializingStates = new Set();
|
|
31
|
+
const shutdownPromises = new WeakMap();
|
|
32
|
+
let heavyModules = null;
|
|
33
|
+
let heavyModulesPromise = null;
|
|
34
|
+
const directExecutors = new Map();
|
|
35
|
+
function loadHeavyModules() {
|
|
36
|
+
if (heavyModules)
|
|
37
|
+
return Promise.resolve(heavyModules);
|
|
38
|
+
if (!heavyModulesPromise) {
|
|
39
|
+
heavyModulesPromise = (async () => {
|
|
40
|
+
const [init, authFlow, commands, proxyModes, directToolExecutor] = await Promise.all([
|
|
41
|
+
import("./init.js"),
|
|
42
|
+
import("./mcp-auth-flow.js"),
|
|
43
|
+
import("./commands.js"),
|
|
44
|
+
import("./proxy-modes.js"),
|
|
45
|
+
import("./direct-tool-executor.js"),
|
|
46
|
+
]);
|
|
47
|
+
const loaded = { init, authFlow, commands, proxyModes, directToolExecutor };
|
|
48
|
+
heavyModules = loaded;
|
|
49
|
+
return loaded;
|
|
50
|
+
})().catch((error) => {
|
|
51
|
+
heavyModulesPromise = null;
|
|
52
|
+
throw error;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return heavyModulesPromise;
|
|
56
|
+
}
|
|
57
|
+
function shutdownState(currentState, reason) {
|
|
17
58
|
if (!currentState)
|
|
59
|
+
return Promise.resolve();
|
|
60
|
+
const existing = shutdownPromises.get(currentState);
|
|
61
|
+
if (existing)
|
|
62
|
+
return existing;
|
|
63
|
+
const shutdown = (async () => {
|
|
64
|
+
if (currentState.uiServer) {
|
|
65
|
+
currentState.uiServer.close(reason);
|
|
66
|
+
currentState.uiServer = null;
|
|
67
|
+
}
|
|
68
|
+
let flushError;
|
|
69
|
+
try {
|
|
70
|
+
if (heavyModules) {
|
|
71
|
+
heavyModules.init.flushMetadataCache(currentState);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
flushError = error;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
await currentState.lifecycle.gracefulShutdown();
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (flushError) {
|
|
82
|
+
console.error("MCP: graceful shutdown failed after metadata flush error", error);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (flushError) {
|
|
89
|
+
throw flushError;
|
|
90
|
+
}
|
|
91
|
+
})();
|
|
92
|
+
shutdownPromises.set(currentState, shutdown);
|
|
93
|
+
return shutdown;
|
|
94
|
+
}
|
|
95
|
+
async function shutdownInitializingStates() {
|
|
96
|
+
const pending = [...initializingStates];
|
|
97
|
+
initializingStates.clear();
|
|
98
|
+
await Promise.all(pending.map((entry) => shutdownState(entry, "initialization_cancelled")));
|
|
99
|
+
}
|
|
100
|
+
async function shutdownLoadedRuntime() {
|
|
101
|
+
if (!heavyModules)
|
|
18
102
|
return;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
103
|
+
await heavyModules.authFlow.shutdownOAuth();
|
|
104
|
+
}
|
|
105
|
+
async function runInitialize(generation, sessionPi, ctx) {
|
|
106
|
+
const signal = sessionAbort.signal;
|
|
107
|
+
const heavy = await loadHeavyModules();
|
|
108
|
+
throwIfAborted(signal);
|
|
109
|
+
if (generation !== lifecycleGeneration) {
|
|
110
|
+
throw new Error("MCP initialization aborted (session changed)");
|
|
111
|
+
}
|
|
112
|
+
await heavy.authFlow.initializeOAuth().catch(err => {
|
|
113
|
+
console.error("MCP OAuth initialization failed:", err);
|
|
114
|
+
});
|
|
115
|
+
if (generation !== lifecycleGeneration) {
|
|
116
|
+
throw new Error("MCP initialization aborted (session changed)");
|
|
22
117
|
}
|
|
23
|
-
let
|
|
118
|
+
let partial;
|
|
24
119
|
try {
|
|
25
|
-
|
|
120
|
+
const initialized = await heavy.init.initializeMcp(sessionPi, ctx, {
|
|
121
|
+
signal,
|
|
122
|
+
onState: (entry) => {
|
|
123
|
+
partial = entry;
|
|
124
|
+
initializingStates.add(entry);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
if (!partial) {
|
|
128
|
+
partial = initialized;
|
|
129
|
+
initializingStates.add(initialized);
|
|
130
|
+
}
|
|
131
|
+
throwIfAborted(signal);
|
|
132
|
+
return initialized;
|
|
26
133
|
}
|
|
27
134
|
catch (error) {
|
|
28
|
-
|
|
135
|
+
if (partial) {
|
|
136
|
+
initializingStates.delete(partial);
|
|
137
|
+
await shutdownState(partial, "initialization_failed");
|
|
138
|
+
}
|
|
139
|
+
throw error;
|
|
29
140
|
}
|
|
30
|
-
|
|
31
|
-
|
|
141
|
+
finally {
|
|
142
|
+
if (partial)
|
|
143
|
+
initializingStates.delete(partial);
|
|
32
144
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
145
|
+
}
|
|
146
|
+
function startSessionInit(generation, sessionPi, ctx) {
|
|
147
|
+
const promise = runInitialize(generation, sessionPi, ctx);
|
|
148
|
+
initPromise = promise;
|
|
149
|
+
promise.then(async (nextState) => {
|
|
150
|
+
if (generation !== lifecycleGeneration || initPromise !== promise) {
|
|
151
|
+
try {
|
|
152
|
+
await shutdownState(nextState, "stale_session_start");
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
console.error("MCP: failed to clean stale session state", error);
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
36
158
|
}
|
|
37
|
-
|
|
38
|
-
|
|
159
|
+
state = nextState;
|
|
160
|
+
if (heavyModules) {
|
|
161
|
+
heavyModules.init.updateStatusBar(nextState);
|
|
162
|
+
}
|
|
163
|
+
initPromise = null;
|
|
164
|
+
}).catch(err => {
|
|
165
|
+
if (generation !== lifecycleGeneration) {
|
|
166
|
+
return;
|
|
39
167
|
}
|
|
168
|
+
if (initPromise !== promise && initPromise !== null) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
console.error("MCP initialization failed:", err);
|
|
172
|
+
initPromise = null;
|
|
173
|
+
});
|
|
174
|
+
return promise;
|
|
175
|
+
}
|
|
176
|
+
async function ensureState(sessionPi, ctx, signal) {
|
|
177
|
+
throwIfAborted(signal);
|
|
178
|
+
if (state)
|
|
179
|
+
return state;
|
|
180
|
+
const generation = lifecycleGeneration;
|
|
181
|
+
if (!initPromise) {
|
|
182
|
+
startSessionInit(generation, sessionPi, ctx);
|
|
40
183
|
}
|
|
41
|
-
|
|
42
|
-
|
|
184
|
+
const promise = initPromise;
|
|
185
|
+
if (!promise) {
|
|
186
|
+
throw new Error("MCP not initialized");
|
|
43
187
|
}
|
|
188
|
+
try {
|
|
189
|
+
const nextState = await abortable(promise, signal);
|
|
190
|
+
if (generation !== lifecycleGeneration) {
|
|
191
|
+
throw new Error("MCP initialization aborted (session changed)");
|
|
192
|
+
}
|
|
193
|
+
if (state)
|
|
194
|
+
return state;
|
|
195
|
+
state = nextState;
|
|
196
|
+
if (initPromise === promise) {
|
|
197
|
+
initPromise = null;
|
|
198
|
+
}
|
|
199
|
+
return state;
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (initPromise === promise && !signal?.aborted) {
|
|
203
|
+
initPromise = null;
|
|
204
|
+
}
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function assertCurrentState(currentState) {
|
|
209
|
+
if (currentState !== state)
|
|
210
|
+
throw new Error("MCP session changed before execution");
|
|
211
|
+
}
|
|
212
|
+
function createLazyDirectToolExecute(spec) {
|
|
213
|
+
return async function execute(toolCallId, params, incomingSignal, onUpdate, ctx) {
|
|
214
|
+
const signal = incomingSignal ? AbortSignal.any([incomingSignal, sessionAbort.signal]) : sessionAbort.signal;
|
|
215
|
+
let currentState;
|
|
216
|
+
try {
|
|
217
|
+
currentState = await ensureState(pi, ctx, signal);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
221
|
+
return {
|
|
222
|
+
content: [{ type: "text", text: `MCP initialization failed: ${message}` }],
|
|
223
|
+
details: { error: "init_failed", message },
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const heavy = await loadHeavyModules();
|
|
227
|
+
throwIfAborted(signal);
|
|
228
|
+
assertCurrentState(currentState);
|
|
229
|
+
let executor = directExecutors.get(spec.prefixedName);
|
|
230
|
+
if (!executor) {
|
|
231
|
+
executor = heavy.directToolExecutor.createDirectToolExecutor(() => currentState, () => null, spec);
|
|
232
|
+
directExecutors.set(spec.prefixedName, executor);
|
|
233
|
+
}
|
|
234
|
+
return executor(toolCallId, params, signal, onUpdate, ctx);
|
|
235
|
+
};
|
|
44
236
|
}
|
|
45
237
|
const earlyConfigPath = getConfigPathFromArgv();
|
|
46
238
|
const earlyConfig = loadMcpConfig(earlyConfigPath);
|
|
@@ -61,7 +253,7 @@ export default function mcpAdapter(pi) {
|
|
|
61
253
|
description: spec.description || "(no description)",
|
|
62
254
|
promptSnippet: truncateAtWord(spec.description, 100) || `MCP tool from ${spec.serverName}`,
|
|
63
255
|
parameters: Type.Unsafe(normalizeDirectToolInputSchema(spec.inputSchema)),
|
|
64
|
-
execute:
|
|
256
|
+
execute: createLazyDirectToolExecute(spec),
|
|
65
257
|
renderCall: createMcpDirectToolCallRenderer(spec.prefixedName),
|
|
66
258
|
renderResult: renderMcpToolResult,
|
|
67
259
|
});
|
|
@@ -73,13 +265,17 @@ export default function mcpAdapter(pi) {
|
|
|
73
265
|
});
|
|
74
266
|
pi.on("session_start", async (_event, ctx) => {
|
|
75
267
|
const generation = ++lifecycleGeneration;
|
|
268
|
+
sessionAbort.abort(new Error("MCP session changed"));
|
|
269
|
+
sessionAbort = new AbortController();
|
|
76
270
|
const previousState = state;
|
|
77
271
|
state = null;
|
|
78
272
|
initPromise = null;
|
|
273
|
+
directExecutors.clear();
|
|
79
274
|
try {
|
|
80
275
|
await Promise.all([
|
|
81
276
|
shutdownState(previousState, "session_restart"),
|
|
82
|
-
|
|
277
|
+
shutdownInitializingStates(),
|
|
278
|
+
shutdownLoadedRuntime(),
|
|
83
279
|
]);
|
|
84
280
|
}
|
|
85
281
|
catch (error) {
|
|
@@ -88,44 +284,26 @@ export default function mcpAdapter(pi) {
|
|
|
88
284
|
if (generation !== lifecycleGeneration) {
|
|
89
285
|
return;
|
|
90
286
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
await shutdownState(nextState, "stale_session_start");
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
console.error("MCP: failed to clean stale session state", error);
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
state = nextState;
|
|
107
|
-
updateStatusBar(nextState);
|
|
108
|
-
initPromise = null;
|
|
109
|
-
}).catch(err => {
|
|
110
|
-
if (generation !== lifecycleGeneration) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (initPromise !== promise && initPromise !== null) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
console.error("MCP initialization failed:", err);
|
|
117
|
-
initPromise = null;
|
|
118
|
-
});
|
|
287
|
+
const configPath = pi.getFlag("mcp-config") ?? earlyConfigPath;
|
|
288
|
+
const sessionConfig = loadMcpConfig(configPath, ctx.cwd);
|
|
289
|
+
const sessionCache = loadMetadataCache();
|
|
290
|
+
if (!shouldBackgroundAutostart(sessionConfig, sessionCache)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
startSessionInit(generation, pi, ctx);
|
|
119
294
|
});
|
|
120
295
|
pi.on("session_shutdown", async () => {
|
|
121
296
|
++lifecycleGeneration;
|
|
297
|
+
sessionAbort.abort(new Error("MCP session ended"));
|
|
122
298
|
const currentState = state;
|
|
123
299
|
state = null;
|
|
124
300
|
initPromise = null;
|
|
301
|
+
directExecutors.clear();
|
|
125
302
|
try {
|
|
126
303
|
await Promise.all([
|
|
127
304
|
shutdownState(currentState, "session_shutdown"),
|
|
128
|
-
|
|
305
|
+
shutdownInitializingStates(),
|
|
306
|
+
shutdownLoadedRuntime(),
|
|
129
307
|
]);
|
|
130
308
|
}
|
|
131
309
|
catch (error) {
|
|
@@ -137,35 +315,31 @@ export default function mcpAdapter(pi) {
|
|
|
137
315
|
pi.registerCommand("mcp", {
|
|
138
316
|
description: "Show MCP server status",
|
|
139
317
|
handler: async (args, ctx) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
146
|
-
if (ctx.hasUI)
|
|
147
|
-
ctx.ui.notify(`MCP initialization failed: ${message}`, "error");
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
318
|
+
let currentState;
|
|
319
|
+
try {
|
|
320
|
+
currentState = await ensureState(pi, ctx);
|
|
150
321
|
}
|
|
151
|
-
|
|
322
|
+
catch (error) {
|
|
323
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
152
324
|
if (ctx.hasUI)
|
|
153
|
-
ctx.ui.notify(
|
|
325
|
+
ctx.ui.notify(`MCP initialization failed: ${message}`, "error");
|
|
154
326
|
return;
|
|
155
327
|
}
|
|
328
|
+
const heavy = await loadHeavyModules();
|
|
329
|
+
assertCurrentState(currentState);
|
|
156
330
|
const parts = args?.trim()?.split(/\s+/) ?? [];
|
|
157
331
|
const subcommand = parts[0] ?? "";
|
|
158
332
|
const targetServer = parts[1];
|
|
159
333
|
const rest = parts.slice(1).join(" ");
|
|
160
334
|
switch (subcommand) {
|
|
161
335
|
case "reconnect":
|
|
162
|
-
await reconnectServers(
|
|
336
|
+
await heavy.commands.reconnectServers(currentState, ctx, targetServer);
|
|
163
337
|
break;
|
|
164
338
|
case "tools":
|
|
165
|
-
await showTools(
|
|
339
|
+
await heavy.commands.showTools(currentState, ctx);
|
|
166
340
|
break;
|
|
167
341
|
case "setup": {
|
|
168
|
-
const result = await openMcpSetup(
|
|
342
|
+
const result = await heavy.commands.openMcpSetup(currentState, pi, ctx, earlyConfigPath, "setup");
|
|
169
343
|
if (result?.configChanged) {
|
|
170
344
|
await ctx.reload();
|
|
171
345
|
return;
|
|
@@ -179,21 +353,21 @@ export default function mcpAdapter(pi) {
|
|
|
179
353
|
ctx.ui.notify("Usage: /mcp logout <server>", "error");
|
|
180
354
|
return;
|
|
181
355
|
}
|
|
182
|
-
await logoutServer(serverName,
|
|
356
|
+
await heavy.commands.logoutServer(serverName, currentState, ctx);
|
|
183
357
|
break;
|
|
184
358
|
}
|
|
185
359
|
case "status":
|
|
186
360
|
case "":
|
|
187
361
|
default:
|
|
188
362
|
if (ctx.hasUI) {
|
|
189
|
-
const result = await openMcpPanel(
|
|
363
|
+
const result = await heavy.commands.openMcpPanel(currentState, pi, ctx, earlyConfigPath);
|
|
190
364
|
if (result?.configChanged) {
|
|
191
365
|
await ctx.reload();
|
|
192
366
|
return;
|
|
193
367
|
}
|
|
194
368
|
}
|
|
195
369
|
else {
|
|
196
|
-
await showStatus(
|
|
370
|
+
await heavy.commands.showStatus(currentState, ctx);
|
|
197
371
|
}
|
|
198
372
|
break;
|
|
199
373
|
}
|
|
@@ -206,27 +380,23 @@ export default function mcpAdapter(pi) {
|
|
|
206
380
|
if (!serverName && !ctx.hasUI) {
|
|
207
381
|
return;
|
|
208
382
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
215
|
-
if (ctx.hasUI)
|
|
216
|
-
ctx.ui.notify(`MCP initialization failed: ${message}`, "error");
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
383
|
+
let currentState;
|
|
384
|
+
try {
|
|
385
|
+
currentState = await ensureState(pi, ctx);
|
|
219
386
|
}
|
|
220
|
-
|
|
387
|
+
catch (error) {
|
|
388
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
221
389
|
if (ctx.hasUI)
|
|
222
|
-
ctx.ui.notify(
|
|
390
|
+
ctx.ui.notify(`MCP initialization failed: ${message}`, "error");
|
|
223
391
|
return;
|
|
224
392
|
}
|
|
393
|
+
const heavy = await loadHeavyModules();
|
|
394
|
+
assertCurrentState(currentState);
|
|
225
395
|
if (!serverName) {
|
|
226
|
-
await openMcpAuthPanel(
|
|
396
|
+
await heavy.commands.openMcpAuthPanel(currentState, pi, ctx, earlyConfigPath);
|
|
227
397
|
return;
|
|
228
398
|
}
|
|
229
|
-
await authenticateServer(serverName,
|
|
399
|
+
await heavy.commands.authenticateServer(serverName, currentState.config, ctx);
|
|
230
400
|
},
|
|
231
401
|
});
|
|
232
402
|
if (shouldRegisterProxyTool) {
|
|
@@ -248,7 +418,8 @@ export default function mcpAdapter(pi) {
|
|
|
248
418
|
action: Type.Optional(Type.String({ description: "Action: 'ui-messages', 'auth-start', or 'auth-complete'" })),
|
|
249
419
|
}),
|
|
250
420
|
renderResult: renderMcpToolResult,
|
|
251
|
-
async execute(_toolCallId, params,
|
|
421
|
+
async execute(_toolCallId, params, incomingSignal, _onUpdate, ctx) {
|
|
422
|
+
const signal = incomingSignal ? AbortSignal.any([incomingSignal, sessionAbort.signal]) : sessionAbort.signal;
|
|
252
423
|
let parsedArgs;
|
|
253
424
|
if (params.args) {
|
|
254
425
|
try {
|
|
@@ -265,26 +436,22 @@ export default function mcpAdapter(pi) {
|
|
|
265
436
|
throw error;
|
|
266
437
|
}
|
|
267
438
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
catch (error) {
|
|
273
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
274
|
-
return {
|
|
275
|
-
content: [{ type: "text", text: `MCP initialization failed: ${message}` }],
|
|
276
|
-
details: { error: "init_failed", message },
|
|
277
|
-
};
|
|
278
|
-
}
|
|
439
|
+
let currentState;
|
|
440
|
+
try {
|
|
441
|
+
currentState = await ensureState(pi, ctx, signal);
|
|
279
442
|
}
|
|
280
|
-
|
|
443
|
+
catch (error) {
|
|
444
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
281
445
|
return {
|
|
282
|
-
content: [{ type: "text", text:
|
|
283
|
-
details: { error: "
|
|
446
|
+
content: [{ type: "text", text: `MCP initialization failed: ${message}` }],
|
|
447
|
+
details: { error: "init_failed", message },
|
|
284
448
|
};
|
|
285
449
|
}
|
|
450
|
+
const heavy = await loadHeavyModules();
|
|
451
|
+
throwIfAborted(signal);
|
|
452
|
+
assertCurrentState(currentState);
|
|
286
453
|
if (params.action === "ui-messages") {
|
|
287
|
-
return executeUiMessages(
|
|
454
|
+
return heavy.proxyModes.executeUiMessages(currentState);
|
|
288
455
|
}
|
|
289
456
|
if (params.action === "auth-start") {
|
|
290
457
|
if (!params.server) {
|
|
@@ -293,7 +460,7 @@ export default function mcpAdapter(pi) {
|
|
|
293
460
|
details: { mode: "auth-start", error: "missing_server" },
|
|
294
461
|
};
|
|
295
462
|
}
|
|
296
|
-
return executeAuthStart(
|
|
463
|
+
return heavy.proxyModes.executeAuthStart(currentState, params.server);
|
|
297
464
|
}
|
|
298
465
|
if (params.action === "auth-complete") {
|
|
299
466
|
if (!params.server) {
|
|
@@ -309,24 +476,24 @@ export default function mcpAdapter(pi) {
|
|
|
309
476
|
details: { mode: "auth-complete", error: "missing_input" },
|
|
310
477
|
};
|
|
311
478
|
}
|
|
312
|
-
return executeAuthComplete(
|
|
479
|
+
return heavy.proxyModes.executeAuthComplete(currentState, params.server, input);
|
|
313
480
|
}
|
|
314
481
|
if (params.tool) {
|
|
315
|
-
return executeCall(
|
|
482
|
+
return heavy.proxyModes.executeCall(currentState, params.tool, parsedArgs, params.server, getPiTools, signal);
|
|
316
483
|
}
|
|
317
484
|
if (params.connect) {
|
|
318
|
-
return executeConnect(
|
|
485
|
+
return heavy.proxyModes.executeConnect(currentState, params.connect, signal);
|
|
319
486
|
}
|
|
320
487
|
if (params.describe) {
|
|
321
|
-
return executeDescribe(
|
|
488
|
+
return heavy.proxyModes.executeDescribe(currentState, params.describe);
|
|
322
489
|
}
|
|
323
490
|
if (params.search) {
|
|
324
|
-
return executeSearch(
|
|
491
|
+
return heavy.proxyModes.executeSearch(currentState, params.search, params.regex, params.server, params.includeSchemas);
|
|
325
492
|
}
|
|
326
493
|
if (params.server) {
|
|
327
|
-
return executeList(
|
|
494
|
+
return heavy.proxyModes.executeList(currentState, params.server);
|
|
328
495
|
}
|
|
329
|
-
return executeStatus(
|
|
496
|
+
return heavy.proxyModes.executeStatus(currentState);
|
|
330
497
|
},
|
|
331
498
|
});
|
|
332
499
|
}
|