@bastani/atomic 0.10.2-alpha.1 → 0.10.3-alpha.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 +112 -0
- package/dist/builtin/intercom/CHANGELOG.md +17 -0
- package/dist/builtin/intercom/broker/broker-instance.ts +2 -13
- package/dist/builtin/intercom/broker/broker.ts +158 -73
- package/dist/builtin/intercom/broker/durable-ended-queue.ts +14 -2
- package/dist/builtin/intercom/broker/host-command-environment.ts +13 -0
- package/dist/builtin/intercom/broker/hosted-session-errors.ts +1 -0
- package/dist/builtin/intercom/broker/multinode-router.ts +111 -16
- package/dist/builtin/intercom/broker/multinode-state-store.ts +50 -4
- package/dist/builtin/intercom/broker/open-broker-state.ts +5 -4
- package/dist/builtin/intercom/broker/spawn.ts +144 -25
- package/dist/builtin/intercom/broker/sql-add-column.ts +33 -0
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +120 -36
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +75 -13
- package/dist/builtin/intercom/broker/start-announcement.ts +55 -10
- package/dist/builtin/intercom/broker/watchdog.ts +10 -7
- package/dist/builtin/intercom/index.bundle.mjs +111 -27
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +29 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/SKILL.md +30 -52
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +34 -40
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/viewer.html +2 -2
- package/dist/builtin/subagents/skills/skill-creator/scripts/atomic_cli.py +668 -0
- package/dist/builtin/subagents/skills/skill-creator/scripts/generate_report.py +3 -3
- package/dist/builtin/subagents/skills/skill-creator/scripts/improve_description.py +42 -38
- package/dist/builtin/subagents/skills/skill-creator/scripts/run_eval.py +268 -176
- package/dist/builtin/subagents/skills/skill-creator/scripts/run_loop.py +20 -11
- package/dist/builtin/subagents/skills/skill-creator/scripts/utils.py +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +163 -97
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/index.bundle.mjs +5 -4
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +10 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +54 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +4 -0
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +17 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +3 -1
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +2 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +34 -13
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +3 -0
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +27 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +213 -30
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +6 -1
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +35 -3
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +2 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +6 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +15 -2
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-typed-queue.d.ts +14 -1
- package/dist/core/agent-session-typed-queue.d.ts.map +1 -1
- package/dist/core/agent-session-typed-queue.js +26 -1
- package/dist/core/agent-session-typed-queue.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async-scope.d.ts +9 -4
- package/dist/core/async-scope.d.ts.map +1 -1
- package/dist/core/async-scope.js +13 -5
- package/dist/core/async-scope.js.map +1 -1
- package/dist/core/builtin-diagnostics.js +2 -2
- package/dist/core/builtin-diagnostics.js.map +1 -1
- package/dist/core/chat-admission-order.d.ts.map +1 -1
- package/dist/core/chat-admission-order.js +2 -1
- package/dist/core/chat-admission-order.js.map +1 -1
- package/dist/core/chat-record-saves.d.ts +4 -0
- package/dist/core/chat-record-saves.d.ts.map +1 -0
- package/dist/core/chat-record-saves.js +25 -0
- package/dist/core/chat-record-saves.js.map +1 -0
- package/dist/core/command-deliveries.d.ts +62 -0
- package/dist/core/command-deliveries.d.ts.map +1 -0
- package/dist/core/command-deliveries.js +139 -0
- package/dist/core/command-deliveries.js.map +1 -0
- package/dist/core/diagnostic-writer.d.ts.map +1 -1
- package/dist/core/diagnostic-writer.js +5 -4
- package/dist/core/diagnostic-writer.js.map +1 -1
- package/dist/core/extension-startup-close.d.ts +1 -2
- package/dist/core/extension-startup-close.d.ts.map +1 -1
- package/dist/core/extension-startup-close.js +2 -2
- package/dist/core/extension-startup-close.js.map +1 -1
- package/dist/core/extensions/jiti-aliases.d.ts +11 -0
- package/dist/core/extensions/jiti-aliases.d.ts.map +1 -0
- package/dist/core/extensions/jiti-aliases.js +28 -0
- package/dist/core/extensions/jiti-aliases.js.map +1 -0
- package/dist/core/extensions/loader-api.js +3 -3
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-bindings.js +2 -2
- package/dist/core/extensions/loader-bindings.js.map +1 -1
- package/dist/core/extensions/loader-rollback.d.ts +1 -2
- package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
- package/dist/core/extensions/loader-rollback.js +2 -2
- package/dist/core/extensions/loader-rollback.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +53 -9
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/native-builtin-entries.d.ts +5 -0
- package/dist/core/extensions/native-builtin-entries.d.ts.map +1 -1
- package/dist/core/extensions/native-builtin-entries.js +8 -1
- package/dist/core/extensions/native-builtin-entries.js.map +1 -1
- package/dist/core/extensions/reloadable-scripts.d.ts +21 -2
- package/dist/core/extensions/reloadable-scripts.d.ts.map +1 -1
- package/dist/core/extensions/reloadable-scripts.js +11 -3
- package/dist/core/extensions/reloadable-scripts.js.map +1 -1
- package/dist/core/extensions/source-builtin-imports.d.ts +40 -0
- package/dist/core/extensions/source-builtin-imports.d.ts.map +1 -0
- package/dist/core/extensions/source-builtin-imports.js +142 -0
- package/dist/core/extensions/source-builtin-imports.js.map +1 -0
- package/dist/core/extensions/transform-graph.d.ts +15 -0
- package/dist/core/extensions/transform-graph.d.ts.map +1 -0
- package/dist/core/extensions/transform-graph.js +85 -0
- package/dist/core/extensions/transform-graph.js.map +1 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts +2 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.js +7 -0
- package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
- package/dist/core/extensions/ts-transform-worker.d.ts +2 -0
- package/dist/core/extensions/ts-transform-worker.d.ts.map +1 -0
- package/dist/core/extensions/ts-transform-worker.js +43 -0
- package/dist/core/extensions/ts-transform-worker.js.map +1 -0
- package/dist/core/message-admission.d.ts.map +1 -1
- package/dist/core/message-admission.js +4 -4
- package/dist/core/message-admission.js.map +1 -1
- package/dist/core/messages.d.ts +5 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +35 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +18 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/process-start-token.d.ts +7 -0
- package/dist/core/process-start-token.d.ts.map +1 -1
- package/dist/core/process-start-token.js +14 -0
- package/dist/core/process-start-token.js.map +1 -1
- package/dist/core/project-trust-electorate.d.ts +24 -0
- package/dist/core/project-trust-electorate.d.ts.map +1 -0
- package/dist/core/project-trust-electorate.js +52 -0
- package/dist/core/project-trust-electorate.js.map +1 -0
- package/dist/core/project-trust-state.d.ts +15 -0
- package/dist/core/project-trust-state.d.ts.map +1 -1
- package/dist/core/project-trust-state.js +15 -0
- package/dist/core/project-trust-state.js.map +1 -1
- package/dist/core/provider-request-admission.d.ts.map +1 -1
- package/dist/core/provider-request-admission.js +2 -2
- package/dist/core/provider-request-admission.js.map +1 -1
- package/dist/core/queued-input-admission.js +2 -2
- package/dist/core/queued-input-admission.js.map +1 -1
- package/dist/core/queued-message-delivery.d.ts +2 -2
- package/dist/core/queued-message-delivery.d.ts.map +1 -1
- package/dist/core/queued-message-delivery.js +6 -3
- package/dist/core/queued-message-delivery.js.map +1 -1
- package/dist/core/resource-admission-scope.js +2 -2
- package/dist/core/resource-admission-scope.js.map +1 -1
- package/dist/core/resume/blueprint/process.d.ts +3 -4
- package/dist/core/resume/blueprint/process.d.ts.map +1 -1
- package/dist/core/resume/blueprint/process.js +33 -17
- package/dist/core/resume/blueprint/process.js.map +1 -1
- package/dist/core/resume/path-mapping.js +4 -4
- package/dist/core/resume/path-mapping.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +9 -0
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +27 -2
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/resume-cache-checkpoint.d.ts +27 -1
- package/dist/core/resume-cache-checkpoint.d.ts.map +1 -1
- package/dist/core/resume-cache-checkpoint.js +45 -0
- package/dist/core/resume-cache-checkpoint.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -31
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-scope.d.ts +1 -2
- package/dist/core/session-lifecycle-scope.d.ts.map +1 -1
- package/dist/core/session-lifecycle-scope.js +2 -2
- package/dist/core/session-lifecycle-scope.js.map +1 -1
- package/dist/core/session-lifecycle-work.js +2 -2
- package/dist/core/session-lifecycle-work.js.map +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +3 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-storage.d.ts +12 -0
- package/dist/core/session-storage.d.ts.map +1 -1
- package/dist/core/session-storage.js +68 -1
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/settings-lock-directory.d.ts.map +1 -1
- package/dist/core/settings-lock-directory.js +4 -3
- package/dist/core/settings-lock-directory.js.map +1 -1
- package/dist/core/settings-write-ownership.d.ts +1 -2
- package/dist/core/settings-write-ownership.d.ts.map +1 -1
- package/dist/core/settings-write-ownership.js +2 -2
- package/dist/core/settings-write-ownership.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +6 -4
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +22 -8
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/system-prompt.d.ts +16 -2
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +33 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
- package/dist/core/tasks/agent-adapter.js +2 -1
- package/dist/core/tasks/agent-adapter.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +3 -2
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/execution-scope.js +2 -2
- package/dist/core/tasks/execution-scope.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
- package/dist/core/tools/history-regex-worker.js +3 -2
- package/dist/core/tools/history-regex-worker.js.map +1 -1
- package/dist/core/tools/shell-task-render.d.ts +3 -2
- package/dist/core/tools/shell-task-render.d.ts.map +1 -1
- package/dist/core/tools/shell-task-render.js +7 -5
- package/dist/core/tools/shell-task-render.js.map +1 -1
- package/dist/core/tools/shell-task-status.d.ts +6 -2
- package/dist/core/tools/shell-task-status.d.ts.map +1 -1
- package/dist/core/tools/shell-task-status.js +13 -8
- package/dist/core/tools/shell-task-status.js.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.js +4 -3
- package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
- package/dist/core/tools/windows-directory-security.d.ts.map +1 -1
- package/dist/core/tools/windows-directory-security.js +2 -1
- package/dist/core/tools/windows-directory-security.js.map +1 -1
- package/dist/core/worktree-snapshot/git.js +2 -2
- package/dist/core/worktree-snapshot/git.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +6 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +150 -18
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/tool-records.d.ts +44 -9
- package/dist/extensions/mcp/tool-records.d.ts.map +1 -1
- package/dist/extensions/mcp/tool-records.js +58 -16
- package/dist/extensions/mcp/tool-records.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +3 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +1 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +230 -96
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +5 -0
- package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +5 -2
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-switcher.js +3 -3
- package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
- package/dist/modes/interactive/agent-view/contracts.d.ts +6 -0
- package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
- package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/install.js +2 -1
- package/dist/modes/interactive/agent-view/install.js.map +1 -1
- package/dist/modes/interactive/agent-view/open-port.d.ts +4 -2
- package/dist/modes/interactive/agent-view/open-port.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/open-port.js +4 -3
- package/dist/modes/interactive/agent-view/open-port.js.map +1 -1
- package/dist/modes/interactive/agent-view/prompt-retarget.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/prompt-retarget.js +18 -5
- package/dist/modes/interactive/agent-view/prompt-retarget.js.map +1 -1
- package/dist/modes/interactive/agent-view/remote-port.d.ts +10 -1
- package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/remote-port.js +36 -4
- package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
- package/dist/modes/interactive/agent-view/viewed-keys.d.ts +56 -0
- package/dist/modes/interactive/agent-view/viewed-keys.d.ts.map +1 -0
- package/dist/modes/interactive/agent-view/viewed-keys.js +63 -0
- package/dist/modes/interactive/agent-view/viewed-keys.js.map +1 -0
- package/dist/modes/interactive/agent-view/viewed-submit.d.ts +14 -4
- package/dist/modes/interactive/agent-view/viewed-submit.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/viewed-submit.js +51 -17
- package/dist/modes/interactive/agent-view/viewed-submit.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +8 -21
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +18 -5
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +6 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +5 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +33 -2
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +58 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.js +2 -2
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.d.ts +16 -5
- package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.js +27 -8
- package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +8 -25
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +18 -17
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.d.ts +20 -3
- package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.js +82 -32
- package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
- package/dist/modes/interactive/components/queued-messages-view.d.ts +5 -2
- package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/queued-messages-view.js +12 -5
- package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
- package/dist/modes/interactive/components/task-board.d.ts +5 -8
- package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-board.js +5 -49
- package/dist/modes/interactive/components/task-board.js.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.js +9 -2
- package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
- package/dist/modes/interactive/components/task-marks.d.ts +19 -0
- package/dist/modes/interactive/components/task-marks.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-marks.js +25 -0
- package/dist/modes/interactive/components/task-marks.js.map +1 -0
- package/dist/modes/interactive/components/task-row.d.ts +10 -2
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +39 -32
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.d.ts +7 -0
- package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.js +106 -10
- package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
- package/dist/modes/interactive/components/tool-block-families.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-block-families.js +8 -9
- package/dist/modes/interactive/components/tool-block-families.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +5 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -1
- package/dist/modes/interactive/extension-command-hold.js +5 -7
- package/dist/modes/interactive/extension-command-hold.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +6 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +21 -7
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts +1 -2
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.js +2 -2
- package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +13 -4
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +2 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +6 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +4 -2
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +6 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +96 -17
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +5 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +37 -5
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +45 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts +4 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +20 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +3 -0
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +43 -5
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +6 -3
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.js +3 -2
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
- package/dist/modes/interactive-engine/engine-health.d.ts +2 -0
- package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-health.js.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.js +33 -0
- package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +7 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +15 -2
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/host-listener-failures.d.ts +24 -0
- package/dist/modes/interactive-engine/host-listener-failures.d.ts.map +1 -0
- package/dist/modes/interactive-engine/host-listener-failures.js +98 -0
- package/dist/modes/interactive-engine/host-listener-failures.js.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +16 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +74 -7
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +5 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +8 -2
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +13 -0
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +69 -4
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +34 -6
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts +7 -0
- package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.js +11 -1
- package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
- package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
- package/dist/modes/rpc/agent-view-rpc-panel.js +11 -5
- package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +8 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +89 -65
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +21 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +77 -33
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +5 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +8 -2
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +9 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/shell.d.ts +5 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +14 -7
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/worker-threads.d.ts +10 -4
- package/dist/utils/worker-threads.d.ts.map +1 -1
- package/dist/utils/worker-threads.js +10 -4
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/background-tasks.md +10 -10
- package/docs/compaction.md +1 -0
- package/docs/development.md +1 -1
- package/docs/environment-variables.md +4 -0
- package/docs/extensions/api-reference.md +2 -0
- package/docs/extensions/events.md +1 -1
- package/docs/getting-started/installation.md +1 -0
- package/docs/guides/non-interactive.md +2 -0
- package/docs/guides/resume-on-any-machine.md +3 -1
- package/docs/intercom/reference.md +1 -1
- package/docs/keybindings.md +6 -5
- package/docs/libraries/ai.md +2 -1
- package/docs/mcp-servers.md +1 -1
- package/docs/sdk/reference.md +1 -1
- package/docs/sdk.md +6 -0
- package/docs/security.md +4 -2
- package/docs/settings.md +2 -1
- package/docs/storage.md +2 -0
- package/docs/subagents.md +2 -2
- package/docs/tui/reference.md +3 -1
- package/npm-shrinkwrap.json +49 -49
- package/package.json +6 -6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AC,SAAS,CAAC,UAAU,KAAK,SAAS;4BAC3D,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE,CACxB,SAAS,CAAC,UAAU,EAAE,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,UAAU,EAAE,KAAK,KAAK,cAAc;4BAC3F,IAAI,EAAE,qCAAqC;yBAC3C,CAAC,CAAC;wBACH,IAAI,CAAC,MAAM;4BAAE,OAAO;wBACpB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;wBACxC,IAAI,OAAO;4BAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;6BACxC,CAAC;4BACL,qBAAqB,CAAC,GAAG,CAAC,CAAC;4BAC3B,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,8BAA8B,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,aAAa,CAAC,MAAM,CAAC,IAAI,EAC9E,MAAM,CACN,CAAC;wBACH,CAAC;wBACD,OAAO;oBACR,CAAC;oBACD;wBACC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACtC,CAAC;YACF,CAAC;SACD,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAqB;IAC/C,OAAO,kBAAkB,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAC9G,CAAC;AAED,eAAe,kBAAkB,EAAE,CAAC","sourcesContent":["/**\n * Built-in MCP integration.\n *\n * Connects the servers from `mcp.json` and the servers extensions register with\n * `pi.registerMcpServer()` when a session starts, and servers registered later right away. A server\n * in `mcp.json` takes precedence over a registered server of the same name. Connections run in the\n * background: the first prompt waits only for servers with `direct` tools, and codemode scripts,\n * `tool_search`, and the resource tools wait for the servers they need when they run. Tools are\n * registered as `mcp__<server>__<tool>`. By default (`\"exposure\": \"codemode\"`) the tools are only\n * callable from codemode scripts, which keeps MCP tools out of the model's tool declarations and\n * the codemode description: scripts find the tools with `searchTools()` and the server instructions\n * with `describeNamespace()`. The codemode tool is activated for that unless `autoEnableCodemode` is\n * false or `-codemode` explicitly removed it. `\"deferred\"` declares the tools to the model once the `tool_search` tool loads them, and\n * activates `tool_search` instead of codemode.\n * `\"exposure\": \"direct\"` declares them to the model right away, and `\"hidden\"` makes them\n * unreachable. `toolExposure` overrides the exposure of single tools. Servers with resources are\n * reached through Codex's `list_mcp_resources`, `list_mcp_resource_templates`, and\n * `read_mcp_resource` tools (resources.ts).\n *\n * Every call runs through pi's tool pipeline, so `tool_call`/`tool_result` hooks and permission\n * extensions apply to MCP tools the same way they do to built-in tools.\n *\n * The session records each declared MCP tool's listing (tool-records.ts). A resumed session declares those tools\n * from their records while their servers reconnect, so its requests keep the tool list the provider cached; a call\n * waits for the server and runs only if the server lists the same tool again.\n *\n * Problems found at startup (config errors, failed connections, servers that need a sign-in) are\n * reported once. `/mcp` opens a manager to sign in, reconnect, enable or disable servers, and change\n * their exposure; the last two are saved to the `mcp.json` that defines the server, or apply to the\n * current session for registered servers.\n */\n\nimport { join, resolve } from \"node:path\";\nimport type { SelectItem } from \"@bastani/atomic-tui\";\nimport type { TSchema } from \"typebox\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../../config.js\";\nimport type {\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tToolDefinition,\n\tToolInfo,\n} from \"../../core/extensions/types.ts\";\nimport { markNativeMcpToolDefinition, matchesMcpDirectToolSelection } from \"../../core/mcp-child-policy.ts\";\nimport { mcpNamespace } from \"../../core/mcp-servers.ts\";\nimport type { ModelRegistry } from \"../../core/model-registry.ts\";\nimport { sliceHead } from \"../../core/tools/truncate.ts\";\nimport { openBrowser } from \"../../utils/open-browser.ts\";\nimport { CODEMODE_TOOL_NAME } from \"../codemode/tool.js\";\nimport { TOOL_SEARCH_TOOL_NAME } from \"../tool-search/tool.js\";\nimport type { Tool as McpTool } from \"./client/index.js\";\nimport {\n\tgetMcpToolExposure,\n\ttype LoadedMcpConfig,\n\tloadMcpConfigAsync,\n\ttype McpExposure,\n\ttype McpServerConfigPatch,\n\ttype McpServerEntry,\n\tmcpRequestTimeoutMs,\n\tupdateMcpServerConfigAsync,\n} from \"./config.ts\";\nimport type { McpOAuthCredentialStore, McpSignInPrompt } from \"./oauth.ts\";\nimport { createMcpResourceToolDefinitions } from \"./resources.js\";\nimport { loadMcpRuntime } from \"./runtime.lazy.ts\";\nimport type * as McpRuntime from \"./runtime.ts\";\nimport type { McpServerConnection, McpServerLog, McpTransportFactory } from \"./runtime.ts\";\nimport {\n\tdeclaredMcpToolNames,\n\tisRecordedToolName,\n\tMCP_TOOL_RECORD_ENTRY_TYPE,\n\ttype McpResourceServerRecord,\n\ttype McpToolRecord,\n\ttype McpToolRecordData,\n\ttype McpToolRecords,\n\tRESOURCE_TOOL_NAMES,\n\treadToolRecords,\n\trecordableTool,\n\tsameListedTool,\n\tsameToolRecord,\n\ttransportFingerprint,\n} from \"./tool-records.ts\";\nimport { createMcpToolDefinition, createMcpToolName, createMcpToolRenderers, type McpToolDetails } from \"./tools.ts\";\nimport { type McpMenu, type McpUi, showMcpManager } from \"./ui.ts\";\n\nfunction isCodemodeDiscoveryTool(tool: ToolInfo): boolean {\n\treturn tool.name === CODEMODE_TOOL_NAME && tool.sourceInfo.path === \"builtin:codemode\";\n}\n\nfunction isToolSearchDiscoveryTool(tool: ToolInfo): boolean {\n\treturn tool.name === TOOL_SEARCH_TOOL_NAME && tool.sourceInfo.path === \"builtin:tool-search\";\n}\n\nexport type { McpTransportFactory } from \"./runtime.ts\";\n\nexport interface McpExtensionOptions {\n\t/** Defaults to reading `mcp.json` from the agent directory and the trusted project. */\n\tloadConfig?: (ctx: ExtensionContext) => LoadedMcpConfig | Promise<LoadedMcpConfig>;\n\t/** Defaults to stdio and streamable HTTP transports built from the server config. */\n\tcreateTransport?: McpTransportFactory;\n\t/** Defaults to `mcp-auth.json` in the agent directory. */\n\tcredentials?: McpOAuthCredentialStore;\n\t/** File server log messages are appended to. Defaults to `mcp.log` in the agent directory. */\n\tlogPath?: string;\n\t/** Opens the OAuth authorization URL. Defaults to the platform browser. */\n\topenUrl?: (url: string) => void;\n\t/**\n\t * Saves `/mcp` changes to the server's config file: its project `override` when set, else its\n\t * `source`. Defaults to editing that `mcp.json`.\n\t */\n\tupdateConfig?: (entry: McpServerEntry, patch: McpServerConfigPatch) => void | Promise<void>;\n\t/**\n\t * How long the first prompt waits for servers with `direct` tools that are still connecting at\n\t * startup, in milliseconds. Their tools become available when they connect. Other servers are\n\t * waited for when a script or search needs them. Default: 10000.\n\t */\n\tstartupWaitMs?: number;\n}\n\nconst DEFAULT_STARTUP_WAIT_MS = 10_000;\n\n/** A configured server. Disabled servers have no connection. */\ninterface McpServer {\n\tentry: McpServerEntry;\n\tconnection?: McpServerConnection;\n\t/** For servers extensions registered: the config as registered, to detect re-registrations. */\n\tregisteredConfig?: string;\n\tattempt?: symbol;\n\t/** Result of the last `/mcp` action that failed, shown in the manager. */\n\tmessage?: string;\n\tclosing?: Promise<void>;\n\t/** Settles when the connection started for the server connected or failed. */\n\tready?: Promise<void>;\n}\n\nconst EXPOSURE_DESCRIPTIONS: Record<Exclude<McpExposure, \"hidden\">, string> = {\n\tcodemode: \"called from codemode scripts, which find them with searchTools()\",\n\tdeferred: \"not declared until tool_search loads them, then called directly; no codemode needed\",\n\tdirect: \"declared to the model like built-in tools\",\n};\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction firstLine(text: string): string {\n\treturn text.split(\"\\n\", 1)[0] ?? \"\";\n}\n\nfunction isEnabled(server: Pick<McpServer, \"entry\">): boolean {\n\treturn server.entry.config.enabled !== false;\n}\n\nfunction hasSelectedMcpServer(selections: readonly string[], name: string): boolean {\n\treturn selections.some((selection) => selection === name || selection.startsWith(`${name}/`));\n}\n\nfunction exposureOf(entry: McpServerEntry): McpExposure {\n\treturn entry.config.exposure ?? \"codemode\";\n}\n\n/** Exposures the server's tools can have, known from its config before it connects. */\nfunction configuredExposures(entry: McpServerEntry): Set<McpExposure> {\n\treturn new Set([exposureOf(entry), ...Object.values(entry.config.toolExposure ?? {})]);\n}\n\n/** Whether some of the server's tools are declared to the model, so the first prompt waits for them. */\nfunction hasDirectTools(entry: McpServerEntry, selections?: readonly string[], toolNames?: readonly string[]): boolean {\n\tconst namespacePrefix = `${mcpNamespace(entry.name)}__`;\n\treturn (\n\t\t(selections !== undefined && hasSelectedMcpServer(selections, entry.name)) ||\n\t\ttoolNames?.some((name) => name.startsWith(namespacePrefix)) === true ||\n\t\tconfiguredExposures(entry).has(\"direct\")\n\t);\n}\n\n/** Whether some of the server's tools are reached through codemode or tool_search. */\nfunction hasIndirectTools(entry: McpServerEntry): boolean {\n\tconst exposures = configuredExposures(entry);\n\treturn exposures.has(\"codemode\") || exposures.has(\"deferred\");\n}\n\n/** Name of the system prompt section that lists the servers whose tools are not declared. */\nexport const MCP_SERVERS_SECTION = \"mcp_servers\";\n/** Characters of a server description in the section, as Codex allows for deferred namespaces. */\nconst MAX_SERVER_DESCRIPTION_CHARS = 250;\n/**\n * Characters of the whole section. Descriptions shrink to fit; when the server lines alone do not\n * fit, the last servers are left out and counted in a closing line.\n */\nexport const MAX_SERVERS_SECTION_CHARS = 4096;\n\n/** The section's first line. It explains only the ways of reaching tools that the listed servers use. */\nfunction serversSectionIntro(reaches: ReadonlySet<string>): string {\n\tlet intro = \"MCP servers whose tools are not declared to you.\";\n\tif (reaches.has(\"codemode\")) intro += \" Call the tools of `codemode` servers from codemode scripts.\";\n\tif (reaches.has(\"tool_search\")) intro += \" Load the tools of `tool_search` servers with `tool_search`.\";\n\treturn intro;\n}\n\nfunction truncate(text: string, max: number): string {\n\tif (text.length <= max) return text;\n\treturn max <= 1 ? \"\" : `${sliceHead(text, max - 1).trimEnd()}…`;\n}\n\n/** What the `mcp_servers` section needs of a server. */\nexport interface McpServerListing {\n\tentry: McpServerEntry;\n\tconnection?: { instructions?: string };\n}\n\n/** First line of the configured description, or of the server instructions once connected. */\nfunction serverSummary(server: McpServerListing): string {\n\tconst text = server.entry.config.description?.trim() || server.connection?.instructions || \"\";\n\treturn (text.split(\"\\n\", 1)[0] ?? \"\").trim();\n}\n\n/**\n * The `mcp_servers` section: every enabled server with codemode or deferred tools, with how its\n * tools are reached and a one-line summary. The model learns of the servers from it, since neither\n * codemode nor tool_search lists them. Undefined when there are no such servers.\n */\nexport function renderServersSection(servers: readonly McpServerListing[]): string | undefined {\n\tconst listed = servers\n\t\t.filter((server) => isEnabled(server) && hasIndirectTools(server.entry))\n\t\t.sort((a, b) => a.entry.name.localeCompare(b.entry.name));\n\tif (listed.length === 0) return undefined;\n\tconst reaches = listed.map((server) =>\n\t\tconfiguredExposures(server.entry).has(\"codemode\") ? \"codemode\" : \"tool_search\",\n\t);\n\tconst intro = serversSectionIntro(new Set(reaches));\n\tconst heads = listed.map((server, index) => `- ${mcpNamespace(server.entry.name)} (${reaches[index]})`);\n\tconst omitted = (count: number) =>\n\t\tcount > 0 ? [`- … ${count} more server${count === 1 ? \"\" : \"s\"}; find their tools with searchTools()`] : [];\n\t// Characters of the intro, the first `kept` server lines without descriptions, and the omission line.\n\tconst size = (kept: number) => [intro, ...heads.slice(0, kept), ...omitted(listed.length - kept)].join(\"\\n\").length;\n\tlet kept = listed.length;\n\twhile (kept > 0 && size(kept) > MAX_SERVERS_SECTION_CHARS) kept--;\n\t// Each description also takes a \": \" separator.\n\tconst perServer =\n\t\tkept === 0\n\t\t\t? 0\n\t\t\t: Math.min(MAX_SERVER_DESCRIPTION_CHARS, Math.floor((MAX_SERVERS_SECTION_CHARS - size(kept)) / kept) - 2);\n\tconst lines = listed.slice(0, kept).map((server, index) => {\n\t\tconst summary = perServer > 0 ? truncate(serverSummary(server), perServer) : \"\";\n\t\treturn summary ? `${heads[index]}: ${summary}` : heads[index];\n\t});\n\treturn [intro, ...lines, ...omitted(listed.length - kept)].join(\"\\n\");\n}\n\n/**\n * Whether a codemode script needs the server: it names the server's namespace, or searches,\n * enumerates, or describes tools or namespaces, which may name the server in other forms.\n */\nfunction scriptNeedsServer(code: string, server: string): boolean {\n\tif (/\\b(searchTools|describeNamespace|describeTool|ALL_TOOLS)\\b/.test(code)) return true;\n\treturn code.includes(mcpNamespace(server));\n}\n\n/** Short state for lists and the startup report. `withError` appends the first line of a failure. */\nfunction describeState(server: McpServer, withError = true): string {\n\tif (!isEnabled(server)) return \"disabled\";\n\tconst connection = server.connection;\n\tif (!connection) return \"starting\";\n\tswitch (connection.state) {\n\t\tcase \"needs-auth\":\n\t\t\treturn \"needs sign-in\";\n\t\tcase \"failed\":\n\t\t\treturn withError ? `failed: ${firstLine(connection.error ?? \"unknown error\")}` : \"failed\";\n\t\tcase \"connected\": {\n\t\t\tconst { tools, hasResources } = connection;\n\t\t\treturn `connected · ${tools.length} tool${tools.length === 1 ? \"\" : \"s\"}${hasResources ? \" · resources\" : \"\"}`;\n\t\t}\n\t\tcase \"connecting\":\n\t\t\treturn \"connecting…\";\n\t\tdefault:\n\t\t\treturn connection.state;\n\t}\n}\n\n/** Servers that need the user first. */\nfunction attentionRank(server: McpServer): number {\n\tif (!isEnabled(server)) return 5;\n\tswitch (server.connection?.state) {\n\t\tcase \"needs-auth\":\n\t\t\treturn 0;\n\t\tcase \"failed\":\n\t\t\treturn 1;\n\t\tcase \"disconnected\":\n\t\t\treturn 2;\n\t\tcase \"connected\":\n\t\t\treturn 4;\n\t\tdefault:\n\t\t\treturn 3;\n\t}\n}\n\nfunction describeTransport(entry: McpServerEntry): string {\n\tconst { config } = entry;\n\tif (\"url\" in config) return config.url;\n\treturn [config.command, ...(config.args ?? [])].join(\" \");\n}\n\nconst MCP_USAGE = \"Usage: /mcp, /mcp login [server], /mcp logout [server], /mcp reconnect [server]\";\n\nexport function createMcpExtension(options: McpExtensionOptions = {}): ExtensionFactory {\n\treturn (pi: ExtensionAPI) => {\n\t\tlet servers: McpServer[] = [];\n\t\t/** Servers from `mcp.json`, which take precedence over registered servers of the same name. */\n\t\tlet configuredEntries: McpServerEntry[] = [];\n\t\tlet configErrors: string[] = [];\n\t\t/** The trusted project's `mcp.json`, where `/mcp` saves project overrides of global servers. */\n\t\tlet projectConfig: string | undefined;\n\t\t/** Registered servers that `mcp.json` overrides, shown in `/mcp`. */\n\t\tlet overridden: string[] = [];\n\t\tlet latestContext: ExtensionContext | undefined;\n\t\tlet subagentMcpDirectTools: readonly string[] | undefined;\n\t\tlet autoEnableCodemode = true;\n\t\t/** Whether the \"codemode tools unreachable\" warning was shown since the session started. */\n\t\tlet warnedUnreachable = false;\n\t\tlet pending: Promise<unknown> | undefined;\n\t\t/** Whether a prompt already waited for the startup connections since the session started. */\n\t\tlet waitedForStartup = false;\n\t\tconst startupWaitMs = options.startupWaitMs ?? DEFAULT_STARTUP_WAIT_MS;\n\t\t/** Working directory of the session, for stdio servers. */\n\t\tlet sessionCwd = process.cwd();\n\t\tlet credentials = options.credentials;\n\t\t/** The session's model registry, which resolves `auth.provider` tokens. */\n\t\tlet modelRegistry: ModelRegistry | undefined;\n\t\tlet serverLog: McpServerLog | undefined;\n\t\tconst openUrl = options.openUrl ?? openBrowser;\n\t\tconst updateConfig =\n\t\t\toptions.updateConfig ??\n\t\t\t((entry, patch) =>\n\t\t\t\tupdateMcpServerConfigAsync(entry.override ?? entry.source, entry.name, patch, {\n\t\t\t\t\toverride: entry.override !== undefined,\n\t\t\t\t}));\n\n\t\t/**\n\t\t * Lifetime of the current session: aborted on session_shutdown, and before the first session_start\n\t\t * (registrations before that are read on session_start). Work captures `session.signal` when it\n\t\t * starts and drops late results once it aborted, for example a runtime load that resolves after\n\t\t * shutdown. Work that outlives the command that started it also stops on the signal and is\n\t\t * registered with `track`, so shutdown can wait for its cleanup.\n\t\t */\n\t\tlet session = new AbortController();\n\t\tsession.abort();\n\t\t/** Work registered with `track`: manager actions opening or closing connections, and sign-ins. */\n\t\tconst backgroundActions = new Set<Promise<void>>();\n\t\tconst track = <T>(work: Promise<T>): Promise<T> => {\n\t\t\tconst task = work.then(\n\t\t\t\t() => undefined,\n\t\t\t\t() => undefined,\n\t\t\t);\n\t\t\tbackgroundActions.add(task);\n\t\t\tvoid task.finally(() => backgroundActions.delete(task));\n\t\t\treturn work;\n\t\t};\n\t\tconst listeners = new Set<() => void>();\n\t\tconst emitChange = () => {\n\t\t\tfor (const listener of listeners) listener();\n\t\t};\n\t\tconst subscribe = (listener: () => void) => {\n\t\t\tlisteners.add(listener);\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t};\n\t\t};\n\n\t\tconst connections = () => servers.flatMap((server) => (server.connection ? [server.connection] : []));\n\t\tconst findServer = (name: string) => servers.find((server) => server.entry.name === name);\n\n\t\t/** Servers extensions registered, except names `mcp.json` defines, which take precedence. */\n\t\tconst registeredServers = (): { servers: McpServer[]; overridden: string[] } => {\n\t\t\tconst registered: McpServer[] = [];\n\t\t\tconst overriddenNames: string[] = [];\n\t\t\tconst namespaceOwners = new Map<string, { name: string; origin: string }>();\n\t\t\tfor (const contribution of pi.getMcpServerContributions?.() ?? []) {\n\t\t\t\tconst { name, config, sourceInfo } = contribution;\n\t\t\t\tconst source = sourceInfo.path;\n\t\t\t\tconst hasProviderAuth =\n\t\t\t\t\t\"url\" in config && typeof config.auth === \"object\" && config.auth !== null && \"provider\" in config.auth;\n\t\t\t\tif (hasProviderAuth && (contribution.origin === \"package\" || sourceInfo.origin === \"package\")) {\n\t\t\t\t\tconfigErrors.push(\n\t\t\t\t\t\t`${source}: server \"${name}\": auth.provider is only allowed for explicit extension registrations`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst configured = configuredEntries.find((entry) => mcpNamespace(entry.name) === mcpNamespace(name));\n\t\t\t\tif (configured) {\n\t\t\t\t\toverriddenNames.push(\n\t\t\t\t\t\t`\"${name}\" registered by ${source} is overridden by \"${configured.name}\" in ${configured.source}`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst namespace = mcpNamespace(name);\n\t\t\t\tconst owner = namespaceOwners.get(namespace);\n\t\t\t\tif (owner) {\n\t\t\t\t\toverriddenNames.push(\n\t\t\t\t\t\t`\"${name}\" from ${contribution.origin} is ignored because its MCP namespace conflicts with \"${owner.name}\" from ${owner.origin}`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tnamespaceOwners.set(namespace, { name, origin: contribution.origin });\n\t\t\t\tregistered.push({\n\t\t\t\t\tentry: { name, config, source, scope: \"extension\" },\n\t\t\t\t\tregisteredConfig: JSON.stringify(config),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn { servers: registered, overridden: overriddenNames };\n\t\t};\n\n\t\tconst getCredentials = (runtime: typeof McpRuntime): McpOAuthCredentialStore => {\n\t\t\tcredentials ??= new runtime.McpOAuthCredentialStore();\n\t\t\treturn credentials;\n\t\t};\n\n\t\tconst getServerLog = (runtime: typeof McpRuntime): McpServerLog => {\n\t\t\tserverLog ??= new runtime.McpServerLog(options.logPath ?? join(getAgentDir(), \"mcp.log\"));\n\t\t\treturn serverLog;\n\t\t};\n\n\t\t/** pi tool name to the `<server>\\0<tool>` it was assigned to, so names stay unique and stable. */\n\t\tconst toolOwners = new Map<string, string>();\n\t\t/** Tool names currently offered by each server. */\n\t\tconst serverTools = new Map<string, Set<string>>();\n\t\t/** Last definition registered under each tool name, to re-register withdrawn tools as hidden. */\n\t\tconst definitions = new Map<string, ToolDefinition<TSchema, McpToolDetails>>();\n\t\t/** Each registered tool name's server and that server's latest listing of the tool. */\n\t\tconst listedTools = new Map<string, { server: string; tool: McpTool }>();\n\t\t/**\n\t\t * Tool names registered from the session's records (see tool-records.ts) that their server has not listed\n\t\t * since the session started. They stay declared while the server connects; calls wait for it.\n\t\t */\n\t\tconst recordedOnly = new Set<string>();\n\t\t/** The latest records on the session's branch. */\n\t\tlet toolRecords: McpToolRecords = { tools: new Map(), resourceServers: undefined };\n\t\t/** Tool records being appended, by name, and the resource servers being appended, as JSON. */\n\t\tconst recordingTools = new Map<string, McpToolRecord>();\n\t\tlet recordingResources: string | undefined;\n\t\t/** MCP tool and resource tool names the session's transcript declares to the model now. */\n\t\tlet declaredNames = new Set<string>();\n\t\t/**\n\t\t * Servers that had resources when the session declared the resource tools and have not finished connecting\n\t\t * since it started. The resource tools stay declared for them meanwhile.\n\t\t */\n\t\tconst pendingResourceServers = new Set<string>();\n\n\t\t// Render resumed MCP calls even when their server has not connected or never connects.\n\t\tpi.registerToolRenderer((toolName, next) => {\n\t\t\tconst registered = next();\n\t\t\tif (registered) return registered;\n\t\t\tif (!toolName.startsWith(\"mcp__\")) return undefined;\n\t\t\tconst owner = toolOwners.get(toolName);\n\t\t\tif (owner) return createMcpToolRenderers(owner.replace(\"\\0\", \"/\"));\n\t\t\tconst encoded = toolName.slice(\"mcp__\".length);\n\t\t\tconst boundary = encoded.indexOf(\"__\");\n\t\t\tconst unambiguous =\n\t\t\t\tboundary > 0 &&\n\t\t\t\tboundary + 2 < encoded.length &&\n\t\t\t\tboundary === encoded.lastIndexOf(\"__\") &&\n\t\t\t\t!/_[a-f0-9]{8}(?:_\\d+)?$/.test(toolName);\n\t\t\tconst label = unambiguous ? `${encoded.slice(0, boundary)}/${encoded.slice(boundary + 2)}` : toolName;\n\t\t\treturn createMcpToolRenderers(label);\n\t\t});\n\n\t\t/** Exposure of one of a server's tools, from its config and the subagent policy. */\n\t\tconst exposureFor = (entry: McpServerEntry, tool: string, name: string): McpExposure => {\n\t\t\tconst server = entry.name;\n\t\t\tconst configuredExposure = getMcpToolExposure(entry.config, tool);\n\t\t\tconst selected =\n\t\t\t\t(subagentMcpDirectTools !== undefined &&\n\t\t\t\t\tmatchesMcpDirectToolSelection(subagentMcpDirectTools, server, tool)) ||\n\t\t\t\t(latestContext?.subagentPolicy?.tools?.includes(name) ?? false);\n\t\t\treturn selected && configuredExposure !== \"hidden\" && exposureOf(entry) !== \"hidden\"\n\t\t\t\t? \"direct\"\n\t\t\t\t: subagentMcpDirectTools === undefined && !latestContext?.subagentPolicy?.tools\n\t\t\t\t\t? configuredExposure\n\t\t\t\t\t: \"hidden\";\n\t\t};\n\n\t\t/**\n\t\t * The definition of a server's tool. `recorded` marks a definition built from the session's record before the\n\t\t * server listed the tool: a call to it runs only once the server lists the same tool under the same name.\n\t\t */\n\t\tconst defineTool = (\n\t\t\tentry: McpServerEntry,\n\t\t\ttool: McpTool,\n\t\t\tname: string,\n\t\t\tinstructions: string | undefined,\n\t\t\trecorded?: McpTool,\n\t\t): ToolDefinition<TSchema, McpToolDetails> => {\n\t\t\tconst server = entry.name;\n\t\t\tconst description = entry.config.description?.trim();\n\t\t\tconst definition = createMcpToolDefinition({\n\t\t\t\tserver,\n\t\t\t\ttool,\n\t\t\t\tname,\n\t\t\t\texposure: exposureFor(entry, tool.name, name),\n\t\t\t\tnamespace: {\n\t\t\t\t\tname: mcpNamespace(server),\n\t\t\t\t\t...(description ? { description } : {}),\n\t\t\t\t\t...(instructions ? { instructions } : {}),\n\t\t\t\t},\n\t\t\t\ttimeoutMs: mcpRequestTimeoutMs(entry.config),\n\t\t\t\tgetClient: async () => {\n\t\t\t\t\tconst current = findServer(server);\n\t\t\t\t\tif (!current || !isEnabled(current)) throw new Error(`MCP server \"${server}\" is disabled.`);\n\t\t\t\t\tconst client = current.connection;\n\t\t\t\t\tif (!client) throw new Error(`MCP server \"${server}\" is still starting.`);\n\t\t\t\t\tif (recorded) {\n\t\t\t\t\t\t// The call waited for the server's connection attempt (tool_call below). Run it only against the\n\t\t\t\t\t\t// tool the session declared: the server must list it again, unchanged, under this name.\n\t\t\t\t\t\tconst listed = listedTools.get(name);\n\t\t\t\t\t\tif (!listed || listed.server !== server) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\tclient.state === \"connected\" || client.state === \"disconnected\"\n\t\t\t\t\t\t\t\t\t? `MCP tool \"${server}/${tool.name}\" is no longer available.`\n\t\t\t\t\t\t\t\t\t: `MCP server \"${server}\" did not reconnect (${describeState(current, false)}), so its tool \"${tool.name}\" is not available.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!sameListedTool(listed.tool, recorded)) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`MCP tool \"${server}/${tool.name}\" changed since this session declared it, so the call did not run. Its new definition is declared with the next request.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tgetMcpToolExposure(current.entry.config, tool.name) === \"hidden\" ||\n\t\t\t\t\t\t(client.state === \"connected\" && !client.tools.some((offered) => offered.name === tool.name))\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new Error(`MCP tool \"${server}/${tool.name}\" is no longer available.`);\n\t\t\t\t\t}\n\t\t\t\t\treturn client;\n\t\t\t\t},\n\t\t\t\treadableResources: () => resourceServers().some((current) => current.name === server),\n\t\t\t});\n\t\t\tmarkNativeMcpToolDefinition(definition, { server, tool: tool.name });\n\t\t\treturn definition;\n\t\t};\n\n\t\t/** Re-register a tool as hidden, which takes it out of the declared tools. */\n\t\tconst withdrawTool = (name: string) => {\n\t\t\tconst definition = definitions.get(name);\n\t\t\tif (definition) pi.registerTool({ ...definition, exposure: \"hidden\" });\n\t\t\tlistedTools.delete(name);\n\t\t\trecordedOnly.delete(name);\n\t\t};\n\n\t\tconst registerTools = (connection: McpServerConnection) => {\n\t\t\tif (!servers.some((candidate) => candidate.connection === connection)) return;\n\t\t\tconst server = connection.entry.name;\n\t\t\tconst entry = findServer(server)?.entry ?? connection.entry;\n\t\t\tconst previous = serverTools.get(server) ?? new Set<string>();\n\t\t\tconst current = new Set<string>();\n\t\t\t// Like Codex, all tools whose names sanitize to the same name get the hash suffix, so which\n\t\t\t// one would keep the plain name does not depend on the order of the list.\n\t\t\tconst plain = [...new Set(connection.tools.map((tool) => tool.name))].map((tool) =>\n\t\t\t\tcreateMcpToolName(server, tool),\n\t\t\t);\n\t\t\tconst assignName = (tool: string, owner: string) => {\n\t\t\t\tconst name = createMcpToolName(server, tool, (candidate) => {\n\t\t\t\t\tconst existing = toolOwners.get(candidate);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(existing !== undefined && existing !== owner) ||\n\t\t\t\t\t\tcurrent.has(candidate) ||\n\t\t\t\t\t\tplain.indexOf(candidate) !== plain.lastIndexOf(candidate)\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\ttoolOwners.set(name, owner);\n\t\t\t\tcurrent.add(name);\n\t\t\t\treturn name;\n\t\t\t};\n\t\t\t// Register in the order of the tool names, not the server's listing, so the order the tools are declared\n\t\t\t// in does not depend on how the server happens to list them.\n\t\t\tconst listing = [...connection.tools].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\t\t\tfor (const tool of listing) {\n\t\t\t\tconst name = assignName(tool.name, `${server}\\0${tool.name}`);\n\t\t\t\tconst definition = defineTool(entry, tool, name, connection.instructions);\n\t\t\t\tdefinitions.set(definition.name, definition);\n\t\t\t\tlistedTools.set(name, { server, tool });\n\t\t\t\trecordedOnly.delete(name);\n\t\t\t\tpi.registerTool(definition);\n\t\t\t}\n\t\t\tserverTools.set(server, current);\n\t\t\t// Tools cannot be unregistered, so tools the server dropped are re-registered as hidden. When\n\t\t\t// the server offers them again they are registered with their configured exposure above.\n\t\t\tfor (const name of previous) if (!current.has(name)) withdrawTool(name);\n\t\t\tsyncResourceTools();\n\t\t\tvoid recordDeclaredTools();\n\t\t};\n\n\t\t/** Make a disabled server's tools unreachable. */\n\t\tconst hideTools = (server: string) => {\n\t\t\tfor (const name of serverTools.get(server) ?? []) withdrawTool(name);\n\t\t\tserverTools.set(server, new Set());\n\t\t\tsyncResourceTools();\n\t\t};\n\n\t\t/**\n\t\t * Record the server's listing of each MCP tool the transcript declares, when it changed since the last record\n\t\t * on the branch, so a resumed session can keep declaring the tool while the server reconnects.\n\t\t */\n\t\tconst recordDeclaredTools = async (): Promise<void> => {\n\t\t\tconst records = toolRecords;\n\t\t\tconst tools: McpToolRecord[] = [];\n\t\t\tfor (const name of [...declaredNames].sort()) {\n\t\t\t\tconst listed = listedTools.get(name);\n\t\t\t\tconst entry = listed && findServer(listed.server)?.entry;\n\t\t\t\tif (!listed || !entry || recordedOnly.has(name)) continue;\n\t\t\t\tconst record: McpToolRecord = {\n\t\t\t\t\tname,\n\t\t\t\t\tserver: listed.server,\n\t\t\t\t\ttransport: transportFingerprint(entry),\n\t\t\t\t\ttool: recordableTool(listed.tool),\n\t\t\t\t};\n\t\t\t\tconst known = [records.tools.get(name), recordingTools.get(name)];\n\t\t\t\tif (known.some((previous) => previous && sameToolRecord(previous, record))) continue;\n\t\t\t\trecordingTools.set(name, record);\n\t\t\t\ttools.push(record);\n\t\t\t}\n\t\t\tlet resourceServers: McpResourceServerRecord[] | undefined;\n\t\t\tif (pendingResourceServers.size === 0 && [...RESOURCE_TOOL_NAMES].some((name) => declaredNames.has(name))) {\n\t\t\t\tconst current = serversWithResources()\n\t\t\t\t\t.map((server) => ({ server: server.entry.name, transport: transportFingerprint(server.entry) }))\n\t\t\t\t\t.sort((a, b) => (a.server < b.server ? -1 : a.server > b.server ? 1 : 0));\n\t\t\t\tconst json = JSON.stringify(current);\n\t\t\t\tconst known = [JSON.stringify(records.resourceServers), recordingResources];\n\t\t\t\tif (current.length > 0 && !known.includes(json)) {\n\t\t\t\t\trecordingResources = json;\n\t\t\t\t\tresourceServers = current;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (tools.length === 0 && !resourceServers) return;\n\t\t\tconst settled = () => {\n\t\t\t\tfor (const record of tools)\n\t\t\t\t\tif (recordingTools.get(record.name) === record) recordingTools.delete(record.name);\n\t\t\t\tif (resourceServers && recordingResources === JSON.stringify(resourceServers))\n\t\t\t\t\trecordingResources = undefined;\n\t\t\t};\n\t\t\t// The records count once they are stored; a failed write is tried again with the next change.\n\t\t\ttry {\n\t\t\t\tawait pi.appendEntry<McpToolRecordData>(MCP_TOOL_RECORD_ENTRY_TYPE, {\n\t\t\t\t\ttools,\n\t\t\t\t\t...(resourceServers ? { resourceServers } : {}),\n\t\t\t\t});\n\t\t\t\tif (toolRecords === records) {\n\t\t\t\t\tfor (const record of tools) records.tools.set(record.name, record);\n\t\t\t\t\tif (resourceServers) records.resourceServers = resourceServers;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Without the record, a later resume treats these tools as before: removed until their server connects.\n\t\t\t} finally {\n\t\t\t\tsettled();\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * On session start, register the tools the transcript declares from their records, for servers that are still\n\t\t * configured with the same URL or command, so the first requests keep declaring them while the servers\n\t\t * connect. A server that connects lists its tools again and they replace these definitions; the ones of a\n\t\t * server that does not connect are withdrawn once its attempt settles.\n\t\t */\n\t\tconst restoreRecordedTools = (ctx: ExtensionContext) => {\n\t\t\tconst branch = ctx.sessionManager.getBranch();\n\t\t\ttoolRecords = readToolRecords(branch);\n\t\t\tdeclaredNames = declaredMcpToolNames(branch);\n\t\t\t// Recorded names stay their servers', as in the session that recorded them: a server that connects first\n\t\t\t// cannot take another server's name, and a call to a declared tool waits for its server. A name a tool had\n\t\t\t// before it was declared under another one is left free.\n\t\t\tconst owner = (record: McpToolRecord) => `${record.server}\\0${record.tool.name}`;\n\t\t\tconst declaredOwners = new Set<string>();\n\t\t\tfor (const name of declaredNames) {\n\t\t\t\tconst record = toolRecords.tools.get(name);\n\t\t\t\tif (!record) continue;\n\t\t\t\ttoolOwners.set(name, owner(record));\n\t\t\t\tdeclaredOwners.add(owner(record));\n\t\t\t}\n\t\t\tfor (const record of toolRecords.tools.values()) {\n\t\t\t\tif (!toolOwners.has(record.name) && !declaredOwners.has(owner(record))) {\n\t\t\t\t\ttoolOwners.set(record.name, owner(record));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const name of declaredNames) {\n\t\t\t\tconst record = toolRecords.tools.get(name);\n\t\t\t\tif (!record) continue;\n\t\t\t\tconst server = findServer(record.server);\n\t\t\t\tif (!server || !isEnabled(server) || transportFingerprint(server.entry) !== record.transport) continue;\n\t\t\t\tif (exposureFor(server.entry, record.tool.name, name) === \"hidden\") continue;\n\t\t\t\tconst definition = defineTool(server.entry, record.tool, name, undefined, record.tool);\n\t\t\t\tdefinitions.set(name, definition);\n\t\t\t\trecordedOnly.add(name);\n\t\t\t\tconst names = serverTools.get(record.server) ?? new Set<string>();\n\t\t\t\tnames.add(name);\n\t\t\t\tserverTools.set(record.server, names);\n\t\t\t\tpi.registerTool(definition);\n\t\t\t}\n\t\t\t// The resource tools stay declared while a server that had resources reconnects.\n\t\t\tif ([...RESOURCE_TOOL_NAMES].some((name) => declaredNames.has(name))) {\n\t\t\t\tfor (const { server: name, transport } of toolRecords.resourceServers ?? []) {\n\t\t\t\t\tconst server = findServer(name);\n\t\t\t\t\tif (server && isEnabled(server) && transportFingerprint(server.entry) === transport) {\n\t\t\t\t\t\tpendingResourceServers.add(name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsyncResourceTools();\n\t\t\t}\n\t\t};\n\n\t\t/** Withdraw the recorded tools of a server whose connection attempt settled without listing them. */\n\t\tconst withdrawUnlistedRecords = (server: string) => {\n\t\t\tfor (const name of serverTools.get(server) ?? []) {\n\t\t\t\tif (!recordedOnly.has(name)) continue;\n\t\t\t\twithdrawTool(name);\n\t\t\t\tserverTools.get(server)?.delete(name);\n\t\t\t}\n\t\t};\n\n\t\t/** Enabled servers with resources whose exposure is not `hidden`, which the resource tools reach. */\n\t\tconst serversWithResources = (): McpServer[] =>\n\t\t\tservers.filter(\n\t\t\t\t(server) => server.connection?.hasResources && isEnabled(server) && exposureOf(server.entry) !== \"hidden\",\n\t\t\t);\n\t\tconst resourceServers = (): McpServerConnection[] =>\n\t\t\tserversWithResources().flatMap((server) => (server.connection ? [server.connection] : []));\n\n\t\t/** Exposure the resource tools were last registered with; undefined until a server has resources. */\n\t\tlet resourceToolsExposure: McpExposure | undefined;\n\t\t/**\n\t\t * Register the resource tools with the widest exposure of the servers they reach: `direct` when\n\t\t * one of them is direct, and so on. They are hidden when no server has resources.\n\t\t */\n\t\tconst syncResourceTools = () => {\n\t\t\tconst exposures = new Set(serversWithResources().map((server) => exposureOf(server.entry)));\n\t\t\tfor (const name of pendingResourceServers) {\n\t\t\t\tconst server = findServer(name);\n\t\t\t\tif (server && isEnabled(server) && exposureOf(server.entry) !== \"hidden\")\n\t\t\t\t\texposures.add(exposureOf(server.entry));\n\t\t\t}\n\t\t\tconst exposure = ([\"direct\", \"codemode\", \"deferred\"] as const).find((candidate) => exposures.has(candidate));\n\t\t\tconst next = exposure ?? \"hidden\";\n\t\t\tif (next === resourceToolsExposure || (resourceToolsExposure === undefined && next === \"hidden\")) return;\n\t\t\tconst wasDirect = resourceToolsExposure === \"direct\";\n\t\t\tresourceToolsExposure = next;\n\t\t\tconst resourceDefinitions = createMcpResourceToolDefinitions({ exposure: next, servers: resourceServers });\n\t\t\tfor (const definition of resourceDefinitions) pi.registerTool(definition);\n\t\t\t// Hidden tools leave the declared tools when they are registered; only other exposures need this.\n\t\t\tif (wasDirect && next !== \"hidden\") {\n\t\t\t\tconst names = new Set(resourceDefinitions.map((definition) => definition.name));\n\t\t\t\tpi.setActiveTools(pi.getActiveTools().filter((name) => !names.has(name)));\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * Tools that are not declared to the model are reached through the codemode tool (scripts call\n\t\t * them) or the tool_search tool (it declares them). Either reaches every such tool. Activate the\n\t\t * one the tools' exposure asks for: codemode for `codemode` unless `autoEnableCodemode` is false,\n\t\t * tool_search for `deferred`.\n\t\t */\n\t\tconst ensureDiscoveryActive = (ctx: ExtensionContext) => {\n\t\t\t// From the config, so the tool is active before the servers connect. Resource tools share\n\t\t\t// their server's exposure.\n\t\t\tconst exposures = new Set<McpExposure>();\n\t\t\tfor (const server of servers) {\n\t\t\t\tif (isEnabled(server)) for (const exposure of configuredExposures(server.entry)) exposures.add(exposure);\n\t\t\t}\n\t\t\tconst needsCodemode = exposures.has(\"codemode\");\n\t\t\tconst needsToolSearch = exposures.has(\"deferred\");\n\t\t\tif (!needsCodemode && !needsToolSearch) return;\n\t\t\t// Other extensions' tools of the same names cannot reach MCP tools, so never activate them.\n\t\t\tconst tools = pi.getAllTools();\n\t\t\tconst codemode = tools.find(isCodemodeDiscoveryTool);\n\t\t\tconst hasCodemode = codemode !== undefined;\n\t\t\tconst hasToolSearch = tools.some(isToolSearchDiscoveryTool);\n\t\t\tconst active = pi.getActiveTools();\n\t\t\tconst activate: string[] = [];\n\t\t\tif (\n\t\t\t\tneedsCodemode &&\n\t\t\t\tcodemode &&\n\t\t\t\t!codemode.explicitDefaultOptOut &&\n\t\t\t\tautoEnableCodemode &&\n\t\t\t\t!active.includes(CODEMODE_TOOL_NAME)\n\t\t\t) {\n\t\t\t\tactivate.push(CODEMODE_TOOL_NAME);\n\t\t\t}\n\t\t\tif (needsToolSearch && hasToolSearch && !active.includes(TOOL_SEARCH_TOOL_NAME)) {\n\t\t\t\tactivate.push(TOOL_SEARCH_TOOL_NAME);\n\t\t\t}\n\t\t\tif (activate.length > 0) pi.setActiveTools([...active, ...activate]);\n\t\t\tconst reachable = [...active, ...activate];\n\t\t\tif (hasCodemode && reachable.includes(CODEMODE_TOOL_NAME)) return;\n\t\t\tif (hasToolSearch && reachable.includes(TOOL_SEARCH_TOOL_NAME)) return;\n\t\t\tif (warnedUnreachable) return;\n\t\t\twarnedUnreachable = true;\n\t\t\tconst reason =\n\t\t\t\tneedsCodemode && codemode?.explicitDefaultOptOut\n\t\t\t\t\t? \" (-codemode removed it from the tool selection)\"\n\t\t\t\t\t: needsCodemode && hasCodemode && !autoEnableCodemode\n\t\t\t\t\t\t? \" (autoEnableCodemode is false)\"\n\t\t\t\t\t\t: \"\";\n\t\t\tctx.ui.notify(\n\t\t\t\t`MCP tools are only reachable from the codemode or tool_search tool, but neither is active${reason}; they cannot be called.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t};\n\n\t\t/**\n\t\t * Stored tokens of servers waiting for a sign-in, as they were when the sign-in was needed.\n\t\t * `pi mcp login` in another process (for example run by the agent) changes them.\n\t\t */\n\t\tconst tokensAtSignIn = new Map<McpServerConnection, Promise<string>>();\n\t\tconst storedTokens = async (connection: McpServerConnection): Promise<string> => {\n\t\t\tconst url = connection.oauthUrl;\n\t\t\treturn url && credentials\n\t\t\t\t? JSON.stringify((await credentials.tokensAsync(connection.name, url)) ?? null)\n\t\t\t\t: \"null\";\n\t\t};\n\t\tconst onConnectionChange = (connection: McpServerConnection) => {\n\t\t\tif (connection.state !== \"needs-auth\") tokensAtSignIn.delete(connection);\n\t\t\telse if (!tokensAtSignIn.has(connection)) {\n\t\t\t\tconst tokens = storedTokens(connection);\n\t\t\t\ttokens.catch(() => {});\n\t\t\t\ttokensAtSignIn.set(connection, tokens);\n\t\t\t}\n\t\t\temitChange();\n\t\t};\n\t\t/** Reconnect servers that need a sign-in when their credentials were stored since. */\n\t\tconst reconnectSignedIn = async (ctx: ExtensionContext) => {\n\t\t\tconst compared = await Promise.all(\n\t\t\t\t[...tokensAtSignIn].map(async ([connection, tokens]) => ({\n\t\t\t\t\tconnection,\n\t\t\t\t\ttokens,\n\t\t\t\t\tchanged: (await storedTokens(connection)) !== (await tokens),\n\t\t\t\t})),\n\t\t\t);\n\t\t\tconst signedIn = compared.filter(({ changed }) => changed);\n\t\t\tif (signedIn.length === 0) return;\n\t\t\tfor (const { connection, tokens } of signedIn) {\n\t\t\t\tif (tokensAtSignIn.get(connection) === tokens) tokensAtSignIn.delete(connection);\n\t\t\t}\n\t\t\tawait Promise.allSettled(signedIn.map(({ connection }) => connection.reconnect()));\n\t\t\tensureDiscoveryActive(ctx);\n\t\t};\n\n\t\t/** Create the server's connection, loading the MCP runtime on first use. */\n\t\tconst createConnection = async (\n\t\t\tserver: McpServer,\n\t\t\tisCurrent: () => boolean,\n\t\t): Promise<McpServerConnection | undefined> => {\n\t\t\tif (!isCurrent()) return;\n\t\t\tconst runtime = await loadMcpRuntime();\n\t\t\tif (!isCurrent()) return;\n\t\t\tconst connection = new runtime.McpServerConnection({\n\t\t\t\tentry: server.entry,\n\t\t\t\tcwd: sessionCwd,\n\t\t\t\tcreateTransport: options.createTransport ?? runtime.createDefaultTransport,\n\t\t\t\tcredentials: getCredentials(runtime),\n\t\t\t\tproviderToken: async (provider) => modelRegistry?.getApiKeyForProvider(provider),\n\t\t\t\tlog: getServerLog(runtime),\n\t\t\t\tonTools: (connection) => {\n\t\t\t\t\tif (isCurrent()) registerTools(connection);\n\t\t\t\t},\n\t\t\t\tonChange: (connection) => {\n\t\t\t\t\tif (isCurrent()) onConnectionChange(connection);\n\t\t\t\t\telse tokensAtSignIn.delete(connection);\n\t\t\t\t},\n\t\t\t});\n\t\t\tserver.connection = connection;\n\t\t\temitChange();\n\t\t\treturn connection;\n\t\t};\n\n\t\tconst startConnection = (server: McpServer, after?: Promise<unknown>): Promise<void> => {\n\t\t\tconst { signal } = session;\n\t\t\tconst attempt = Symbol();\n\t\t\tserver.attempt = attempt;\n\t\t\tconst isCurrent = () =>\n\t\t\t\t!signal.aborted && server.attempt === attempt && isEnabled(server) && servers.includes(server);\n\t\t\tconst ready = (async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait after;\n\t\t\t\t\tif (!isCurrent()) return;\n\t\t\t\t\tconst connection = await createConnection(server, isCurrent);\n\t\t\t\t\tif (!connection || !isCurrent()) return;\n\t\t\t\t\tawait connection.getClient().catch(() => undefined);\n\t\t\t\t} finally {\n\t\t\t\t\tif (isCurrent()) {\n\t\t\t\t\t\twithdrawUnlistedRecords(server.entry.name);\n\t\t\t\t\t\tif (pendingResourceServers.delete(server.entry.name)) syncResourceTools();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})();\n\t\t\tserver.ready = ready.catch(() => undefined);\n\t\t\treturn ready;\n\t\t};\n\n\t\tconst waitForServers = async (waiting: readonly McpServer[], signal: AbortSignal | undefined) => {\n\t\t\tfor (;;) {\n\t\t\t\tconst ready = waiting.flatMap((server) =>\n\t\t\t\t\tisEnabled(server) && servers.includes(server) && server.ready ? [{ server, ready: server.ready }] : [],\n\t\t\t\t);\n\t\t\t\tif (ready.length === 0 || signal?.aborted) return;\n\t\t\t\tlet onAbort: (() => void) | undefined;\n\t\t\t\tawait Promise.race([\n\t\t\t\t\tPromise.all(ready.map((attempt) => attempt.ready)),\n\t\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\t\tonAbort = () => resolve();\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t}),\n\t\t\t\t]);\n\t\t\t\tif (onAbort) signal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\tif (\n\t\t\t\t\tsignal?.aborted ||\n\t\t\t\t\tready.every(\n\t\t\t\t\t\t(attempt) =>\n\t\t\t\t\t\t\t!isEnabled(attempt.server) ||\n\t\t\t\t\t\t\t!servers.includes(attempt.server) ||\n\t\t\t\t\t\t\tattempt.ready === attempt.server.ready,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * One message for everything that needs the user after startup, or only for `only`, servers\n\t\t * that connected later.\n\t\t */\n\t\tconst reportProblems = (ctx: ExtensionContext, only?: readonly McpServer[]) => {\n\t\t\tconst lines = only ? [] : configErrors.map((error) => `config: ${error}`);\n\t\t\tfor (const server of only ?? servers) {\n\t\t\t\tconst state = server.connection?.state;\n\t\t\t\tif (state === \"needs-auth\" || state === \"failed\")\n\t\t\t\t\tlines.push(`${server.entry.name}: ${describeState(server)}`);\n\t\t\t}\n\t\t\tif (lines.length === 0) return;\n\t\t\tctx.ui.notify(\n\t\t\t\t`MCP servers need attention:\\n${lines.map((line) => ` ${line}`).join(\"\\n\")}\\nRun /mcp to fix.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t};\n\n\t\t/**\n\t\t * Save a config change; returns an error message when the file could not be updated. Changes to\n\t\t * registered servers only apply to the current session. `inProject` adds a project override.\n\t\t */\n\t\tconst saveConfig = async (\n\t\t\tserver: McpServer,\n\t\t\tpatch: McpServerConfigPatch,\n\t\t\tinProject = false,\n\t\t): Promise<string | undefined> => {\n\t\t\tconst override = inProject ? projectConfig : server.entry.override;\n\t\t\tconst entry = override ? { ...server.entry, override } : server.entry;\n\t\t\tif (entry.scope !== \"extension\") {\n\t\t\t\ttry {\n\t\t\t\t\tawait updateConfig(entry, patch);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn `Could not update ${entry.override ?? entry.source}: ${errorMessage(error)}`;\n\t\t\t\t}\n\t\t\t}\n\t\t\tserver.entry = { ...entry, config: { ...entry.config, ...patch } };\n\t\t\treturn undefined;\n\t\t};\n\n\t\t/** Sign in, then reconnect. Returns an error message on failure. `cancel` or the session's end stops the sign-in. */\n\t\tconst signIn = async (\n\t\t\tserver: McpServer,\n\t\t\tprompt: McpSignInPrompt,\n\t\t\tcancel?: AbortSignal,\n\t\t): Promise<string | undefined> => {\n\t\t\tconst connection = server.connection;\n\t\t\tconst url = connection?.oauthUrl;\n\t\t\tif (!connection || !url) return `MCP server \"${server.entry.name}\" does not use OAuth.`;\n\t\t\tconst runtime = await loadMcpRuntime();\n\t\t\tconst signal = cancel ? AbortSignal.any([session.signal, cancel]) : session.signal;\n\t\t\ttry {\n\t\t\t\tawait track(\n\t\t\t\t\truntime.signInMcpServer({\n\t\t\t\t\t\tserverUrl: url,\n\t\t\t\t\t\tstore: getCredentials(runtime).forServer(server.entry.name, url),\n\t\t\t\t\t\tsettings: await connection.oauthSettings(),\n\t\t\t\t\t\tchallenge: connection.challenge,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof runtime.McpSignInCancelledError) return \"Sign-in cancelled.\";\n\t\t\t\treturn `Sign-in failed: ${errorMessage(error)}`;\n\t\t\t}\n\t\t\t// The challenge that asked for this sign-in (for example for more scope) is answered.\n\t\t\tconnection.challenge = undefined;\n\t\t\ttry {\n\t\t\t\tawait connection.reconnect();\n\t\t\t} catch (error) {\n\t\t\t\treturn `Signed in, but ${errorMessage(error)}`;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t};\n\n\t\tconst signOut = async (server: McpServer): Promise<boolean> => {\n\t\t\tconst connection = server.connection;\n\t\t\tconst url = connection?.oauthUrl;\n\t\t\tif (!connection || !url) return false;\n\t\t\tconst removed = await getCredentials(await loadMcpRuntime()).removeAsync(server.entry.name, url);\n\t\t\tawait connection.signOut();\n\t\t\treturn removed;\n\t\t};\n\n\t\tconst reconnect = async (server: McpServer): Promise<string | undefined> => {\n\t\t\tconst connection = server.connection;\n\t\t\tif (!connection) return `MCP server \"${server.entry.name}\" is disabled.`;\n\t\t\tconst previous = server.ready;\n\t\t\tconst ready = (async () => {\n\t\t\t\tawait previous;\n\t\t\t\tawait connection.reconnect();\n\t\t\t})();\n\t\t\tserver.ready = ready.catch(() => undefined);\n\t\t\ttry {\n\t\t\t\tawait ready;\n\t\t\t\treturn undefined;\n\t\t\t} catch (error) {\n\t\t\t\treturn errorMessage(error);\n\t\t\t}\n\t\t};\n\n\t\t/** Returns an error message when the config could not be saved; connection errors show in the state. */\n\t\tconst setEnabled = async (\n\t\t\tserver: McpServer,\n\t\t\tenabled: boolean,\n\t\t\tinProject = false,\n\t\t): Promise<string | undefined> => {\n\t\t\tconst failed = await saveConfig(server, { enabled }, inProject);\n\t\t\tif (failed) return failed;\n\t\t\tif (!enabled) {\n\t\t\t\tconst connection = server.connection;\n\t\t\t\tserver.attempt = undefined;\n\t\t\t\tserver.connection = undefined;\n\t\t\t\tif (connection) {\n\t\t\t\t\tserver.closing = connection.close();\n\t\t\t\t}\n\t\t\t\tconst closing = server.closing;\n\t\t\t\thideTools(server.entry.name);\n\t\t\t\temitChange();\n\t\t\t\ttry {\n\t\t\t\t\tawait closing;\n\t\t\t\t} finally {\n\t\t\t\t\tif (server.closing === closing) server.closing = undefined;\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tawait startConnection(server, server.closing);\n\t\t\treturn undefined;\n\t\t};\n\n\t\tconst setExposure = async (server: McpServer, exposure: McpExposure): Promise<string | undefined> => {\n\t\t\tconst failed = await saveConfig(server, { exposure });\n\t\t\tif (failed) return failed;\n\t\t\tif (server.connection?.state === \"connected\") registerTools(server.connection);\n\t\t\tsyncResourceTools();\n\t\t\t// Tools no longer exposed directly leave the declared set; direct tools are activated on registration.\n\t\t\tconst indirect = new Set(\n\t\t\t\tpi\n\t\t\t\t\t.getAllTools()\n\t\t\t\t\t.filter((tool) => tool.exposure !== \"direct\")\n\t\t\t\t\t.map((tool) => tool.name),\n\t\t\t);\n\t\t\tconst tools = serverTools.get(server.entry.name) ?? new Set<string>();\n\t\t\tpi.setActiveTools(pi.getActiveTools().filter((name) => !tools.has(name) || !indirect.has(name)));\n\t\t\temitChange();\n\t\t\treturn undefined;\n\t\t};\n\n\t\t// ---------------------------------------------------------------------------------------\n\t\t// Manager (`/mcp` in the TUI)\n\t\t// ---------------------------------------------------------------------------------------\n\n\t\tconst notices = () => [\n\t\t\t...configErrors.map((error) => `config: ${error}`),\n\t\t\t...overridden.map((line) => `overridden: ${line}`),\n\t\t];\n\n\t\tconst serversMenu = (): McpMenu => ({\n\t\t\ttitle: \"MCP servers\",\n\t\t\terror: notices().join(\"\\n\") || undefined,\n\t\t\titems: [...servers]\n\t\t\t\t.sort((a, b) => attentionRank(a) - attentionRank(b) || a.entry.name.localeCompare(b.entry.name))\n\t\t\t\t.map((server) => ({\n\t\t\t\t\tvalue: server.entry.name,\n\t\t\t\t\tlabel: server.entry.name,\n\t\t\t\t\tdescription: `${describeState(server)} · ${exposureOf(server.entry)} · ${server.entry.override ? \"global, project override\" : (server.entry.scope ?? server.entry.source)}`,\n\t\t\t\t})),\n\t\t\tempty: `No MCP servers configured. Add them to ${resolve(getAgentDir(), \"mcp.json\")} or ${CONFIG_DIR_NAME}/mcp.json.`,\n\t\t\tconfirmLabel: \"manage\",\n\t\t\tcancelLabel: \"close\",\n\t\t});\n\n\t\tconst serverMenu = (name: string): McpMenu => {\n\t\t\tconst server = findServer(name);\n\t\t\tif (!server) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: name,\n\t\t\t\t\titems: [],\n\t\t\t\t\tempty: \"This server is no longer configured.\",\n\t\t\t\t\tconfirmLabel: \"\",\n\t\t\t\t\tcancelLabel: \"back\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst { entry, connection } = server;\n\t\t\tconst saved =\n\t\t\t\tentry.scope === \"extension\"\n\t\t\t\t\t? \"for this session\"\n\t\t\t\t\t: entry.override\n\t\t\t\t\t\t? \"saved to the project mcp.json\"\n\t\t\t\t\t\t: entry.scope\n\t\t\t\t\t\t\t? `saved to the ${entry.scope} mcp.json`\n\t\t\t\t\t\t\t: \"saved to mcp.json\";\n\t\t\t// Global servers without an override can be turned on or off for the trusted project alone.\n\t\t\tconst inProject = entry.scope === \"global\" && !entry.override && projectConfig !== undefined;\n\t\t\tconst inProjectSaved = \"saved to the project mcp.json\";\n\t\t\tconst items: SelectItem[] = [];\n\t\t\tif (!isEnabled(server)) {\n\t\t\t\titems.push({ value: \"enable\", label: \"Enable\", description: saved });\n\t\t\t\tif (inProject) {\n\t\t\t\t\titems.push({ value: \"enable-project\", label: \"Enable in this project\", description: inProjectSaved });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst state = connection?.state;\n\t\t\t\tif (state === \"needs-auth\")\n\t\t\t\t\titems.push({ value: \"signin\", label: \"Sign in\", description: \"opens the browser\" });\n\t\t\t\tif (state === \"connected\" && connection) {\n\t\t\t\t\titems.push({ value: \"tools\", label: \"Tools\", description: `${connection.tools.length} offered` });\n\t\t\t\t}\n\t\t\t\tif (state === \"failed\" || state === \"disconnected\" || state === \"connected\" || state === \"needs-auth\") {\n\t\t\t\t\titems.push({ value: \"reconnect\", label: \"Reconnect\" });\n\t\t\t\t}\n\t\t\t\tif (state === \"connected\" && connection?.oauthUrl) {\n\t\t\t\t\titems.push({ value: \"signout\", label: \"Sign out\", description: \"deletes the stored credentials\" });\n\t\t\t\t}\n\t\t\t\titems.push({ value: \"exposure\", label: \"Exposure\", description: exposureOf(entry) });\n\t\t\t\titems.push({ value: \"disable\", label: \"Disable\", description: saved });\n\t\t\t\tif (inProject) {\n\t\t\t\t\titems.push({ value: \"disable-project\", label: \"Disable in this project\", description: inProjectSaved });\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst details = [\n\t\t\t\tdescribeTransport(entry),\n\t\t\t\t`${entry.scope ?? \"config\"}: ${entry.source}`,\n\t\t\t\t...(entry.override ? [`project override: ${entry.override}`] : []),\n\t\t\t\t`State: ${describeState(server, false)}`,\n\t\t\t];\n\t\t\tconst error = [server.message, connection?.state === \"connected\" ? undefined : connection?.error]\n\t\t\t\t.filter((line): line is string => line !== undefined)\n\t\t\t\t.join(\"\\n\");\n\t\t\treturn {\n\t\t\t\ttitle: `MCP server ${name}`,\n\t\t\t\tdetails: details.join(\"\\n\"),\n\t\t\t\terror: error || undefined,\n\t\t\t\titems,\n\t\t\t\tselected: items[0]?.value,\n\t\t\t\tconfirmLabel: \"select\",\n\t\t\t\tcancelLabel: \"back\",\n\t\t\t};\n\t\t};\n\n\t\tconst showTools = async (ui: McpUi, server: McpServer) => {\n\t\t\tconst exposure = exposureOf(server.entry);\n\t\t\tconst overridden = Object.keys(server.entry.config.toolExposure ?? {}).length > 0;\n\t\t\tawait ui.menu(() => ({\n\t\t\t\ttitle: `Tools of ${server.entry.name}`,\n\t\t\t\tdetails: `Exposure ${exposure}: ${exposure === \"hidden\" ? \"unreachable\" : EXPOSURE_DESCRIPTIONS[exposure]}${overridden ? \"\\nSome tools override it with toolExposure.\" : \"\"}`,\n\t\t\t\titems: (server.connection?.tools ?? []).map((tool) => {\n\t\t\t\t\tconst toolExposure = getMcpToolExposure(server.entry.config, tool.name);\n\t\t\t\t\tconst description = firstLine(tool.description ?? \"\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: tool.name,\n\t\t\t\t\t\tlabel: tool.name,\n\t\t\t\t\t\tdescription: toolExposure === exposure ? description : `[${toolExposure}] ${description}`,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t\tempty: \"The server offers no tools.\",\n\t\t\t\tconfirmLabel: \"back\",\n\t\t\t\tcancelLabel: \"back\",\n\t\t\t}));\n\t\t};\n\n\t\tconst chooseExposure = async (ui: McpUi, server: McpServer): Promise<string | undefined> => {\n\t\t\tconst current = exposureOf(server.entry);\n\t\t\tconst choice = await ui.menu(() => ({\n\t\t\t\ttitle: `Exposure of ${server.entry.name}`,\n\t\t\t\tdetails:\n\t\t\t\t\tserver.entry.scope === \"extension\"\n\t\t\t\t\t\t? `Applies to this session; the server is registered by ${server.entry.source}.`\n\t\t\t\t\t\t: `Saved to ${server.entry.override ?? server.entry.source}.`,\n\t\t\t\titems: (Object.keys(EXPOSURE_DESCRIPTIONS) as (keyof typeof EXPOSURE_DESCRIPTIONS)[]).map((exposure) => ({\n\t\t\t\t\tvalue: exposure,\n\t\t\t\t\tlabel: `${exposure === current ? \"✓ \" : \" \"}${exposure}`,\n\t\t\t\t\tdescription: EXPOSURE_DESCRIPTIONS[exposure],\n\t\t\t\t})),\n\t\t\t\tselected: current,\n\t\t\t\tconfirmLabel: \"save\",\n\t\t\t\tcancelLabel: \"back\",\n\t\t\t}));\n\t\t\tif (!choice || choice === current) return undefined;\n\t\t\treturn setExposure(server, choice as McpExposure);\n\t\t};\n\n\t\tconst signInWithUi = (ui: McpUi, server: McpServer): Promise<string | undefined> => {\n\t\t\tconst title = `Sign in to ${server.entry.name}`;\n\t\t\tconst cancel = new AbortController();\n\t\t\tconst status = (message: string) => ui.status(title, message, () => cancel.abort());\n\t\t\tlet authorizationUrl = \"\";\n\t\t\tstatus(\"Contacting the authorization server…\");\n\t\t\treturn signIn(\n\t\t\t\tserver,\n\t\t\t\t{\n\t\t\t\t\tshowAuthorizationUrl: (url) => {\n\t\t\t\t\t\tauthorizationUrl = url.href;\n\t\t\t\t\t\topenUrl(url.href);\n\t\t\t\t\t},\n\t\t\t\t\tpromptForRedirectUrl: async (signal) => {\n\t\t\t\t\t\tconst value = await ui.redirectUrl(title, authorizationUrl, signal);\n\t\t\t\t\t\tstatus(\"Connecting…\");\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tcancel.signal,\n\t\t\t);\n\t\t};\n\n\t\tconst runInBackground = (\n\t\t\tctx: ExtensionContext,\n\t\t\tserver: McpServer,\n\t\t\toperation: () => Promise<string | undefined>,\n\t\t) => {\n\t\t\tconst ready = operation();\n\t\t\tconst attempt = server.attempt;\n\t\t\tconst { signal } = session;\n\t\t\tconst finish = (message: string | undefined) => {\n\t\t\t\tif (signal.aborted || server.attempt !== attempt || !servers.includes(server)) return;\n\t\t\t\tserver.message = message;\n\t\t\t\tensureDiscoveryActive(ctx);\n\t\t\t\temitChange();\n\t\t\t};\n\t\t\tvoid track(ready.then(finish, (error) => finish(errorMessage(error))));\n\t\t};\n\n\t\tconst runAction = async (ui: McpUi, ctx: ExtensionContext, server: McpServer, action: string) => {\n\t\t\tconst { signal } = session;\n\t\t\tlet message: string | undefined;\n\t\t\tswitch (action) {\n\t\t\t\tcase \"signin\":\n\t\t\t\t\tmessage = await signInWithUi(ui, server);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"reconnect\":\n\t\t\t\t\trunInBackground(ctx, server, async () => {\n\t\t\t\t\t\tawait reconnect(server);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"signout\":\n\t\t\t\t\tawait signOut(server);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tools\":\n\t\t\t\t\tawait showTools(ui, server);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"exposure\":\n\t\t\t\t\tmessage = await chooseExposure(ui, server);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"enable\":\n\t\t\t\tcase \"disable\":\n\t\t\t\tcase \"enable-project\":\n\t\t\t\tcase \"disable-project\": {\n\t\t\t\t\tconst enable = action.startsWith(\"enable\");\n\t\t\t\t\trunInBackground(ctx, server, () => setEnabled(server, enable, action.endsWith(\"-project\")));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The session ended meanwhile (for example during a sign-in), which made ctx stale.\n\t\t\tif (signal.aborted) return;\n\t\t\tserver.message = message;\n\t\t\tensureDiscoveryActive(ctx);\n\t\t\temitChange();\n\t\t};\n\t\tconst manage = async (ui: McpUi, ctx: ExtensionContext) => {\n\t\t\tfor (;;) {\n\t\t\t\tconst name = await ui.menu(serversMenu, subscribe);\n\t\t\t\tif (!name) return;\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst action = await ui.menu(() => serverMenu(name), subscribe);\n\t\t\t\t\tconst server = findServer(name);\n\t\t\t\t\tif (!action || !server) break;\n\t\t\t\t\tawait runAction(ui, ctx, server, action);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// ---------------------------------------------------------------------------------------\n\t\t// Subcommands and plain status (no TUI)\n\t\t// ---------------------------------------------------------------------------------------\n\n\t\tconst formatStatus = (): string => {\n\t\t\tif (servers.length === 0 && configErrors.length === 0 && overridden.length === 0) {\n\t\t\t\treturn `No MCP servers configured. Add them to ${resolve(getAgentDir(), \"mcp.json\")} or ${CONFIG_DIR_NAME}/mcp.json.`;\n\t\t\t}\n\t\t\tconst lines = servers.map((server) => {\n\t\t\t\tconst { name } = server.entry;\n\t\t\t\tconst exposure = exposureOf(server.entry);\n\t\t\t\tconst connection = server.connection;\n\t\t\t\tif (connection?.state === \"needs-auth\")\n\t\t\t\t\treturn `${name}: needs sign-in, run /mcp login ${name} (${exposure})`;\n\t\t\t\tconst tools = connection?.state === \"connected\" ? `, ${connection.tools.length} tools` : \"\";\n\t\t\t\tconst state = !isEnabled(server)\n\t\t\t\t\t? \"disabled\"\n\t\t\t\t\t: connection?.state === \"disconnected\"\n\t\t\t\t\t\t? \"disconnected, reconnects on next call\"\n\t\t\t\t\t\t: (connection?.state ?? \"starting\");\n\t\t\t\tconst error =\n\t\t\t\t\tconnection?.error && connection.state !== \"connected\"\n\t\t\t\t\t\t? `\\n ${connection.error.split(\"\\n\").join(\"\\n \")}`\n\t\t\t\t\t\t: \"\";\n\t\t\t\treturn `${name}: ${state}${tools} (${exposure})${error}`;\n\t\t\t});\n\t\t\tfor (const error of configErrors) lines.push(`config error: ${error}`);\n\t\t\tfor (const line of overridden) lines.push(`overridden: ${line}`);\n\t\t\treturn lines.join(\"\\n\");\n\t\t};\n\n\t\t/** Resolve the server for a subcommand, asking when the name is omitted and ambiguous. */\n\t\tconst pickServer = async (\n\t\t\tname: string | undefined,\n\t\t\tctx: ExtensionCommandContext,\n\t\t\toptions: { eligible: (server: McpServer) => boolean; preferred: (server: McpServer) => boolean; none: string },\n\t\t): Promise<McpServer | undefined> => {\n\t\t\tif (name) {\n\t\t\t\tconst server = findServer(name);\n\t\t\t\tif (!server) ctx.ui.notify(`No MCP server named \"${name}\".`, \"error\");\n\t\t\t\telse if (!options.eligible(server)) ctx.ui.notify(options.none, \"error\");\n\t\t\t\treturn server && options.eligible(server) ? server : undefined;\n\t\t\t}\n\t\t\tconst candidates = servers.filter(options.eligible);\n\t\t\tif (candidates.length === 0) {\n\t\t\t\tctx.ui.notify(options.none, \"info\");\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst preferred = candidates.filter(options.preferred);\n\t\t\tif (candidates.length === 1) return candidates[0];\n\t\t\tif (preferred.length === 1) return preferred[0];\n\t\t\tconst choice = await ctx.ui.select(\n\t\t\t\t\"MCP server\",\n\t\t\t\tcandidates.map((server) => server.entry.name),\n\t\t\t);\n\t\t\treturn candidates.find((server) => server.entry.name === choice);\n\t\t};\n\n\t\tconst usesOAuth = (server: McpServer) => server.connection?.oauthUrl !== undefined;\n\t\tconst oauthPick = {\n\t\t\teligible: usesOAuth,\n\t\t\tpreferred: (server: McpServer) => server.connection?.state === \"needs-auth\",\n\t\t\tnone: \"No enabled MCP server uses OAuth. Only HTTP servers without an Authorization header do.\",\n\t\t};\n\n\t\tconst loginCommand = async (server: McpServer, ctx: ExtensionCommandContext) => {\n\t\t\tconst { name } = server.entry;\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(`Signing in to MCP server \"${name}\" requires interactive mode.`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { signal } = session;\n\t\t\tlet failure: string | undefined;\n\t\t\tif (ctx.mode === \"tui\") {\n\t\t\t\tlet completed = false;\n\t\t\t\tawait showMcpManager(ctx, async (ui) => {\n\t\t\t\t\tfailure = await signInWithUi(ui, server);\n\t\t\t\t\tcompleted = true;\n\t\t\t\t});\n\t\t\t\tif (!completed) return;\n\t\t\t} else {\n\t\t\t\tfailure = await signIn(server, {\n\t\t\t\t\tshowAuthorizationUrl: (url) => {\n\t\t\t\t\t\tctx.ui.notify(`Sign in to MCP server \"${name}\" in your browser:\\n${url.href}`, \"info\");\n\t\t\t\t\t\topenUrl(url.href);\n\t\t\t\t\t},\n\t\t\t\t\tpromptForRedirectUrl: (signal) =>\n\t\t\t\t\t\tctx.ui.input(\n\t\t\t\t\t\t\t`Waiting for sign-in to \"${name}\". If the browser cannot reach this machine, paste the URL it was redirected to.`,\n\t\t\t\t\t\t\t\"http://127.0.0.1:.../callback?code=...\",\n\t\t\t\t\t\t\t{ signal },\n\t\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t}\n\t\t\t// The session ended meanwhile, which cancelled the sign-in and made ctx stale.\n\t\t\tif (signal.aborted) return;\n\t\t\tif (failure) {\n\t\t\t\tctx.ui.notify(failure, failure === \"Sign-in cancelled.\" ? \"info\" : \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tensureDiscoveryActive(ctx);\n\t\t\tctx.ui.notify(`Signed in to MCP server \"${name}\" (${server.connection?.tools.length ?? 0} tools).`, \"info\");\n\t\t};\n\n\t\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\t\tconst loaded = await (options.loadConfig ?? defaultLoadConfig)(ctx);\n\t\t\tlatestContext = ctx;\n\t\t\tsubagentMcpDirectTools = ctx.subagentPolicy?.mcpDirectTools;\n\t\t\tconfigErrors = loaded.errors;\n\t\t\tprojectConfig = loaded.projectConfig;\n\t\t\tautoEnableCodemode = (ctx.subagentPolicy ? false : loaded.autoEnableCodemode) ?? true;\n\t\t\twarnedUnreachable = false;\n\t\t\twaitedForStartup = false;\n\t\t\tsessionCwd = ctx.cwd;\n\t\t\tmodelRegistry = ctx.modelRegistry;\n\t\t\tsession = new AbortController();\n\t\t\tconst { signal } = session;\n\t\t\tconfiguredEntries = loaded.servers;\n\t\t\tconst registered = registeredServers();\n\t\t\toverridden = registered.overridden;\n\t\t\tservers = [...loaded.servers.map((entry) => ({ entry })), ...registered.servers];\n\t\t\trestoreRecordedTools(ctx);\n\t\t\temitChange();\n\t\t\t// Codemode or tool_search is activated from the config: the first prompt does not wait for\n\t\t\t// servers whose tools are not declared to the model, and scripts or searches wait for them.\n\t\t\tensureDiscoveryActive(ctx);\n\t\t\tconst enabled = servers.filter(isEnabled);\n\t\t\tif (enabled.length === 0) {\n\t\t\t\treportProblems(ctx);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The MCP client loads only now, so sessions without servers never pay for it. Waiting one\n\t\t\t// event loop turn lets the first render happen before loading and connecting.\n\t\t\tconst runtime = new Promise((resolve) => setImmediate(resolve)).then(() => loadMcpRuntime());\n\t\t\tpending = Promise.all(enabled.map((server) => startConnection(server, runtime)))\n\t\t\t\t.then(() => {\n\t\t\t\t\tif (!signal.aborted) reportProblems(ctx);\n\t\t\t\t})\n\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t// The session may have been disposed meanwhile, which makes ctx stale.\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.ui.notify(`MCP failed to load: ${errorMessage(error)}`, \"error\");\n\t\t\t\t\t} catch {}\n\t\t\t\t});\n\t\t});\n\n\t\t// The first prompt waits for servers whose tools are declared to the model, so they are declared\n\t\t// in its first request, but not indefinitely: a slow or hanging server must not hold up the\n\t\t// prompt. Other servers are waited for when a script or search needs them (below).\n\t\tconst waitForDirectServers = async (ctx: ExtensionContext) => {\n\t\t\tif (waitedForStartup) return;\n\t\t\twaitedForStartup = true;\n\t\t\tconst ready = servers.flatMap((server) =>\n\t\t\t\tisEnabled(server) &&\n\t\t\t\thasDirectTools(server.entry, subagentMcpDirectTools, latestContext?.subagentPolicy?.tools) &&\n\t\t\t\tserver.ready\n\t\t\t\t\t? [server.ready]\n\t\t\t\t\t: [],\n\t\t\t);\n\t\t\tif (ready.length === 0) return;\n\t\t\tlet timer: NodeJS.Timeout | undefined;\n\t\t\tconst finished = await Promise.race([\n\t\t\t\tPromise.all(ready).then(() => true),\n\t\t\t\tnew Promise<boolean>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => resolve(false), startupWaitMs);\n\t\t\t\t}),\n\t\t\t]);\n\t\t\tclearTimeout(timer);\n\t\t\tif (!finished) {\n\t\t\t\tctx.ui.notify(\"MCP servers are still connecting; their tools become available once connected.\", \"info\");\n\t\t\t}\n\t\t};\n\n\t\t// Every prompt lists the servers in the `mcp_servers` section as they are when it starts. Pi\n\t\t// appends the section to the conversation when it changed, for example after a server connected.\n\t\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\t\tawait waitForDirectServers(ctx);\n\t\t\tconst { sections } = event.systemPromptOptions;\n\t\t\tconst section = renderServersSection(servers);\n\t\t\tif (section) sections[MCP_SERVERS_SECTION] = section;\n\t\t\telse delete sections[MCP_SERVERS_SECTION];\n\t\t});\n\n\t\t// A codemode script waits for the servers it names, or for every server when it searches or\n\t\t// enumerates tools, so their tools are registered before the script runs. tool_search and the\n\t\t// resource tools reach every server, so they wait for all of them.\n\t\tpi.on(\"tool_call\", async (event, ctx) => {\n\t\t\tconst tool = pi.getAllTools().find((candidate) => candidate.name === event.toolName);\n\t\t\tif (!tool) return;\n\t\t\tconst readyServers = servers.filter((server) => isEnabled(server) && server.ready);\n\t\t\tif (readyServers.length === 0) return;\n\t\t\tlet waiting: McpServer[] = [];\n\t\t\tif (isCodemodeDiscoveryTool(tool)) {\n\t\t\t\tconst { code } = event.input as { code?: unknown };\n\t\t\t\tconst source = typeof code === \"string\" ? code : \"\";\n\t\t\t\twaiting = readyServers.filter((server) => scriptNeedsServer(source, server.entry.name));\n\t\t\t} else if (isToolSearchDiscoveryTool(tool) || RESOURCE_TOOL_NAMES.has(tool.name)) {\n\t\t\t\twaiting = readyServers;\n\t\t\t} else {\n\t\t\t\tconst owner = toolOwners.get(event.toolName)?.split(\"\\0\", 1)[0];\n\t\t\t\twaiting = readyServers.filter((server) => server.entry.name === owner);\n\t\t\t}\n\t\t\tawait waitForServers(waiting, ctx.signal);\n\t\t});\n\n\t\t// Keep track of the MCP tools the transcript declares, and record the ones whose listing was not recorded yet.\n\t\tpi.on(\"message_end\", async (event) => {\n\t\t\tconst { message } = event;\n\t\t\tif (message.role !== \"system\" || (!message.toolsAdded && !message.toolsRemoved)) return;\n\t\t\tfor (const tool of message.toolsRemoved ?? []) declaredNames.delete(tool.name);\n\t\t\tfor (const tool of message.toolsAdded ?? []) if (isRecordedToolName(tool.name)) declaredNames.add(tool.name);\n\t\t\t// Stored before the request that declares the tools is sent.\n\t\t\tawait recordDeclaredTools();\n\t\t});\n\n\t\t// Another branch declares other tools and carries other records.\n\t\tpi.on(\"session_tree\", (_event, ctx) => {\n\t\t\tconst branch = ctx.sessionManager.getBranch();\n\t\t\ttoolRecords = readToolRecords(branch);\n\t\t\tdeclaredNames = declaredMcpToolNames(branch);\n\t\t\tvoid recordDeclaredTools();\n\t\t});\n\n\t\t// Pick up sign-ins done outside the session, such as `pi mcp login` run by the agent.\n\t\tpi.on(\"turn_start\", async (_event, ctx) => {\n\t\t\tif (tokensAtSignIn.size > 0) await reconnectSignedIn(ctx);\n\t\t});\n\n\t\t// Servers registered or unregistered during the session connect or disconnect right away.\n\t\tpi.onMcpServerContributionsChanged?.(() => {\n\t\t\tconst { signal } = session;\n\t\t\tif (signal.aborted) return;\n\t\t\tconst registered = registeredServers();\n\t\t\toverridden = registered.overridden;\n\t\t\tconst next = new Map(registered.servers.map((server) => [server.entry.name, server]));\n\t\t\tconst removed = servers.filter(\n\t\t\t\t(server) =>\n\t\t\t\t\tserver.entry.scope === \"extension\" &&\n\t\t\t\t\tnext.get(server.entry.name)?.registeredConfig !== server.registeredConfig,\n\t\t\t);\n\t\t\tservers = servers.filter((server) => !removed.includes(server));\n\t\t\tfor (const server of removed) hideTools(server.entry.name);\n\t\t\tconst added = registered.servers.filter((server) => !findServer(server.entry.name));\n\t\t\tservers.push(...added);\n\t\t\temitChange();\n\t\t\tif (latestContext) ensureDiscoveryActive(latestContext);\n\t\t\tvoid Promise.all(removed.map((server) => server.connection?.close())).then(async () => {\n\t\t\t\tconst connecting = added.filter(isEnabled);\n\t\t\t\tif (signal.aborted || connecting.length === 0) return;\n\t\t\t\ttry {\n\t\t\t\t\tawait Promise.all(connecting.map((server) => startConnection(server)));\n\t\t\t\t\tif (!signal.aborted) reportProblems(latestContext!, connecting);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) latestContext?.ui.notify(`MCP failed to load: ${errorMessage(error)}`, \"error\");\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tpi.on(\"session_shutdown\", async () => {\n\t\t\tsession.abort();\n\t\t\tconst closing = connections();\n\t\t\t// The retiring registry is discarded. Do not register hidden tools or call a\n\t\t\t// captured UI here: reload has already revoked this generation's authority.\n\t\t\tlisteners.clear();\n\t\t\tserverTools.clear();\n\t\t\tdefinitions.clear();\n\t\t\ttoolOwners.clear();\n\t\t\tlistedTools.clear();\n\t\t\trecordedOnly.clear();\n\t\t\ttoolRecords = { tools: new Map(), resourceServers: undefined };\n\t\t\trecordingTools.clear();\n\t\t\trecordingResources = undefined;\n\t\t\tpendingResourceServers.clear();\n\t\t\tdeclaredNames = new Set();\n\t\t\ttokensAtSignIn.clear();\n\t\t\tresourceToolsExposure = undefined;\n\t\t\tservers = [];\n\t\t\tlatestContext = undefined;\n\t\t\tsubagentMcpDirectTools = undefined;\n\t\t\tawait Promise.all([...backgroundActions, ...closing.map((connection) => connection.close())]);\n\t\t\tawait serverLog?.flush();\n\t\t});\n\n\t\tpi.registerCommand(\"mcp\", {\n\t\t\tdescription: \"Manage MCP servers: sign in, reconnect, enable or disable, and change exposure\",\n\t\t\tgetArgumentCompletions: (prefix) => {\n\t\t\t\tconst [action, server, ...rest] = prefix.trimStart().split(/\\s+/);\n\t\t\t\tif (rest.length > 0) return null;\n\t\t\t\tif (server === undefined) {\n\t\t\t\t\treturn [\"login\", \"logout\", \"reconnect\"]\n\t\t\t\t\t\t.filter((item) => item.startsWith(action ?? \"\"))\n\t\t\t\t\t\t.map((item) => ({ value: `${item} `, label: item }));\n\t\t\t\t}\n\t\t\t\tif (action !== \"login\" && action !== \"logout\" && action !== \"reconnect\") return null;\n\t\t\t\tconst items = servers\n\t\t\t\t\t.filter((candidate) =>\n\t\t\t\t\t\taction === \"reconnect\" ? candidate.connection !== undefined : usesOAuth(candidate),\n\t\t\t\t\t)\n\t\t\t\t\t.filter((candidate) => candidate.entry.name.startsWith(server))\n\t\t\t\t\t.map((candidate) => ({\n\t\t\t\t\t\tvalue: `${action} ${candidate.entry.name}`,\n\t\t\t\t\t\tlabel: candidate.entry.name,\n\t\t\t\t\t\tdescription: describeState(candidate),\n\t\t\t\t\t}));\n\t\t\t\treturn items.length > 0 ? items : null;\n\t\t\t},\n\t\t\thandler: async (args, ctx) => {\n\t\t\t\tconst [action, name, ...extra] = args.trim().split(/\\s+/).filter(Boolean);\n\t\t\t\tif (action === undefined) {\n\t\t\t\t\tif (ctx.mode === \"tui\") await showMcpManager(ctx, (ui) => manage(ui, ctx));\n\t\t\t\t\telse {\n\t\t\t\t\t\tawait pending;\n\t\t\t\t\t\tctx.ui.notify(formatStatus(), \"info\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (extra.length > 0) {\n\t\t\t\t\tctx.ui.notify(MCP_USAGE, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait pending;\n\t\t\t\tswitch (action) {\n\t\t\t\t\tcase \"login\": {\n\t\t\t\t\t\tconst server = await pickServer(name, ctx, oauthPick);\n\t\t\t\t\t\tif (server) await loginCommand(server, ctx);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"logout\": {\n\t\t\t\t\t\tconst server = await pickServer(name, ctx, oauthPick);\n\t\t\t\t\t\tif (!server) return;\n\t\t\t\t\t\tconst removed = await signOut(server);\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\tremoved\n\t\t\t\t\t\t\t\t? `Signed out of MCP server \"${server.entry.name}\".`\n\t\t\t\t\t\t\t\t: `No stored credentials for MCP server \"${server.entry.name}\".`,\n\t\t\t\t\t\t\t\"info\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"reconnect\": {\n\t\t\t\t\t\tconst server = await pickServer(name, ctx, {\n\t\t\t\t\t\t\teligible: (candidate) => candidate.connection !== undefined,\n\t\t\t\t\t\t\tpreferred: (candidate) =>\n\t\t\t\t\t\t\t\tcandidate.connection?.state === \"failed\" || candidate.connection?.state === \"disconnected\",\n\t\t\t\t\t\t\tnone: \"No enabled MCP server to reconnect.\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!server) return;\n\t\t\t\t\t\tconst failure = await reconnect(server);\n\t\t\t\t\t\tif (failure) ctx.ui.notify(failure, \"error\");\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tensureDiscoveryActive(ctx);\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Reconnected to MCP server \"${server.entry.name}\" (${describeState(server)}).`,\n\t\t\t\t\t\t\t\t\"info\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tctx.ui.notify(MCP_USAGE, \"warning\");\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t};\n}\n\nfunction defaultLoadConfig(ctx: ExtensionContext): Promise<LoadedMcpConfig> {\n\treturn loadMcpConfigAsync({ agentDir: getAgentDir(), cwd: ctx.cwd, projectTrusted: ctx.isProjectTrusted() });\n}\n\nexport default createMcpExtension();\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAU/D,OAAO,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EACN,kBAAkB,EAElB,kBAAkB,EAIlB,mBAAmB,EACnB,0BAA0B,GAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,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and the servers extensions register with\n * `pi.registerMcpServer()` when a session starts, and servers registered later right away. A server\n * in `mcp.json` takes precedence over a registered server of the same name. Connections run in the\n * background: the first prompt waits only for servers with `direct` tools, and codemode scripts,\n * `tool_search`, and the resource tools wait for the servers they need when they run. Tools are\n * registered as `mcp__<server>__<tool>`. By default (`\"exposure\": \"codemode\"`) the tools are only\n * callable from codemode scripts, which keeps MCP tools out of the model's tool declarations and\n * the codemode description: scripts find the tools with `searchTools()` and the server instructions\n * with `describeNamespace()`. The codemode tool is activated for that unless `autoEnableCodemode` is\n * false or `-codemode` explicitly removed it. `\"deferred\"` declares the tools to the model once the `tool_search` tool loads them, and\n * activates `tool_search` instead of codemode.\n * `\"exposure\": \"direct\"` declares them to the model right away, and `\"hidden\"` makes them\n * unreachable. `toolExposure` overrides the exposure of single tools. Servers with resources are\n * reached through Codex's `list_mcp_resources`, `list_mcp_resource_templates`, and\n * `read_mcp_resource` tools (resources.ts).\n *\n * Every call runs through pi's tool pipeline, so `tool_call`/`tool_result` hooks and permission\n * extensions apply to MCP tools the same way they do to built-in tools.\n *\n * The session records each declared MCP tool's listing (tool-records.ts). A resumed session declares those tools\n * from their records while their servers reconnect, so its requests keep the tool list the provider cached; a call\n * waits for the server and runs only if the server lists the same tool again. It also records the summary the\n * `mcp_servers` section showed for each server, and shows it while the server reconnects.\n *\n * Problems found at startup (config errors, failed connections, servers that need a sign-in) are\n * reported once. `/mcp` opens a manager to sign in, reconnect, enable or disable servers, and change\n * their exposure; the last two are saved to the `mcp.json` that defines the server, or apply to the\n * current session for registered servers.\n */\n\nimport { join, resolve } from \"node:path\";\nimport type { SelectItem } from \"@bastani/atomic-tui\";\nimport type { TSchema } from \"typebox\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../../config.js\";\nimport type {\n\tBuildSystemPromptOptions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tToolDefinition,\n\tToolInfo,\n} from \"../../core/extensions/types.ts\";\nimport { markNativeMcpToolDefinition, matchesMcpDirectToolSelection } from \"../../core/mcp-child-policy.ts\";\nimport { mcpNamespace } from \"../../core/mcp-servers.ts\";\nimport type { ModelRegistry } from \"../../core/model-registry.ts\";\nimport { sliceHead } from \"../../core/tools/truncate.ts\";\nimport { openBrowser } from \"../../utils/open-browser.ts\";\nimport { CODEMODE_TOOL_NAME } from \"../codemode/tool.js\";\nimport { TOOL_SEARCH_TOOL_NAME } from \"../tool-search/tool.js\";\nimport type { Tool as McpTool } from \"./client/index.js\";\nimport {\n\tgetMcpToolExposure,\n\ttype LoadedMcpConfig,\n\tloadMcpConfigAsync,\n\ttype McpExposure,\n\ttype McpServerConfigPatch,\n\ttype McpServerEntry,\n\tmcpRequestTimeoutMs,\n\tupdateMcpServerConfigAsync,\n} from \"./config.ts\";\nimport type { McpOAuthCredentialStore, McpSignInPrompt } from \"./oauth.ts\";\nimport { createMcpResourceToolDefinitions } from \"./resources.js\";\nimport { loadMcpRuntime } from \"./runtime.lazy.ts\";\nimport type * as McpRuntime from \"./runtime.ts\";\nimport type { McpServerConnection, McpServerLog, McpTransportFactory } from \"./runtime.ts\";\nimport {\n\tdeclaredMcpToolNames,\n\tisRecordedToolName,\n\tMCP_TOOL_RECORD_ENTRY_TYPE,\n\ttype McpResourceServerRecord,\n\ttype McpServerIdentity,\n\ttype McpServerSummaryRecord,\n\ttype McpToolRecord,\n\ttype McpToolRecordData,\n\ttype McpToolRecords,\n\tRESOURCE_TOOL_NAMES,\n\treadToolRecords,\n\trecordableTool,\n\trecordMatchesServer,\n\tsameListedTool,\n\tsameToolRecord,\n\tserverIdentity,\n} from \"./tool-records.ts\";\nimport { createMcpToolDefinition, createMcpToolName, createMcpToolRenderers, type McpToolDetails } from \"./tools.ts\";\nimport { type McpMenu, type McpUi, showMcpManager } from \"./ui.ts\";\n\nfunction isCodemodeDiscoveryTool(tool: ToolInfo): boolean {\n\treturn tool.name === CODEMODE_TOOL_NAME && tool.sourceInfo.path === \"builtin:codemode\";\n}\n\nfunction isToolSearchDiscoveryTool(tool: ToolInfo): boolean {\n\treturn tool.name === TOOL_SEARCH_TOOL_NAME && tool.sourceInfo.path === \"builtin:tool-search\";\n}\n\nexport type { McpTransportFactory } from \"./runtime.ts\";\n\nexport interface McpExtensionOptions {\n\t/** Defaults to reading `mcp.json` from the agent directory and the trusted project. */\n\tloadConfig?: (ctx: ExtensionContext) => LoadedMcpConfig | Promise<LoadedMcpConfig>;\n\t/** Defaults to stdio and streamable HTTP transports built from the server config. */\n\tcreateTransport?: McpTransportFactory;\n\t/** Defaults to `mcp-auth.json` in the agent directory. */\n\tcredentials?: McpOAuthCredentialStore;\n\t/** File server log messages are appended to. Defaults to `mcp.log` in the agent directory. */\n\tlogPath?: string;\n\t/** Opens the OAuth authorization URL. Defaults to the platform browser. */\n\topenUrl?: (url: string) => void;\n\t/**\n\t * Saves `/mcp` changes to the server's config file: its project `override` when set, else its\n\t * `source`. Defaults to editing that `mcp.json`.\n\t */\n\tupdateConfig?: (entry: McpServerEntry, patch: McpServerConfigPatch) => void | Promise<void>;\n\t/**\n\t * How long the first prompt waits for servers with `direct` tools that are still connecting at\n\t * startup, in milliseconds. Their tools become available when they connect. Other servers are\n\t * waited for when a script or search needs them. Default: 10000.\n\t */\n\tstartupWaitMs?: number;\n}\n\nconst DEFAULT_STARTUP_WAIT_MS = 10_000;\n\n/** A configured server. Disabled servers have no connection. */\ninterface McpServer {\n\tentry: McpServerEntry;\n\tconnection?: McpServerConnection;\n\t/** For servers extensions registered: the config as registered, to detect re-registrations. */\n\tregisteredConfig?: string;\n\tattempt?: symbol;\n\t/** Result of the last `/mcp` action that failed, shown in the manager. */\n\tmessage?: string;\n\tclosing?: Promise<void>;\n\t/** Settles when the connection started for the server connected or failed. */\n\tready?: Promise<void>;\n}\n\nconst EXPOSURE_DESCRIPTIONS: Record<Exclude<McpExposure, \"hidden\">, string> = {\n\tcodemode: \"called from codemode scripts, which find them with searchTools()\",\n\tdeferred: \"not declared until tool_search loads them, then called directly; no codemode needed\",\n\tdirect: \"declared to the model like built-in tools\",\n};\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction firstLine(text: string): string {\n\treturn text.split(\"\\n\", 1)[0] ?? \"\";\n}\n\nfunction isEnabled(server: Pick<McpServer, \"entry\">): boolean {\n\treturn server.entry.config.enabled !== false;\n}\n\nfunction hasSelectedMcpServer(selections: readonly string[], name: string): boolean {\n\treturn selections.some((selection) => selection === name || selection.startsWith(`${name}/`));\n}\n\nfunction exposureOf(entry: McpServerEntry): McpExposure {\n\treturn entry.config.exposure ?? \"codemode\";\n}\n\n/** Exposures the server's tools can have, known from its config before it connects. */\nfunction configuredExposures(entry: McpServerEntry): Set<McpExposure> {\n\treturn new Set([exposureOf(entry), ...Object.values(entry.config.toolExposure ?? {})]);\n}\n\n/** Whether some of the server's tools are declared to the model, so the first prompt waits for them. */\nfunction hasDirectTools(entry: McpServerEntry, selections?: readonly string[], toolNames?: readonly string[]): boolean {\n\tconst namespacePrefix = `${mcpNamespace(entry.name)}__`;\n\treturn (\n\t\t(selections !== undefined && hasSelectedMcpServer(selections, entry.name)) ||\n\t\ttoolNames?.some((name) => name.startsWith(namespacePrefix)) === true ||\n\t\tconfiguredExposures(entry).has(\"direct\")\n\t);\n}\n\n/** Whether some of the server's tools are reached through codemode or tool_search. */\nfunction hasIndirectTools(entry: McpServerEntry): boolean {\n\tconst exposures = configuredExposures(entry);\n\treturn exposures.has(\"codemode\") || exposures.has(\"deferred\");\n}\n\n/** Name of the system prompt section that lists the servers whose tools are not declared. */\nexport const MCP_SERVERS_SECTION = \"mcp_servers\";\n/** Characters of a server description in the section, as Codex allows for deferred namespaces. */\nconst MAX_SERVER_DESCRIPTION_CHARS = 250;\n/**\n * Characters of the whole section. Descriptions shrink to fit; when the server lines alone do not\n * fit, the last servers are left out and counted in a closing line.\n */\nexport const MAX_SERVERS_SECTION_CHARS = 4096;\n\n/** The section's first line. It explains only the ways of reaching tools that the listed servers use. */\nfunction serversSectionIntro(reaches: ReadonlySet<string>): string {\n\tlet intro = \"MCP servers whose tools are not declared to you.\";\n\tif (reaches.has(\"codemode\")) intro += \" Call the tools of `codemode` servers from codemode scripts.\";\n\tif (reaches.has(\"tool_search\")) intro += \" Load the tools of `tool_search` servers with `tool_search`.\";\n\treturn intro;\n}\n\nfunction truncate(text: string, max: number): string {\n\tif (text.length <= max) return text;\n\treturn max <= 1 ? \"\" : `${sliceHead(text, max - 1).trimEnd()}…`;\n}\n\n/** What the `mcp_servers` section needs of a server. */\nexport interface McpServerListing {\n\tentry: McpServerEntry;\n\tconnection?: { instructions?: string };\n\t/** The summary the session recorded for the server, shown instead of its instructions while it reconnects. */\n\trecordedSummary?: string;\n\t/** The recorded summary is the ellipsis of a longer one, so with room for one character it shows none. */\n\trecordedSummaryCut?: boolean;\n}\n\n/** First line of the configured description, or of the server instructions once connected. */\nfunction serverSummary(server: McpServerListing): string {\n\tconst text = server.entry.config.description?.trim() || server.connection?.instructions || \"\";\n\treturn (text.split(\"\\n\", 1)[0] ?? \"\").trim();\n}\n\n/**\n * The summary a server's line shows with room for `room` characters: its configured description, else its recorded\n * summary while it reconnects (none with room for one character when the record is a cut summary's ellipsis), else\n * the first line of its instructions.\n */\nfunction shownSummary(server: McpServerListing, room: number): string {\n\tif (server.entry.config.description?.trim() || server.recordedSummary === undefined) {\n\t\treturn truncate(serverSummary(server), room);\n\t}\n\treturn room === 1 && server.recordedSummaryCut ? \"\" : truncate(server.recordedSummary, room);\n}\n\n/** A summary as a server's line shows it, whether it is only the ellipsis of a longer one, and the server shown. */\ninterface ShownSummary {\n\tsummary: string;\n\tcut: boolean;\n\tidentity: Required<McpServerIdentity>;\n}\n\n/** The section's text, and the summary it shows for each server whose line has room for one, as shown. */\ninterface ServersSection {\n\ttext: string;\n\tsummarized: { listing: McpServerListing; summary: string }[];\n}\n\n/**\n * The `mcp_servers` section: every enabled server with codemode or deferred tools, with how its\n * tools are reached and a one-line summary. The model learns of the servers from it, since neither\n * codemode nor tool_search lists them. Undefined when there are no such servers.\n */\nexport function renderServersSection(servers: readonly McpServerListing[]): string | undefined {\n\treturn layOutServersSection(servers)?.text;\n}\n\nfunction layOutServersSection(servers: readonly McpServerListing[]): ServersSection | undefined {\n\tconst listed = servers\n\t\t.filter((server) => isEnabled(server) && hasIndirectTools(server.entry))\n\t\t.sort((a, b) => a.entry.name.localeCompare(b.entry.name));\n\tif (listed.length === 0) return undefined;\n\tconst reaches = listed.map((server) =>\n\t\tconfiguredExposures(server.entry).has(\"codemode\") ? \"codemode\" : \"tool_search\",\n\t);\n\tconst intro = serversSectionIntro(new Set(reaches));\n\tconst heads = listed.map((server, index) => `- ${mcpNamespace(server.entry.name)} (${reaches[index]})`);\n\tconst omitted = (count: number) =>\n\t\tcount > 0 ? [`- … ${count} more server${count === 1 ? \"\" : \"s\"}; find their tools with searchTools()`] : [];\n\t// Characters of the intro, the first `kept` server lines without descriptions, and the omission line.\n\tconst size = (kept: number) => [intro, ...heads.slice(0, kept), ...omitted(listed.length - kept)].join(\"\\n\").length;\n\tlet kept = listed.length;\n\twhile (kept > 0 && size(kept) > MAX_SERVERS_SECTION_CHARS) kept--;\n\t// Each description also takes a \": \" separator.\n\tconst perServer =\n\t\tkept === 0\n\t\t\t? 0\n\t\t\t: Math.min(MAX_SERVER_DESCRIPTION_CHARS, Math.floor((MAX_SERVERS_SECTION_CHARS - size(kept)) / kept) - 2);\n\tconst summarized =\n\t\tperServer > 0\n\t\t\t? listed.slice(0, kept).map((listing) => ({ listing, summary: shownSummary(listing, perServer) }))\n\t\t\t: [];\n\tconst lines = listed\n\t\t.slice(0, kept)\n\t\t.map((_, index) => (summarized[index]?.summary ? `${heads[index]}: ${summarized[index].summary}` : heads[index]));\n\treturn { text: [intro, ...lines, ...omitted(listed.length - kept)].join(\"\\n\"), summarized };\n}\n\n/**\n * Whether a codemode script needs the server: it names the server's namespace, or searches,\n * enumerates, or describes tools or namespaces, which may name the server in other forms.\n */\nfunction scriptNeedsServer(code: string, server: string): boolean {\n\tif (/\\b(searchTools|describeNamespace|describeTool|ALL_TOOLS)\\b/.test(code)) return true;\n\treturn code.includes(mcpNamespace(server));\n}\n\n/** Short state for lists and the startup report. `withError` appends the first line of a failure. */\nfunction describeState(server: McpServer, withError = true): string {\n\tif (!isEnabled(server)) return \"disabled\";\n\tconst connection = server.connection;\n\tif (!connection) return \"starting\";\n\tswitch (connection.state) {\n\t\tcase \"needs-auth\":\n\t\t\treturn \"needs sign-in\";\n\t\tcase \"failed\":\n\t\t\treturn withError ? `failed: ${firstLine(connection.error ?? \"unknown error\")}` : \"failed\";\n\t\tcase \"connected\": {\n\t\t\tconst { tools, hasResources } = connection;\n\t\t\treturn `connected · ${tools.length} tool${tools.length === 1 ? \"\" : \"s\"}${hasResources ? \" · resources\" : \"\"}`;\n\t\t}\n\t\tcase \"connecting\":\n\t\t\treturn \"connecting…\";\n\t\tdefault:\n\t\t\treturn connection.state;\n\t}\n}\n\n/** Servers that need the user first. */\nfunction attentionRank(server: McpServer): number {\n\tif (!isEnabled(server)) return 5;\n\tswitch (server.connection?.state) {\n\t\tcase \"needs-auth\":\n\t\t\treturn 0;\n\t\tcase \"failed\":\n\t\t\treturn 1;\n\t\tcase \"disconnected\":\n\t\t\treturn 2;\n\t\tcase \"connected\":\n\t\t\treturn 4;\n\t\tdefault:\n\t\t\treturn 3;\n\t}\n}\n\nfunction describeTransport(entry: McpServerEntry): string {\n\tconst { config } = entry;\n\tif (\"url\" in config) return config.url;\n\treturn [config.command, ...(config.args ?? [])].join(\" \");\n}\n\nconst MCP_USAGE = \"Usage: /mcp, /mcp login [server], /mcp logout [server], /mcp reconnect [server]\";\n\nexport function createMcpExtension(options: McpExtensionOptions = {}): ExtensionFactory {\n\treturn (pi: ExtensionAPI) => {\n\t\tlet servers: McpServer[] = [];\n\t\t/** Servers from `mcp.json`, which take precedence over registered servers of the same name. */\n\t\tlet configuredEntries: McpServerEntry[] = [];\n\t\tlet configErrors: string[] = [];\n\t\t/** The trusted project's `mcp.json`, where `/mcp` saves project overrides of global servers. */\n\t\tlet projectConfig: string | undefined;\n\t\t/** Registered servers that `mcp.json` overrides, shown in `/mcp`. */\n\t\tlet overridden: string[] = [];\n\t\tlet latestContext: ExtensionContext | undefined;\n\t\tlet subagentMcpDirectTools: readonly string[] | undefined;\n\t\tlet autoEnableCodemode = true;\n\t\t/** Whether the \"codemode tools unreachable\" warning was shown since the session started. */\n\t\tlet warnedUnreachable = false;\n\t\tlet pending: Promise<unknown> | undefined;\n\t\t/** Whether a prompt already waited for the startup connections since the session started. */\n\t\tlet waitedForStartup = false;\n\t\tconst startupWaitMs = options.startupWaitMs ?? DEFAULT_STARTUP_WAIT_MS;\n\t\t/** Working directory of the session, for stdio servers. */\n\t\tlet sessionCwd = process.cwd();\n\t\tlet credentials = options.credentials;\n\t\t/** The session's model registry, which resolves `auth.provider` tokens. */\n\t\tlet modelRegistry: ModelRegistry | undefined;\n\t\tlet serverLog: McpServerLog | undefined;\n\t\tconst openUrl = options.openUrl ?? openBrowser;\n\t\tconst updateConfig =\n\t\t\toptions.updateConfig ??\n\t\t\t((entry, patch) =>\n\t\t\t\tupdateMcpServerConfigAsync(entry.override ?? entry.source, entry.name, patch, {\n\t\t\t\t\toverride: entry.override !== undefined,\n\t\t\t\t}));\n\n\t\t/**\n\t\t * Lifetime of the current session: aborted on session_shutdown, and before the first session_start\n\t\t * (registrations before that are read on session_start). Work captures `session.signal` when it\n\t\t * starts and drops late results once it aborted, for example a runtime load that resolves after\n\t\t * shutdown. Work that outlives the command that started it also stops on the signal and is\n\t\t * registered with `track`, so shutdown can wait for its cleanup.\n\t\t */\n\t\tlet session = new AbortController();\n\t\tsession.abort();\n\t\t/** Work registered with `track`: manager actions opening or closing connections, and sign-ins. */\n\t\tconst backgroundActions = new Set<Promise<void>>();\n\t\tconst track = <T>(work: Promise<T>): Promise<T> => {\n\t\t\tconst task = work.then(\n\t\t\t\t() => undefined,\n\t\t\t\t() => undefined,\n\t\t\t);\n\t\t\tbackgroundActions.add(task);\n\t\t\tvoid task.finally(() => backgroundActions.delete(task));\n\t\t\treturn work;\n\t\t};\n\t\tconst listeners = new Set<() => void>();\n\t\tconst emitChange = () => {\n\t\t\tfor (const listener of listeners) listener();\n\t\t};\n\t\tconst subscribe = (listener: () => void) => {\n\t\t\tlisteners.add(listener);\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t};\n\t\t};\n\n\t\tconst connections = () => servers.flatMap((server) => (server.connection ? [server.connection] : []));\n\t\tconst findServer = (name: string) => servers.find((server) => server.entry.name === name);\n\n\t\t/** Servers extensions registered, except names `mcp.json` defines, which take precedence. */\n\t\tconst registeredServers = (): { servers: McpServer[]; overridden: string[] } => {\n\t\t\tconst registered: McpServer[] = [];\n\t\t\tconst overriddenNames: string[] = [];\n\t\t\tconst namespaceOwners = new Map<string, { name: string; origin: string }>();\n\t\t\tfor (const contribution of pi.getMcpServerContributions?.() ?? []) {\n\t\t\t\tconst { name, config, sourceInfo } = contribution;\n\t\t\t\tconst source = sourceInfo.path;\n\t\t\t\tconst hasProviderAuth =\n\t\t\t\t\t\"url\" in config && typeof config.auth === \"object\" && config.auth !== null && \"provider\" in config.auth;\n\t\t\t\tif (hasProviderAuth && (contribution.origin === \"package\" || sourceInfo.origin === \"package\")) {\n\t\t\t\t\tconfigErrors.push(\n\t\t\t\t\t\t`${source}: server \"${name}\": auth.provider is only allowed for explicit extension registrations`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst configured = configuredEntries.find((entry) => mcpNamespace(entry.name) === mcpNamespace(name));\n\t\t\t\tif (configured) {\n\t\t\t\t\toverriddenNames.push(\n\t\t\t\t\t\t`\"${name}\" registered by ${source} is overridden by \"${configured.name}\" in ${configured.source}`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst namespace = mcpNamespace(name);\n\t\t\t\tconst owner = namespaceOwners.get(namespace);\n\t\t\t\tif (owner) {\n\t\t\t\t\toverriddenNames.push(\n\t\t\t\t\t\t`\"${name}\" from ${contribution.origin} is ignored because its MCP namespace conflicts with \"${owner.name}\" from ${owner.origin}`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tnamespaceOwners.set(namespace, { name, origin: contribution.origin });\n\t\t\t\tregistered.push({\n\t\t\t\t\tentry: { name, config, source, scope: \"extension\" },\n\t\t\t\t\tregisteredConfig: JSON.stringify(config),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn { servers: registered, overridden: overriddenNames };\n\t\t};\n\n\t\tconst getCredentials = (runtime: typeof McpRuntime): McpOAuthCredentialStore => {\n\t\t\tcredentials ??= new runtime.McpOAuthCredentialStore();\n\t\t\treturn credentials;\n\t\t};\n\n\t\tconst getServerLog = (runtime: typeof McpRuntime): McpServerLog => {\n\t\t\tserverLog ??= new runtime.McpServerLog(options.logPath ?? join(getAgentDir(), \"mcp.log\"));\n\t\t\treturn serverLog;\n\t\t};\n\n\t\t/** pi tool name to the `<server>\\0<tool>` it was assigned to, so names stay unique and stable. */\n\t\tconst toolOwners = new Map<string, string>();\n\t\t/** Tool names currently offered by each server. */\n\t\tconst serverTools = new Map<string, Set<string>>();\n\t\t/** Last definition registered under each tool name, to re-register withdrawn tools as hidden. */\n\t\tconst definitions = new Map<string, ToolDefinition<TSchema, McpToolDetails>>();\n\t\t/** Each registered tool name's server and that server's latest listing of the tool. */\n\t\tconst listedTools = new Map<string, { server: string; tool: McpTool }>();\n\t\t/**\n\t\t * Tool names registered from the session's records (see tool-records.ts) that their server has not listed\n\t\t * since the session started. They stay declared while the server connects; calls wait for it.\n\t\t */\n\t\tconst recordedOnly = new Set<string>();\n\t\t/** The latest records on the session's branch. */\n\t\tlet toolRecords: McpToolRecords = { tools: new Map(), resourceServers: undefined, summaries: new Map() };\n\t\t/** Tool records being appended, by name, and the resource servers being appended, as JSON. */\n\t\tconst recordingTools = new Map<string, McpToolRecord>();\n\t\tlet recordingResources: string | undefined;\n\t\t/** MCP tool and resource tool names the session's transcript declares to the model now. */\n\t\tlet declaredNames = new Set<string>();\n\t\t/**\n\t\t * Servers that had resources when the session declared the resource tools and have not finished connecting\n\t\t * since it started. The resource tools stay declared for them meanwhile.\n\t\t */\n\t\tconst pendingResourceServers = new Set<string>();\n\t\t/**\n\t\t * Servers whose recorded summary the `mcp_servers` section shows: their record matched them when the session\n\t\t * started (see recordMatchesServer), and their connection attempt has not settled since.\n\t\t */\n\t\tconst pendingSummaries = new Set<string>();\n\t\t/**\n\t\t * The `mcp_servers` section of the prompt being started and the options it was set in, with the summary its\n\t\t * line shows from each server's instructions, and the servers whose line shows their recorded summary.\n\t\t */\n\t\tlet promptSection:\n\t\t\t| {\n\t\t\t\t\toptions: BuildSystemPromptOptions;\n\t\t\t\t\ttext: string | undefined;\n\t\t\t\t\tshown: Map<string, ShownSummary>;\n\t\t\t\t\tkept: Set<string>;\n\t\t\t }\n\t\t\t| undefined;\n\n\t\t// Render resumed MCP calls even when their server has not connected or never connects.\n\t\tpi.registerToolRenderer((toolName, next) => {\n\t\t\tconst registered = next();\n\t\t\tif (registered) return registered;\n\t\t\tif (!toolName.startsWith(\"mcp__\")) return undefined;\n\t\t\tconst owner = toolOwners.get(toolName);\n\t\t\tif (owner) return createMcpToolRenderers(owner.replace(\"\\0\", \"/\"));\n\t\t\tconst encoded = toolName.slice(\"mcp__\".length);\n\t\t\tconst boundary = encoded.indexOf(\"__\");\n\t\t\tconst unambiguous =\n\t\t\t\tboundary > 0 &&\n\t\t\t\tboundary + 2 < encoded.length &&\n\t\t\t\tboundary === encoded.lastIndexOf(\"__\") &&\n\t\t\t\t!/_[a-f0-9]{8}(?:_\\d+)?$/.test(toolName);\n\t\t\tconst label = unambiguous ? `${encoded.slice(0, boundary)}/${encoded.slice(boundary + 2)}` : toolName;\n\t\t\treturn createMcpToolRenderers(label);\n\t\t});\n\n\t\t/** Exposure of one of a server's tools, from its config and the subagent policy. */\n\t\tconst exposureFor = (entry: McpServerEntry, tool: string, name: string): McpExposure => {\n\t\t\tconst server = entry.name;\n\t\t\tconst configuredExposure = getMcpToolExposure(entry.config, tool);\n\t\t\tconst selected =\n\t\t\t\t(subagentMcpDirectTools !== undefined &&\n\t\t\t\t\tmatchesMcpDirectToolSelection(subagentMcpDirectTools, server, tool)) ||\n\t\t\t\t(latestContext?.subagentPolicy?.tools?.includes(name) ?? false);\n\t\t\treturn selected && configuredExposure !== \"hidden\" && exposureOf(entry) !== \"hidden\"\n\t\t\t\t? \"direct\"\n\t\t\t\t: subagentMcpDirectTools === undefined && !latestContext?.subagentPolicy?.tools\n\t\t\t\t\t? configuredExposure\n\t\t\t\t\t: \"hidden\";\n\t\t};\n\n\t\t/**\n\t\t * The definition of a server's tool. `recorded` marks a definition built from the session's record before the\n\t\t * server listed the tool: a call to it runs only once the server lists the same tool under the same name.\n\t\t */\n\t\tconst defineTool = (\n\t\t\tentry: McpServerEntry,\n\t\t\ttool: McpTool,\n\t\t\tname: string,\n\t\t\tinstructions: string | undefined,\n\t\t\trecorded?: McpTool,\n\t\t): ToolDefinition<TSchema, McpToolDetails> => {\n\t\t\tconst server = entry.name;\n\t\t\tconst description = entry.config.description?.trim();\n\t\t\tconst definition = createMcpToolDefinition({\n\t\t\t\tserver,\n\t\t\t\ttool,\n\t\t\t\tname,\n\t\t\t\texposure: exposureFor(entry, tool.name, name),\n\t\t\t\tnamespace: {\n\t\t\t\t\tname: mcpNamespace(server),\n\t\t\t\t\t...(description ? { description } : {}),\n\t\t\t\t\t...(instructions ? { instructions } : {}),\n\t\t\t\t},\n\t\t\t\ttimeoutMs: mcpRequestTimeoutMs(entry.config),\n\t\t\t\tgetClient: async () => {\n\t\t\t\t\tconst current = findServer(server);\n\t\t\t\t\tif (!current || !isEnabled(current)) throw new Error(`MCP server \"${server}\" is disabled.`);\n\t\t\t\t\tconst client = current.connection;\n\t\t\t\t\tif (!client) throw new Error(`MCP server \"${server}\" is still starting.`);\n\t\t\t\t\tif (recorded) {\n\t\t\t\t\t\t// The call waited for the server's connection attempt (tool_call below). Run it only against the\n\t\t\t\t\t\t// tool the session declared: the server must list it again, unchanged, under this name.\n\t\t\t\t\t\tconst listed = listedTools.get(name);\n\t\t\t\t\t\tif (!listed || listed.server !== server) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\tclient.state === \"connected\" || client.state === \"disconnected\"\n\t\t\t\t\t\t\t\t\t? `MCP tool \"${server}/${tool.name}\" is no longer available.`\n\t\t\t\t\t\t\t\t\t: `MCP server \"${server}\" did not reconnect (${describeState(current, false)}), so its tool \"${tool.name}\" is not available.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!sameListedTool(listed.tool, recorded)) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`MCP tool \"${server}/${tool.name}\" changed since this session declared it, so the call did not run. Its new definition is declared with the next request.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tgetMcpToolExposure(current.entry.config, tool.name) === \"hidden\" ||\n\t\t\t\t\t\t(client.state === \"connected\" && !client.tools.some((offered) => offered.name === tool.name))\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new Error(`MCP tool \"${server}/${tool.name}\" is no longer available.`);\n\t\t\t\t\t}\n\t\t\t\t\treturn client;\n\t\t\t\t},\n\t\t\t\treadableResources: () => resourceServers().some((current) => current.name === server),\n\t\t\t});\n\t\t\tmarkNativeMcpToolDefinition(definition, { server, tool: tool.name });\n\t\t\treturn definition;\n\t\t};\n\n\t\t/** Re-register a tool as hidden, which takes it out of the declared tools. */\n\t\tconst withdrawTool = (name: string) => {\n\t\t\tconst definition = definitions.get(name);\n\t\t\tif (definition) pi.registerTool({ ...definition, exposure: \"hidden\" });\n\t\t\tlistedTools.delete(name);\n\t\t\trecordedOnly.delete(name);\n\t\t};\n\n\t\tconst registerTools = (connection: McpServerConnection) => {\n\t\t\tif (!servers.some((candidate) => candidate.connection === connection)) return;\n\t\t\tconst server = connection.entry.name;\n\t\t\tconst entry = findServer(server)?.entry ?? connection.entry;\n\t\t\tconst previous = serverTools.get(server) ?? new Set<string>();\n\t\t\tconst current = new Set<string>();\n\t\t\t// The connection's instructions replace the recorded summary.\n\t\t\tpendingSummaries.delete(server);\n\t\t\t// Like Codex, all tools whose names sanitize to the same name get the hash suffix, so which\n\t\t\t// one would keep the plain name does not depend on the order of the list.\n\t\t\tconst plain = [...new Set(connection.tools.map((tool) => tool.name))].map((tool) =>\n\t\t\t\tcreateMcpToolName(server, tool),\n\t\t\t);\n\t\t\tconst assignName = (tool: string, owner: string) => {\n\t\t\t\tconst name = createMcpToolName(server, tool, (candidate) => {\n\t\t\t\t\tconst existing = toolOwners.get(candidate);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(existing !== undefined && existing !== owner) ||\n\t\t\t\t\t\tcurrent.has(candidate) ||\n\t\t\t\t\t\tplain.indexOf(candidate) !== plain.lastIndexOf(candidate)\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\ttoolOwners.set(name, owner);\n\t\t\t\tcurrent.add(name);\n\t\t\t\treturn name;\n\t\t\t};\n\t\t\t// Register in the order of the tool names, not the server's listing, so the order the tools are declared\n\t\t\t// in does not depend on how the server happens to list them.\n\t\t\tconst listing = [...connection.tools].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\t\t\tfor (const tool of listing) {\n\t\t\t\tconst name = assignName(tool.name, `${server}\\0${tool.name}`);\n\t\t\t\tconst definition = defineTool(entry, tool, name, connection.instructions);\n\t\t\t\tdefinitions.set(definition.name, definition);\n\t\t\t\tlistedTools.set(name, { server, tool });\n\t\t\t\trecordedOnly.delete(name);\n\t\t\t\tpi.registerTool(definition);\n\t\t\t}\n\t\t\tserverTools.set(server, current);\n\t\t\t// Tools cannot be unregistered, so tools the server dropped are re-registered as hidden. When\n\t\t\t// the server offers them again they are registered with their configured exposure above.\n\t\t\tfor (const name of previous) if (!current.has(name)) withdrawTool(name);\n\t\t\tsyncResourceTools();\n\t\t\tvoid recordDeclaredTools();\n\t\t};\n\n\t\t/** Make a disabled server's tools unreachable. */\n\t\tconst hideTools = (server: string) => {\n\t\t\tpendingSummaries.delete(server);\n\t\t\tfor (const name of serverTools.get(server) ?? []) withdrawTool(name);\n\t\t\tserverTools.set(server, new Set());\n\t\t\tsyncResourceTools();\n\t\t};\n\n\t\t/**\n\t\t * Record the server's listing of each MCP tool the transcript declares, when it changed since the last record\n\t\t * on the branch, so a resumed session can keep declaring the tool while the server reconnects.\n\t\t */\n\t\tconst recordDeclaredTools = async (): Promise<void> => {\n\t\t\tconst records = toolRecords;\n\t\t\tconst tools: McpToolRecord[] = [];\n\t\t\tfor (const name of [...declaredNames].sort()) {\n\t\t\t\tconst listed = listedTools.get(name);\n\t\t\t\tconst entry = listed && findServer(listed.server)?.entry;\n\t\t\t\tif (!listed || !entry || recordedOnly.has(name)) continue;\n\t\t\t\tconst record: McpToolRecord = {\n\t\t\t\t\tname,\n\t\t\t\t\tserver: listed.server,\n\t\t\t\t\t...serverIdentity(entry),\n\t\t\t\t\ttool: recordableTool(listed.tool),\n\t\t\t\t};\n\t\t\t\tconst known = [records.tools.get(name), recordingTools.get(name)];\n\t\t\t\tif (known.some((previous) => previous && sameToolRecord(previous, record))) continue;\n\t\t\t\trecordingTools.set(name, record);\n\t\t\t\ttools.push(record);\n\t\t\t}\n\t\t\tlet resourceServers: McpResourceServerRecord[] | undefined;\n\t\t\tif (pendingResourceServers.size === 0 && [...RESOURCE_TOOL_NAMES].some((name) => declaredNames.has(name))) {\n\t\t\t\tconst current = serversWithResources()\n\t\t\t\t\t.map((server) => ({ server: server.entry.name, ...serverIdentity(server.entry) }))\n\t\t\t\t\t.sort((a, b) => (a.server < b.server ? -1 : a.server > b.server ? 1 : 0));\n\t\t\t\tconst json = JSON.stringify(current);\n\t\t\t\tconst known = [JSON.stringify(records.resourceServers), recordingResources];\n\t\t\t\tif (current.length > 0 && !known.includes(json)) {\n\t\t\t\t\trecordingResources = json;\n\t\t\t\t\tresourceServers = current;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (tools.length === 0 && !resourceServers) return;\n\t\t\tconst settled = () => {\n\t\t\t\tfor (const record of tools)\n\t\t\t\t\tif (recordingTools.get(record.name) === record) recordingTools.delete(record.name);\n\t\t\t\tif (resourceServers && recordingResources === JSON.stringify(resourceServers))\n\t\t\t\t\trecordingResources = undefined;\n\t\t\t};\n\t\t\t// The records count once they are stored; a failed write is tried again with the next change.\n\t\t\ttry {\n\t\t\t\tawait pi.appendEntry<McpToolRecordData>(MCP_TOOL_RECORD_ENTRY_TYPE, {\n\t\t\t\t\ttools,\n\t\t\t\t\t...(resourceServers ? { resourceServers } : {}),\n\t\t\t\t});\n\t\t\t\tif (toolRecords === records) {\n\t\t\t\t\tfor (const record of tools) records.tools.set(record.name, record);\n\t\t\t\t\tif (resourceServers) records.resourceServers = resourceServers;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Without the record, a later resume treats these tools as before: removed until their server connects.\n\t\t\t} finally {\n\t\t\t\tsettled();\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * On session start, register the tools the transcript declares from their records, for servers that are still\n\t\t * configured with the same URL or command, so the first requests keep declaring them while the servers\n\t\t * connect. A server that connects lists its tools again and they replace these definitions; the ones of a\n\t\t * server that does not connect are withdrawn once its attempt settles.\n\t\t */\n\t\tconst restoreRecordedTools = (ctx: ExtensionContext) => {\n\t\t\tconst branch = ctx.sessionManager.getBranch();\n\t\t\ttoolRecords = readToolRecords(branch);\n\t\t\tdeclaredNames = declaredMcpToolNames(branch);\n\t\t\t// Recorded names stay their servers', as in the session that recorded them: a server that connects first\n\t\t\t// cannot take another server's name, and a call to a declared tool waits for its server. A name a tool had\n\t\t\t// before it was declared under another one is left free.\n\t\t\tconst owner = (record: McpToolRecord) => `${record.server}\\0${record.tool.name}`;\n\t\t\tconst declaredOwners = new Set<string>();\n\t\t\tfor (const name of declaredNames) {\n\t\t\t\tconst record = toolRecords.tools.get(name);\n\t\t\t\tif (!record) continue;\n\t\t\t\ttoolOwners.set(name, owner(record));\n\t\t\t\tdeclaredOwners.add(owner(record));\n\t\t\t}\n\t\t\tfor (const record of toolRecords.tools.values()) {\n\t\t\t\tif (!toolOwners.has(record.name) && !declaredOwners.has(owner(record))) {\n\t\t\t\t\ttoolOwners.set(record.name, owner(record));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const name of declaredNames) {\n\t\t\t\tconst record = toolRecords.tools.get(name);\n\t\t\t\tif (!record) continue;\n\t\t\t\tconst server = findServer(record.server);\n\t\t\t\tif (!server || !isEnabled(server) || !recordMatchesServer(server.entry, record)) continue;\n\t\t\t\tif (exposureFor(server.entry, record.tool.name, name) === \"hidden\") continue;\n\t\t\t\tconst definition = defineTool(server.entry, record.tool, name, undefined, record.tool);\n\t\t\t\tdefinitions.set(name, definition);\n\t\t\t\trecordedOnly.add(name);\n\t\t\t\tconst names = serverTools.get(record.server) ?? new Set<string>();\n\t\t\t\tnames.add(name);\n\t\t\t\tserverTools.set(record.server, names);\n\t\t\t\tpi.registerTool(definition);\n\t\t\t}\n\t\t\t// The resource tools stay declared while a server that had resources reconnects.\n\t\t\tif ([...RESOURCE_TOOL_NAMES].some((name) => declaredNames.has(name))) {\n\t\t\t\tfor (const record of toolRecords.resourceServers ?? []) {\n\t\t\t\t\tconst server = findServer(record.server);\n\t\t\t\t\tif (server && isEnabled(server) && recordMatchesServer(server.entry, record)) {\n\t\t\t\t\t\tpendingResourceServers.add(record.server);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsyncResourceTools();\n\t\t\t}\n\t\t\t// The `mcp_servers` section shows a server's recorded summary while the server reconnects.\n\t\t\tfor (const record of toolRecords.summaries.values()) {\n\t\t\t\tconst server = findServer(record.server);\n\t\t\t\tif (server && isEnabled(server) && recordMatchesServer(server.entry, record))\n\t\t\t\t\tpendingSummaries.add(record.server);\n\t\t\t}\n\t\t};\n\n\t\t/** The summary record of a server whose connection attempt has not settled since the session started. */\n\t\tconst pendingSummary = (server: McpServer): McpServerSummaryRecord | undefined => {\n\t\t\tconst record = pendingSummaries.has(server.entry.name)\n\t\t\t\t? toolRecords.summaries.get(server.entry.name)\n\t\t\t\t: undefined;\n\t\t\treturn record && recordMatchesServer(server.entry, record) ? record : undefined;\n\t\t};\n\n\t\t/**\n\t\t * The records that make the branch's summary records say what the conversation shows of each server once the\n\t\t * prompt was sent: the summary its line shows from the server's instructions, or none (for a server with a\n\t\t * configured description, no room for a summary, no line, or no longer configured). A missing record counts as\n\t\t * no summary, and a line that shows a server's recorded summary keeps its record.\n\t\t */\n\t\tconst summaryUpdates = (\n\t\t\tshown: ReadonlyMap<string, ShownSummary>,\n\t\t\tkept: ReadonlySet<string>,\n\t\t): McpServerSummaryRecord[] => {\n\t\t\tconst updates: McpServerSummaryRecord[] = [];\n\t\t\tfor (const name of new Set([...shown.keys(), ...toolRecords.summaries.keys()])) {\n\t\t\t\tif (kept.has(name)) continue;\n\t\t\t\tconst line = shown.get(name);\n\t\t\t\tconst record = toolRecords.summaries.get(name);\n\t\t\t\tif (line?.summary) {\n\t\t\t\t\t// Recorded for the server the line was rendered for, which may have been replaced since.\n\t\t\t\t\tconst { summary, cut, identity } = line;\n\t\t\t\t\tif (\n\t\t\t\t\t\t!record ||\n\t\t\t\t\t\trecord.summary !== summary ||\n\t\t\t\t\t\t(record.cut ?? false) !== cut ||\n\t\t\t\t\t\trecord.transport !== identity.transport ||\n\t\t\t\t\t\trecord.scope !== identity.scope\n\t\t\t\t\t) {\n\t\t\t\t\t\tupdates.push({ server: name, ...identity, summary, ...(cut ? { cut: true as const } : {}) });\n\t\t\t\t\t}\n\t\t\t\t} else if (record?.summary) {\n\t\t\t\t\tupdates.push({ server: name, transport: record.transport, scope: record.scope ?? null, summary: \"\" });\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn updates;\n\t\t};\n\n\t\t/** Append summary records; a failed write is tried again with the next prompt, which finds them changed still. */\n\t\tconst recordSummaries = async (summaries: McpServerSummaryRecord[]): Promise<void> => {\n\t\t\tconst records = toolRecords;\n\t\t\ttry {\n\t\t\t\tawait pi.appendEntry<McpToolRecordData>(MCP_TOOL_RECORD_ENTRY_TYPE, { tools: [], summaries });\n\t\t\t\tif (toolRecords === records) {\n\t\t\t\t\tfor (const record of summaries) {\n\t\t\t\t\t\tif (record.summary) records.summaries.set(record.server, record);\n\t\t\t\t\t\telse records.summaries.delete(record.server);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Without the record, a later resume shows the server without a summary until it connects, as before.\n\t\t\t}\n\t\t};\n\n\t\t/** Withdraw the recorded tools of a server whose connection attempt settled without listing them. */\n\t\tconst withdrawUnlistedRecords = (server: string) => {\n\t\t\tfor (const name of serverTools.get(server) ?? []) {\n\t\t\t\tif (!recordedOnly.has(name)) continue;\n\t\t\t\twithdrawTool(name);\n\t\t\t\tserverTools.get(server)?.delete(name);\n\t\t\t}\n\t\t};\n\n\t\t/** Enabled servers with resources whose exposure is not `hidden`, which the resource tools reach. */\n\t\tconst serversWithResources = (): McpServer[] =>\n\t\t\tservers.filter(\n\t\t\t\t(server) => server.connection?.hasResources && isEnabled(server) && exposureOf(server.entry) !== \"hidden\",\n\t\t\t);\n\t\tconst resourceServers = (): McpServerConnection[] =>\n\t\t\tserversWithResources().flatMap((server) => (server.connection ? [server.connection] : []));\n\n\t\t/** Exposure the resource tools were last registered with; undefined until a server has resources. */\n\t\tlet resourceToolsExposure: McpExposure | undefined;\n\t\t/**\n\t\t * Register the resource tools with the widest exposure of the servers they reach: `direct` when\n\t\t * one of them is direct, and so on. They are hidden when no server has resources.\n\t\t */\n\t\tconst syncResourceTools = () => {\n\t\t\tconst exposures = new Set(serversWithResources().map((server) => exposureOf(server.entry)));\n\t\t\tfor (const name of pendingResourceServers) {\n\t\t\t\tconst server = findServer(name);\n\t\t\t\tif (server && isEnabled(server) && exposureOf(server.entry) !== \"hidden\")\n\t\t\t\t\texposures.add(exposureOf(server.entry));\n\t\t\t}\n\t\t\tconst exposure = ([\"direct\", \"codemode\", \"deferred\"] as const).find((candidate) => exposures.has(candidate));\n\t\t\tconst next = exposure ?? \"hidden\";\n\t\t\tif (next === resourceToolsExposure || (resourceToolsExposure === undefined && next === \"hidden\")) return;\n\t\t\tconst wasDirect = resourceToolsExposure === \"direct\";\n\t\t\tresourceToolsExposure = next;\n\t\t\tconst resourceDefinitions = createMcpResourceToolDefinitions({ exposure: next, servers: resourceServers });\n\t\t\tfor (const definition of resourceDefinitions) pi.registerTool(definition);\n\t\t\t// Hidden tools leave the declared tools when they are registered; only other exposures need this.\n\t\t\tif (wasDirect && next !== \"hidden\") {\n\t\t\t\tconst names = new Set(resourceDefinitions.map((definition) => definition.name));\n\t\t\t\tpi.setActiveTools(pi.getActiveTools().filter((name) => !names.has(name)));\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * Tools that are not declared to the model are reached through the codemode tool (scripts call\n\t\t * them) or the tool_search tool (it declares them). Either reaches every such tool. Activate the\n\t\t * one the tools' exposure asks for: codemode for `codemode` unless `autoEnableCodemode` is false,\n\t\t * tool_search for `deferred`.\n\t\t */\n\t\tconst ensureDiscoveryActive = (ctx: ExtensionContext) => {\n\t\t\t// From the config, so the tool is active before the servers connect. Resource tools share\n\t\t\t// their server's exposure.\n\t\t\tconst exposures = new Set<McpExposure>();\n\t\t\tfor (const server of servers) {\n\t\t\t\tif (isEnabled(server)) for (const exposure of configuredExposures(server.entry)) exposures.add(exposure);\n\t\t\t}\n\t\t\tconst needsCodemode = exposures.has(\"codemode\");\n\t\t\tconst needsToolSearch = exposures.has(\"deferred\");\n\t\t\tif (!needsCodemode && !needsToolSearch) return;\n\t\t\t// Other extensions' tools of the same names cannot reach MCP tools, so never activate them.\n\t\t\tconst tools = pi.getAllTools();\n\t\t\tconst codemode = tools.find(isCodemodeDiscoveryTool);\n\t\t\tconst hasCodemode = codemode !== undefined;\n\t\t\tconst hasToolSearch = tools.some(isToolSearchDiscoveryTool);\n\t\t\tconst active = pi.getActiveTools();\n\t\t\tconst activate: string[] = [];\n\t\t\tif (\n\t\t\t\tneedsCodemode &&\n\t\t\t\tcodemode &&\n\t\t\t\t!codemode.explicitDefaultOptOut &&\n\t\t\t\tautoEnableCodemode &&\n\t\t\t\t!active.includes(CODEMODE_TOOL_NAME)\n\t\t\t) {\n\t\t\t\tactivate.push(CODEMODE_TOOL_NAME);\n\t\t\t}\n\t\t\tif (needsToolSearch && hasToolSearch && !active.includes(TOOL_SEARCH_TOOL_NAME)) {\n\t\t\t\tactivate.push(TOOL_SEARCH_TOOL_NAME);\n\t\t\t}\n\t\t\tif (activate.length > 0) pi.setActiveTools([...active, ...activate]);\n\t\t\tconst reachable = [...active, ...activate];\n\t\t\tif (hasCodemode && reachable.includes(CODEMODE_TOOL_NAME)) return;\n\t\t\tif (hasToolSearch && reachable.includes(TOOL_SEARCH_TOOL_NAME)) return;\n\t\t\tif (warnedUnreachable) return;\n\t\t\twarnedUnreachable = true;\n\t\t\tconst reason =\n\t\t\t\tneedsCodemode && codemode?.explicitDefaultOptOut\n\t\t\t\t\t? \" (-codemode removed it from the tool selection)\"\n\t\t\t\t\t: needsCodemode && hasCodemode && !autoEnableCodemode\n\t\t\t\t\t\t? \" (autoEnableCodemode is false)\"\n\t\t\t\t\t\t: \"\";\n\t\t\tctx.ui.notify(\n\t\t\t\t`MCP tools are only reachable from the codemode or tool_search tool, but neither is active${reason}; they cannot be called.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t};\n\n\t\t/**\n\t\t * Stored tokens of servers waiting for a sign-in, as they were when the sign-in was needed.\n\t\t * `pi mcp login` in another process (for example run by the agent) changes them.\n\t\t */\n\t\tconst tokensAtSignIn = new Map<McpServerConnection, Promise<string>>();\n\t\tconst storedTokens = async (connection: McpServerConnection): Promise<string> => {\n\t\t\tconst url = connection.oauthUrl;\n\t\t\treturn url && credentials\n\t\t\t\t? JSON.stringify((await credentials.tokensAsync(connection.name, url)) ?? null)\n\t\t\t\t: \"null\";\n\t\t};\n\t\tconst onConnectionChange = (connection: McpServerConnection) => {\n\t\t\tif (connection.state !== \"needs-auth\") tokensAtSignIn.delete(connection);\n\t\t\telse if (!tokensAtSignIn.has(connection)) {\n\t\t\t\tconst tokens = storedTokens(connection);\n\t\t\t\ttokens.catch(() => {});\n\t\t\t\ttokensAtSignIn.set(connection, tokens);\n\t\t\t}\n\t\t\temitChange();\n\t\t};\n\t\t/** Reconnect servers that need a sign-in when their credentials were stored since. */\n\t\tconst reconnectSignedIn = async (ctx: ExtensionContext) => {\n\t\t\tconst compared = await Promise.all(\n\t\t\t\t[...tokensAtSignIn].map(async ([connection, tokens]) => ({\n\t\t\t\t\tconnection,\n\t\t\t\t\ttokens,\n\t\t\t\t\tchanged: (await storedTokens(connection)) !== (await tokens),\n\t\t\t\t})),\n\t\t\t);\n\t\t\tconst signedIn = compared.filter(({ changed }) => changed);\n\t\t\tif (signedIn.length === 0) return;\n\t\t\tfor (const { connection, tokens } of signedIn) {\n\t\t\t\tif (tokensAtSignIn.get(connection) === tokens) tokensAtSignIn.delete(connection);\n\t\t\t}\n\t\t\tawait Promise.allSettled(signedIn.map(({ connection }) => connection.reconnect()));\n\t\t\tensureDiscoveryActive(ctx);\n\t\t};\n\n\t\t/** Create the server's connection, loading the MCP runtime on first use. */\n\t\tconst createConnection = async (\n\t\t\tserver: McpServer,\n\t\t\tisCurrent: () => boolean,\n\t\t): Promise<McpServerConnection | undefined> => {\n\t\t\tif (!isCurrent()) return;\n\t\t\tconst runtime = await loadMcpRuntime();\n\t\t\tif (!isCurrent()) return;\n\t\t\tconst connection = new runtime.McpServerConnection({\n\t\t\t\tentry: server.entry,\n\t\t\t\tcwd: sessionCwd,\n\t\t\t\tcreateTransport: options.createTransport ?? runtime.createDefaultTransport,\n\t\t\t\tcredentials: getCredentials(runtime),\n\t\t\t\tproviderToken: async (provider) => modelRegistry?.getApiKeyForProvider(provider),\n\t\t\t\tlog: getServerLog(runtime),\n\t\t\t\tonTools: (connection) => {\n\t\t\t\t\tif (isCurrent()) registerTools(connection);\n\t\t\t\t},\n\t\t\t\tonChange: (connection) => {\n\t\t\t\t\tif (isCurrent()) onConnectionChange(connection);\n\t\t\t\t\telse tokensAtSignIn.delete(connection);\n\t\t\t\t},\n\t\t\t});\n\t\t\tserver.connection = connection;\n\t\t\temitChange();\n\t\t\treturn connection;\n\t\t};\n\n\t\tconst startConnection = (server: McpServer, after?: Promise<unknown>): Promise<void> => {\n\t\t\tconst { signal } = session;\n\t\t\tconst attempt = Symbol();\n\t\t\tserver.attempt = attempt;\n\t\t\tconst isCurrent = () =>\n\t\t\t\t!signal.aborted && server.attempt === attempt && isEnabled(server) && servers.includes(server);\n\t\t\tconst ready = (async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait after;\n\t\t\t\t\tif (!isCurrent()) return;\n\t\t\t\t\tconst connection = await createConnection(server, isCurrent);\n\t\t\t\t\tif (!connection || !isCurrent()) return;\n\t\t\t\t\tawait connection.getClient().catch(() => undefined);\n\t\t\t\t} finally {\n\t\t\t\t\tif (isCurrent()) {\n\t\t\t\t\t\twithdrawUnlistedRecords(server.entry.name);\n\t\t\t\t\t\tif (pendingResourceServers.delete(server.entry.name)) syncResourceTools();\n\t\t\t\t\t\t// A server that did not connect shows no summary, as when it never connected.\n\t\t\t\t\t\tpendingSummaries.delete(server.entry.name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})();\n\t\t\tserver.ready = ready.catch(() => undefined);\n\t\t\treturn ready;\n\t\t};\n\n\t\tconst waitForServers = async (waiting: readonly McpServer[], signal: AbortSignal | undefined) => {\n\t\t\tfor (;;) {\n\t\t\t\tconst ready = waiting.flatMap((server) =>\n\t\t\t\t\tisEnabled(server) && servers.includes(server) && server.ready ? [{ server, ready: server.ready }] : [],\n\t\t\t\t);\n\t\t\t\tif (ready.length === 0 || signal?.aborted) return;\n\t\t\t\tlet onAbort: (() => void) | undefined;\n\t\t\t\tawait Promise.race([\n\t\t\t\t\tPromise.all(ready.map((attempt) => attempt.ready)),\n\t\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\t\tonAbort = () => resolve();\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t}),\n\t\t\t\t]);\n\t\t\t\tif (onAbort) signal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\tif (\n\t\t\t\t\tsignal?.aborted ||\n\t\t\t\t\tready.every(\n\t\t\t\t\t\t(attempt) =>\n\t\t\t\t\t\t\t!isEnabled(attempt.server) ||\n\t\t\t\t\t\t\t!servers.includes(attempt.server) ||\n\t\t\t\t\t\t\tattempt.ready === attempt.server.ready,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * One message for everything that needs the user after startup, or only for `only`, servers\n\t\t * that connected later.\n\t\t */\n\t\tconst reportProblems = (ctx: ExtensionContext, only?: readonly McpServer[]) => {\n\t\t\tconst lines = only ? [] : configErrors.map((error) => `config: ${error}`);\n\t\t\tfor (const server of only ?? servers) {\n\t\t\t\tconst state = server.connection?.state;\n\t\t\t\tif (state === \"needs-auth\" || state === \"failed\")\n\t\t\t\t\tlines.push(`${server.entry.name}: ${describeState(server)}`);\n\t\t\t}\n\t\t\tif (lines.length === 0) return;\n\t\t\tctx.ui.notify(\n\t\t\t\t`MCP servers need attention:\\n${lines.map((line) => ` ${line}`).join(\"\\n\")}\\nRun /mcp to fix.`,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t};\n\n\t\t/**\n\t\t * Save a config change; returns an error message when the file could not be updated. Changes to\n\t\t * registered servers only apply to the current session. `inProject` adds a project override.\n\t\t */\n\t\tconst saveConfig = async (\n\t\t\tserver: McpServer,\n\t\t\tpatch: McpServerConfigPatch,\n\t\t\tinProject = false,\n\t\t): Promise<string | undefined> => {\n\t\t\tconst override = inProject ? projectConfig : server.entry.override;\n\t\t\tconst entry = override ? { ...server.entry, override } : server.entry;\n\t\t\tif (entry.scope !== \"extension\") {\n\t\t\t\ttry {\n\t\t\t\t\tawait updateConfig(entry, patch);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn `Could not update ${entry.override ?? entry.source}: ${errorMessage(error)}`;\n\t\t\t\t}\n\t\t\t}\n\t\t\tserver.entry = { ...entry, config: { ...entry.config, ...patch } };\n\t\t\treturn undefined;\n\t\t};\n\n\t\t/** Sign in, then reconnect. Returns an error message on failure. `cancel` or the session's end stops the sign-in. */\n\t\tconst signIn = async (\n\t\t\tserver: McpServer,\n\t\t\tprompt: McpSignInPrompt,\n\t\t\tcancel?: AbortSignal,\n\t\t): Promise<string | undefined> => {\n\t\t\tconst connection = server.connection;\n\t\t\tconst url = connection?.oauthUrl;\n\t\t\tif (!connection || !url) return `MCP server \"${server.entry.name}\" does not use OAuth.`;\n\t\t\tconst runtime = await loadMcpRuntime();\n\t\t\tconst signal = cancel ? AbortSignal.any([session.signal, cancel]) : session.signal;\n\t\t\ttry {\n\t\t\t\tawait track(\n\t\t\t\t\truntime.signInMcpServer({\n\t\t\t\t\t\tserverUrl: url,\n\t\t\t\t\t\tstore: getCredentials(runtime).forServer(server.entry.name, url),\n\t\t\t\t\t\tsettings: await connection.oauthSettings(),\n\t\t\t\t\t\tchallenge: connection.challenge,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof runtime.McpSignInCancelledError) return \"Sign-in cancelled.\";\n\t\t\t\treturn `Sign-in failed: ${errorMessage(error)}`;\n\t\t\t}\n\t\t\t// The challenge that asked for this sign-in (for example for more scope) is answered.\n\t\t\tconnection.challenge = undefined;\n\t\t\ttry {\n\t\t\t\tawait connection.reconnect();\n\t\t\t} catch (error) {\n\t\t\t\treturn `Signed in, but ${errorMessage(error)}`;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t};\n\n\t\tconst signOut = async (server: McpServer): Promise<boolean> => {\n\t\t\tconst connection = server.connection;\n\t\t\tconst url = connection?.oauthUrl;\n\t\t\tif (!connection || !url) return false;\n\t\t\tconst removed = await getCredentials(await loadMcpRuntime()).removeAsync(server.entry.name, url);\n\t\t\tawait connection.signOut();\n\t\t\treturn removed;\n\t\t};\n\n\t\tconst reconnect = async (server: McpServer): Promise<string | undefined> => {\n\t\t\tconst connection = server.connection;\n\t\t\tif (!connection) return `MCP server \"${server.entry.name}\" is disabled.`;\n\t\t\tconst previous = server.ready;\n\t\t\tconst ready = (async () => {\n\t\t\t\tawait previous;\n\t\t\t\tawait connection.reconnect();\n\t\t\t})();\n\t\t\tserver.ready = ready.catch(() => undefined);\n\t\t\ttry {\n\t\t\t\tawait ready;\n\t\t\t\treturn undefined;\n\t\t\t} catch (error) {\n\t\t\t\treturn errorMessage(error);\n\t\t\t}\n\t\t};\n\n\t\t/** Returns an error message when the config could not be saved; connection errors show in the state. */\n\t\tconst setEnabled = async (\n\t\t\tserver: McpServer,\n\t\t\tenabled: boolean,\n\t\t\tinProject = false,\n\t\t): Promise<string | undefined> => {\n\t\t\tconst failed = await saveConfig(server, { enabled }, inProject);\n\t\t\tif (failed) return failed;\n\t\t\tif (!enabled) {\n\t\t\t\tconst connection = server.connection;\n\t\t\t\tserver.attempt = undefined;\n\t\t\t\tserver.connection = undefined;\n\t\t\t\tif (connection) {\n\t\t\t\t\tserver.closing = connection.close();\n\t\t\t\t}\n\t\t\t\tconst closing = server.closing;\n\t\t\t\thideTools(server.entry.name);\n\t\t\t\temitChange();\n\t\t\t\ttry {\n\t\t\t\t\tawait closing;\n\t\t\t\t} finally {\n\t\t\t\t\tif (server.closing === closing) server.closing = undefined;\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tawait startConnection(server, server.closing);\n\t\t\treturn undefined;\n\t\t};\n\n\t\tconst setExposure = async (server: McpServer, exposure: McpExposure): Promise<string | undefined> => {\n\t\t\tconst failed = await saveConfig(server, { exposure });\n\t\t\tif (failed) return failed;\n\t\t\tif (server.connection?.state === \"connected\") registerTools(server.connection);\n\t\t\tsyncResourceTools();\n\t\t\t// Tools no longer exposed directly leave the declared set; direct tools are activated on registration.\n\t\t\tconst indirect = new Set(\n\t\t\t\tpi\n\t\t\t\t\t.getAllTools()\n\t\t\t\t\t.filter((tool) => tool.exposure !== \"direct\")\n\t\t\t\t\t.map((tool) => tool.name),\n\t\t\t);\n\t\t\tconst tools = serverTools.get(server.entry.name) ?? new Set<string>();\n\t\t\tpi.setActiveTools(pi.getActiveTools().filter((name) => !tools.has(name) || !indirect.has(name)));\n\t\t\temitChange();\n\t\t\treturn undefined;\n\t\t};\n\n\t\t// ---------------------------------------------------------------------------------------\n\t\t// Manager (`/mcp` in the TUI)\n\t\t// ---------------------------------------------------------------------------------------\n\n\t\tconst notices = () => [\n\t\t\t...configErrors.map((error) => `config: ${error}`),\n\t\t\t...overridden.map((line) => `overridden: ${line}`),\n\t\t];\n\n\t\tconst serversMenu = (): McpMenu => ({\n\t\t\ttitle: \"MCP servers\",\n\t\t\terror: notices().join(\"\\n\") || undefined,\n\t\t\titems: [...servers]\n\t\t\t\t.sort((a, b) => attentionRank(a) - attentionRank(b) || a.entry.name.localeCompare(b.entry.name))\n\t\t\t\t.map((server) => ({\n\t\t\t\t\tvalue: server.entry.name,\n\t\t\t\t\tlabel: server.entry.name,\n\t\t\t\t\tdescription: `${describeState(server)} · ${exposureOf(server.entry)} · ${server.entry.override ? \"global, project override\" : (server.entry.scope ?? server.entry.source)}`,\n\t\t\t\t})),\n\t\t\tempty: `No MCP servers configured. Add them to ${resolve(getAgentDir(), \"mcp.json\")} or ${CONFIG_DIR_NAME}/mcp.json.`,\n\t\t\tconfirmLabel: \"manage\",\n\t\t\tcancelLabel: \"close\",\n\t\t});\n\n\t\tconst serverMenu = (name: string): McpMenu => {\n\t\t\tconst server = findServer(name);\n\t\t\tif (!server) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: name,\n\t\t\t\t\titems: [],\n\t\t\t\t\tempty: \"This server is no longer configured.\",\n\t\t\t\t\tconfirmLabel: \"\",\n\t\t\t\t\tcancelLabel: \"back\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst { entry, connection } = server;\n\t\t\tconst saved =\n\t\t\t\tentry.scope === \"extension\"\n\t\t\t\t\t? \"for this session\"\n\t\t\t\t\t: entry.override\n\t\t\t\t\t\t? \"saved to the project mcp.json\"\n\t\t\t\t\t\t: entry.scope\n\t\t\t\t\t\t\t? `saved to the ${entry.scope} mcp.json`\n\t\t\t\t\t\t\t: \"saved to mcp.json\";\n\t\t\t// Global servers without an override can be turned on or off for the trusted project alone.\n\t\t\tconst inProject = entry.scope === \"global\" && !entry.override && projectConfig !== undefined;\n\t\t\tconst inProjectSaved = \"saved to the project mcp.json\";\n\t\t\tconst items: SelectItem[] = [];\n\t\t\tif (!isEnabled(server)) {\n\t\t\t\titems.push({ value: \"enable\", label: \"Enable\", description: saved });\n\t\t\t\tif (inProject) {\n\t\t\t\t\titems.push({ value: \"enable-project\", label: \"Enable in this project\", description: inProjectSaved });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst state = connection?.state;\n\t\t\t\tif (state === \"needs-auth\")\n\t\t\t\t\titems.push({ value: \"signin\", label: \"Sign in\", description: \"opens the browser\" });\n\t\t\t\tif (state === \"connected\" && connection) {\n\t\t\t\t\titems.push({ value: \"tools\", label: \"Tools\", description: `${connection.tools.length} offered` });\n\t\t\t\t}\n\t\t\t\tif (state === \"failed\" || state === \"disconnected\" || state === \"connected\" || state === \"needs-auth\") {\n\t\t\t\t\titems.push({ value: \"reconnect\", label: \"Reconnect\" });\n\t\t\t\t}\n\t\t\t\tif (state === \"connected\" && connection?.oauthUrl) {\n\t\t\t\t\titems.push({ value: \"signout\", label: \"Sign out\", description: \"deletes the stored credentials\" });\n\t\t\t\t}\n\t\t\t\titems.push({ value: \"exposure\", label: \"Exposure\", description: exposureOf(entry) });\n\t\t\t\titems.push({ value: \"disable\", label: \"Disable\", description: saved });\n\t\t\t\tif (inProject) {\n\t\t\t\t\titems.push({ value: \"disable-project\", label: \"Disable in this project\", description: inProjectSaved });\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst details = [\n\t\t\t\tdescribeTransport(entry),\n\t\t\t\t`${entry.scope ?? \"config\"}: ${entry.source}`,\n\t\t\t\t...(entry.override ? [`project override: ${entry.override}`] : []),\n\t\t\t\t`State: ${describeState(server, false)}`,\n\t\t\t];\n\t\t\tconst error = [server.message, connection?.state === \"connected\" ? undefined : connection?.error]\n\t\t\t\t.filter((line): line is string => line !== undefined)\n\t\t\t\t.join(\"\\n\");\n\t\t\treturn {\n\t\t\t\ttitle: `MCP server ${name}`,\n\t\t\t\tdetails: details.join(\"\\n\"),\n\t\t\t\terror: error || undefined,\n\t\t\t\titems,\n\t\t\t\tselected: items[0]?.value,\n\t\t\t\tconfirmLabel: \"select\",\n\t\t\t\tcancelLabel: \"back\",\n\t\t\t};\n\t\t};\n\n\t\tconst showTools = async (ui: McpUi, server: McpServer) => {\n\t\t\tconst exposure = exposureOf(server.entry);\n\t\t\tconst overridden = Object.keys(server.entry.config.toolExposure ?? {}).length > 0;\n\t\t\tawait ui.menu(() => ({\n\t\t\t\ttitle: `Tools of ${server.entry.name}`,\n\t\t\t\tdetails: `Exposure ${exposure}: ${exposure === \"hidden\" ? \"unreachable\" : EXPOSURE_DESCRIPTIONS[exposure]}${overridden ? \"\\nSome tools override it with toolExposure.\" : \"\"}`,\n\t\t\t\titems: (server.connection?.tools ?? []).map((tool) => {\n\t\t\t\t\tconst toolExposure = getMcpToolExposure(server.entry.config, tool.name);\n\t\t\t\t\tconst description = firstLine(tool.description ?? \"\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: tool.name,\n\t\t\t\t\t\tlabel: tool.name,\n\t\t\t\t\t\tdescription: toolExposure === exposure ? description : `[${toolExposure}] ${description}`,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t\tempty: \"The server offers no tools.\",\n\t\t\t\tconfirmLabel: \"back\",\n\t\t\t\tcancelLabel: \"back\",\n\t\t\t}));\n\t\t};\n\n\t\tconst chooseExposure = async (ui: McpUi, server: McpServer): Promise<string | undefined> => {\n\t\t\tconst current = exposureOf(server.entry);\n\t\t\tconst choice = await ui.menu(() => ({\n\t\t\t\ttitle: `Exposure of ${server.entry.name}`,\n\t\t\t\tdetails:\n\t\t\t\t\tserver.entry.scope === \"extension\"\n\t\t\t\t\t\t? `Applies to this session; the server is registered by ${server.entry.source}.`\n\t\t\t\t\t\t: `Saved to ${server.entry.override ?? server.entry.source}.`,\n\t\t\t\titems: (Object.keys(EXPOSURE_DESCRIPTIONS) as (keyof typeof EXPOSURE_DESCRIPTIONS)[]).map((exposure) => ({\n\t\t\t\t\tvalue: exposure,\n\t\t\t\t\tlabel: `${exposure === current ? \"✓ \" : \" \"}${exposure}`,\n\t\t\t\t\tdescription: EXPOSURE_DESCRIPTIONS[exposure],\n\t\t\t\t})),\n\t\t\t\tselected: current,\n\t\t\t\tconfirmLabel: \"save\",\n\t\t\t\tcancelLabel: \"back\",\n\t\t\t}));\n\t\t\tif (!choice || choice === current) return undefined;\n\t\t\treturn setExposure(server, choice as McpExposure);\n\t\t};\n\n\t\tconst signInWithUi = (ui: McpUi, server: McpServer): Promise<string | undefined> => {\n\t\t\tconst title = `Sign in to ${server.entry.name}`;\n\t\t\tconst cancel = new AbortController();\n\t\t\tconst status = (message: string) => ui.status(title, message, () => cancel.abort());\n\t\t\tlet authorizationUrl = \"\";\n\t\t\tstatus(\"Contacting the authorization server…\");\n\t\t\treturn signIn(\n\t\t\t\tserver,\n\t\t\t\t{\n\t\t\t\t\tshowAuthorizationUrl: (url) => {\n\t\t\t\t\t\tauthorizationUrl = url.href;\n\t\t\t\t\t\topenUrl(url.href);\n\t\t\t\t\t},\n\t\t\t\t\tpromptForRedirectUrl: async (signal) => {\n\t\t\t\t\t\tconst value = await ui.redirectUrl(title, authorizationUrl, signal);\n\t\t\t\t\t\tstatus(\"Connecting…\");\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tcancel.signal,\n\t\t\t);\n\t\t};\n\n\t\tconst runInBackground = (\n\t\t\tctx: ExtensionContext,\n\t\t\tserver: McpServer,\n\t\t\toperation: () => Promise<string | undefined>,\n\t\t) => {\n\t\t\tconst ready = operation();\n\t\t\tconst attempt = server.attempt;\n\t\t\tconst { signal } = session;\n\t\t\tconst finish = (message: string | undefined) => {\n\t\t\t\tif (signal.aborted || server.attempt !== attempt || !servers.includes(server)) return;\n\t\t\t\tserver.message = message;\n\t\t\t\tensureDiscoveryActive(ctx);\n\t\t\t\temitChange();\n\t\t\t};\n\t\t\tvoid track(ready.then(finish, (error) => finish(errorMessage(error))));\n\t\t};\n\n\t\tconst runAction = async (ui: McpUi, ctx: ExtensionContext, server: McpServer, action: string) => {\n\t\t\tconst { signal } = session;\n\t\t\tlet message: string | undefined;\n\t\t\tswitch (action) {\n\t\t\t\tcase \"signin\":\n\t\t\t\t\tmessage = await signInWithUi(ui, server);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"reconnect\":\n\t\t\t\t\trunInBackground(ctx, server, async () => {\n\t\t\t\t\t\tawait reconnect(server);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"signout\":\n\t\t\t\t\tawait signOut(server);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tools\":\n\t\t\t\t\tawait showTools(ui, server);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"exposure\":\n\t\t\t\t\tmessage = await chooseExposure(ui, server);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"enable\":\n\t\t\t\tcase \"disable\":\n\t\t\t\tcase \"enable-project\":\n\t\t\t\tcase \"disable-project\": {\n\t\t\t\t\tconst enable = action.startsWith(\"enable\");\n\t\t\t\t\trunInBackground(ctx, server, () => setEnabled(server, enable, action.endsWith(\"-project\")));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The session ended meanwhile (for example during a sign-in), which made ctx stale.\n\t\t\tif (signal.aborted) return;\n\t\t\tserver.message = message;\n\t\t\tensureDiscoveryActive(ctx);\n\t\t\temitChange();\n\t\t};\n\t\tconst manage = async (ui: McpUi, ctx: ExtensionContext) => {\n\t\t\tfor (;;) {\n\t\t\t\tconst name = await ui.menu(serversMenu, subscribe);\n\t\t\t\tif (!name) return;\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst action = await ui.menu(() => serverMenu(name), subscribe);\n\t\t\t\t\tconst server = findServer(name);\n\t\t\t\t\tif (!action || !server) break;\n\t\t\t\t\tawait runAction(ui, ctx, server, action);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// ---------------------------------------------------------------------------------------\n\t\t// Subcommands and plain status (no TUI)\n\t\t// ---------------------------------------------------------------------------------------\n\n\t\tconst formatStatus = (): string => {\n\t\t\tif (servers.length === 0 && configErrors.length === 0 && overridden.length === 0) {\n\t\t\t\treturn `No MCP servers configured. Add them to ${resolve(getAgentDir(), \"mcp.json\")} or ${CONFIG_DIR_NAME}/mcp.json.`;\n\t\t\t}\n\t\t\tconst lines = servers.map((server) => {\n\t\t\t\tconst { name } = server.entry;\n\t\t\t\tconst exposure = exposureOf(server.entry);\n\t\t\t\tconst connection = server.connection;\n\t\t\t\tif (connection?.state === \"needs-auth\")\n\t\t\t\t\treturn `${name}: needs sign-in, run /mcp login ${name} (${exposure})`;\n\t\t\t\tconst tools = connection?.state === \"connected\" ? `, ${connection.tools.length} tools` : \"\";\n\t\t\t\tconst state = !isEnabled(server)\n\t\t\t\t\t? \"disabled\"\n\t\t\t\t\t: connection?.state === \"disconnected\"\n\t\t\t\t\t\t? \"disconnected, reconnects on next call\"\n\t\t\t\t\t\t: (connection?.state ?? \"starting\");\n\t\t\t\tconst error =\n\t\t\t\t\tconnection?.error && connection.state !== \"connected\"\n\t\t\t\t\t\t? `\\n ${connection.error.split(\"\\n\").join(\"\\n \")}`\n\t\t\t\t\t\t: \"\";\n\t\t\t\treturn `${name}: ${state}${tools} (${exposure})${error}`;\n\t\t\t});\n\t\t\tfor (const error of configErrors) lines.push(`config error: ${error}`);\n\t\t\tfor (const line of overridden) lines.push(`overridden: ${line}`);\n\t\t\treturn lines.join(\"\\n\");\n\t\t};\n\n\t\t/** Resolve the server for a subcommand, asking when the name is omitted and ambiguous. */\n\t\tconst pickServer = async (\n\t\t\tname: string | undefined,\n\t\t\tctx: ExtensionCommandContext,\n\t\t\toptions: { eligible: (server: McpServer) => boolean; preferred: (server: McpServer) => boolean; none: string },\n\t\t): Promise<McpServer | undefined> => {\n\t\t\tif (name) {\n\t\t\t\tconst server = findServer(name);\n\t\t\t\tif (!server) ctx.ui.notify(`No MCP server named \"${name}\".`, \"error\");\n\t\t\t\telse if (!options.eligible(server)) ctx.ui.notify(options.none, \"error\");\n\t\t\t\treturn server && options.eligible(server) ? server : undefined;\n\t\t\t}\n\t\t\tconst candidates = servers.filter(options.eligible);\n\t\t\tif (candidates.length === 0) {\n\t\t\t\tctx.ui.notify(options.none, \"info\");\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst preferred = candidates.filter(options.preferred);\n\t\t\tif (candidates.length === 1) return candidates[0];\n\t\t\tif (preferred.length === 1) return preferred[0];\n\t\t\tconst choice = await ctx.ui.select(\n\t\t\t\t\"MCP server\",\n\t\t\t\tcandidates.map((server) => server.entry.name),\n\t\t\t);\n\t\t\treturn candidates.find((server) => server.entry.name === choice);\n\t\t};\n\n\t\tconst usesOAuth = (server: McpServer) => server.connection?.oauthUrl !== undefined;\n\t\tconst oauthPick = {\n\t\t\teligible: usesOAuth,\n\t\t\tpreferred: (server: McpServer) => server.connection?.state === \"needs-auth\",\n\t\t\tnone: \"No enabled MCP server uses OAuth. Only HTTP servers without an Authorization header do.\",\n\t\t};\n\n\t\tconst loginCommand = async (server: McpServer, ctx: ExtensionCommandContext) => {\n\t\t\tconst { name } = server.entry;\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(`Signing in to MCP server \"${name}\" requires interactive mode.`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { signal } = session;\n\t\t\tlet failure: string | undefined;\n\t\t\tif (ctx.mode === \"tui\") {\n\t\t\t\tlet completed = false;\n\t\t\t\tawait showMcpManager(ctx, async (ui) => {\n\t\t\t\t\tfailure = await signInWithUi(ui, server);\n\t\t\t\t\tcompleted = true;\n\t\t\t\t});\n\t\t\t\tif (!completed) return;\n\t\t\t} else {\n\t\t\t\tfailure = await signIn(server, {\n\t\t\t\t\tshowAuthorizationUrl: (url) => {\n\t\t\t\t\t\tctx.ui.notify(`Sign in to MCP server \"${name}\" in your browser:\\n${url.href}`, \"info\");\n\t\t\t\t\t\topenUrl(url.href);\n\t\t\t\t\t},\n\t\t\t\t\tpromptForRedirectUrl: (signal) =>\n\t\t\t\t\t\tctx.ui.input(\n\t\t\t\t\t\t\t`Waiting for sign-in to \"${name}\". If the browser cannot reach this machine, paste the URL it was redirected to.`,\n\t\t\t\t\t\t\t\"http://127.0.0.1:.../callback?code=...\",\n\t\t\t\t\t\t\t{ signal },\n\t\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t}\n\t\t\t// The session ended meanwhile, which cancelled the sign-in and made ctx stale.\n\t\t\tif (signal.aborted) return;\n\t\t\tif (failure) {\n\t\t\t\tctx.ui.notify(failure, failure === \"Sign-in cancelled.\" ? \"info\" : \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tensureDiscoveryActive(ctx);\n\t\t\tctx.ui.notify(`Signed in to MCP server \"${name}\" (${server.connection?.tools.length ?? 0} tools).`, \"info\");\n\t\t};\n\n\t\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\t\tconst loaded = await (options.loadConfig ?? defaultLoadConfig)(ctx);\n\t\t\tlatestContext = ctx;\n\t\t\tsubagentMcpDirectTools = ctx.subagentPolicy?.mcpDirectTools;\n\t\t\tconfigErrors = loaded.errors;\n\t\t\tprojectConfig = loaded.projectConfig;\n\t\t\tautoEnableCodemode = (ctx.subagentPolicy ? false : loaded.autoEnableCodemode) ?? true;\n\t\t\twarnedUnreachable = false;\n\t\t\twaitedForStartup = false;\n\t\t\tsessionCwd = ctx.cwd;\n\t\t\tmodelRegistry = ctx.modelRegistry;\n\t\t\tsession = new AbortController();\n\t\t\tconst { signal } = session;\n\t\t\tconfiguredEntries = loaded.servers;\n\t\t\tconst registered = registeredServers();\n\t\t\toverridden = registered.overridden;\n\t\t\tservers = [...loaded.servers.map((entry) => ({ entry })), ...registered.servers];\n\t\t\trestoreRecordedTools(ctx);\n\t\t\temitChange();\n\t\t\t// Codemode or tool_search is activated from the config: the first prompt does not wait for\n\t\t\t// servers whose tools are not declared to the model, and scripts or searches wait for them.\n\t\t\tensureDiscoveryActive(ctx);\n\t\t\tconst enabled = servers.filter(isEnabled);\n\t\t\tif (enabled.length === 0) {\n\t\t\t\treportProblems(ctx);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The MCP client loads only now, so sessions without servers never pay for it. Waiting one\n\t\t\t// event loop turn lets the first render happen before loading and connecting.\n\t\t\tconst runtime = new Promise((resolve) => setImmediate(resolve)).then(() => loadMcpRuntime());\n\t\t\tpending = Promise.all(enabled.map((server) => startConnection(server, runtime)))\n\t\t\t\t.then(() => {\n\t\t\t\t\tif (!signal.aborted) reportProblems(ctx);\n\t\t\t\t})\n\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t// The session may have been disposed meanwhile, which makes ctx stale.\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx.ui.notify(`MCP failed to load: ${errorMessage(error)}`, \"error\");\n\t\t\t\t\t} catch {}\n\t\t\t\t});\n\t\t});\n\n\t\t// The first prompt waits for servers whose tools are declared to the model, so they are declared\n\t\t// in its first request, but not indefinitely: a slow or hanging server must not hold up the\n\t\t// prompt. Other servers are waited for when a script or search needs them (below).\n\t\tconst waitForDirectServers = async (ctx: ExtensionContext) => {\n\t\t\tif (waitedForStartup) return;\n\t\t\twaitedForStartup = true;\n\t\t\tconst ready = servers.flatMap((server) =>\n\t\t\t\tisEnabled(server) &&\n\t\t\t\thasDirectTools(server.entry, subagentMcpDirectTools, latestContext?.subagentPolicy?.tools) &&\n\t\t\t\tserver.ready\n\t\t\t\t\t? [server.ready]\n\t\t\t\t\t: [],\n\t\t\t);\n\t\t\tif (ready.length === 0) return;\n\t\t\tlet timer: NodeJS.Timeout | undefined;\n\t\t\tconst finished = await Promise.race([\n\t\t\t\tPromise.all(ready).then(() => true),\n\t\t\t\tnew Promise<boolean>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => resolve(false), startupWaitMs);\n\t\t\t\t}),\n\t\t\t]);\n\t\t\tclearTimeout(timer);\n\t\t\tif (!finished) {\n\t\t\t\tctx.ui.notify(\"MCP servers are still connecting; their tools become available once connected.\", \"info\");\n\t\t\t}\n\t\t};\n\n\t\t// Every prompt lists the servers in the `mcp_servers` section as they are when it starts. Pi\n\t\t// appends the section to the conversation when it changed, for example after a server connected.\n\t\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\t\tawait waitForDirectServers(ctx);\n\t\t\tconst { sections } = event.systemPromptOptions;\n\t\t\tconst section = layOutServersSection(\n\t\t\t\tservers.map((server) => {\n\t\t\t\t\tconst record = pendingSummary(server);\n\t\t\t\t\treturn { ...server, recordedSummary: record?.summary, recordedSummaryCut: record?.cut };\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (section) sections[MCP_SERVERS_SECTION] = section.text;\n\t\t\telse delete sections[MCP_SERVERS_SECTION];\n\t\t\tconst shown = new Map<string, ShownSummary>();\n\t\t\tconst kept = new Set<string>();\n\t\t\tfor (const { listing, summary } of section?.summarized ?? []) {\n\t\t\t\tif (listing.entry.config.description?.trim()) continue;\n\t\t\t\tif (listing.recordedSummary !== undefined) kept.add(listing.entry.name);\n\t\t\t\t// A summary cut down to its ellipsis is recorded as such: with less room it shows none, as the summary does.\n\t\t\t\telse {\n\t\t\t\t\tshown.set(listing.entry.name, {\n\t\t\t\t\t\tsummary,\n\t\t\t\t\t\tcut: summary === \"…\" && serverSummary(listing) !== \"…\",\n\t\t\t\t\t\tidentity: serverIdentity(listing.entry),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Recorded once the prompt sends its first message (message_end below).\n\t\t\tpromptSection = { options: event.systemPromptOptions, text: section?.text, shown, kept };\n\t\t});\n\n\t\t// A codemode script waits for the servers it names, or for every server when it searches or\n\t\t// enumerates tools, so their tools are registered before the script runs. tool_search and the\n\t\t// resource tools reach every server, so they wait for all of them.\n\t\tpi.on(\"tool_call\", async (event, ctx) => {\n\t\t\tconst tool = pi.getAllTools().find((candidate) => candidate.name === event.toolName);\n\t\t\tif (!tool) return;\n\t\t\tconst readyServers = servers.filter((server) => isEnabled(server) && server.ready);\n\t\t\tif (readyServers.length === 0) return;\n\t\t\tlet waiting: McpServer[] = [];\n\t\t\tif (isCodemodeDiscoveryTool(tool)) {\n\t\t\t\tconst { code } = event.input as { code?: unknown };\n\t\t\t\tconst source = typeof code === \"string\" ? code : \"\";\n\t\t\t\twaiting = readyServers.filter((server) => scriptNeedsServer(source, server.entry.name));\n\t\t\t} else if (isToolSearchDiscoveryTool(tool) || RESOURCE_TOOL_NAMES.has(tool.name)) {\n\t\t\t\twaiting = readyServers;\n\t\t\t} else {\n\t\t\t\tconst owner = toolOwners.get(event.toolName)?.split(\"\\0\", 1)[0];\n\t\t\t\twaiting = readyServers.filter((server) => server.entry.name === owner);\n\t\t\t}\n\t\t\tawait waitForServers(waiting, ctx.signal);\n\t\t});\n\n\t\t// Keep track of the MCP tools the transcript declares, and record the ones whose listing was not recorded yet.\n\t\t// The summaries the prompt's section shows are recorded once its first message ends (the section update, or\n\t\t// the prompt itself when the section did not change), so the records say what the conversation shows. When a\n\t\t// later handler replaced the section or the prompt, the conversation shows no summary. A reply first means the\n\t\t// prompt sent nothing, so nothing changed.\n\t\tpi.on(\"message_end\", async (event) => {\n\t\t\tconst { message } = event;\n\t\t\tif (promptSection) {\n\t\t\t\tconst { options, text, shown, kept } = promptSection;\n\t\t\t\tpromptSection = undefined;\n\t\t\t\tif (message.role === \"system\" || message.role === \"user\" || message.role === \"custom\") {\n\t\t\t\t\tconst sent =\n\t\t\t\t\t\ttext !== undefined &&\n\t\t\t\t\t\toptions.forceSystemPrompt === undefined &&\n\t\t\t\t\t\toptions.sections?.[MCP_SERVERS_SECTION] === text;\n\t\t\t\t\tconst updates = sent ? summaryUpdates(shown, kept) : summaryUpdates(new Map(), new Set());\n\t\t\t\t\tif (updates.length > 0) await recordSummaries(updates);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (message.role !== \"system\" || (!message.toolsAdded && !message.toolsRemoved)) return;\n\t\t\tfor (const tool of message.toolsRemoved ?? []) declaredNames.delete(tool.name);\n\t\t\tfor (const tool of message.toolsAdded ?? []) if (isRecordedToolName(tool.name)) declaredNames.add(tool.name);\n\t\t\t// Stored before the request that declares the tools is sent.\n\t\t\tawait recordDeclaredTools();\n\t\t});\n\n\t\t// Another branch declares other tools and carries other records.\n\t\tpi.on(\"session_tree\", (_event, ctx) => {\n\t\t\tconst branch = ctx.sessionManager.getBranch();\n\t\t\ttoolRecords = readToolRecords(branch);\n\t\t\tdeclaredNames = declaredMcpToolNames(branch);\n\t\t\tvoid recordDeclaredTools();\n\t\t});\n\n\t\t// Pick up sign-ins done outside the session, such as `pi mcp login` run by the agent.\n\t\tpi.on(\"turn_start\", async (_event, ctx) => {\n\t\t\tif (tokensAtSignIn.size > 0) await reconnectSignedIn(ctx);\n\t\t});\n\n\t\t// Servers registered or unregistered during the session connect or disconnect right away.\n\t\tpi.onMcpServerContributionsChanged?.(() => {\n\t\t\tconst { signal } = session;\n\t\t\tif (signal.aborted) return;\n\t\t\tconst registered = registeredServers();\n\t\t\toverridden = registered.overridden;\n\t\t\tconst next = new Map(registered.servers.map((server) => [server.entry.name, server]));\n\t\t\tconst removed = servers.filter(\n\t\t\t\t(server) =>\n\t\t\t\t\tserver.entry.scope === \"extension\" &&\n\t\t\t\t\tnext.get(server.entry.name)?.registeredConfig !== server.registeredConfig,\n\t\t\t);\n\t\t\tservers = servers.filter((server) => !removed.includes(server));\n\t\t\tfor (const server of removed) hideTools(server.entry.name);\n\t\t\tconst added = registered.servers.filter((server) => !findServer(server.entry.name));\n\t\t\tservers.push(...added);\n\t\t\temitChange();\n\t\t\tif (latestContext) ensureDiscoveryActive(latestContext);\n\t\t\tvoid Promise.all(removed.map((server) => server.connection?.close())).then(async () => {\n\t\t\t\tconst connecting = added.filter(isEnabled);\n\t\t\t\tif (signal.aborted || connecting.length === 0) return;\n\t\t\t\ttry {\n\t\t\t\t\tawait Promise.all(connecting.map((server) => startConnection(server)));\n\t\t\t\t\tif (!signal.aborted) reportProblems(latestContext!, connecting);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) latestContext?.ui.notify(`MCP failed to load: ${errorMessage(error)}`, \"error\");\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tpi.on(\"session_shutdown\", async () => {\n\t\t\tsession.abort();\n\t\t\tconst closing = connections();\n\t\t\t// The retiring registry is discarded. Do not register hidden tools or call a\n\t\t\t// captured UI here: reload has already revoked this generation's authority.\n\t\t\tlisteners.clear();\n\t\t\tserverTools.clear();\n\t\t\tdefinitions.clear();\n\t\t\ttoolOwners.clear();\n\t\t\tlistedTools.clear();\n\t\t\trecordedOnly.clear();\n\t\t\ttoolRecords = { tools: new Map(), resourceServers: undefined, summaries: new Map() };\n\t\t\trecordingTools.clear();\n\t\t\trecordingResources = undefined;\n\t\t\tpendingResourceServers.clear();\n\t\t\tpendingSummaries.clear();\n\t\t\tpromptSection = undefined;\n\t\t\tdeclaredNames = new Set();\n\t\t\ttokensAtSignIn.clear();\n\t\t\tresourceToolsExposure = undefined;\n\t\t\tservers = [];\n\t\t\tlatestContext = undefined;\n\t\t\tsubagentMcpDirectTools = undefined;\n\t\t\tawait Promise.all([...backgroundActions, ...closing.map((connection) => connection.close())]);\n\t\t\tawait serverLog?.flush();\n\t\t});\n\n\t\tpi.registerCommand(\"mcp\", {\n\t\t\tdescription: \"Manage MCP servers: sign in, reconnect, enable or disable, and change exposure\",\n\t\t\tgetArgumentCompletions: (prefix) => {\n\t\t\t\tconst [action, server, ...rest] = prefix.trimStart().split(/\\s+/);\n\t\t\t\tif (rest.length > 0) return null;\n\t\t\t\tif (server === undefined) {\n\t\t\t\t\treturn [\"login\", \"logout\", \"reconnect\"]\n\t\t\t\t\t\t.filter((item) => item.startsWith(action ?? \"\"))\n\t\t\t\t\t\t.map((item) => ({ value: `${item} `, label: item }));\n\t\t\t\t}\n\t\t\t\tif (action !== \"login\" && action !== \"logout\" && action !== \"reconnect\") return null;\n\t\t\t\tconst items = servers\n\t\t\t\t\t.filter((candidate) =>\n\t\t\t\t\t\taction === \"reconnect\" ? candidate.connection !== undefined : usesOAuth(candidate),\n\t\t\t\t\t)\n\t\t\t\t\t.filter((candidate) => candidate.entry.name.startsWith(server))\n\t\t\t\t\t.map((candidate) => ({\n\t\t\t\t\t\tvalue: `${action} ${candidate.entry.name}`,\n\t\t\t\t\t\tlabel: candidate.entry.name,\n\t\t\t\t\t\tdescription: describeState(candidate),\n\t\t\t\t\t}));\n\t\t\t\treturn items.length > 0 ? items : null;\n\t\t\t},\n\t\t\thandler: async (args, ctx) => {\n\t\t\t\tconst [action, name, ...extra] = args.trim().split(/\\s+/).filter(Boolean);\n\t\t\t\tif (action === undefined) {\n\t\t\t\t\tif (ctx.mode === \"tui\") await showMcpManager(ctx, (ui) => manage(ui, ctx));\n\t\t\t\t\telse {\n\t\t\t\t\t\tawait pending;\n\t\t\t\t\t\tctx.ui.notify(formatStatus(), \"info\");\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (extra.length > 0) {\n\t\t\t\t\tctx.ui.notify(MCP_USAGE, \"warning\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait pending;\n\t\t\t\tswitch (action) {\n\t\t\t\t\tcase \"login\": {\n\t\t\t\t\t\tconst server = await pickServer(name, ctx, oauthPick);\n\t\t\t\t\t\tif (server) await loginCommand(server, ctx);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"logout\": {\n\t\t\t\t\t\tconst server = await pickServer(name, ctx, oauthPick);\n\t\t\t\t\t\tif (!server) return;\n\t\t\t\t\t\tconst removed = await signOut(server);\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\tremoved\n\t\t\t\t\t\t\t\t? `Signed out of MCP server \"${server.entry.name}\".`\n\t\t\t\t\t\t\t\t: `No stored credentials for MCP server \"${server.entry.name}\".`,\n\t\t\t\t\t\t\t\"info\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"reconnect\": {\n\t\t\t\t\t\tconst server = await pickServer(name, ctx, {\n\t\t\t\t\t\t\teligible: (candidate) => candidate.connection !== undefined,\n\t\t\t\t\t\t\tpreferred: (candidate) =>\n\t\t\t\t\t\t\t\tcandidate.connection?.state === \"failed\" || candidate.connection?.state === \"disconnected\",\n\t\t\t\t\t\t\tnone: \"No enabled MCP server to reconnect.\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!server) return;\n\t\t\t\t\t\tconst failure = await reconnect(server);\n\t\t\t\t\t\tif (failure) ctx.ui.notify(failure, \"error\");\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tensureDiscoveryActive(ctx);\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Reconnected to MCP server \"${server.entry.name}\" (${describeState(server)}).`,\n\t\t\t\t\t\t\t\t\"info\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tctx.ui.notify(MCP_USAGE, \"warning\");\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t};\n}\n\nfunction defaultLoadConfig(ctx: ExtensionContext): Promise<LoadedMcpConfig> {\n\treturn loadMcpConfigAsync({ agentDir: getAgentDir(), cwd: ctx.cwd, projectTrusted: ctx.isProjectTrusted() });\n}\n\nexport default createMcpExtension();\n"]}
|