mindweave 0.0.1 → 2.1.2
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/LICENSE +190 -0
- package/README.md +171 -14
- package/dist/alternator/chassis/cache.js +47 -0
- package/dist/alternator/chassis/cache.js.map +1 -0
- package/dist/alternator/chassis/domRefs.js +53 -0
- package/dist/alternator/chassis/domRefs.js.map +1 -0
- package/dist/alternator/chassis/extractWorker.js +65 -0
- package/dist/alternator/chassis/extractWorker.js.map +1 -0
- package/dist/alternator/chassis/graph.js +221 -0
- package/dist/alternator/chassis/graph.js.map +1 -0
- package/dist/alternator/chassis/index.js +463 -0
- package/dist/alternator/chassis/index.js.map +1 -0
- package/dist/alternator/chassis/isolation.js +336 -0
- package/dist/alternator/chassis/isolation.js.map +1 -0
- package/dist/alternator/chassis/langCases.js +69 -0
- package/dist/alternator/chassis/langCases.js.map +1 -0
- package/dist/alternator/chassis/lsp.js +469 -0
- package/dist/alternator/chassis/lsp.js.map +1 -0
- package/dist/alternator/chassis/markup.js +262 -0
- package/dist/alternator/chassis/markup.js.map +1 -0
- package/dist/alternator/chassis/provision.js +198 -0
- package/dist/alternator/chassis/provision.js.map +1 -0
- package/dist/alternator/chassis/rank.js +72 -0
- package/dist/alternator/chassis/rank.js.map +1 -0
- package/dist/alternator/chassis/servers.js +215 -0
- package/dist/alternator/chassis/servers.js.map +1 -0
- package/dist/alternator/chassis/treesitter.js +608 -0
- package/dist/alternator/chassis/treesitter.js.map +1 -0
- package/dist/alternator/chassis/types.js +24 -0
- package/dist/alternator/chassis/types.js.map +1 -0
- package/dist/alternator/lane.js +67 -0
- package/dist/alternator/lane.js.map +1 -0
- package/dist/cli/App.js +2586 -0
- package/dist/cli/App.js.map +1 -0
- package/dist/cli/altScreen.js +67 -0
- package/dist/cli/altScreen.js.map +1 -0
- package/dist/cli/approvalChannel.js +72 -0
- package/dist/cli/approvalChannel.js.map +1 -0
- package/dist/cli/attachments.js +188 -0
- package/dist/cli/attachments.js.map +1 -0
- package/dist/cli/bootstrap.js +279 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/chatAnchor.js +94 -0
- package/dist/cli/chatAnchor.js.map +1 -0
- package/dist/cli/commandArgs.js +79 -0
- package/dist/cli/commandArgs.js.map +1 -0
- package/dist/cli/commandRoute.js +78 -0
- package/dist/cli/commandRoute.js.map +1 -0
- package/dist/cli/compaction.js +69 -0
- package/dist/cli/compaction.js.map +1 -0
- package/dist/cli/components/ApprovalBox.js +100 -0
- package/dist/cli/components/ApprovalBox.js.map +1 -0
- package/dist/cli/components/BlockView.js +128 -0
- package/dist/cli/components/BlockView.js.map +1 -0
- package/dist/cli/components/FirstRunFrame.js +41 -0
- package/dist/cli/components/FirstRunFrame.js.map +1 -0
- package/dist/cli/components/KeyManager.js +197 -0
- package/dist/cli/components/KeyManager.js.map +1 -0
- package/dist/cli/components/KeySetup.js +125 -0
- package/dist/cli/components/KeySetup.js.map +1 -0
- package/dist/cli/components/MenuFrame.js +24 -0
- package/dist/cli/components/MenuFrame.js.map +1 -0
- package/dist/cli/components/Picker.js +82 -0
- package/dist/cli/components/Picker.js.map +1 -0
- package/dist/cli/components/PromptInput.js +509 -0
- package/dist/cli/components/PromptInput.js.map +1 -0
- package/dist/cli/components/SubagentView.js +86 -0
- package/dist/cli/components/SubagentView.js.map +1 -0
- package/dist/cli/components/ToolGroup.js +60 -0
- package/dist/cli/components/ToolGroup.js.map +1 -0
- package/dist/cli/components/ToolLine.js +123 -0
- package/dist/cli/components/ToolLine.js.map +1 -0
- package/dist/cli/components/TrustGate.js +37 -0
- package/dist/cli/components/TrustGate.js.map +1 -0
- package/dist/cli/costView.js +40 -0
- package/dist/cli/costView.js.map +1 -0
- package/dist/cli/frameRate.js +30 -0
- package/dist/cli/frameRate.js.map +1 -0
- package/dist/cli/framebuffer/paint.js +165 -0
- package/dist/cli/framebuffer/paint.js.map +1 -0
- package/dist/cli/framebuffer/parse.js +266 -0
- package/dist/cli/framebuffer/parse.js.map +1 -0
- package/dist/cli/framebuffer/screen.js +196 -0
- package/dist/cli/framebuffer/screen.js.map +1 -0
- package/dist/cli/framebuffer/writer.js +139 -0
- package/dist/cli/framebuffer/writer.js.map +1 -0
- package/dist/cli/groupReveal.js +51 -0
- package/dist/cli/groupReveal.js.map +1 -0
- package/dist/cli/help.js +55 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/inputView.js +105 -0
- package/dist/cli/inputView.js.map +1 -0
- package/dist/cli/keyManager.js +65 -0
- package/dist/cli/keyManager.js.map +1 -0
- package/dist/cli/keySetup.js +35 -0
- package/dist/cli/keySetup.js.map +1 -0
- package/dist/cli/keyStore.js +73 -0
- package/dist/cli/keyStore.js.map +1 -0
- package/dist/cli/markdown.js +460 -0
- package/dist/cli/markdown.js.map +1 -0
- package/dist/cli/messageQueue.js +96 -0
- package/dist/cli/messageQueue.js.map +1 -0
- package/dist/cli/modes.js +90 -0
- package/dist/cli/modes.js.map +1 -0
- package/dist/cli/mouse.js +78 -0
- package/dist/cli/mouse.js.map +1 -0
- package/dist/cli/pasteAssembler.js +44 -0
- package/dist/cli/pasteAssembler.js.map +1 -0
- package/dist/cli/pathComplete.js +39 -0
- package/dist/cli/pathComplete.js.map +1 -0
- package/dist/cli/perfLog.js +90 -0
- package/dist/cli/perfLog.js.map +1 -0
- package/dist/cli/reveal.js +32 -0
- package/dist/cli/reveal.js.map +1 -0
- package/dist/cli/revealPace.js +59 -0
- package/dist/cli/revealPace.js.map +1 -0
- package/dist/cli/sessionCarry.js +19 -0
- package/dist/cli/sessionCarry.js.map +1 -0
- package/dist/cli/smoothScroll.js +74 -0
- package/dist/cli/smoothScroll.js.map +1 -0
- package/dist/cli/startupArgs.js +96 -0
- package/dist/cli/startupArgs.js.map +1 -0
- package/dist/cli/terminalRestore.js +34 -0
- package/dist/cli/terminalRestore.js.map +1 -0
- package/dist/cli/toolDisplay.js +219 -0
- package/dist/cli/toolDisplay.js.map +1 -0
- package/dist/cli/toolItems.js +65 -0
- package/dist/cli/toolItems.js.map +1 -0
- package/dist/cli/transcript.js +351 -0
- package/dist/cli/transcript.js.map +1 -0
- package/dist/cli/trust.js +79 -0
- package/dist/cli/trust.js.map +1 -0
- package/dist/cli/updateCheck.js +107 -0
- package/dist/cli/updateCheck.js.map +1 -0
- package/dist/cli/version.js +39 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/viewport.js +179 -0
- package/dist/cli/viewport.js.map +1 -0
- package/dist/cli/virtualWindow.js +103 -0
- package/dist/cli/virtualWindow.js.map +1 -0
- package/dist/cli/workingVerb.js +37 -0
- package/dist/cli/workingVerb.js.map +1 -0
- package/dist/cli/wrap.js +145 -0
- package/dist/cli/wrap.js.map +1 -0
- package/dist/drivers/anthropic/cachePoints.js +77 -0
- package/dist/drivers/anthropic/cachePoints.js.map +1 -0
- package/dist/drivers/anthropic/client.js +432 -0
- package/dist/drivers/anthropic/client.js.map +1 -0
- package/dist/drivers/anthropic/index.js +10 -0
- package/dist/drivers/anthropic/index.js.map +1 -0
- package/dist/drivers/anthropic/manifest.js +221 -0
- package/dist/drivers/anthropic/manifest.js.map +1 -0
- package/dist/drivers/cerebras/client.js +69 -0
- package/dist/drivers/cerebras/client.js.map +1 -0
- package/dist/drivers/cerebras/index.js +5 -0
- package/dist/drivers/cerebras/index.js.map +1 -0
- package/dist/drivers/cerebras/manifest.js +140 -0
- package/dist/drivers/cerebras/manifest.js.map +1 -0
- package/dist/drivers/clientId.js +41 -0
- package/dist/drivers/clientId.js.map +1 -0
- package/dist/drivers/contextOverflow.js +77 -0
- package/dist/drivers/contextOverflow.js.map +1 -0
- package/dist/drivers/deepseek/client.js +168 -0
- package/dist/drivers/deepseek/client.js.map +1 -0
- package/dist/drivers/deepseek/index.js +16 -0
- package/dist/drivers/deepseek/index.js.map +1 -0
- package/dist/drivers/deepseek/inlineTools.js +46 -0
- package/dist/drivers/deepseek/inlineTools.js.map +1 -0
- package/dist/drivers/deepseek/manifest.js +166 -0
- package/dist/drivers/deepseek/manifest.js.map +1 -0
- package/dist/drivers/gemini/client.js +38 -0
- package/dist/drivers/gemini/client.js.map +1 -0
- package/dist/drivers/gemini/index.js +5 -0
- package/dist/drivers/gemini/index.js.map +1 -0
- package/dist/drivers/gemini/manifest.js +150 -0
- package/dist/drivers/gemini/manifest.js.map +1 -0
- package/dist/drivers/glm/client.js +90 -0
- package/dist/drivers/glm/client.js.map +1 -0
- package/dist/drivers/glm/index.js +9 -0
- package/dist/drivers/glm/index.js.map +1 -0
- package/dist/drivers/glm/manifest.js +183 -0
- package/dist/drivers/glm/manifest.js.map +1 -0
- package/dist/drivers/groq/client.js +80 -0
- package/dist/drivers/groq/client.js.map +1 -0
- package/dist/drivers/groq/index.js +5 -0
- package/dist/drivers/groq/index.js.map +1 -0
- package/dist/drivers/groq/manifest.js +160 -0
- package/dist/drivers/groq/manifest.js.map +1 -0
- package/dist/drivers/kimi/client.js +82 -0
- package/dist/drivers/kimi/client.js.map +1 -0
- package/dist/drivers/kimi/index.js +9 -0
- package/dist/drivers/kimi/index.js.map +1 -0
- package/dist/drivers/kimi/manifest.js +168 -0
- package/dist/drivers/kimi/manifest.js.map +1 -0
- package/dist/drivers/meta/client.js +30 -0
- package/dist/drivers/meta/client.js.map +1 -0
- package/dist/drivers/meta/index.js +5 -0
- package/dist/drivers/meta/index.js.map +1 -0
- package/dist/drivers/meta/manifest.js +101 -0
- package/dist/drivers/meta/manifest.js.map +1 -0
- package/dist/drivers/minimax/client.js +36 -0
- package/dist/drivers/minimax/client.js.map +1 -0
- package/dist/drivers/minimax/index.js +5 -0
- package/dist/drivers/minimax/index.js.map +1 -0
- package/dist/drivers/minimax/manifest.js +120 -0
- package/dist/drivers/minimax/manifest.js.map +1 -0
- package/dist/drivers/mistral/client.js +54 -0
- package/dist/drivers/mistral/client.js.map +1 -0
- package/dist/drivers/mistral/index.js +5 -0
- package/dist/drivers/mistral/index.js.map +1 -0
- package/dist/drivers/mistral/manifest.js +118 -0
- package/dist/drivers/mistral/manifest.js.map +1 -0
- package/dist/drivers/openai/client.js +290 -0
- package/dist/drivers/openai/client.js.map +1 -0
- package/dist/drivers/openai/index.js +9 -0
- package/dist/drivers/openai/index.js.map +1 -0
- package/dist/drivers/openai/manifest.js +133 -0
- package/dist/drivers/openai/manifest.js.map +1 -0
- package/dist/drivers/openaiCompat/wire.js +493 -0
- package/dist/drivers/openaiCompat/wire.js.map +1 -0
- package/dist/drivers/partialTurn.js +23 -0
- package/dist/drivers/partialTurn.js.map +1 -0
- package/dist/drivers/providerError.js +181 -0
- package/dist/drivers/providerError.js.map +1 -0
- package/dist/drivers/qwen/client.js +93 -0
- package/dist/drivers/qwen/client.js.map +1 -0
- package/dist/drivers/qwen/index.js +9 -0
- package/dist/drivers/qwen/index.js.map +1 -0
- package/dist/drivers/qwen/manifest.js +146 -0
- package/dist/drivers/qwen/manifest.js.map +1 -0
- package/dist/drivers/registry.js +177 -0
- package/dist/drivers/registry.js.map +1 -0
- package/dist/drivers/retryPolicy.js +129 -0
- package/dist/drivers/retryPolicy.js.map +1 -0
- package/dist/drivers/searchBlocks.js +61 -0
- package/dist/drivers/searchBlocks.js.map +1 -0
- package/dist/drivers/types.js +2 -0
- package/dist/drivers/types.js.map +1 -0
- package/dist/drivers/xai/client.js +63 -0
- package/dist/drivers/xai/client.js.map +1 -0
- package/dist/drivers/xai/index.js +5 -0
- package/dist/drivers/xai/index.js.map +1 -0
- package/dist/drivers/xai/manifest.js +137 -0
- package/dist/drivers/xai/manifest.js.map +1 -0
- package/dist/dynamo/_probe.tmp.js +20 -0
- package/dist/dynamo/_probe.tmp.js.map +1 -0
- package/dist/dynamo/cacheBreak.js +88 -0
- package/dist/dynamo/cacheBreak.js.map +1 -0
- package/dist/dynamo/contextWindow.js +243 -0
- package/dist/dynamo/contextWindow.js.map +1 -0
- package/dist/dynamo/engine.js +2011 -0
- package/dist/dynamo/engine.js.map +1 -0
- package/dist/dynamo/guard.js +132 -0
- package/dist/dynamo/guard.js.map +1 -0
- package/dist/dynamo/liveMeter.js +58 -0
- package/dist/dynamo/liveMeter.js.map +1 -0
- package/dist/dynamo/model.js +172 -0
- package/dist/dynamo/model.js.map +1 -0
- package/dist/dynamo/planArtifact.js +125 -0
- package/dist/dynamo/planArtifact.js.map +1 -0
- package/dist/dynamo/pricing.js +140 -0
- package/dist/dynamo/pricing.js.map +1 -0
- package/dist/dynamo/prompt.js +264 -0
- package/dist/dynamo/prompt.js.map +1 -0
- package/dist/dynamo/spend.js +45 -0
- package/dist/dynamo/spend.js.map +1 -0
- package/dist/dynamo/verify.js +483 -0
- package/dist/dynamo/verify.js.map +1 -0
- package/dist/governor/forbidden.js +181 -0
- package/dist/governor/forbidden.js.map +1 -0
- package/dist/governor/freshness.js +83 -0
- package/dist/governor/freshness.js.map +1 -0
- package/dist/governor/frontmatter.js +38 -0
- package/dist/governor/frontmatter.js.map +1 -0
- package/dist/governor/glob.js +75 -0
- package/dist/governor/glob.js.map +1 -0
- package/dist/governor/index.js +87 -0
- package/dist/governor/index.js.map +1 -0
- package/dist/governor/rules.js +80 -0
- package/dist/governor/rules.js.map +1 -0
- package/dist/governor/scope.js +91 -0
- package/dist/governor/scope.js.map +1 -0
- package/dist/governor/skills.js +176 -0
- package/dist/governor/skills.js.map +1 -0
- package/dist/governor/types.js +16 -0
- package/dist/governor/types.js.map +1 -0
- package/dist/governor/write.js +182 -0
- package/dist/governor/write.js.map +1 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/catalog.js +232 -0
- package/dist/mcp/catalog.js.map +1 -0
- package/dist/mcp/config.js +116 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/configWrite.js +254 -0
- package/dist/mcp/configWrite.js.map +1 -0
- package/dist/mcp/connection.js +504 -0
- package/dist/mcp/connection.js.map +1 -0
- package/dist/mcp/deferred.js +104 -0
- package/dist/mcp/deferred.js.map +1 -0
- package/dist/mcp/discover.js +128 -0
- package/dist/mcp/discover.js.map +1 -0
- package/dist/mcp/manager.js +679 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/paramHeaders.js +163 -0
- package/dist/mcp/paramHeaders.js.map +1 -0
- package/dist/mcp/prompts.js +136 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/protocol.js +171 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/resources.js +119 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/resultStore.js +180 -0
- package/dist/mcp/resultStore.js.map +1 -0
- package/dist/mcp/subscriptions.js +74 -0
- package/dist/mcp/subscriptions.js.map +1 -0
- package/dist/mcp/transport/headerValue.js +40 -0
- package/dist/mcp/transport/headerValue.js.map +1 -0
- package/dist/mcp/transport/http.js +321 -0
- package/dist/mcp/transport/http.js.map +1 -0
- package/dist/mcp/transport/stdio.js +234 -0
- package/dist/mcp/transport/stdio.js.map +1 -0
- package/dist/mcp/transport/types.js +27 -0
- package/dist/mcp/transport/types.js.map +1 -0
- package/dist/mcp/trust.js +98 -0
- package/dist/mcp/trust.js.map +1 -0
- package/dist/mcp/trustStore.js +55 -0
- package/dist/mcp/trustStore.js.map +1 -0
- package/dist/memory/autoMemory.js +340 -0
- package/dist/memory/autoMemory.js.map +1 -0
- package/dist/memory/compaction.js +513 -0
- package/dist/memory/compaction.js.map +1 -0
- package/dist/memory/images.js +173 -0
- package/dist/memory/images.js.map +1 -0
- package/dist/memory/presence.js +59 -0
- package/dist/memory/presence.js.map +1 -0
- package/dist/memory/projectNotes.js +247 -0
- package/dist/memory/projectNotes.js.map +1 -0
- package/dist/memory/restore.js +72 -0
- package/dist/memory/restore.js.map +1 -0
- package/dist/memory/session.js +472 -0
- package/dist/memory/session.js.map +1 -0
- package/dist/memory/sessionMemory.js +142 -0
- package/dist/memory/sessionMemory.js.map +1 -0
- package/dist/memory/sessionMemoryCompact.js +136 -0
- package/dist/memory/sessionMemoryCompact.js.map +1 -0
- package/dist/memory/store.js +217 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/types.js +14 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/workingSet.js +383 -0
- package/dist/memory/workingSet.js.map +1 -0
- package/dist/project/context.js +425 -0
- package/dist/project/context.js.map +1 -0
- package/dist/tools/approval.js +189 -0
- package/dist/tools/approval.js.map +1 -0
- package/dist/tools/askUser.js +103 -0
- package/dist/tools/askUser.js.map +1 -0
- package/dist/tools/atomicWrite.js +151 -0
- package/dist/tools/atomicWrite.js.map +1 -0
- package/dist/tools/backgroundShells.js +468 -0
- package/dist/tools/backgroundShells.js.map +1 -0
- package/dist/tools/captureSweep.js +77 -0
- package/dist/tools/captureSweep.js.map +1 -0
- package/dist/tools/chassisMux.js +92 -0
- package/dist/tools/chassisMux.js.map +1 -0
- package/dist/tools/checkpoints.js +328 -0
- package/dist/tools/checkpoints.js.map +1 -0
- package/dist/tools/codeIntel.js +267 -0
- package/dist/tools/codeIntel.js.map +1 -0
- package/dist/tools/deferredNative.js +121 -0
- package/dist/tools/deferredNative.js.map +1 -0
- package/dist/tools/detail.js +135 -0
- package/dist/tools/detail.js.map +1 -0
- package/dist/tools/diagnostics.js +174 -0
- package/dist/tools/diagnostics.js.map +1 -0
- package/dist/tools/edit.js +167 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/editCore.js +283 -0
- package/dist/tools/editCore.js.map +1 -0
- package/dist/tools/editFile.js +183 -0
- package/dist/tools/editFile.js.map +1 -0
- package/dist/tools/editRipple.js +126 -0
- package/dist/tools/editRipple.js.map +1 -0
- package/dist/tools/editTarget.js +131 -0
- package/dist/tools/editTarget.js.map +1 -0
- package/dist/tools/editWindow.js +49 -0
- package/dist/tools/editWindow.js.map +1 -0
- package/dist/tools/eol.js +56 -0
- package/dist/tools/eol.js.map +1 -0
- package/dist/tools/exitPlan.js +175 -0
- package/dist/tools/exitPlan.js.map +1 -0
- package/dist/tools/focus.js +42 -0
- package/dist/tools/focus.js.map +1 -0
- package/dist/tools/gitignore.js +148 -0
- package/dist/tools/gitignore.js.map +1 -0
- package/dist/tools/glob.js +134 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/governorTools.js +258 -0
- package/dist/tools/governorTools.js.map +1 -0
- package/dist/tools/grep.js +450 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/guard.js +220 -0
- package/dist/tools/guard.js.map +1 -0
- package/dist/tools/killTree.js +215 -0
- package/dist/tools/killTree.js.map +1 -0
- package/dist/tools/listDir.js +143 -0
- package/dist/tools/listDir.js.map +1 -0
- package/dist/tools/mcpAdd.js +176 -0
- package/dist/tools/mcpAdd.js.map +1 -0
- package/dist/tools/mcpResources.js +116 -0
- package/dist/tools/mcpResources.js.map +1 -0
- package/dist/tools/mcpSearch.js +123 -0
- package/dist/tools/mcpSearch.js.map +1 -0
- package/dist/tools/multiEdit.js +168 -0
- package/dist/tools/multiEdit.js.map +1 -0
- package/dist/tools/paths.js +225 -0
- package/dist/tools/paths.js.map +1 -0
- package/dist/tools/posixShell.js +123 -0
- package/dist/tools/posixShell.js.map +1 -0
- package/dist/tools/readFile.js +371 -0
- package/dist/tools/readFile.js.map +1 -0
- package/dist/tools/readSymbol.js +145 -0
- package/dist/tools/readSymbol.js.map +1 -0
- package/dist/tools/registry.js +120 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/replaceSymbol.js +141 -0
- package/dist/tools/replaceSymbol.js.map +1 -0
- package/dist/tools/results.js +15 -0
- package/dist/tools/results.js.map +1 -0
- package/dist/tools/ripgrep.js +145 -0
- package/dist/tools/ripgrep.js.map +1 -0
- package/dist/tools/runCommand.js +633 -0
- package/dist/tools/runCommand.js.map +1 -0
- package/dist/tools/saveMemory.js +102 -0
- package/dist/tools/saveMemory.js.map +1 -0
- package/dist/tools/screenshot.js +200 -0
- package/dist/tools/screenshot.js.map +1 -0
- package/dist/tools/screenshotWin.js +227 -0
- package/dist/tools/screenshotWin.js.map +1 -0
- package/dist/tools/search.js +121 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/sessionTools.js +187 -0
- package/dist/tools/sessionTools.js.map +1 -0
- package/dist/tools/shellCheckpoint.js +123 -0
- package/dist/tools/shellCheckpoint.js.map +1 -0
- package/dist/tools/shellLint.js +102 -0
- package/dist/tools/shellLint.js.map +1 -0
- package/dist/tools/shellTools.js +203 -0
- package/dist/tools/shellTools.js.map +1 -0
- package/dist/tools/spanCore.js +78 -0
- package/dist/tools/spanCore.js.map +1 -0
- package/dist/tools/subagent.js +224 -0
- package/dist/tools/subagent.js.map +1 -0
- package/dist/tools/subagentReport.js +114 -0
- package/dist/tools/subagentReport.js.map +1 -0
- package/dist/tools/tempSweep.js +118 -0
- package/dist/tools/tempSweep.js.map +1 -0
- package/dist/tools/todo.js +117 -0
- package/dist/tools/todo.js.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/untrusted.js +46 -0
- package/dist/tools/untrusted.js.map +1 -0
- package/dist/tools/useSkill.js +62 -0
- package/dist/tools/useSkill.js.map +1 -0
- package/dist/tools/walk.js +152 -0
- package/dist/tools/walk.js.map +1 -0
- package/dist/tools/web.js +61 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/tools/webFetch.js +444 -0
- package/dist/tools/webFetch.js.map +1 -0
- package/dist/tools/webSearch.js +130 -0
- package/dist/tools/webSearch.js.map +1 -0
- package/dist/tools/workspace.js +212 -0
- package/dist/tools/workspace.js.map +1 -0
- package/dist/tools/workspaceDiscover.js +216 -0
- package/dist/tools/workspaceDiscover.js.map +1 -0
- package/dist/tools/writeFile.js +162 -0
- package/dist/tools/writeFile.js.map +1 -0
- package/package.json +74 -28
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* connection.ts — one MCP server, and what state it is in.
|
|
3
|
+
*
|
|
4
|
+
* The previous implementation had no notion of state: a server was in a map or it was
|
|
5
|
+
* not. That makes three ordinary situations indistinguishable — still starting, failed
|
|
6
|
+
* to start, and waiting on the user to authenticate — so nothing could report anything
|
|
7
|
+
* useful and a dead server stayed dead for the session.
|
|
8
|
+
*
|
|
9
|
+
* So a connection is a small state machine:
|
|
10
|
+
*
|
|
11
|
+
* pending ──► connected ──► (dies) ──► pending ──► …
|
|
12
|
+
* │ │
|
|
13
|
+
* ├──► failed (cap reached) ◄─┘
|
|
14
|
+
* └──► needs-auth
|
|
15
|
+
*
|
|
16
|
+
* `needs-auth` is deliberately separate from `failed`. A 401 is not a broken server, it
|
|
17
|
+
* is a server waiting on the user, and collapsing the two would make the eventual auth
|
|
18
|
+
* flow look like an outage.
|
|
19
|
+
*
|
|
20
|
+
* Reconnection is capped at 3 consecutive failures, the same number used by the
|
|
21
|
+
* repeat-failure breaker in the engine. Past the cap we STOP and surface the state
|
|
22
|
+
* rather than retrying forever: a server that cannot start will not start on the
|
|
23
|
+
* fourth try, and quietly burning attempts is how a session ends up slow for a reason
|
|
24
|
+
* the user cannot see. `/mcp` can always retry by hand.
|
|
25
|
+
*/
|
|
26
|
+
import { appVersion } from "../cli/version.js";
|
|
27
|
+
import { parseToolList } from "./catalog.js";
|
|
28
|
+
import { paramHeaders } from "./paramHeaders.js";
|
|
29
|
+
import { probe, UnsupportedProtocolVersionError } from "./discover.js";
|
|
30
|
+
import { buildMeta, DEFAULT_CLIENT_CAPABILITIES, cacheDirectiveOf, readInputRequired } from "./protocol.js";
|
|
31
|
+
import { hasPrompts, parsePromptList } from "./prompts.js";
|
|
32
|
+
import { hasResources, parseResourceList, parseResourceRead, parseTemplateList, } from "./resources.js";
|
|
33
|
+
import { HttpTransport } from "./transport/http.js";
|
|
34
|
+
import { StdioTransport } from "./transport/stdio.js";
|
|
35
|
+
import { RpcError } from "./transport/types.js";
|
|
36
|
+
import { isPromptsChanged, isResourcesChanged, isToolsChanged, subscriptionsFor } from "./subscriptions.js";
|
|
37
|
+
/** Consecutive failed connect attempts before we stop trying on our own. */
|
|
38
|
+
export const MAX_CONNECT_ATTEMPTS = 3;
|
|
39
|
+
/**
|
|
40
|
+
* Backoff between automatic reconnects, in ms.
|
|
41
|
+
*
|
|
42
|
+
* Deliberately short and deliberately finite. A server that dies mid-session is usually
|
|
43
|
+
* a crash or a restart, and getting it back within a few seconds is the difference
|
|
44
|
+
* between a blip and losing its tools for the rest of the session. But retrying forever
|
|
45
|
+
* is the pattern the repeat-failure breaker exists to prevent: a server that will not
|
|
46
|
+
* come back does not come back on the tenth attempt either, and quietly burning them is
|
|
47
|
+
* how a session gets slow for a reason the user cannot see. After the last one we stop
|
|
48
|
+
* and say so; `/mcp` can always retry by hand.
|
|
49
|
+
*/
|
|
50
|
+
export const RECONNECT_BACKOFF_MS = [1_000, 4_000, 10_000];
|
|
51
|
+
/**
|
|
52
|
+
* How many extra round trips one MRTR call may take before we give up.
|
|
53
|
+
*
|
|
54
|
+
* A server is explicitly allowed to keep answering `input_required` "if they want to
|
|
55
|
+
* repeatedly prompt the user for information until they have what they need", so nothing
|
|
56
|
+
* on the server side ever has to stop. Terminating is therefore the client's job. Four
|
|
57
|
+
* is well past any ordinary exchange (which is one, occasionally two) and small enough
|
|
58
|
+
* that a server looping on us costs a moment rather than a session.
|
|
59
|
+
*/
|
|
60
|
+
export const MAX_INPUT_ROUNDS = 4;
|
|
61
|
+
/** Is this error the server telling us it wants credentials? */
|
|
62
|
+
export function isAuthError(error) {
|
|
63
|
+
const e = error;
|
|
64
|
+
if (typeof e?.code === "number" && e.code === -32001)
|
|
65
|
+
return true;
|
|
66
|
+
return typeof e?.message === "string" && /\b401\b|\b403\b|unauthor|forbidden/i.test(e.message);
|
|
67
|
+
}
|
|
68
|
+
export class McpConnection {
|
|
69
|
+
config;
|
|
70
|
+
transport = null;
|
|
71
|
+
negotiated = null;
|
|
72
|
+
toolDefs = [];
|
|
73
|
+
/** Tools dropped from the last catalog load, with the reason. Drained by the manager
|
|
74
|
+
* into user-facing notices — a tool that silently does not exist is the failure mode
|
|
75
|
+
* quarantine already taught us to avoid. */
|
|
76
|
+
toolWarnings = [];
|
|
77
|
+
promptDefs = [];
|
|
78
|
+
resourceDefs = [];
|
|
79
|
+
templateDefs = [];
|
|
80
|
+
cache = {};
|
|
81
|
+
toolsFetchedAt = 0;
|
|
82
|
+
/** When the resource listing was last fetched (0 = never). Resources are loaded lazily,
|
|
83
|
+
* so this is the only thing standing between a curious model and a refetch per call. */
|
|
84
|
+
resourcesFetchedAt = 0;
|
|
85
|
+
resourceCache = {};
|
|
86
|
+
state;
|
|
87
|
+
lastError = "";
|
|
88
|
+
attempts = 0;
|
|
89
|
+
connecting = null;
|
|
90
|
+
retryTimer = null;
|
|
91
|
+
closed = false;
|
|
92
|
+
onChange = null;
|
|
93
|
+
constructor(config) {
|
|
94
|
+
this.config = config;
|
|
95
|
+
this.state = config.disabled ? "disabled" : "pending";
|
|
96
|
+
}
|
|
97
|
+
/** Told whenever this server's state or catalog moves, so the UI can repaint. */
|
|
98
|
+
setOnChange(handler) {
|
|
99
|
+
this.onChange = handler;
|
|
100
|
+
}
|
|
101
|
+
changed() {
|
|
102
|
+
this.onChange?.();
|
|
103
|
+
}
|
|
104
|
+
status() {
|
|
105
|
+
return {
|
|
106
|
+
name: this.config.name,
|
|
107
|
+
state: this.state,
|
|
108
|
+
toolCount: this.toolDefs.length,
|
|
109
|
+
promptCount: this.promptDefs.length,
|
|
110
|
+
offersResources: this.offersResources(),
|
|
111
|
+
attempts: this.attempts,
|
|
112
|
+
...(this.lastError ? { error: this.lastError } : {}),
|
|
113
|
+
...(this.negotiated ? { version: this.negotiated.version, legacy: this.negotiated.legacy } : {}),
|
|
114
|
+
...(this.negotiated?.serverInfo ? { serverInfo: this.negotiated.serverInfo } : {}),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
tools() {
|
|
118
|
+
return this.toolDefs;
|
|
119
|
+
}
|
|
120
|
+
/** This server's prompts, fetched at connect (they have to exist before the command
|
|
121
|
+
* list is rendered, and there is no way to discover them lazily from a keystroke). */
|
|
122
|
+
prompts() {
|
|
123
|
+
return this.promptDefs;
|
|
124
|
+
}
|
|
125
|
+
isConnected() {
|
|
126
|
+
return this.state === "connected";
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Connect, handshake or discover, and load the tool catalog.
|
|
130
|
+
*
|
|
131
|
+
* Concurrent callers share one attempt: the pool starts every server in parallel and
|
|
132
|
+
* a `/mcp` retry can land on top of that, and two transports for one server would
|
|
133
|
+
* leak a child process.
|
|
134
|
+
*/
|
|
135
|
+
async connect() {
|
|
136
|
+
if (this.state === "disabled")
|
|
137
|
+
return;
|
|
138
|
+
if (this.state === "connected")
|
|
139
|
+
return;
|
|
140
|
+
if (this.connecting)
|
|
141
|
+
return this.connecting;
|
|
142
|
+
if (this.attempts >= MAX_CONNECT_ATTEMPTS && this.state !== "pending")
|
|
143
|
+
return;
|
|
144
|
+
this.connecting = this.attempt().finally(() => {
|
|
145
|
+
this.connecting = null;
|
|
146
|
+
});
|
|
147
|
+
return this.connecting;
|
|
148
|
+
}
|
|
149
|
+
/** Force a retry even past the cap — what `/mcp` reconnect does. */
|
|
150
|
+
async reconnect() {
|
|
151
|
+
this.clearRetry();
|
|
152
|
+
await this.closeTransport();
|
|
153
|
+
this.closed = false;
|
|
154
|
+
this.attempts = 0;
|
|
155
|
+
this.state = this.config.disabled ? "disabled" : "pending";
|
|
156
|
+
this.lastError = "";
|
|
157
|
+
await this.connect();
|
|
158
|
+
}
|
|
159
|
+
async attempt() {
|
|
160
|
+
this.attempts++;
|
|
161
|
+
this.state = "pending";
|
|
162
|
+
try {
|
|
163
|
+
const transport = this.open();
|
|
164
|
+
this.transport = transport;
|
|
165
|
+
// If the server dies later, drop back to pending so a future call can revive it
|
|
166
|
+
// instead of dispatching into a corpse.
|
|
167
|
+
void transport.closed.then(() => {
|
|
168
|
+
if (this.transport === transport)
|
|
169
|
+
this.onDied();
|
|
170
|
+
});
|
|
171
|
+
const identity = { name: "mindweave", version: appVersion() };
|
|
172
|
+
this.negotiated = await probe({
|
|
173
|
+
request: (method, params) => this.raw(transport, method, params),
|
|
174
|
+
notify: (method, params) => transport.notify(method, params),
|
|
175
|
+
}, identity, DEFAULT_CLIENT_CAPABILITIES);
|
|
176
|
+
await this.loadTools();
|
|
177
|
+
// Prompts are eager, resources are not, and the difference is deliberate. A prompt
|
|
178
|
+
// has to exist before the user presses `/`, so there is no lazy moment to fetch it
|
|
179
|
+
// in. A resource listing is only ever wanted when the model goes looking, and
|
|
180
|
+
// fetching every server's on connect would slow every session down for a feature
|
|
181
|
+
// most projects never touch.
|
|
182
|
+
await this.loadPrompts();
|
|
183
|
+
transport.onNotification((note) => this.onNotify(note));
|
|
184
|
+
await this.subscribe(transport);
|
|
185
|
+
this.state = "connected";
|
|
186
|
+
this.lastError = "";
|
|
187
|
+
this.attempts = 0; // a success clears the budget for the next outage
|
|
188
|
+
this.changed();
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
await this.closeTransport();
|
|
192
|
+
this.lastError = describeError(error);
|
|
193
|
+
// A server asking for credentials is waiting on the user, not broken — and
|
|
194
|
+
// retrying cannot help, so it does not consume the attempt budget's meaning.
|
|
195
|
+
this.state = isAuthError(error) ? "needs-auth" : "failed";
|
|
196
|
+
this.changed();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Opt into the change notifications we can actually act on.
|
|
201
|
+
*
|
|
202
|
+
* Best-effort by design: a server that does not support `subscriptions/listen` (every
|
|
203
|
+
* pre-2026 one) or refuses the request is still perfectly usable. Letting a failed
|
|
204
|
+
* subscription fail the whole connection would drop most servers in existence for the
|
|
205
|
+
* sake of an optimization.
|
|
206
|
+
*
|
|
207
|
+
* Be precise about what is lost, because an earlier version of this comment was not:
|
|
208
|
+
* there is NO periodic refresh. `ttlMs` is only ever read as permission to SKIP a
|
|
209
|
+
* refetch, never as a timer, so nothing polls. Without a subscription the catalog moves
|
|
210
|
+
* only when the server pushes `notifications/tools/list_changed` on its own (which
|
|
211
|
+
* stdio servers do regardless of dialect, and many pre-2026 ones send) or when the user
|
|
212
|
+
* reconnects it from `/mcp`. A poller is deliberately not built: it would re-fetch every
|
|
213
|
+
* server on a timer to catch a case the push path already covers, and each refresh that
|
|
214
|
+
* did find a change would cost a prompt-cache prefix.
|
|
215
|
+
*/
|
|
216
|
+
async subscribe(transport) {
|
|
217
|
+
if (!this.negotiated || this.negotiated.dialect !== "stateless")
|
|
218
|
+
return;
|
|
219
|
+
const types = subscriptionsFor(this.negotiated.capabilities);
|
|
220
|
+
if (types.length === 0)
|
|
221
|
+
return;
|
|
222
|
+
try {
|
|
223
|
+
if (transport.openStream)
|
|
224
|
+
await transport.openStream("subscriptions/listen", { types });
|
|
225
|
+
else
|
|
226
|
+
await this.call("subscriptions/listen", { types });
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
// No subscription. The catalog is then whatever the server pushes unprompted, or
|
|
230
|
+
// what a `/mcp` reconnect fetches — see above.
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** A server telling us one of its lists moved. */
|
|
234
|
+
onNotify(note) {
|
|
235
|
+
// Force past the TTL in every case: the server just told us the cached answer is wrong.
|
|
236
|
+
const refresh = isToolsChanged(note.method)
|
|
237
|
+
? this.loadTools(true)
|
|
238
|
+
: isPromptsChanged(note.method)
|
|
239
|
+
? this.loadPrompts()
|
|
240
|
+
: isResourcesChanged(note.method)
|
|
241
|
+
? this.loadResources(true)
|
|
242
|
+
: null;
|
|
243
|
+
if (!refresh)
|
|
244
|
+
return;
|
|
245
|
+
void refresh
|
|
246
|
+
.then(() => this.changed())
|
|
247
|
+
.catch(() => {
|
|
248
|
+
// A refresh that fails leaves the previous list in place, which is strictly
|
|
249
|
+
// better than dropping it because one notification could not be served.
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
open() {
|
|
253
|
+
if (this.config.type === "http") {
|
|
254
|
+
return new HttpTransport({ url: this.config.url, ...(this.config.headers ? { headers: this.config.headers } : {}) });
|
|
255
|
+
}
|
|
256
|
+
return new StdioTransport({
|
|
257
|
+
command: this.config.command,
|
|
258
|
+
args: this.config.args,
|
|
259
|
+
...(this.config.env ? { env: this.config.env } : {}),
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
/** A request that has NOT yet negotiated a dialect (the probe itself). */
|
|
263
|
+
raw(transport, method, params) {
|
|
264
|
+
return transport.request(method, params);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* A request on the negotiated dialect: `_meta` is attached on stateless servers and
|
|
268
|
+
* omitted on handshake ones, where it would be an unknown field.
|
|
269
|
+
*/
|
|
270
|
+
/**
|
|
271
|
+
* A call that may take several round trips (MRTR, 2026-07-28).
|
|
272
|
+
*
|
|
273
|
+
* A server that cannot finish in one go does not hold a connection open and does not
|
|
274
|
+
* ask us a question over a side channel — both of those are gone. It returns
|
|
275
|
+
* `resultType: "input_required"` with an opaque `requestState`, and the client calls
|
|
276
|
+
* again, echoing that state back. Each attempt is a genuinely independent request with
|
|
277
|
+
* its own id; nothing on this side is resumed.
|
|
278
|
+
*
|
|
279
|
+
* Two rules of the echo are easy to get subtly wrong, so they are explicit below: the
|
|
280
|
+
* state is whatever THIS round returned, never a value carried over from an earlier
|
|
281
|
+
* one, and a round that returns no state must be retried with no state rather than
|
|
282
|
+
* with the last one we happened to hold.
|
|
283
|
+
*
|
|
284
|
+
* We answer no `inputRequests`, and that is a consequence of declaring no elicitation
|
|
285
|
+
* capability rather than an omission here — a conforming server is forbidden from
|
|
286
|
+
* sending them (see `ClientCapabilities`). If one arrives anyway we fail the call and
|
|
287
|
+
* say what was asked for. Returning the half-finished result instead, which is what
|
|
288
|
+
* happened before this existed, told the model the tool had answered.
|
|
289
|
+
*/
|
|
290
|
+
async callMultiRound(method, params, mirrored) {
|
|
291
|
+
let requestState;
|
|
292
|
+
for (let round = 0; round <= MAX_INPUT_ROUNDS; round++) {
|
|
293
|
+
const body = requestState === undefined ? params : { ...params, requestState };
|
|
294
|
+
const result = await this.call(method, body, mirrored);
|
|
295
|
+
const pending = readInputRequired(result);
|
|
296
|
+
if (!pending)
|
|
297
|
+
return result;
|
|
298
|
+
const asked = Object.values(pending.inputRequests).map((r) => r.method);
|
|
299
|
+
if (asked.length > 0) {
|
|
300
|
+
throw new RpcError(-32603, `mcp server '${this.config.name}' asked for input this client cannot provide (${[...new Set(asked)].join(", ")}). ` +
|
|
301
|
+
`Mindweave declares no elicitation capability, so a conforming server should not have requested it.`);
|
|
302
|
+
}
|
|
303
|
+
requestState = pending.requestState;
|
|
304
|
+
}
|
|
305
|
+
// A server MAY ask again on every attempt, so terminating is our job, not its own.
|
|
306
|
+
throw new RpcError(-32603, `mcp server '${this.config.name}' still needed more input after ${MAX_INPUT_ROUNDS + 1} attempts at ${method}`);
|
|
307
|
+
}
|
|
308
|
+
async call(method, params, mirrored) {
|
|
309
|
+
if (!this.transport || !this.negotiated)
|
|
310
|
+
throw new RpcError(-32603, `mcp server '${this.config.name}' is not connected`);
|
|
311
|
+
const meta = buildMeta(this.negotiated.dialect, this.negotiated.version, { name: "mindweave", version: appVersion() });
|
|
312
|
+
const body = meta ? { ...(params ?? {}), _meta: meta } : params;
|
|
313
|
+
return this.transport.request(method, body, mirrored);
|
|
314
|
+
}
|
|
315
|
+
/** Fetch (or refresh) the tool catalog, honouring the server's own `ttlMs`. */
|
|
316
|
+
async loadTools(force = false) {
|
|
317
|
+
if (!force && this.toolsFetchedAt && this.cache.ttlMs !== undefined) {
|
|
318
|
+
if (Date.now() - this.toolsFetchedAt < this.cache.ttlMs)
|
|
319
|
+
return; // still fresh
|
|
320
|
+
}
|
|
321
|
+
const result = await this.call("tools/list");
|
|
322
|
+
this.toolDefs = parseToolList(this.config.name, result, {
|
|
323
|
+
mirrorsHeaders: this.config.type === "http",
|
|
324
|
+
onReject: (tool, reason) => {
|
|
325
|
+
this.toolWarnings.push(`'${this.config.name}' tool '${tool}' was dropped: ${reason}`);
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
this.cache = cacheDirectiveOf(result);
|
|
329
|
+
this.toolsFetchedAt = Date.now();
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Fetch this server's prompts, if it has any.
|
|
333
|
+
*
|
|
334
|
+
* Best-effort in both directions: a server that does not advertise prompts is not
|
|
335
|
+
* asked, and one that advertises them but fails the call simply has none. A broken
|
|
336
|
+
* `prompts/list` must not cost the user the server's tools, which are the main event.
|
|
337
|
+
*/
|
|
338
|
+
async loadPrompts() {
|
|
339
|
+
if (!this.negotiated || !hasPrompts(this.negotiated.capabilities))
|
|
340
|
+
return;
|
|
341
|
+
try {
|
|
342
|
+
this.promptDefs = parsePromptList(this.config.name, await this.call("prompts/list"));
|
|
343
|
+
}
|
|
344
|
+
catch {
|
|
345
|
+
this.promptDefs = [];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/** Render one of this server's prompts. Rejects, because the caller is a command the
|
|
349
|
+
* user just typed and silence would be worse than an error. */
|
|
350
|
+
async getPrompt(name, args) {
|
|
351
|
+
return this.callMultiRound("prompts/get", { name, ...(Object.keys(args).length > 0 ? { arguments: args } : {}) });
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Fetch (or refresh) this server's resources and templates.
|
|
355
|
+
*
|
|
356
|
+
* Honours the server's own `ttlMs` the same way the tool catalog does, which matters
|
|
357
|
+
* more here: the model can call the listing tool repeatedly within one turn, and
|
|
358
|
+
* without the cache each call would be two round trips to every server.
|
|
359
|
+
*/
|
|
360
|
+
async loadResources(force = false) {
|
|
361
|
+
if (!this.negotiated || !hasResources(this.negotiated.capabilities))
|
|
362
|
+
return;
|
|
363
|
+
if (!force && this.resourcesFetchedAt && this.resourceCache.ttlMs !== undefined) {
|
|
364
|
+
if (Date.now() - this.resourcesFetchedAt < this.resourceCache.ttlMs)
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
const listed = await this.call("resources/list");
|
|
369
|
+
this.resourceDefs = parseResourceList(this.config.name, listed);
|
|
370
|
+
this.resourceCache = cacheDirectiveOf(listed);
|
|
371
|
+
this.resourcesFetchedAt = Date.now();
|
|
372
|
+
}
|
|
373
|
+
catch {
|
|
374
|
+
this.resourceDefs = [];
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
// Separate try: templates are optional even for a server that has resources, and a
|
|
378
|
+
// server that has never heard of `resources/templates/list` must not lose its list.
|
|
379
|
+
this.templateDefs = parseTemplateList(this.config.name, await this.call("resources/templates/list"));
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
this.templateDefs = [];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
resources() {
|
|
386
|
+
return this.resourceDefs;
|
|
387
|
+
}
|
|
388
|
+
resourceTemplates() {
|
|
389
|
+
return this.templateDefs;
|
|
390
|
+
}
|
|
391
|
+
/** True when this server declared a resources capability at all. */
|
|
392
|
+
offersResources() {
|
|
393
|
+
return Boolean(this.negotiated && hasResources(this.negotiated.capabilities));
|
|
394
|
+
}
|
|
395
|
+
/** Read one resource by URI. */
|
|
396
|
+
async readResource(uri) {
|
|
397
|
+
return parseResourceRead(await this.callMultiRound("resources/read", { uri }));
|
|
398
|
+
}
|
|
399
|
+
/** Invoke a tool on this server.
|
|
400
|
+
*
|
|
401
|
+
* Any parameter the server annotated with `x-mcp-header` is repeated in the headers.
|
|
402
|
+
* Not an optimisation: a server MUST reject a call whose annotated value is in the
|
|
403
|
+
* body but absent from the headers, so a tool with an annotation is simply uncallable
|
|
404
|
+
* without this. The annotations were validated when the catalog was parsed, which is
|
|
405
|
+
* why nothing here can fail. */
|
|
406
|
+
async callTool(name, args) {
|
|
407
|
+
const annotations = this.toolDefs.find((d) => d.name === name)?.paramHeaders;
|
|
408
|
+
const mirrored = annotations?.length ? paramHeaders(annotations, args) : undefined;
|
|
409
|
+
return this.callMultiRound("tools/call", { name, arguments: args }, mirrored);
|
|
410
|
+
}
|
|
411
|
+
/** Drain warnings about tools dropped from this server's catalog. One-shot. */
|
|
412
|
+
takeToolWarnings() {
|
|
413
|
+
const out = this.toolWarnings;
|
|
414
|
+
this.toolWarnings = [];
|
|
415
|
+
return out;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* The server went away on its own. Drop the catalog and schedule a revival.
|
|
419
|
+
*
|
|
420
|
+
* Automatic, because the alternative is that a server which crashed once is gone for
|
|
421
|
+
* the rest of the session and the user has no way to know why their tools vanished.
|
|
422
|
+
* Bounded, because a server that cannot come back never does.
|
|
423
|
+
*/
|
|
424
|
+
onDied() {
|
|
425
|
+
this.transport = null;
|
|
426
|
+
this.negotiated = null;
|
|
427
|
+
this.toolDefs = [];
|
|
428
|
+
this.promptDefs = [];
|
|
429
|
+
this.resourceDefs = [];
|
|
430
|
+
this.templateDefs = [];
|
|
431
|
+
this.toolsFetchedAt = 0;
|
|
432
|
+
this.resourcesFetchedAt = 0;
|
|
433
|
+
if (this.state === "connected") {
|
|
434
|
+
this.state = "pending";
|
|
435
|
+
this.lastError = "server exited";
|
|
436
|
+
this.attempts = 0; // this is a NEW outage, not a continuation of the last one
|
|
437
|
+
this.scheduleRetry();
|
|
438
|
+
}
|
|
439
|
+
this.changed();
|
|
440
|
+
}
|
|
441
|
+
scheduleRetry() {
|
|
442
|
+
if (this.closed || this.config.disabled)
|
|
443
|
+
return;
|
|
444
|
+
const delay = RECONNECT_BACKOFF_MS[this.attempts];
|
|
445
|
+
if (delay === undefined) {
|
|
446
|
+
// Out of automatic attempts. Say so plainly rather than sitting in `pending`
|
|
447
|
+
// forever, which reads as "still trying".
|
|
448
|
+
this.state = "failed";
|
|
449
|
+
this.lastError = `${this.lastError || "server exited"} (gave up after ${RECONNECT_BACKOFF_MS.length} reconnect attempts; /mcp to retry)`;
|
|
450
|
+
this.changed();
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
this.clearRetry();
|
|
454
|
+
this.retryTimer = setTimeout(() => {
|
|
455
|
+
this.retryTimer = null;
|
|
456
|
+
void this.attempt().then(() => {
|
|
457
|
+
if (this.state !== "connected")
|
|
458
|
+
this.scheduleRetry();
|
|
459
|
+
});
|
|
460
|
+
}, delay);
|
|
461
|
+
// Never hold the process open just to retry a background server.
|
|
462
|
+
this.retryTimer.unref?.();
|
|
463
|
+
}
|
|
464
|
+
clearRetry() {
|
|
465
|
+
if (this.retryTimer)
|
|
466
|
+
clearTimeout(this.retryTimer);
|
|
467
|
+
this.retryTimer = null;
|
|
468
|
+
}
|
|
469
|
+
/** Tear down the transport but keep this connection revivable.
|
|
470
|
+
* `sync` is forwarded so an exit-handler teardown kills synchronously. */
|
|
471
|
+
async closeTransport(sync = false) {
|
|
472
|
+
const transport = this.transport;
|
|
473
|
+
this.transport = null;
|
|
474
|
+
this.negotiated = null;
|
|
475
|
+
this.toolDefs = [];
|
|
476
|
+
this.promptDefs = [];
|
|
477
|
+
this.resourceDefs = [];
|
|
478
|
+
this.templateDefs = [];
|
|
479
|
+
this.toolsFetchedAt = 0;
|
|
480
|
+
this.resourcesFetchedAt = 0;
|
|
481
|
+
if (transport)
|
|
482
|
+
await transport.close(sync).catch(() => { });
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Shut down for good: no more retries, no more tools.
|
|
486
|
+
*
|
|
487
|
+
* `sync` must be set when closing from a process-exit handler. The kill that
|
|
488
|
+
* reaps a shelled server spawns `taskkill`, and an async spawn never reaches
|
|
489
|
+
* the OS during exit, so the server would outlive us.
|
|
490
|
+
*/
|
|
491
|
+
async close(sync = false) {
|
|
492
|
+
this.closed = true;
|
|
493
|
+
this.clearRetry();
|
|
494
|
+
await this.closeTransport(sync);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function describeError(error) {
|
|
498
|
+
if (error instanceof UnsupportedProtocolVersionError)
|
|
499
|
+
return error.message;
|
|
500
|
+
if (error instanceof Error)
|
|
501
|
+
return error.message;
|
|
502
|
+
return String(error);
|
|
503
|
+
}
|
|
504
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection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AAY,+BAA+B;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IAC3E,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { mcpToolName } from "./catalog.js";
|
|
2
|
+
/**
|
|
3
|
+
* Catalogs at or below this many tools are advertised in full.
|
|
4
|
+
*
|
|
5
|
+
* Below the threshold, deferral is strictly WORSE: the model pays a search round trip
|
|
6
|
+
* to reach tools it could simply have been shown, and a small catalog costs little to
|
|
7
|
+
* send. The point is to fix the many-tools case, not to hide three tools behind a menu.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFER_THRESHOLD = 25;
|
|
10
|
+
/** How many results one search returns. Enough to choose from, few enough to read. */
|
|
11
|
+
export const MAX_SEARCH_RESULTS = 8;
|
|
12
|
+
/** Should this catalog be held back behind search? */
|
|
13
|
+
export function shouldDefer(toolCount, threshold = DEFER_THRESHOLD) {
|
|
14
|
+
return toolCount > threshold;
|
|
15
|
+
}
|
|
16
|
+
/** Split a tool name into lowercase parts: `mcp__github__create_issue` → github, create, issue. */
|
|
17
|
+
export function nameParts(def) {
|
|
18
|
+
return `${def.server} ${def.name}`
|
|
19
|
+
.toLowerCase()
|
|
20
|
+
.split(/[^a-z0-9]+/)
|
|
21
|
+
.filter(Boolean);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Score one tool against the query terms (pure).
|
|
25
|
+
*
|
|
26
|
+
* Weights are deliberately blunt. This is keyword matching, not retrieval: the model
|
|
27
|
+
* already knows roughly what it wants and usually queries with a server name ("github"),
|
|
28
|
+
* an action ("create issue"), or the tool name itself. Precision matters less than never
|
|
29
|
+
* returning nothing useful for a reasonable query.
|
|
30
|
+
*/
|
|
31
|
+
export function scoreTool(def, terms) {
|
|
32
|
+
const parts = nameParts(def);
|
|
33
|
+
const description = def.description.toLowerCase();
|
|
34
|
+
let score = 0;
|
|
35
|
+
for (const term of terms) {
|
|
36
|
+
if (parts.includes(term))
|
|
37
|
+
score += 10; // whole word in the name: the strongest signal
|
|
38
|
+
else if (parts.some((p) => p.includes(term)))
|
|
39
|
+
score += 5;
|
|
40
|
+
// A description match is weak on its own — descriptions are long and mention a lot.
|
|
41
|
+
if (description.includes(term))
|
|
42
|
+
score += 2;
|
|
43
|
+
}
|
|
44
|
+
return score;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Find tools matching a query (pure).
|
|
48
|
+
*
|
|
49
|
+
* The two special cases at the top are not politeness, they are the failure modes this
|
|
50
|
+
* kind of search actually hits. A model that already knows the exact tool name will
|
|
51
|
+
* pass it verbatim rather than describing it, and a model that knows the server will
|
|
52
|
+
* pass `mcp__server`. Both look like zero-scoring queries to a keyword ranker and would
|
|
53
|
+
* return nothing, which reads to the model as "that tool does not exist" — so it stops
|
|
54
|
+
* asking and guesses instead. Handling them is what keeps search from being a dead end.
|
|
55
|
+
*/
|
|
56
|
+
export function searchCatalog(query, defs, max = MAX_SEARCH_RESULTS) {
|
|
57
|
+
const q = query.toLowerCase().trim();
|
|
58
|
+
if (!q)
|
|
59
|
+
return [];
|
|
60
|
+
// Exact advertised name, or exact bare name.
|
|
61
|
+
const exact = defs.find((d) => mcpToolName(d.server, d.name).toLowerCase() === q || d.name.toLowerCase() === q);
|
|
62
|
+
if (exact)
|
|
63
|
+
return [exact];
|
|
64
|
+
// A server prefix: give back that server's tools.
|
|
65
|
+
if (q.startsWith("mcp__")) {
|
|
66
|
+
const prefixed = defs.filter((d) => mcpToolName(d.server, d.name).toLowerCase().startsWith(q));
|
|
67
|
+
if (prefixed.length > 0)
|
|
68
|
+
return prefixed.slice(0, max);
|
|
69
|
+
}
|
|
70
|
+
// A bare server name: same idea, without the prefix.
|
|
71
|
+
const byServer = defs.filter((d) => d.server.toLowerCase() === q);
|
|
72
|
+
if (byServer.length > 0)
|
|
73
|
+
return byServer.slice(0, max);
|
|
74
|
+
const terms = q.split(/[^a-z0-9]+/).filter(Boolean);
|
|
75
|
+
if (terms.length === 0)
|
|
76
|
+
return [];
|
|
77
|
+
const scored = defs
|
|
78
|
+
.map((def) => ({ def, score: scoreTool(def, terms) }))
|
|
79
|
+
.filter((s) => s.score > 0)
|
|
80
|
+
// Ties break on name so results are stable between identical searches.
|
|
81
|
+
.sort((a, b) => b.score - a.score || mcpToolName(a.def.server, a.def.name).localeCompare(mcpToolName(b.def.server, b.def.name)));
|
|
82
|
+
return scored.slice(0, max).map((s) => s.def);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Render search results for the model: each match's full callable definition.
|
|
86
|
+
*
|
|
87
|
+
* The FULL schema, not a summary line, and that is what makes deferral pay. A summary
|
|
88
|
+
* only tells the model a tool exists; it then has to be added to the advertised `tools`
|
|
89
|
+
* array before it can be called, and that rewrites the provider's cached prefix — tools,
|
|
90
|
+
* system and messages — at full price. Delivered here instead, the schema rides in an
|
|
91
|
+
* appended message: every earlier byte is untouched, the cache survives, and the schema
|
|
92
|
+
* is itself cached from the next call onward. Dispatch resolves against the catalog
|
|
93
|
+
* rather than against what was advertised, so a name and a schema is all it takes.
|
|
94
|
+
*/
|
|
95
|
+
export function renderResults(defs) {
|
|
96
|
+
return defs
|
|
97
|
+
.map((d) => `<function>${JSON.stringify({
|
|
98
|
+
name: mcpToolName(d.server, d.name),
|
|
99
|
+
description: d.description,
|
|
100
|
+
parameters: d.inputSchema,
|
|
101
|
+
})}</function>`)
|
|
102
|
+
.join("\n");
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=deferred.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferred.js","sourceRoot":"","sources":["../../src/mcp/deferred.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CA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