@draht/coding-agent 2026.10.20-1 → 2026.10.23-1
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 +138 -0
- package/agents/advisor.md +2 -2
- package/agents/architect.md +11 -33
- package/agents/debugger.md +13 -54
- package/agents/git-committer.md +18 -42
- package/agents/implementer.md +14 -36
- package/agents/investigator.md +12 -63
- package/agents/reviewer.md +16 -44
- package/agents/security-auditor.md +22 -56
- package/agents/spec-reviewer.md +13 -53
- package/agents/verifier.md +14 -33
- package/bin/drahtbank.mjs +4 -0
- package/dist/agents/advisor.md +2 -2
- package/dist/agents/architect.md +11 -33
- package/dist/agents/debugger.md +13 -54
- package/dist/agents/git-committer.md +18 -42
- package/dist/agents/implementer.md +14 -36
- package/dist/agents/investigator.md +12 -63
- package/dist/agents/reviewer.md +16 -44
- package/dist/agents/security-auditor.md +22 -56
- package/dist/agents/spec-reviewer.md +13 -53
- package/dist/agents/verifier.md +14 -33
- package/dist/bundle/chunks/anthropic-messages-G57VPNTF.js +6 -0
- package/dist/bundle/chunks/anthropic.js +1 -1
- package/dist/bundle/chunks/azure-openai-responses-AYUCZ5WN.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +23 -20
- package/dist/bundle/chunks/chunk-3GDEPGTR.js +16 -0
- package/dist/bundle/chunks/chunk-5JW3NSTV.js +2 -0
- package/dist/bundle/chunks/{chunk-FHX2S5IG.js → chunk-6WESOD4H.js} +1 -1
- package/dist/bundle/chunks/chunk-76YNMQ57.js +2 -0
- package/dist/bundle/chunks/chunk-AC3MSTC6.js +2 -0
- package/dist/bundle/chunks/chunk-ACLWH5WQ.js +2 -0
- package/dist/bundle/chunks/chunk-BL72B6LV.js +82 -0
- package/dist/bundle/chunks/{chunk-5QJFWTKA.js → chunk-CLKG6K6Z.js} +5 -2
- package/dist/bundle/chunks/chunk-DN7SM3LX.js +479 -0
- package/dist/bundle/chunks/{chunk-UTRX2VHB.js → chunk-DOUMZTXH.js} +3 -3
- package/dist/bundle/chunks/chunk-DQ4G4IS4.js +20 -0
- package/dist/bundle/chunks/chunk-E4VZJRJ2.js +9 -0
- package/dist/bundle/chunks/chunk-FOYIPAAD.js +6 -0
- package/dist/bundle/chunks/chunk-FXCTQRNN.js +2 -0
- package/dist/bundle/chunks/chunk-GQXRTK54.js +20 -0
- package/dist/bundle/chunks/chunk-IGO52ZOY.js +132 -0
- package/dist/bundle/chunks/{chunk-VXUJMEMO.js → chunk-IT4RIOZD.js} +1 -1
- package/dist/bundle/chunks/chunk-JJKPUMH2.js +1424 -0
- package/dist/bundle/chunks/chunk-JNWRE5F4.js +2 -0
- package/dist/bundle/chunks/chunk-KSGHCBHT.js +2 -0
- package/dist/bundle/chunks/chunk-MBFTIGLS.js +2 -0
- package/dist/bundle/chunks/chunk-N26RGV3K.js +11 -0
- package/dist/bundle/chunks/{chunk-KPO5375S.js → chunk-RCRGGYLW.js} +1 -1
- package/dist/bundle/chunks/chunk-UCJ7FLSO.js +166 -0
- package/dist/bundle/chunks/chunk-USCN7R2E.js +2 -0
- package/dist/bundle/chunks/chunk-WFHH5SX6.js +4 -0
- package/dist/bundle/chunks/chunk-WYWBXNDO.js +6 -0
- package/dist/bundle/chunks/chunk-ZRPAOMVB.js +2 -0
- package/dist/bundle/chunks/{cli-VCHSHNKT.js → cli-HTUB6WOG.js} +6 -6
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-RRSO6OXX.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +188 -21
- package/dist/bundle/chunks/execute-UUPNZJJG.js +31 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-VJSS5EBX.js +2 -0
- package/dist/bundle/chunks/google-vertex-K23DBWTT.js +2 -0
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-EJ5XMSQL.js → llama-cpp-classify-3VDXTYVJ.js} +3 -3
- package/dist/bundle/chunks/mistral-conversations-SKVQJGFZ.js +5 -0
- package/dist/bundle/chunks/node-DXZFQBEO.js +16 -0
- package/dist/bundle/chunks/{node-6IIDYB3K.js → node-LBZLUIBE.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/dist/bundle/chunks/openai-codex-responses-LV4RIZL3.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/openai-completions-PUIR2V25.js +7 -0
- package/dist/bundle/chunks/openai-decisions-2DJLSYQF.js +5 -0
- package/dist/bundle/chunks/openai-responses-6ESQOXAF.js +4 -0
- package/dist/bundle/chunks/opencode-go.js +1 -1
- package/dist/bundle/chunks/openrouter-images-TVXBMY3V.js +2 -0
- package/dist/bundle/chunks/pi-messages-XS7FDWQI.js +8 -0
- package/dist/bundle/chunks/runtime-IB3XQ7E3.js +2 -0
- package/dist/bundle/chunks/runtime-LB35PK4J.js +3 -0
- package/dist/bundle/chunks/settings-manager-YNY5F4RU.js +2 -0
- package/dist/bundle/chunks/typesafe-system-one-67GAWZXE.js +2 -0
- package/dist/bundle/chunks/virtual-modules-U4CBGVMI.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +2 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +30 -8
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/config.d.ts +18 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +44 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +65 -8
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +240 -102
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +20 -13
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +42 -52
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bug-report.d.ts +9 -1
- package/dist/core/bug-report.d.ts.map +1 -1
- package/dist/core/builtins/completion-checks.d.ts +3 -0
- package/dist/core/builtins/completion-checks.d.ts.map +1 -0
- package/dist/core/builtins/completion-checks.js +142 -0
- package/dist/core/builtins/completion-checks.js.map +1 -0
- package/dist/core/builtins/duet.d.ts.map +1 -1
- package/dist/core/builtins/duet.js +7 -5
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/builtins/git-safety.d.ts +3 -0
- package/dist/core/builtins/git-safety.d.ts.map +1 -0
- package/dist/core/builtins/git-safety.js +34 -0
- package/dist/core/builtins/git-safety.js.map +1 -0
- package/dist/core/builtins/index.d.ts.map +1 -1
- package/dist/core/builtins/index.js +4 -0
- package/dist/core/builtins/index.js.map +1 -1
- package/dist/core/client-identity.d.ts +8 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +15 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +6 -0
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +7 -8
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +23 -17
- package/dist/core/export-html/tool-renderer.d.ts +3 -3
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +5 -3
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +30 -29
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +7 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +16 -4
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +61 -7
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +2 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/key-id-schema.d.ts +6 -0
- package/dist/core/key-id-schema.d.ts.map +1 -0
- package/dist/core/key-id-schema.js +16 -0
- package/dist/core/key-id-schema.js.map +1 -0
- package/dist/core/keybindings-schema.d.ts +4 -0
- package/dist/core/keybindings-schema.d.ts.map +1 -0
- package/dist/core/keybindings-schema.js +16 -0
- package/dist/core/keybindings-schema.js.map +1 -0
- package/dist/core/keybindings.d.ts +242 -75
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +30 -23
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +22 -0
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +72 -11
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-config.d.ts +1623 -74
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +70 -184
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +56 -43
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +253 -358
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +19 -10
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +1 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -1
- package/dist/core/nested-tool-calls.js +1 -0
- package/dist/core/nested-tool-calls.js.map +1 -1
- package/dist/core/package-manager.js +3 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/polyphase/keyword.js +1 -1
- package/dist/core/polyphase/keyword.js.map +1 -1
- package/dist/core/polyphase/model-selection.d.ts.map +1 -1
- package/dist/core/polyphase/model-selection.js +15 -7
- package/dist/core/polyphase/model-selection.js.map +1 -1
- package/dist/core/polyphase/workflow/prelude.d.ts +2 -0
- package/dist/core/polyphase/workflow/prelude.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/prelude.js +12 -16
- package/dist/core/polyphase/workflow/prelude.js.map +1 -1
- package/dist/core/polyphase/workflow/runtime.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/runtime.js +2 -1
- package/dist/core/polyphase/workflow/runtime.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +2 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +7 -2
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +13 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +12 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +84 -24
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +3 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +7 -4
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +13 -4
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +27 -15
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +65 -0
- package/dist/core/settings-defaults.d.ts.map +1 -0
- package/dist/core/settings-defaults.js +66 -0
- package/dist/core/settings-defaults.js.map +1 -0
- package/dist/core/settings-manager.d.ts +17 -178
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +86 -57
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +269 -0
- package/dist/core/settings-schema.d.ts.map +1 -0
- package/dist/core/settings-schema.js +318 -0
- package/dist/core/settings-schema.js.map +1 -0
- package/dist/core/skills.d.ts +4 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -5
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/grep.d.ts +8 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +19 -7
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +2 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +2 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +4 -10
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +6 -6
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts +13 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +32 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +20 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +67 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +7 -35
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/edit.d.ts.map +1 -1
- package/dist/core/tools/renderers/edit.js +5 -4
- package/dist/core/tools/renderers/edit.js.map +1 -1
- package/dist/core/tools/renderers/index.d.ts +2 -2
- package/dist/core/tools/renderers/index.d.ts.map +1 -1
- package/dist/core/tools/renderers/index.js.map +1 -1
- package/dist/core/tools/renderers/read.d.ts.map +1 -1
- package/dist/core/tools/renderers/read.js +7 -11
- package/dist/core/tools/renderers/read.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +391 -80
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +3 -1
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts +2 -2
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +9 -3
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +22 -21
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +96 -123
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +34 -11
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +27 -33
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +15 -3
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +49 -12
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +4 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +279 -129
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +21 -11
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +166 -45
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/resources.d.ts +3 -10
- package/dist/extensions/mcp/resources.d.ts.map +1 -1
- package/dist/extensions/mcp/resources.js +4 -5
- package/dist/extensions/mcp/resources.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +7 -7
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +31 -45
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +7 -5
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +87 -29
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +3 -3
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +18 -6
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +0 -2
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +2 -4
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/hooks/checks/checks-runtime.cjs +215 -0
- package/dist/hooks/checks/git-safety.cjs +198 -0
- package/dist/hooks/checks/git-safety.d.cts +1 -0
- package/dist/hooks/gsd/draht-post-task.js +78 -39
- package/dist/hooks/gsd/draht-quality-gate.js +210 -122
- package/dist/hooks/gsd/package.json +3 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -3
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/auth-url.d.ts +14 -0
- package/dist/modes/interactive/components/auth-url.d.ts.map +1 -0
- package/dist/modes/interactive/components/auth-url.js +37 -0
- package/dist/modes/interactive/components/auth-url.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +5 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +17 -14
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +5 -2
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +5 -2
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +3 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +8 -2
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +3 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +38 -10
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +24 -21
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +85 -0
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +9 -8
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +5 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +2 -2
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +12 -13
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +32 -45
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -9
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +5 -4
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +43 -48
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +362 -278
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/program-status-reporter.d.ts +34 -0
- package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
- package/dist/modes/interactive/program-status-reporter.js +110 -0
- package/dist/modes/interactive/program-status-reporter.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/system-theme.js +16 -5
- package/dist/modes/interactive/theme/system-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.js +105 -0
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.js +94 -0
- package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +13 -16
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +22 -29
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +4 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +26 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/atomic-commit.md +8 -6
- package/dist/prompts/commands/brainstorm.md +5 -149
- package/dist/prompts/commands/create-verification-skill.md +8 -48
- package/dist/prompts/commands/discuss-phase.md +6 -10
- package/dist/prompts/commands/execute-phase.md +18 -45
- package/dist/prompts/commands/fix.md +16 -128
- package/dist/prompts/commands/grill.md +6 -53
- package/dist/prompts/commands/init-project.md +13 -18
- package/dist/prompts/commands/map-codebase.md +3 -3
- package/dist/prompts/commands/new-project.md +12 -17
- package/dist/prompts/commands/next-milestone.md +4 -8
- package/dist/prompts/commands/orchestrate-loop.md +12 -12
- package/dist/prompts/commands/orchestrate.md +12 -11
- package/dist/prompts/commands/pause-work.md +1 -1
- package/dist/prompts/commands/plan-phase.md +15 -37
- package/dist/prompts/commands/quick.md +11 -64
- package/dist/prompts/commands/resolve-conflicts.md +2 -15
- package/dist/prompts/commands/triage.md +3 -14
- package/dist/prompts/commands/verify-work.md +15 -63
- package/dist/prompts/commands/why.md +18 -118
- package/dist/skills/atomic-reasoning/SKILL.md +6 -105
- package/dist/skills/blast-radius/SKILL.md +1 -1
- package/dist/skills/epistemics/SKILL.md +12 -87
- package/dist/skills/explainers/SKILL.md +1 -1
- package/dist/skills/typescript-discipline/SKILL.md +12 -42
- package/dist/skills/typescript-discipline/references/patterns.md +25 -266
- package/dist/skills/unslop/SKILL.md +14 -105
- package/dist/utils/ansi.d.ts +8 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +30 -11
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +3 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +18 -12
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/draht-user-agent.d.ts +1 -0
- package/dist/utils/draht-user-agent.d.ts.map +1 -1
- package/dist/utils/draht-user-agent.js +3 -2
- package/dist/utils/draht-user-agent.js.map +1 -1
- package/dist/utils/image-convert.d.ts +12 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +45 -6
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts +12 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +5 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.js +3 -2
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +9 -10
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/output-files.d.ts +15 -0
- package/dist/utils/output-files.d.ts.map +1 -0
- package/dist/utils/output-files.js +30 -0
- package/dist/utils/output-files.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +43 -13
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +6 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +4 -3
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/cli-integration.md +1 -1
- package/docs/cli.md +30 -26
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +5 -5
- package/docs/containerization.md +1 -1
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +17 -1
- package/docs/drahtbank.md +163 -0
- package/docs/environment-variables.md +5 -2
- package/docs/extensions.md +143 -13
- package/docs/index.md +1 -1
- package/docs/json.md +3 -3
- package/docs/keybindings.md +9 -5
- package/docs/llama-cpp.md +9 -2
- package/docs/mcp.md +59 -3
- package/docs/message-types.md +22 -4
- package/docs/models-configuration.md +187 -0
- package/docs/models.md +67 -4
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/providers.md +70 -5
- package/docs/sdk.md +1 -1
- package/docs/settings.md +10 -8
- package/docs/terminal-setup.md +14 -0
- package/docs/themes.md +4 -2
- package/docs/tui.md +71 -1
- package/docs/usage.md +1 -1
- package/docs/windows.md +16 -2
- package/eval/drahtbank/adapters.d.mts +35 -0
- package/eval/drahtbank/adapters.mjs +192 -0
- package/eval/drahtbank/bank.d.mts +141 -0
- package/eval/drahtbank/bank.mjs +515 -0
- package/eval/drahtbank/cases-v2.d.mts +28 -0
- package/eval/drahtbank/cases-v2.mjs +164 -0
- package/eval/drahtbank/cases.d.mts +17 -0
- package/eval/drahtbank/cases.mjs +198 -0
- package/eval/drahtbank/cli.mjs +120 -0
- package/eval/drahtbank/grading-v2.d.mts +26 -0
- package/eval/drahtbank/grading-v2.mjs +227 -0
- package/eval/drahtbank/isolated-tools.ts +223 -0
- package/eval/drahtbank/isolation-worker.mjs +53 -0
- package/eval/drahtbank/isolation.d.mts +52 -0
- package/eval/drahtbank/isolation.mjs +345 -0
- package/eval/drahtbank/runtime-checks.d.mts +15 -0
- package/eval/drahtbank/runtime-checks.mjs +187 -0
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/minimal-mode.ts +4 -5
- package/examples/extensions/overlay-test.ts +2 -2
- package/examples/extensions/plan-mode/index.ts +6 -2
- package/examples/extensions/subagent/index.ts +4 -6
- package/hooks/checks/checks-runtime.cjs +215 -0
- package/hooks/checks/git-safety.cjs +198 -0
- package/hooks/checks/git-safety.d.cts +1 -0
- package/hooks/gsd/draht-post-task.js +78 -39
- package/hooks/gsd/draht-quality-gate.js +210 -122
- package/hooks/gsd/package.json +3 -0
- package/package.json +21 -16
- package/prompts/commands/atomic-commit.md +8 -6
- package/prompts/commands/brainstorm.md +5 -149
- package/prompts/commands/create-verification-skill.md +8 -48
- package/prompts/commands/discuss-phase.md +6 -10
- package/prompts/commands/execute-phase.md +18 -45
- package/prompts/commands/fix.md +16 -128
- package/prompts/commands/grill.md +6 -53
- package/prompts/commands/init-project.md +13 -18
- package/prompts/commands/map-codebase.md +3 -3
- package/prompts/commands/new-project.md +12 -17
- package/prompts/commands/next-milestone.md +4 -8
- package/prompts/commands/orchestrate-loop.md +12 -12
- package/prompts/commands/orchestrate.md +12 -11
- package/prompts/commands/pause-work.md +1 -1
- package/prompts/commands/plan-phase.md +15 -37
- package/prompts/commands/quick.md +11 -64
- package/prompts/commands/resolve-conflicts.md +2 -15
- package/prompts/commands/triage.md +3 -14
- package/prompts/commands/verify-work.md +15 -63
- package/prompts/commands/why.md +18 -118
- package/schemas/keybindings.schema.json +433 -0
- package/schemas/models.schema.json +1190 -0
- package/schemas/settings.schema.json +849 -0
- package/schemas/theme.schema.json +365 -0
- package/skills/atomic-reasoning/SKILL.md +6 -105
- package/skills/blast-radius/SKILL.md +1 -1
- package/skills/epistemics/SKILL.md +12 -87
- package/skills/explainers/SKILL.md +1 -1
- package/skills/typescript-discipline/SKILL.md +12 -42
- package/skills/typescript-discipline/references/patterns.md +25 -266
- package/skills/unslop/SKILL.md +14 -105
- package/dist/bundle/chunks/anthropic-messages-E2P6C3P7.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-JZMSTDIM.js +0 -2
- package/dist/bundle/chunks/chunk-2E5VODES.js +0 -2
- package/dist/bundle/chunks/chunk-3DQNSI5W.js +0 -137
- package/dist/bundle/chunks/chunk-4COXSQRQ.js +0 -18
- package/dist/bundle/chunks/chunk-D3HO453P.js +0 -42
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +0 -2
- package/dist/bundle/chunks/chunk-I2SOJ4JN.js +0 -65
- package/dist/bundle/chunks/chunk-I5OKY6RH.js +0 -11
- package/dist/bundle/chunks/chunk-ILSPVHVH.js +0 -1623
- package/dist/bundle/chunks/chunk-KY2BG6BC.js +0 -11
- package/dist/bundle/chunks/chunk-PGJAHC3R.js +0 -107
- package/dist/bundle/chunks/chunk-QVFELZW2.js +0 -312
- package/dist/bundle/chunks/chunk-QVTLBSTH.js +0 -4
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +0 -2
- package/dist/bundle/chunks/chunk-U6LDZZGM.js +0 -146
- package/dist/bundle/chunks/chunk-X3YFUSCK.js +0 -82
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +0 -2
- package/dist/bundle/chunks/chunk-XHCO4PPH.js +0 -8
- package/dist/bundle/chunks/chunk-YH7HNI7D.js +0 -2
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +0 -2
- package/dist/bundle/chunks/execute-AGEWJLIO.js +0 -18
- package/dist/bundle/chunks/google-generative-ai-HPNDIAZD.js +0 -2
- package/dist/bundle/chunks/google-vertex-KPAWJ4SP.js +0 -2
- package/dist/bundle/chunks/mistral-conversations-FMSPWQ7A.js +0 -5
- package/dist/bundle/chunks/node-4JNG6XQO.js +0 -16
- package/dist/bundle/chunks/openai-codex-responses-TU7NGPXE.js +0 -10
- package/dist/bundle/chunks/openai-completions-GANCQQO5.js +0 -7
- package/dist/bundle/chunks/openai-responses-ASDPAX3E.js +0 -3
- package/dist/bundle/chunks/openrouter-images-NROSQXMZ.js +0 -2
- package/dist/bundle/chunks/pi-messages-2QEJYOAO.js +0 -8
- package/dist/bundle/chunks/runtime-2B56SZM6.js +0 -2
- package/dist/bundle/chunks/runtime-TJ3EAMJK.js +0 -3
- package/dist/bundle/chunks/settings-manager-HC5RR36T.js +0 -2
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +0 -2
- package/dist/bundle/chunks/virtual-modules-XKLDADFR.js +0 -2
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -72
- package/dist/core/provider-attribution.js.map +0 -1
- package/dist/experimental/micro/api.d.ts +0 -81
- package/dist/experimental/micro/api.d.ts.map +0 -1
- package/dist/experimental/micro/api.js +0 -2
- package/dist/experimental/micro/api.js.map +0 -1
- package/dist/experimental/micro/main.d.ts +0 -3
- package/dist/experimental/micro/main.d.ts.map +0 -1
- package/dist/experimental/micro/main.js +0 -21
- package/dist/experimental/micro/main.js.map +0 -1
- package/dist/experimental/micro/models.d.ts +0 -11
- package/dist/experimental/micro/models.d.ts.map +0 -1
- package/dist/experimental/micro/models.js +0 -95
- package/dist/experimental/micro/models.js.map +0 -1
- package/dist/experimental/micro/runtime.d.ts +0 -12
- package/dist/experimental/micro/runtime.d.ts.map +0 -1
- package/dist/experimental/micro/runtime.js +0 -465
- package/dist/experimental/micro/runtime.js.map +0 -1
- package/dist/experimental/micro/sessions.d.ts +0 -10
- package/dist/experimental/micro/sessions.d.ts.map +0 -1
- package/dist/experimental/micro/sessions.js +0 -41
- package/dist/experimental/micro/sessions.js.map +0 -1
- package/dist/experimental/micro/tools.d.ts +0 -10
- package/dist/experimental/micro/tools.d.ts.map +0 -1
- package/dist/experimental/micro/tools.js +0 -96
- package/dist/experimental/micro/tools.js.map +0 -1
- package/dist/experimental/micro/tui.d.ts +0 -3
- package/dist/experimental/micro/tui.d.ts.map +0 -1
- package/dist/experimental/micro/tui.js +0 -510
- package/dist/experimental/micro/tui.js.map +0 -1
- package/dist/experimental/mini/main.d.ts +0 -7
- package/dist/experimental/mini/main.d.ts.map +0 -1
- package/dist/experimental/mini/main.js +0 -21
- package/dist/experimental/mini/main.js.map +0 -1
- package/dist/experimental/mini/server/entry.d.ts +0 -3
- package/dist/experimental/mini/server/entry.d.ts.map +0 -1
- package/dist/experimental/mini/server/entry.js +0 -11
- package/dist/experimental/mini/server/entry.js.map +0 -1
- package/dist/experimental/mini/server/run.d.ts +0 -13
- package/dist/experimental/mini/server/run.d.ts.map +0 -1
- package/dist/experimental/mini/server/run.js +0 -150
- package/dist/experimental/mini/server/run.js.map +0 -1
- package/dist/experimental/mini/shared/protocol.d.ts +0 -127
- package/dist/experimental/mini/shared/protocol.d.ts.map +0 -1
- package/dist/experimental/mini/shared/protocol.js +0 -13
- package/dist/experimental/mini/shared/protocol.js.map +0 -1
- package/dist/experimental/mini/shared/rpc.d.ts +0 -49
- package/dist/experimental/mini/shared/rpc.d.ts.map +0 -1
- package/dist/experimental/mini/shared/rpc.js +0 -171
- package/dist/experimental/mini/shared/rpc.js.map +0 -1
- package/dist/experimental/mini/shared/transport.d.ts +0 -35
- package/dist/experimental/mini/shared/transport.d.ts.map +0 -1
- package/dist/experimental/mini/shared/transport.js +0 -94
- package/dist/experimental/mini/shared/transport.js.map +0 -1
- package/dist/experimental/mini/tui/run.d.ts +0 -9
- package/dist/experimental/mini/tui/run.d.ts.map +0 -1
- package/dist/experimental/mini/tui/run.js +0 -62
- package/dist/experimental/mini/tui/run.js.map +0 -1
- package/dist/experimental/mini/tui/session.d.ts +0 -26
- package/dist/experimental/mini/tui/session.d.ts.map +0 -1
- package/dist/experimental/mini/tui/session.js +0 -94
- package/dist/experimental/mini/tui/session.js.map +0 -1
- package/dist/experimental/mini/tui/view.d.ts +0 -10
- package/dist/experimental/mini/tui/view.d.ts.map +0 -1
- package/dist/experimental/mini/tui/view.js +0 -461
- package/dist/experimental/mini/tui/view.js.map +0 -1
- package/dist/experimental/mini/worker/entry.d.ts +0 -3
- package/dist/experimental/mini/worker/entry.d.ts.map +0 -1
- package/dist/experimental/mini/worker/entry.js +0 -10
- package/dist/experimental/mini/worker/entry.js.map +0 -1
- package/dist/experimental/mini/worker/lane-service.d.ts +0 -44
- package/dist/experimental/mini/worker/lane-service.d.ts.map +0 -1
- package/dist/experimental/mini/worker/lane-service.js +0 -97
- package/dist/experimental/mini/worker/lane-service.js.map +0 -1
- package/dist/experimental/mini/worker/models-service.d.ts +0 -19
- package/dist/experimental/mini/worker/models-service.d.ts.map +0 -1
- package/dist/experimental/mini/worker/models-service.js +0 -136
- package/dist/experimental/mini/worker/models-service.js.map +0 -1
- package/dist/experimental/mini/worker/run.d.ts +0 -14
- package/dist/experimental/mini/worker/run.d.ts.map +0 -1
- package/dist/experimental/mini/worker/run.js +0 -88
- package/dist/experimental/mini/worker/run.js.map +0 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +0 -85
- package/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme-json.js +0 -132
- package/dist/modes/interactive/theme/theme-json.js.map +0 -1
- package/dist/modes/interactive/theme/theme-schema.json +0 -361
- /package/dist/bundle/chunks/{chunk-FBU742QF.js → chunk-MOOADNVS.js} +0 -0
|
@@ -29,12 +29,12 @@ import { join, resolve } from "node:path";
|
|
|
29
29
|
import { CONFIG_DIR_NAME, getAgentDir } from "../../config.js";
|
|
30
30
|
import { mcpNamespace } from "../../core/mcp-servers.js";
|
|
31
31
|
import { openBrowser } from "../../utils/open-browser.js";
|
|
32
|
-
import { CODEMODE_TOOL_NAME
|
|
33
|
-
import {
|
|
32
|
+
import { CODEMODE_TOOL_NAME } from "../codemode/tool.js";
|
|
33
|
+
import { TOOL_SEARCH_TOOL_NAME } from "../tool-search/tool.js";
|
|
34
34
|
import { getMcpToolExposure, loadMcpConfig, updateMcpServerConfig, } from "./config.js";
|
|
35
35
|
import { createMcpResourceToolDefinitions, LIST_MCP_RESOURCE_TEMPLATES_TOOL, LIST_MCP_RESOURCES_TOOL, READ_MCP_RESOURCE_TOOL, } from "./resources.js";
|
|
36
36
|
import { loadMcpRuntime } from "./runtime.lazy.js";
|
|
37
|
-
import { createMcpToolDefinition, createMcpToolName } from "./tools.js";
|
|
37
|
+
import { createMcpToolDefinition, createMcpToolName, createMcpToolRenderers } from "./tools.js";
|
|
38
38
|
import { showMcpManager } from "./ui.js";
|
|
39
39
|
const DEFAULT_STARTUP_WAIT_MS = 10_000;
|
|
40
40
|
const RESOURCE_TOOL_NAMES = new Set([
|
|
@@ -81,7 +81,15 @@ const MAX_SERVER_DESCRIPTION_CHARS = 250;
|
|
|
81
81
|
* fit, the last servers are left out and counted in a closing line.
|
|
82
82
|
*/
|
|
83
83
|
export const MAX_SERVERS_SECTION_CHARS = 4096;
|
|
84
|
-
|
|
84
|
+
/** The section's first line. It explains only the ways of reaching tools that the listed servers use. */
|
|
85
|
+
function serversSectionIntro(reaches) {
|
|
86
|
+
let intro = "MCP servers whose tools are not declared to you.";
|
|
87
|
+
if (reaches.has("codemode"))
|
|
88
|
+
intro += " Call the tools of `codemode` servers from codemode scripts.";
|
|
89
|
+
if (reaches.has("tool_search"))
|
|
90
|
+
intro += " Load the tools of `tool_search` servers with `tool_search`.";
|
|
91
|
+
return intro;
|
|
92
|
+
}
|
|
85
93
|
function truncate(text, max) {
|
|
86
94
|
if (text.length <= max)
|
|
87
95
|
return text;
|
|
@@ -103,14 +111,12 @@ export function renderServersSection(servers) {
|
|
|
103
111
|
.sort((a, b) => a.entry.name.localeCompare(b.entry.name));
|
|
104
112
|
if (listed.length === 0)
|
|
105
113
|
return undefined;
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return `- ${mcpNamespace(server.entry.name)} (${reach})`;
|
|
110
|
-
});
|
|
114
|
+
const reaches = listed.map((server) => configuredExposures(server.entry).has("codemode") ? "codemode" : "tool_search");
|
|
115
|
+
const intro = serversSectionIntro(new Set(reaches));
|
|
116
|
+
const heads = listed.map((server, index) => `- ${mcpNamespace(server.entry.name)} (${reaches[index]})`);
|
|
111
117
|
const omitted = (count) => count > 0 ? [`- … ${count} more server${count === 1 ? "" : "s"}; find their tools with searchTools()`] : [];
|
|
112
118
|
// Characters of the intro, the first `kept` server lines without descriptions, and the omission line.
|
|
113
|
-
const size = (kept) => [
|
|
119
|
+
const size = (kept) => [intro, ...heads.slice(0, kept), ...omitted(listed.length - kept)].join("\n").length;
|
|
114
120
|
let kept = listed.length;
|
|
115
121
|
while (kept > 0 && size(kept) > MAX_SERVERS_SECTION_CHARS)
|
|
116
122
|
kept--;
|
|
@@ -122,16 +128,17 @@ export function renderServersSection(servers) {
|
|
|
122
128
|
const summary = perServer > 0 ? truncate(serverSummary(server), perServer) : "";
|
|
123
129
|
return summary ? `${heads[index]}: ${summary}` : heads[index];
|
|
124
130
|
});
|
|
125
|
-
return [
|
|
131
|
+
return [intro, ...lines, ...omitted(listed.length - kept)].join("\n");
|
|
126
132
|
}
|
|
127
133
|
/**
|
|
128
|
-
* Whether a
|
|
129
|
-
*
|
|
134
|
+
* Whether a call that reaches `reach` (see `ToolDefinition.reachesTools`) needs the server: it
|
|
135
|
+
* reaches every tool, or one of its words contains the server's namespace.
|
|
130
136
|
*/
|
|
131
|
-
function
|
|
132
|
-
if (
|
|
137
|
+
function reachesServer(reach, server) {
|
|
138
|
+
if (reach === "all")
|
|
133
139
|
return true;
|
|
134
|
-
|
|
140
|
+
const namespace = mcpNamespace(server);
|
|
141
|
+
return reach.some((word) => word.includes(namespace));
|
|
135
142
|
}
|
|
136
143
|
/** Short state for lists and the startup report. `withError` appends the first line of a failure. */
|
|
137
144
|
function describeState(server, withError = true) {
|
|
@@ -146,10 +153,8 @@ function describeState(server, withError = true) {
|
|
|
146
153
|
case "failed":
|
|
147
154
|
return withError ? `failed: ${firstLine(connection.error ?? "unknown error")}` : "failed";
|
|
148
155
|
case "connected": {
|
|
149
|
-
const { tools,
|
|
150
|
-
|
|
151
|
-
const resourceCount = count > 0 ? ` · ${count} resource${count === 1 ? "" : "s"}` : "";
|
|
152
|
-
return `connected · ${tools.length} tool${tools.length === 1 ? "" : "s"}${resourceCount}`;
|
|
156
|
+
const { tools, hasResources } = connection;
|
|
157
|
+
return `connected · ${tools.length} tool${tools.length === 1 ? "" : "s"}${hasResources ? " · resources" : ""}`;
|
|
153
158
|
}
|
|
154
159
|
case "connecting":
|
|
155
160
|
return "connecting…";
|
|
@@ -187,10 +192,10 @@ export function createMcpExtension(options = {}) {
|
|
|
187
192
|
/** Servers from `mcp.json`, which take precedence over registered servers of the same name. */
|
|
188
193
|
let configuredEntries = [];
|
|
189
194
|
let configErrors = [];
|
|
195
|
+
/** The trusted project's `mcp.json`, where `/mcp` saves project overrides of global servers. */
|
|
196
|
+
let projectConfig;
|
|
190
197
|
/** Registered servers that `mcp.json` overrides, shown in `/mcp`. */
|
|
191
198
|
let overridden = [];
|
|
192
|
-
/** Between session_start and session_shutdown. Registrations before that are read on session_start. */
|
|
193
|
-
let sessionActive = false;
|
|
194
199
|
let autoEnableCodemode = true;
|
|
195
200
|
/** Whether the "codemode tools unreachable" warning was shown since the session started. */
|
|
196
201
|
let warnedUnreachable = false;
|
|
@@ -198,8 +203,6 @@ export function createMcpExtension(options = {}) {
|
|
|
198
203
|
/** Whether a prompt already waited for the startup connections since the session started. */
|
|
199
204
|
let waitedForStartup = false;
|
|
200
205
|
const startupWaitMs = options.startupWaitMs ?? DEFAULT_STARTUP_WAIT_MS;
|
|
201
|
-
/** Bumped on every session start and shutdown so a runtime load that resolves late is dropped. */
|
|
202
|
-
let generation = 0;
|
|
203
206
|
/** Working directory of the session, for stdio servers. */
|
|
204
207
|
let sessionCwd = process.cwd();
|
|
205
208
|
let credentials = options.credentials;
|
|
@@ -207,7 +210,27 @@ export function createMcpExtension(options = {}) {
|
|
|
207
210
|
let modelRegistry;
|
|
208
211
|
let serverLog;
|
|
209
212
|
const openUrl = options.openUrl ?? openBrowser;
|
|
210
|
-
const updateConfig = options.updateConfig ??
|
|
213
|
+
const updateConfig = options.updateConfig ??
|
|
214
|
+
((entry, patch) => updateMcpServerConfig(entry.override ?? entry.source, entry.name, patch, {
|
|
215
|
+
override: entry.override !== undefined,
|
|
216
|
+
}));
|
|
217
|
+
/**
|
|
218
|
+
* Lifetime of the current session: aborted on session_shutdown, and before the first session_start
|
|
219
|
+
* (registrations before that are read on session_start). Work captures `session.signal` when it
|
|
220
|
+
* starts and drops late results once it aborted, for example a runtime load that resolves after
|
|
221
|
+
* shutdown. Work that outlives the command that started it also stops on the signal and is
|
|
222
|
+
* registered with `track`, so shutdown can wait for its cleanup.
|
|
223
|
+
*/
|
|
224
|
+
let session = new AbortController();
|
|
225
|
+
session.abort();
|
|
226
|
+
/** Work registered with `track`: manager actions opening or closing connections, and sign-ins. */
|
|
227
|
+
const backgroundActions = new Set();
|
|
228
|
+
const track = (work) => {
|
|
229
|
+
const task = work.then(() => undefined, () => undefined);
|
|
230
|
+
backgroundActions.add(task);
|
|
231
|
+
void task.finally(() => backgroundActions.delete(task));
|
|
232
|
+
return work;
|
|
233
|
+
};
|
|
211
234
|
const listeners = new Set();
|
|
212
235
|
const emitChange = () => {
|
|
213
236
|
for (const listener of listeners)
|
|
@@ -252,12 +275,19 @@ export function createMcpExtension(options = {}) {
|
|
|
252
275
|
const serverTools = new Map();
|
|
253
276
|
/** Last definition registered under each tool name, to re-register withdrawn tools as hidden. */
|
|
254
277
|
const definitions = new Map();
|
|
278
|
+
// A resumed session renders calls to MCP tools before their server connected, if it ever does.
|
|
279
|
+
pi.registerToolRenderer((toolName, next) => {
|
|
280
|
+
const match = /^mcp__(.+?)__(.+)$/.exec(toolName);
|
|
281
|
+
return next() ?? (match ? createMcpToolRenderers(`${match[1]}/${match[2]}`) : undefined);
|
|
282
|
+
});
|
|
255
283
|
const registerTools = (connection) => {
|
|
256
284
|
const server = connection.entry.name;
|
|
257
285
|
const entry = findServer(server)?.entry ?? connection.entry;
|
|
258
286
|
const description = entry.config.description?.trim();
|
|
259
287
|
const namespace = {
|
|
260
288
|
name: mcpNamespace(server),
|
|
289
|
+
// `describeNamespace("docs")` finds `mcp__docs`.
|
|
290
|
+
aliases: [server],
|
|
261
291
|
...(description ? { description } : {}),
|
|
262
292
|
...(connection.instructions ? { instructions: connection.instructions } : {}),
|
|
263
293
|
};
|
|
@@ -285,8 +315,22 @@ export function createMcpExtension(options = {}) {
|
|
|
285
315
|
exposure: getMcpToolExposure(entry.config, tool.name),
|
|
286
316
|
namespace,
|
|
287
317
|
timeoutMs: connection.timeoutMs,
|
|
288
|
-
getClient: async () =>
|
|
289
|
-
|
|
318
|
+
getClient: async () => {
|
|
319
|
+
// A prepared call can outlive this definition's connection while the readiness
|
|
320
|
+
// hook waits for a disable/re-enable. Resolve the replacement at execution time.
|
|
321
|
+
const current = findServer(server);
|
|
322
|
+
if (!current || !isEnabled(current))
|
|
323
|
+
throw new Error(`MCP server "${server}" is disabled.`);
|
|
324
|
+
const client = current.connection;
|
|
325
|
+
if (!client)
|
|
326
|
+
throw new Error(`MCP server "${server}" is still starting.`);
|
|
327
|
+
if (getMcpToolExposure(current.entry.config, tool.name) === "hidden" ||
|
|
328
|
+
(client.state === "connected" && !client.tools.some((offered) => offered.name === tool.name))) {
|
|
329
|
+
throw new Error(`MCP tool "${server}/${tool.name}" is no longer available.`);
|
|
330
|
+
}
|
|
331
|
+
return client;
|
|
332
|
+
},
|
|
333
|
+
readableResources: () => resourceServers().some((current) => current.name === server),
|
|
290
334
|
});
|
|
291
335
|
definitions.set(definition.name, definition);
|
|
292
336
|
pi.registerTool(definition);
|
|
@@ -355,10 +399,12 @@ export function createMcpExtension(options = {}) {
|
|
|
355
399
|
const needsToolSearch = exposures.has("deferred");
|
|
356
400
|
if (!needsCodemode && !needsToolSearch)
|
|
357
401
|
return;
|
|
358
|
-
//
|
|
402
|
+
// Only a tool of these names that declares `reachesTools` can reach MCP tools; another
|
|
403
|
+
// extension's tool of the same name without it is never activated.
|
|
359
404
|
const tools = pi.getAllTools();
|
|
360
|
-
const
|
|
361
|
-
const
|
|
405
|
+
const hasReachingTool = (name) => tools.some((tool) => tool.name === name && tool.reachesTools);
|
|
406
|
+
const hasCodemode = hasReachingTool(CODEMODE_TOOL_NAME);
|
|
407
|
+
const hasToolSearch = hasReachingTool(TOOL_SEARCH_TOOL_NAME);
|
|
362
408
|
const active = pi.getActiveTools();
|
|
363
409
|
const activate = [];
|
|
364
410
|
if (needsCodemode && hasCodemode && autoEnableCodemode && !active.includes(CODEMODE_TOOL_NAME)) {
|
|
@@ -387,7 +433,7 @@ export function createMcpExtension(options = {}) {
|
|
|
387
433
|
const tokensAtSignIn = new Map();
|
|
388
434
|
const storedTokens = (connection) => {
|
|
389
435
|
const url = connection.oauthUrl;
|
|
390
|
-
return url && credentials ? JSON.stringify(credentials.tokens(url) ?? null) : "null";
|
|
436
|
+
return url && credentials ? JSON.stringify(credentials.tokens(connection.name, url) ?? null) : "null";
|
|
391
437
|
};
|
|
392
438
|
const onConnectionChange = (connection) => {
|
|
393
439
|
if (connection.state !== "needs-auth")
|
|
@@ -407,8 +453,10 @@ export function createMcpExtension(options = {}) {
|
|
|
407
453
|
ensureDiscoveryActive(ctx);
|
|
408
454
|
};
|
|
409
455
|
/** Create the server's connection, loading the MCP runtime on first use. */
|
|
410
|
-
const createConnection = async (server) => {
|
|
456
|
+
const createConnection = async (server, isCurrent) => {
|
|
411
457
|
const runtime = await loadMcpRuntime();
|
|
458
|
+
if (!isCurrent())
|
|
459
|
+
return undefined;
|
|
412
460
|
const connection = new runtime.McpServerConnection({
|
|
413
461
|
entry: server.entry,
|
|
414
462
|
cwd: sessionCwd,
|
|
@@ -416,8 +464,16 @@ export function createMcpExtension(options = {}) {
|
|
|
416
464
|
credentials: getCredentials(runtime),
|
|
417
465
|
providerToken: async (provider) => modelRegistry?.getApiKeyForProvider(provider),
|
|
418
466
|
log: getServerLog(runtime),
|
|
419
|
-
onTools:
|
|
420
|
-
|
|
467
|
+
onTools: (connection) => {
|
|
468
|
+
if (isCurrent())
|
|
469
|
+
registerTools(connection);
|
|
470
|
+
},
|
|
471
|
+
onChange: (connection) => {
|
|
472
|
+
if (isCurrent())
|
|
473
|
+
onConnectionChange(connection);
|
|
474
|
+
else
|
|
475
|
+
tokensAtSignIn.delete(connection);
|
|
476
|
+
},
|
|
421
477
|
});
|
|
422
478
|
server.connection = connection;
|
|
423
479
|
emitChange();
|
|
@@ -425,37 +481,48 @@ export function createMcpExtension(options = {}) {
|
|
|
425
481
|
};
|
|
426
482
|
/**
|
|
427
483
|
* Connect the server in the background. `server.ready` settles when it connected or failed;
|
|
428
|
-
* failures show in its state. It starts after `after
|
|
484
|
+
* failures show in its state. It starts after `after`, unless disabled, replaced, or shut down
|
|
429
485
|
* meanwhile. The returned promise rejects when the MCP runtime cannot be loaded.
|
|
430
486
|
*/
|
|
431
|
-
const startConnection = (server,
|
|
487
|
+
const startConnection = (server, after) => {
|
|
488
|
+
const { signal } = session;
|
|
489
|
+
const attempt = Symbol();
|
|
490
|
+
server.attempt = attempt;
|
|
491
|
+
const isCurrent = () => !signal.aborted && server.attempt === attempt && isEnabled(server) && servers.includes(server);
|
|
432
492
|
const ready = (async () => {
|
|
433
493
|
await after;
|
|
434
494
|
if (!isCurrent())
|
|
435
495
|
return;
|
|
436
|
-
const connection = await createConnection(server);
|
|
437
|
-
if (!isCurrent())
|
|
496
|
+
const connection = await createConnection(server, isCurrent);
|
|
497
|
+
if (!connection || !isCurrent())
|
|
438
498
|
return;
|
|
439
499
|
await connection.getClient().catch(() => undefined);
|
|
440
500
|
})();
|
|
441
501
|
server.ready = ready.catch(() => undefined);
|
|
442
502
|
return ready;
|
|
443
503
|
};
|
|
444
|
-
/** Wait for
|
|
504
|
+
/** Wait for the latest connection attempts, including ones queued while waiting, or an abort. */
|
|
445
505
|
const waitForServers = async (waiting, signal) => {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
Promise.
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
506
|
+
for (;;) {
|
|
507
|
+
const ready = waiting.flatMap((server) => isEnabled(server) && servers.includes(server) && server.ready ? [{ server, ready: server.ready }] : []);
|
|
508
|
+
if (ready.length === 0 || signal?.aborted)
|
|
509
|
+
return;
|
|
510
|
+
let onAbort;
|
|
511
|
+
await Promise.race([
|
|
512
|
+
Promise.all(ready.map((attempt) => attempt.ready)),
|
|
513
|
+
new Promise((resolve) => {
|
|
514
|
+
onAbort = () => resolve();
|
|
515
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
516
|
+
}),
|
|
517
|
+
]);
|
|
518
|
+
if (onAbort)
|
|
519
|
+
signal?.removeEventListener("abort", onAbort);
|
|
520
|
+
if (signal?.aborted ||
|
|
521
|
+
ready.every((attempt) => !isEnabled(attempt.server) ||
|
|
522
|
+
!servers.includes(attempt.server) ||
|
|
523
|
+
attempt.ready === attempt.server.ready))
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
459
526
|
};
|
|
460
527
|
/**
|
|
461
528
|
* One message for everything that needs the user after startup, or only for `only`, servers
|
|
@@ -474,34 +541,39 @@ export function createMcpExtension(options = {}) {
|
|
|
474
541
|
};
|
|
475
542
|
/**
|
|
476
543
|
* Save a config change; returns an error message when the file could not be updated. Changes to
|
|
477
|
-
* registered servers only apply to the current session.
|
|
544
|
+
* registered servers only apply to the current session. `inProject` adds a project override.
|
|
478
545
|
*/
|
|
479
|
-
const saveConfig = (server, patch) => {
|
|
480
|
-
|
|
546
|
+
const saveConfig = (server, patch, inProject = false) => {
|
|
547
|
+
const override = inProject ? projectConfig : server.entry.override;
|
|
548
|
+
const entry = override ? { ...server.entry, override } : server.entry;
|
|
549
|
+
if (entry.scope !== "extension") {
|
|
481
550
|
try {
|
|
482
|
-
updateConfig(
|
|
551
|
+
updateConfig(entry, patch);
|
|
483
552
|
}
|
|
484
553
|
catch (error) {
|
|
485
|
-
return `Could not update ${
|
|
554
|
+
return `Could not update ${entry.override ?? entry.source}: ${errorMessage(error)}`;
|
|
486
555
|
}
|
|
487
556
|
}
|
|
488
|
-
server.entry = { ...
|
|
557
|
+
server.entry = { ...entry, config: { ...entry.config, ...patch } };
|
|
489
558
|
return undefined;
|
|
490
559
|
};
|
|
491
|
-
|
|
560
|
+
/** Sign in, then reconnect. Returns an error message on failure. `cancel` or the session's end stops the sign-in. */
|
|
561
|
+
const signIn = async (server, prompt, cancel) => {
|
|
492
562
|
const connection = server.connection;
|
|
493
563
|
const url = connection?.oauthUrl;
|
|
494
564
|
if (!connection || !url)
|
|
495
565
|
return `MCP server "${server.entry.name}" does not use OAuth.`;
|
|
496
566
|
const runtime = await loadMcpRuntime();
|
|
567
|
+
const signal = cancel ? AbortSignal.any([session.signal, cancel]) : session.signal;
|
|
497
568
|
try {
|
|
498
|
-
await runtime.signInMcpServer({
|
|
569
|
+
await track(runtime.signInMcpServer({
|
|
499
570
|
serverUrl: url,
|
|
500
|
-
store: getCredentials(runtime).forServer(url),
|
|
571
|
+
store: getCredentials(runtime).forServer(server.entry.name, url),
|
|
501
572
|
settings: connection.oauthSettings(),
|
|
502
573
|
challenge: connection.challenge,
|
|
503
574
|
prompt,
|
|
504
|
-
|
|
575
|
+
signal,
|
|
576
|
+
}));
|
|
505
577
|
}
|
|
506
578
|
catch (error) {
|
|
507
579
|
if (error instanceof runtime.McpSignInCancelledError)
|
|
@@ -523,7 +595,7 @@ export function createMcpExtension(options = {}) {
|
|
|
523
595
|
const url = connection?.oauthUrl;
|
|
524
596
|
if (!connection || !url)
|
|
525
597
|
return false;
|
|
526
|
-
const removed = getCredentials(await loadMcpRuntime()).remove(url);
|
|
598
|
+
const removed = getCredentials(await loadMcpRuntime()).remove(server.entry.name, url);
|
|
527
599
|
await connection.signOut();
|
|
528
600
|
return removed;
|
|
529
601
|
};
|
|
@@ -531,8 +603,14 @@ export function createMcpExtension(options = {}) {
|
|
|
531
603
|
const connection = server.connection;
|
|
532
604
|
if (!connection)
|
|
533
605
|
return `MCP server "${server.entry.name}" is disabled.`;
|
|
534
|
-
|
|
606
|
+
const previous = server.ready;
|
|
607
|
+
const ready = (async () => {
|
|
608
|
+
await previous;
|
|
535
609
|
await connection.reconnect();
|
|
610
|
+
})();
|
|
611
|
+
server.ready = ready.catch(() => undefined);
|
|
612
|
+
try {
|
|
613
|
+
await ready;
|
|
536
614
|
return undefined;
|
|
537
615
|
}
|
|
538
616
|
catch (error) {
|
|
@@ -540,19 +618,32 @@ export function createMcpExtension(options = {}) {
|
|
|
540
618
|
}
|
|
541
619
|
};
|
|
542
620
|
/** Returns an error message when the config could not be saved; connection errors show in the state. */
|
|
543
|
-
const setEnabled = async (server, enabled) => {
|
|
544
|
-
const failed = saveConfig(server, { enabled });
|
|
621
|
+
const setEnabled = async (server, enabled, inProject = false) => {
|
|
622
|
+
const failed = saveConfig(server, { enabled }, inProject);
|
|
545
623
|
if (failed)
|
|
546
624
|
return failed;
|
|
547
625
|
if (!enabled) {
|
|
548
626
|
const connection = server.connection;
|
|
627
|
+
server.attempt = undefined;
|
|
549
628
|
server.connection = undefined;
|
|
629
|
+
if (connection) {
|
|
630
|
+
// A reconnect may already have detached its old client while awaiting transport
|
|
631
|
+
// shutdown. Closing the connection alone does not wait for that reconnect.
|
|
632
|
+
server.closing = Promise.all([connection.close(), server.ready]).then(() => undefined);
|
|
633
|
+
}
|
|
634
|
+
const closing = server.closing;
|
|
550
635
|
hideTools(server.entry.name);
|
|
551
636
|
emitChange();
|
|
552
|
-
|
|
637
|
+
try {
|
|
638
|
+
await closing;
|
|
639
|
+
}
|
|
640
|
+
finally {
|
|
641
|
+
if (server.closing === closing)
|
|
642
|
+
server.closing = undefined;
|
|
643
|
+
}
|
|
553
644
|
return undefined;
|
|
554
645
|
}
|
|
555
|
-
await startConnection(server,
|
|
646
|
+
await startConnection(server, server.closing);
|
|
556
647
|
return undefined;
|
|
557
648
|
};
|
|
558
649
|
const setExposure = (server, exposure) => {
|
|
@@ -587,7 +678,7 @@ export function createMcpExtension(options = {}) {
|
|
|
587
678
|
.map((server) => ({
|
|
588
679
|
value: server.entry.name,
|
|
589
680
|
label: server.entry.name,
|
|
590
|
-
description: `${describeState(server)} · ${exposureOf(server.entry)} · ${server.entry.scope ?? server.entry.source}`,
|
|
681
|
+
description: `${describeState(server)} · ${exposureOf(server.entry)} · ${server.entry.override ? "global, project override" : (server.entry.scope ?? server.entry.source)}`,
|
|
591
682
|
})),
|
|
592
683
|
empty: `No MCP servers configured. Add them to ${resolve(getAgentDir(), "mcp.json")} or ${CONFIG_DIR_NAME}/mcp.json.`,
|
|
593
684
|
confirmLabel: "manage",
|
|
@@ -607,12 +698,20 @@ export function createMcpExtension(options = {}) {
|
|
|
607
698
|
const { entry, connection } = server;
|
|
608
699
|
const saved = entry.scope === "extension"
|
|
609
700
|
? "for this session"
|
|
610
|
-
: entry.
|
|
611
|
-
?
|
|
612
|
-
:
|
|
701
|
+
: entry.override
|
|
702
|
+
? "saved to the project mcp.json"
|
|
703
|
+
: entry.scope
|
|
704
|
+
? `saved to the ${entry.scope} mcp.json`
|
|
705
|
+
: "saved to mcp.json";
|
|
706
|
+
// Global servers without an override can be turned on or off for the trusted project alone.
|
|
707
|
+
const inProject = entry.scope === "global" && !entry.override && projectConfig !== undefined;
|
|
708
|
+
const inProjectSaved = "saved to the project mcp.json";
|
|
613
709
|
const items = [];
|
|
614
710
|
if (!isEnabled(server)) {
|
|
615
711
|
items.push({ value: "enable", label: "Enable", description: saved });
|
|
712
|
+
if (inProject) {
|
|
713
|
+
items.push({ value: "enable-project", label: "Enable in this project", description: inProjectSaved });
|
|
714
|
+
}
|
|
616
715
|
}
|
|
617
716
|
else {
|
|
618
717
|
const state = connection?.state;
|
|
@@ -629,10 +728,14 @@ export function createMcpExtension(options = {}) {
|
|
|
629
728
|
}
|
|
630
729
|
items.push({ value: "exposure", label: "Exposure", description: exposureOf(entry) });
|
|
631
730
|
items.push({ value: "disable", label: "Disable", description: saved });
|
|
731
|
+
if (inProject) {
|
|
732
|
+
items.push({ value: "disable-project", label: "Disable in this project", description: inProjectSaved });
|
|
733
|
+
}
|
|
632
734
|
}
|
|
633
735
|
const details = [
|
|
634
736
|
describeTransport(entry),
|
|
635
737
|
`${entry.scope ?? "config"}: ${entry.source}`,
|
|
738
|
+
...(entry.override ? [`project override: ${entry.override}`] : []),
|
|
636
739
|
`State: ${describeState(server, false)}`,
|
|
637
740
|
];
|
|
638
741
|
const error = [server.message, connection?.state === "connected" ? undefined : connection?.error]
|
|
@@ -674,7 +777,7 @@ export function createMcpExtension(options = {}) {
|
|
|
674
777
|
title: `Exposure of ${server.entry.name}`,
|
|
675
778
|
details: server.entry.scope === "extension"
|
|
676
779
|
? `Applies to this session; the server is registered by ${server.entry.source}.`
|
|
677
|
-
: `Saved to ${server.entry.source}.`,
|
|
780
|
+
: `Saved to ${server.entry.override ?? server.entry.source}.`,
|
|
678
781
|
items: Object.keys(EXPOSURE_DESCRIPTIONS).map((exposure) => ({
|
|
679
782
|
value: exposure,
|
|
680
783
|
label: `${exposure === current ? "✓ " : " "}${exposure}`,
|
|
@@ -688,31 +791,52 @@ export function createMcpExtension(options = {}) {
|
|
|
688
791
|
return undefined;
|
|
689
792
|
return setExposure(server, choice);
|
|
690
793
|
};
|
|
794
|
+
/** Sign in with the manager view's sign-in screen, which shows the URL with a copy key and cancels with Esc. */
|
|
795
|
+
const signInWithUi = (ui, server) => {
|
|
796
|
+
const title = `Sign in to ${server.entry.name}`;
|
|
797
|
+
const cancel = new AbortController();
|
|
798
|
+
const status = (message) => ui.status(title, message, () => cancel.abort());
|
|
799
|
+
let authorizationUrl = "";
|
|
800
|
+
status("Contacting the authorization server…");
|
|
801
|
+
return signIn(server, {
|
|
802
|
+
showAuthorizationUrl: (url) => {
|
|
803
|
+
authorizationUrl = url.href;
|
|
804
|
+
openUrl(url.href);
|
|
805
|
+
},
|
|
806
|
+
promptForRedirectUrl: async (signal) => {
|
|
807
|
+
const value = await ui.redirectUrl(title, authorizationUrl, signal);
|
|
808
|
+
status("Connecting…");
|
|
809
|
+
return value;
|
|
810
|
+
},
|
|
811
|
+
}, cancel.signal);
|
|
812
|
+
};
|
|
813
|
+
/** Keep the subscribed menu usable while a connection opens or closes. */
|
|
814
|
+
const runInBackground = (ctx, server, operation) => {
|
|
815
|
+
const ready = operation();
|
|
816
|
+
const attempt = server.attempt;
|
|
817
|
+
const { signal } = session;
|
|
818
|
+
const finish = (message) => {
|
|
819
|
+
if (signal.aborted || server.attempt !== attempt || !servers.includes(server))
|
|
820
|
+
return;
|
|
821
|
+
server.message = message;
|
|
822
|
+
ensureDiscoveryActive(ctx);
|
|
823
|
+
emitChange();
|
|
824
|
+
};
|
|
825
|
+
void track(ready.then(finish, (error) => finish(errorMessage(error))));
|
|
826
|
+
};
|
|
691
827
|
const runAction = async (ui, ctx, server, action) => {
|
|
692
|
-
const {
|
|
828
|
+
const { signal } = session;
|
|
693
829
|
let message;
|
|
694
830
|
switch (action) {
|
|
695
|
-
case "signin":
|
|
696
|
-
|
|
697
|
-
let authorizationUrl = "";
|
|
698
|
-
ui.status(title, "Contacting the authorization server…");
|
|
699
|
-
message = await signIn(server, {
|
|
700
|
-
showAuthorizationUrl: (url) => {
|
|
701
|
-
authorizationUrl = url.href;
|
|
702
|
-
openUrl(url.href);
|
|
703
|
-
},
|
|
704
|
-
promptForRedirectUrl: async (signal) => {
|
|
705
|
-
const value = await ui.redirectUrl(title, authorizationUrl, signal);
|
|
706
|
-
ui.status(title, "Connecting…");
|
|
707
|
-
return value;
|
|
708
|
-
},
|
|
709
|
-
});
|
|
831
|
+
case "signin":
|
|
832
|
+
message = await signInWithUi(ui, server);
|
|
710
833
|
break;
|
|
711
|
-
}
|
|
712
834
|
case "reconnect":
|
|
713
|
-
//
|
|
714
|
-
|
|
715
|
-
|
|
835
|
+
// Connection state and error already report failures, including required sign-ins.
|
|
836
|
+
runInBackground(ctx, server, async () => {
|
|
837
|
+
await reconnect(server);
|
|
838
|
+
return undefined;
|
|
839
|
+
});
|
|
716
840
|
break;
|
|
717
841
|
case "signout":
|
|
718
842
|
await signOut(server);
|
|
@@ -725,10 +849,16 @@ export function createMcpExtension(options = {}) {
|
|
|
725
849
|
break;
|
|
726
850
|
case "enable":
|
|
727
851
|
case "disable":
|
|
728
|
-
|
|
729
|
-
|
|
852
|
+
case "enable-project":
|
|
853
|
+
case "disable-project": {
|
|
854
|
+
const enable = action.startsWith("enable");
|
|
855
|
+
runInBackground(ctx, server, () => setEnabled(server, enable, action.endsWith("-project")));
|
|
730
856
|
break;
|
|
857
|
+
}
|
|
731
858
|
}
|
|
859
|
+
// The session ended meanwhile (for example during a sign-in), which made ctx stale.
|
|
860
|
+
if (signal.aborted)
|
|
861
|
+
return;
|
|
732
862
|
server.message = message;
|
|
733
863
|
ensureDiscoveryActive(ctx);
|
|
734
864
|
emitChange();
|
|
@@ -812,13 +942,25 @@ export function createMcpExtension(options = {}) {
|
|
|
812
942
|
ctx.ui.notify(`Signing in to MCP server "${name}" requires interactive mode.`, "error");
|
|
813
943
|
return;
|
|
814
944
|
}
|
|
815
|
-
const
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
}
|
|
945
|
+
const { signal } = session;
|
|
946
|
+
let failure;
|
|
947
|
+
if (ctx.mode === "tui") {
|
|
948
|
+
await showMcpManager(ctx, async (ui) => {
|
|
949
|
+
failure = await signInWithUi(ui, server);
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
else {
|
|
953
|
+
failure = await signIn(server, {
|
|
954
|
+
showAuthorizationUrl: (url) => {
|
|
955
|
+
ctx.ui.notify(`Sign in to MCP server "${name}" in your browser:\n${url.href}`, "info");
|
|
956
|
+
openUrl(url.href);
|
|
957
|
+
},
|
|
958
|
+
promptForRedirectUrl: (signal) => ctx.ui.input(`Waiting for sign-in to "${name}". If the browser cannot reach this machine, paste the URL it was redirected to.`, "http://127.0.0.1:.../callback?code=...", { signal }),
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
// The session ended meanwhile, which cancelled the sign-in and made ctx stale.
|
|
962
|
+
if (signal.aborted)
|
|
963
|
+
return;
|
|
822
964
|
if (failure) {
|
|
823
965
|
ctx.ui.notify(failure, failure === "Sign-in cancelled." ? "info" : "error");
|
|
824
966
|
return;
|
|
@@ -829,13 +971,14 @@ export function createMcpExtension(options = {}) {
|
|
|
829
971
|
pi.on("session_start", (_event, ctx) => {
|
|
830
972
|
const loaded = (options.loadConfig ?? defaultLoadConfig)(ctx);
|
|
831
973
|
configErrors = loaded.errors;
|
|
974
|
+
projectConfig = loaded.projectConfig;
|
|
832
975
|
autoEnableCodemode = loaded.autoEnableCodemode ?? true;
|
|
833
976
|
warnedUnreachable = false;
|
|
834
977
|
waitedForStartup = false;
|
|
835
978
|
sessionCwd = ctx.cwd;
|
|
836
979
|
modelRegistry = ctx.modelRegistry;
|
|
837
|
-
|
|
838
|
-
|
|
980
|
+
session = new AbortController();
|
|
981
|
+
const { signal } = session;
|
|
839
982
|
configuredEntries = loaded.servers;
|
|
840
983
|
const registered = registeredServers();
|
|
841
984
|
overridden = registered.overridden;
|
|
@@ -852,10 +995,9 @@ export function createMcpExtension(options = {}) {
|
|
|
852
995
|
// The MCP client loads only now, so sessions without servers never pay for it. Waiting one
|
|
853
996
|
// event loop turn lets the first render happen before loading and connecting.
|
|
854
997
|
const runtime = new Promise((resolve) => setImmediate(resolve)).then(() => loadMcpRuntime());
|
|
855
|
-
|
|
856
|
-
pending = Promise.all(enabled.map((server) => startConnection(server, isCurrent, runtime)))
|
|
998
|
+
pending = Promise.all(enabled.map((server) => startConnection(server, runtime)))
|
|
857
999
|
.then(() => {
|
|
858
|
-
if (
|
|
1000
|
+
if (!signal.aborted)
|
|
859
1001
|
reportProblems(ctx);
|
|
860
1002
|
})
|
|
861
1003
|
.catch((error) => {
|
|
@@ -899,24 +1041,31 @@ export function createMcpExtension(options = {}) {
|
|
|
899
1041
|
else
|
|
900
1042
|
delete sections[MCP_SERVERS_SECTION];
|
|
901
1043
|
});
|
|
902
|
-
// A
|
|
903
|
-
//
|
|
904
|
-
//
|
|
1044
|
+
// A tool that reaches other tools (`reachesTools`) waits for the servers it may reach, so their
|
|
1045
|
+
// tools are registered before it runs: a codemode script for the servers it names, or for every
|
|
1046
|
+
// server when it searches or enumerates tools, and tool_search for every server. The resource
|
|
1047
|
+
// tools reach every server, so they wait for all of them. Direct MCP calls wait only for their
|
|
1048
|
+
// own server, including a reconnect still closing its old transport.
|
|
905
1049
|
pi.on("tool_call", async (event, ctx) => {
|
|
906
1050
|
const tool = pi.getAllTools().find((candidate) => candidate.name === event.toolName);
|
|
907
1051
|
if (!tool)
|
|
908
1052
|
return;
|
|
909
|
-
|
|
910
|
-
|
|
1053
|
+
// Readiness can be pending while the display state is still connected: reconnect first
|
|
1054
|
+
// closes the old transport, then opens a new one. Settled promises return immediately.
|
|
1055
|
+
const readyServers = servers.filter((server) => isEnabled(server) && server.ready);
|
|
1056
|
+
if (readyServers.length === 0)
|
|
911
1057
|
return;
|
|
912
1058
|
let waiting = [];
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
waiting = pendingServers.filter((server) => scriptNeedsServer(source, server.entry.name));
|
|
1059
|
+
const reach = tool.reachesTools?.(event.input);
|
|
1060
|
+
if (reach !== undefined) {
|
|
1061
|
+
waiting = readyServers.filter((server) => reachesServer(reach, server.entry.name));
|
|
917
1062
|
}
|
|
918
|
-
else if (
|
|
919
|
-
waiting =
|
|
1063
|
+
else if (RESOURCE_TOOL_NAMES.has(tool.name)) {
|
|
1064
|
+
waiting = readyServers;
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
const owner = toolOwners.get(event.toolName)?.split("\0", 1)[0];
|
|
1068
|
+
waiting = readyServers.filter((server) => server.entry.name === owner);
|
|
920
1069
|
}
|
|
921
1070
|
await waitForServers(waiting, ctx.signal);
|
|
922
1071
|
});
|
|
@@ -927,9 +1076,9 @@ export function createMcpExtension(options = {}) {
|
|
|
927
1076
|
});
|
|
928
1077
|
// Servers registered or unregistered during the session connect or disconnect right away.
|
|
929
1078
|
pi.on("mcp_servers_change", async (_event, ctx) => {
|
|
930
|
-
|
|
1079
|
+
const { signal } = session;
|
|
1080
|
+
if (signal.aborted)
|
|
931
1081
|
return;
|
|
932
|
-
const current = generation;
|
|
933
1082
|
const registered = registeredServers();
|
|
934
1083
|
overridden = registered.overridden;
|
|
935
1084
|
const next = new Map(registered.servers.map((server) => [server.entry.name, server]));
|
|
@@ -945,11 +1094,11 @@ export function createMcpExtension(options = {}) {
|
|
|
945
1094
|
ensureDiscoveryActive(ctx);
|
|
946
1095
|
await Promise.all(removed.map((server) => server.connection?.close()));
|
|
947
1096
|
const connecting = added.filter(isEnabled);
|
|
948
|
-
if (
|
|
1097
|
+
if (signal.aborted || connecting.length === 0)
|
|
949
1098
|
return;
|
|
950
1099
|
try {
|
|
951
|
-
await Promise.all(connecting.map((server) => startConnection(server
|
|
952
|
-
if (
|
|
1100
|
+
await Promise.all(connecting.map((server) => startConnection(server)));
|
|
1101
|
+
if (signal.aborted) {
|
|
953
1102
|
await Promise.all(connecting.map((server) => server.connection?.close()));
|
|
954
1103
|
return;
|
|
955
1104
|
}
|
|
@@ -958,17 +1107,16 @@ export function createMcpExtension(options = {}) {
|
|
|
958
1107
|
ctx.ui.notify(`MCP failed to load: ${errorMessage(error)}`, "error");
|
|
959
1108
|
return;
|
|
960
1109
|
}
|
|
961
|
-
if (
|
|
1110
|
+
if (signal.aborted)
|
|
962
1111
|
return;
|
|
963
1112
|
reportProblems(ctx, connecting);
|
|
964
1113
|
});
|
|
965
1114
|
pi.on("session_shutdown", async () => {
|
|
966
|
-
|
|
967
|
-
generation++;
|
|
1115
|
+
session.abort();
|
|
968
1116
|
const closing = connections();
|
|
969
1117
|
servers = [];
|
|
970
1118
|
emitChange();
|
|
971
|
-
await Promise.all(closing.map((connection) => connection.close()));
|
|
1119
|
+
await Promise.all([...backgroundActions, ...closing.map((connection) => connection.close())]);
|
|
972
1120
|
});
|
|
973
1121
|
pi.registerCommand("mcp", {
|
|
974
1122
|
description: "Manage MCP servers: sign in, reconnect, enable or disable, and change exposure",
|
|
@@ -994,19 +1142,21 @@ export function createMcpExtension(options = {}) {
|
|
|
994
1142
|
return items.length > 0 ? items : null;
|
|
995
1143
|
},
|
|
996
1144
|
handler: async (args, ctx) => {
|
|
997
|
-
await pending;
|
|
998
1145
|
const [action, name, ...extra] = args.trim().split(/\s+/).filter(Boolean);
|
|
999
1146
|
if (action === undefined) {
|
|
1000
1147
|
if (ctx.mode === "tui")
|
|
1001
1148
|
await showMcpManager(ctx, (ui) => manage(ui, ctx));
|
|
1002
|
-
else
|
|
1149
|
+
else {
|
|
1150
|
+
await pending;
|
|
1003
1151
|
ctx.ui.notify(formatStatus(), "info");
|
|
1152
|
+
}
|
|
1004
1153
|
return;
|
|
1005
1154
|
}
|
|
1006
1155
|
if (extra.length > 0) {
|
|
1007
1156
|
ctx.ui.notify(MCP_USAGE, "warning");
|
|
1008
1157
|
return;
|
|
1009
1158
|
}
|
|
1159
|
+
await pending;
|
|
1010
1160
|
switch (action) {
|
|
1011
1161
|
case "login": {
|
|
1012
1162
|
const server = await pickServer(name, ctx, oauthPick);
|