@ashx-j/lunr 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin-extensions/ashxj-spinners.d.ts +1 -1
- package/dist/builtin-extensions/ashxj-spinners.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-spinners.js.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts +5 -5
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +3 -3
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +2 -2
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +2 -2
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/lunr-cron.d.ts +1 -1
- package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-cron.js.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/index.d.ts +1 -1
- package/dist/builtin-extensions/lunr-local-providers/index.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -1
- package/dist/builtin-extensions/lunr-plan-tools.d.ts +1 -1
- package/dist/builtin-extensions/lunr-plan-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-plan-tools.js +1 -1
- package/dist/builtin-extensions/lunr-plan-tools.js.map +1 -1
- package/dist/builtin-extensions/lunr-skill-creator/index.d.ts +1 -1
- package/dist/builtin-extensions/lunr-skill-creator/index.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-skill-creator/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-todos.d.ts +1 -1
- package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-todos.js +1 -1
- package/dist/builtin-extensions/lunr-todos.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts +2 -2
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.js +2 -2
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/compose.d.ts +2 -2
- package/dist/builtin-extensions/pi-intercom/ui/compose.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/compose.js +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/compose.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/inline-message.d.ts +2 -2
- package/dist/builtin-extensions/pi-intercom/ui/inline-message.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/inline-message.js +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/inline-message.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/session-list.d.ts +2 -2
- package/dist/builtin-extensions/pi-intercom/ui/session-list.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/session-list.js +1 -1
- package/dist/builtin-extensions/pi-intercom/ui/session-list.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.d.ts +2 -2
- package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/state.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.d.ts +2 -2
- package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/types.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/types.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/utils.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/utils.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.generated.d.ts +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.generated.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.generated.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.d.ts +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.d.ts +2 -2
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/index.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/model-selection.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/model-selection.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/model-selection.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/notifications.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/notifications.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/notifications.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.d.ts +2 -2
- package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.d.ts +2 -2
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.d.ts +3 -3
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.d.ts +2 -2
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/rpc.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/rpc.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/rpc.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +3 -3
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/fleet.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/tui/fleet.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/fleet.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/fleet.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +3 -3
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/render.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/render.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts +3 -3
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +3 -3
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -1
- package/dist/builtin-extensions/pi-tps.d.ts +1 -1
- package/dist/builtin-extensions/pi-tps.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-tps.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +2 -2
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/openai-search.d.ts +1 -1
- package/dist/builtin-extensions/pi-web-access/openai-search.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/openai-search.js +1 -1
- package/dist/builtin-extensions/pi-web-access/openai-search.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.d.ts +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/summary-review.d.ts +1 -1
- package/dist/builtin-extensions/pi-web-access/summary-review.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/summary-review.js +1 -1
- package/dist/builtin-extensions/pi-web-access/summary-review.js.map +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/register-bedrock.js +2 -2
- package/dist/bun/register-bedrock.js.map +1 -1
- package/dist/catalog/models.json +1 -1
- package/dist/catalog/providers/opencode-go.json +1 -1
- package/dist/catalog/providers/openrouter.json +1 -1
- package/dist/catalog/providers/qwen-token-plan-cn.json +1 -1
- package/dist/catalog/providers/qwen-token-plan.json +1 -1
- package/dist/catalog/publication.json +3 -3
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +2 -2
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +2 -2
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/cache-stats.d.ts +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/catalog-merge.d.ts +1 -1
- package/dist/core/catalog-merge.d.ts.map +1 -1
- package/dist/core/catalog-merge.js +7 -1
- package/dist/core/catalog-merge.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -2
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +1 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +2 -2
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/context-breakdown.d.ts +1 -1
- package/dist/core/context-breakdown.d.ts.map +1 -1
- package/dist/core/context-breakdown.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -1
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/export-html/index.d.ts +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +25 -25
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -3
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +5 -5
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/grok-cli-auth.d.ts +32 -0
- package/dist/core/grok-cli-auth.d.ts.map +1 -0
- package/dist/core/grok-cli-auth.js +218 -0
- package/dist/core/grok-cli-auth.js.map +1 -0
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/live-catalog.d.ts +1 -1
- package/dist/core/live-catalog.d.ts.map +1 -1
- package/dist/core/live-catalog.js.map +1 -1
- package/dist/core/messages.d.ts +3 -3
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +10 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +24 -5
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/official-catalog.d.ts +1 -1
- package/dist/core/official-catalog.d.ts.map +1 -1
- package/dist/core/official-catalog.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +1 -1
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-composer.d.ts +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +2 -2
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -1
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts +3 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/subscriptions.d.ts +1 -1
- package/dist/core/subscriptions.d.ts.map +1 -1
- package/dist/core/subscriptions.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +1 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +2 -2
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -1
- package/dist/core/usage-adapters/openai-codex.js.map +1 -1
- package/dist/core/usage-adapters/xai.d.ts.map +1 -1
- package/dist/core/usage-adapters/xai.js +4 -0
- package/dist/core/usage-adapters/xai.js.map +1 -1
- package/dist/core/usage-history.d.ts.map +1 -1
- package/dist/core/usage-history.js.map +1 -1
- package/dist/core/usage-service.d.ts +11 -1
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +45 -9
- package/dist/core/usage-service.js.map +1 -1
- package/dist/core/user-models.d.ts +1 -1
- package/dist/core/user-models.d.ts.map +1 -1
- package/dist/core/user-models.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +3 -3
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/commands.d.ts.map +1 -1
- package/dist/gateway/commands.js.map +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +2 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +1 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/boot-screen.d.ts +1 -1
- package/dist/modes/interactive/components/boot-screen.d.ts.map +1 -1
- package/dist/modes/interactive/components/boot-screen.js +1 -1
- package/dist/modes/interactive/components/boot-screen.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +1 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +1 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +1 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/injected-prompt-message.d.ts +1 -1
- package/dist/modes/interactive/components/injected-prompt-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/injected-prompt-message.js +1 -1
- package/dist/modes/interactive/components/injected-prompt-message.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +2 -2
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +2 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/processes-selector.d.ts +1 -1
- package/dist/modes/interactive/components/processes-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/processes-selector.js +1 -1
- package/dist/modes/interactive/components/processes-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +1 -1
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +1 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +1 -1
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +1 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +2 -2
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-summary.d.ts +1 -1
- package/dist/modes/interactive/components/thinking-summary.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-summary.js.map +1 -1
- package/dist/modes/interactive/components/thinking-tail.d.ts +1 -1
- package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-tail.js +1 -1
- package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +1 -1
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/usage-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-view.js +1 -1
- package/dist/modes/interactive/components/usage-view.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +29 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/smooth-streaming.d.ts +1 -1
- package/dist/modes/interactive/smooth-streaming.d.ts.map +1 -1
- package/dist/modes/interactive/smooth-streaming.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +2 -2
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +2 -2
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/examples/extensions/auto-commit-on-exit.ts +1 -1
- package/examples/extensions/bash-spawn-hook.ts +2 -2
- package/examples/extensions/bookmark.ts +1 -1
- package/examples/extensions/border-status-editor.ts +3 -3
- package/examples/extensions/built-in-tool-renderer.ts +3 -3
- package/examples/extensions/claude-rules.ts +1 -1
- package/examples/extensions/commands.ts +1 -1
- package/examples/extensions/confirm-destructive.ts +1 -1
- package/examples/extensions/custom-compaction.ts +3 -3
- package/examples/extensions/custom-footer.ts +3 -3
- package/examples/extensions/custom-header.ts +2 -2
- package/examples/extensions/custom-provider-anthropic/index.ts +2 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
- package/examples/extensions/dirty-repo-guard.ts +1 -1
- package/examples/extensions/doom-overlay/doom-component.ts +2 -2
- package/examples/extensions/doom-overlay/doom-keys.ts +1 -1
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/dynamic-resources/index.ts +1 -1
- package/examples/extensions/dynamic-tools.ts +1 -1
- package/examples/extensions/entry-renderer.ts +2 -2
- package/examples/extensions/event-bus.ts +1 -1
- package/examples/extensions/file-trigger.ts +1 -1
- package/examples/extensions/git-checkpoint.ts +1 -1
- package/examples/extensions/git-merge-and-resolve.ts +1 -1
- package/examples/extensions/github-issue-autocomplete.ts +2 -2
- package/examples/extensions/gondolin/index.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +4 -4
- package/examples/extensions/hello.ts +2 -2
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/inline-bash.ts +1 -1
- package/examples/extensions/input-transform-streaming.ts +1 -1
- package/examples/extensions/input-transform.ts +1 -1
- package/examples/extensions/interactive-shell.ts +1 -1
- package/examples/extensions/kimi-deferred-tools.ts +1 -1
- package/examples/extensions/mac-system-theme.ts +1 -1
- package/examples/extensions/message-renderer.ts +2 -2
- package/examples/extensions/minimal-mode.ts +3 -3
- package/examples/extensions/modal-editor.ts +2 -2
- package/examples/extensions/model-status.ts +1 -1
- package/examples/extensions/notify.ts +1 -1
- package/examples/extensions/overlay-qa-tests.ts +3 -3
- package/examples/extensions/overlay-test.ts +2 -2
- package/examples/extensions/permission-gate.ts +1 -1
- package/examples/extensions/pirate.ts +1 -1
- package/examples/extensions/plan-mode/index.ts +4 -4
- package/examples/extensions/preset.ts +4 -4
- package/examples/extensions/project-trust.ts +1 -1
- package/examples/extensions/prompt-customizer.ts +1 -1
- package/examples/extensions/protected-paths.ts +1 -1
- package/examples/extensions/provider-payload.ts +1 -1
- package/examples/extensions/qna.ts +3 -3
- package/examples/extensions/question.ts +2 -2
- package/examples/extensions/questionnaire.ts +2 -2
- package/examples/extensions/rainbow-editor.ts +1 -1
- package/examples/extensions/reload-runtime.ts +1 -1
- package/examples/extensions/rpc-demo.ts +1 -1
- package/examples/extensions/sandbox/index.ts +2 -2
- package/examples/extensions/send-user-message.ts +1 -1
- package/examples/extensions/session-name.ts +1 -1
- package/examples/extensions/shutdown-command.ts +1 -1
- package/examples/extensions/snake.ts +2 -2
- package/examples/extensions/space-invaders.ts +2 -2
- package/examples/extensions/ssh.ts +2 -2
- package/examples/extensions/status-line.ts +1 -1
- package/examples/extensions/structured-output.ts +2 -2
- package/examples/extensions/subagent/agents.ts +1 -1
- package/examples/extensions/subagent/index.ts +5 -5
- package/examples/extensions/summarize.ts +4 -4
- package/examples/extensions/system-prompt-header.ts +1 -1
- package/examples/extensions/tic-tac-toe.ts +3 -3
- package/examples/extensions/timed-confirm.ts +1 -1
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/todo.ts +3 -3
- package/examples/extensions/tool-override.ts +2 -2
- package/examples/extensions/tools.ts +3 -3
- package/examples/extensions/trigger-compact.ts +1 -1
- package/examples/extensions/truncated-tool.ts +3 -3
- package/examples/extensions/widget-placement.ts +1 -1
- package/examples/extensions/with-deps/index.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/working-indicator.ts +1 -1
- package/examples/extensions/working-message-test.ts +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/01-minimal.ts +1 -1
- package/examples/sdk/02-custom-model.ts +2 -2
- package/examples/sdk/03-custom-prompt.ts +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/examples/sdk/05-tools.ts +1 -1
- package/examples/sdk/06-extensions.ts +2 -2
- package/examples/sdk/07-context-files.ts +1 -1
- package/examples/sdk/08-prompt-templates.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
- package/examples/sdk/10-settings.ts +1 -1
- package/examples/sdk/11-sessions.ts +1 -1
- package/examples/sdk/12-full-control.ts +2 -2
- package/examples/sdk/13-session-runtime.ts +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-modes.d.ts","sourceRoot":"","sources":["../../../src/builtin-extensions/pi-mcp-adapter/proxy-modes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAA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E,WAAW,GACnB,OAAO,CAAC,eAAe,CAAC,CAyW1B","sourcesContent":["// @ts-nocheck\nimport type { AgentToolResult, ToolInfo } from \"@earendil-works/pi-coding-agent\";\nimport { UrlElicitationRequiredError } from \"@modelcontextprotocol/sdk/types.js\";\nimport { checkSync } from \"recheck\";\nimport type { McpExtensionState } from \"./state.ts\";\nimport type { ToolMetadata, McpContent } from \"./types.ts\";\nimport { getServerPrefix, parseUiPromptHandoff } from \"./types.ts\";\nimport { lazyConnect, updateServerMetadata, updateMetadataCache, getFailureAgeSeconds, updateStatusBar } from \"./init.ts\";\nimport { abortable, throwIfAborted } from \"./abort.ts\";\nimport { buildToolMetadata, getToolNames, findToolByName, formatSchema } from \"./tool-metadata.ts\";\nimport { resolveMcpResultContent, transformMcpContent } from \"./tool-registrar.ts\";\nimport { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from \"./mcp-output-guard.ts\";\nimport { maybeStartUiSession, type UiSessionRuntime } from \"./ui-session.ts\";\nimport { formatAuthRequiredMessage, truncateAtWord } from \"./utils.ts\";\nimport { authenticate, completeAuthFromInput, startAuth, supportsOAuth } from \"./mcp-auth-flow.ts\";\n\ntype ProxyToolResult = AgentToolResult<Record<string, unknown>>;\n\nconst MAX_REGEX_SEARCH_QUERY_LENGTH = 256;\nconst REGEX_SAFETY_CHECK_PARAMS = {\n attackTimeout: 50,\n incubationTimeout: 50,\n timeout: 250,\n} as const;\n\ntype AutoAuthResult =\n | { status: \"skipped\" }\n | { status: \"success\" }\n | { status: \"failed\"; message: string };\n\nfunction getAuthRequiredMessage(\n state: McpExtensionState,\n serverName: string,\n defaultMessage = `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n): string {\n return formatAuthRequiredMessage(state.config, serverName, defaultMessage);\n}\n\nfunction getAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {\n const customGuidance = state.config.settings?.authRequiredMessage;\n if (customGuidance) {\n return `OAuth authentication failed for \"${serverName}\": ${message}. ${getAuthRequiredMessage(state, serverName)}`;\n }\n return `OAuth authentication failed for \"${serverName}\": ${message}. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;\n}\n\nfunction getRedirectPort(authorizationUrl: string): number | undefined {\n try {\n const redirectUri = new URL(authorizationUrl).searchParams.get(\"redirect_uri\");\n if (!redirectUri) return undefined;\n const port = Number.parseInt(new URL(redirectUri).port, 10);\n return Number.isInteger(port) ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction formatManualAuthInstructions(serverName: string, authorizationUrl: string): string {\n const port = getRedirectPort(authorizationUrl);\n const portNote = port\n ? `\\nThe redirect URL will use local port ${port}. On a remote server it is expected for that localhost page to fail locally; copy the address bar URL anyway.`\n : \"\";\n\n return [\n `MCP OAuth required for \"${serverName}\".`,\n \"\",\n \"Open this URL in your local browser:\",\n \"\",\n authorizationUrl,\n \"\",\n \"After approving, copy the full redirected localhost URL from your browser address bar and send it back with:\",\n `mcp({ action: \"auth-complete\", server: \"${serverName}\", args: '{\"redirectUrl\":\"PASTE_REDIRECT_URL_HERE\"}' })`,\n \"\",\n \"You can also pass just the `code` query parameter as `args: '{\\\"code\\\":\\\"PASTE_CODE_HERE\\\"}'`.\",\n portNote.trimEnd(),\n ].filter(Boolean).join(\"\\n\");\n}\n\nasync function attemptAutoAuth(\n state: McpExtensionState,\n serverName: string,\n): Promise<AutoAuthResult> {\n if (state.config.settings?.autoAuth !== true) {\n return { status: \"skipped\" };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition || !supportsOAuth(definition) || !definition.url) {\n return { status: \"skipped\" };\n }\n\n const grantType = definition.oauth ? definition.oauth.grantType ?? \"authorization_code\" : \"authorization_code\";\n if (!state.ui && grantType !== \"client_credentials\") {\n return {\n status: \"failed\",\n message: getAuthRequiredMessage(\n state,\n serverName,\n `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n ),\n };\n }\n\n try {\n await authenticate(serverName, definition.url, definition);\n return { status: \"success\" };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n message: getAuthFailedMessage(state, serverName, message),\n };\n }\n}\n\nexport function executeUiMessages(state: McpExtensionState): ProxyToolResult {\n const sessions = state.completedUiSessions;\n\n if (sessions.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"No UI session messages available.\" }],\n details: { sessions: 0 },\n };\n }\n\n const output: string[] = [];\n output.push(`UI Session Messages (${sessions.length} session${sessions.length > 1 ? \"s\" : \"\"}):\\n`);\n\n const allPrompts: string[] = [];\n const allIntents = sessions.flatMap((session) => session.messages.intents);\n const parsedHandoffs: Array<{ intent: string; params: Record<string, unknown>; raw: string }> = [];\n\n for (const session of sessions) {\n const timestamp = session.completedAt.toLocaleTimeString();\n output.push(`\\n## ${session.serverName} / ${session.toolName} (${timestamp}, ${session.reason})`);\n\n const plainPrompts: string[] = [];\n for (const prompt of session.messages.prompts) {\n allPrompts.push(prompt);\n const handoff = parseUiPromptHandoff(prompt);\n if (handoff) {\n parsedHandoffs.push(handoff);\n } else {\n plainPrompts.push(prompt);\n }\n }\n\n if (plainPrompts.length > 0) {\n output.push(\"\\n### Prompts:\");\n for (const prompt of plainPrompts) {\n output.push(`- ${prompt}`);\n }\n }\n\n const intentsForSession = [\n ...session.messages.intents,\n ...session.messages.prompts\n .map((prompt) => parseUiPromptHandoff(prompt))\n .filter((handoff): handoff is NonNullable<typeof handoff> => !!handoff)\n .map((handoff) => ({ intent: handoff.intent, params: handoff.params })),\n ];\n\n if (intentsForSession.length > 0) {\n output.push(\"\\n### Intents:\");\n for (const intent of intentsForSession) {\n const params = intent.params ? ` (${JSON.stringify(intent.params)})` : \"\";\n output.push(`- ${intent.intent}${params}`);\n }\n }\n\n if (session.messages.notifications.length > 0) {\n output.push(\"\\n### Notifications:\");\n for (const notification of session.messages.notifications) {\n output.push(`- ${notification}`);\n }\n }\n }\n\n const count = sessions.length;\n state.completedUiSessions = [];\n\n return {\n content: [{ type: \"text\" as const, text: output.join(\"\\n\") }],\n details: {\n sessions: count,\n prompts: allPrompts,\n intents: [...allIntents, ...parsedHandoffs.map(({ intent, params }) => ({ intent, params }))],\n handoffs: parsedHandoffs,\n cleared: true,\n },\n };\n}\n\nexport function executeStatus(state: McpExtensionState): ProxyToolResult {\n const servers: Array<{ name: string; status: string; toolCount: number; failedAgo: number | null }> = [];\n\n for (const name of Object.keys(state.config.mcpServers)) {\n const connection = state.manager.getConnection(name);\n const metadata = state.toolMetadata.get(name);\n const toolCount = metadata?.length ?? 0;\n const failedAgo = getFailureAgeSeconds(state, name);\n let status = \"not connected\";\n if (connection?.status === \"connected\") {\n status = \"connected\";\n } else if (connection?.status === \"needs-auth\") {\n status = \"needs-auth\";\n } else if (failedAgo !== null) {\n status = \"failed\";\n } else if (metadata !== undefined) {\n status = \"cached\";\n }\n\n servers.push({ name, status, toolCount, failedAgo });\n }\n\n const totalTools = servers.reduce((sum, s) => sum + s.toolCount, 0);\n const connectedCount = servers.filter(s => s.status === \"connected\").length;\n\n let text = `MCP: ${connectedCount}/${servers.length} servers, ${totalTools} tools\\n\\n`;\n for (const server of servers) {\n if (server.status === \"connected\") {\n text += `✓ ${server.name} (${server.toolCount} tools)\\n`;\n continue;\n }\n if (server.status === \"needs-auth\") {\n text += `⚠ ${server.name} (needs auth)\\n`;\n continue;\n }\n if (server.status === \"cached\") {\n text += `○ ${server.name} (${server.toolCount} tools, cached)\\n`;\n continue;\n }\n if (server.status === \"failed\") {\n text += `✗ ${server.name} (failed ${server.failedAgo ?? 0}s ago)\\n`;\n continue;\n }\n text += `○ ${server.name} (not connected)\\n`;\n }\n\n if (servers.length > 0) {\n text += `\\nmcp({ server: \"name\" }) to list tools, mcp({ search: \"...\" }) to search`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"status\", servers, totalTools, connectedCount },\n };\n}\n\nexport async function executeAuthStart(state: McpExtensionState, serverName: string): Promise<ProxyToolResult> {\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-start\", error: \"not_found\", server: serverName },\n };\n }\n\n if (!definition.url || !supportsOAuth(definition)) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" is not configured for OAuth over HTTP.` }],\n details: { mode: \"auth-start\", error: \"oauth_not_supported\", server: serverName },\n };\n }\n\n try {\n const { authorizationUrl } = await startAuth(serverName, definition.url, definition);\n if (!authorizationUrl) {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\".` }],\n details: { mode: \"auth-start\", server: serverName, authenticated: true },\n };\n }\n\n return {\n content: [{ type: \"text\" as const, text: formatManualAuthInstructions(serverName, authorizationUrl) }],\n details: { mode: \"auth-start\", server: serverName, authorizationUrl },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to start OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-start\", error: \"auth_start_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeAuthComplete(state: McpExtensionState, serverName: string, input: string): Promise<ProxyToolResult> {\n if (!state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-complete\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n const status = await completeAuthFromInput(serverName, input);\n if (status !== \"authenticated\") {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication did not complete for \"${serverName}\".` }],\n details: { mode: \"auth-complete\", error: \"not_authenticated\", server: serverName, status },\n };\n }\n\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\". Run mcp({ connect: \"${serverName}\" }) to connect with the new token.` }],\n details: { mode: \"auth-complete\", server: serverName, authenticated: true },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to complete OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-complete\", error: \"auth_complete_failed\", server: serverName, message },\n };\n }\n}\n\nexport function executeDescribe(state: McpExtensionState, toolName: string): ProxyToolResult {\n let serverName: string | undefined;\n let toolMeta: ToolMetadata | undefined;\n\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n\n if (!serverName || !toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found. Use mcp({ search: \"...\" }) to search.` }],\n details: { mode: \"describe\", error: \"tool_not_found\", requestedTool: toolName },\n };\n }\n\n let text = `${toolMeta.name}\\n`;\n text += `Server: ${serverName}\\n`;\n if (toolMeta.resourceUri) {\n text += `Type: Resource (reads from ${toolMeta.resourceUri})\\n`;\n }\n text += `\\n${toolMeta.description || \"(no description)\"}\\n`;\n\n if (toolMeta.inputSchema && !toolMeta.resourceUri) {\n text += `\\nParameters:\\n${formatSchema(toolMeta.inputSchema)}`;\n } else if (toolMeta.resourceUri) {\n text += `\\nNo parameters required (resource tool).`;\n } else {\n text += `\\nNo parameters defined.`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"describe\", tool: toolMeta, server: serverName },\n };\n}\n\nexport function executeSearch(\n state: McpExtensionState,\n query: string,\n regex?: boolean,\n server?: string,\n includeSchemas?: boolean,\n): ProxyToolResult {\n const showSchemas = includeSchemas !== false;\n\n const matches: Array<{ server: string; tool: ToolMetadata }> = [];\n\n let pattern: RegExp;\n try {\n if (regex) {\n if (query.length > MAX_REGEX_SEARCH_QUERY_LENGTH) {\n return {\n content: [{ type: \"text\" as const, text: `Regex query is too long; maximum length is ${MAX_REGEX_SEARCH_QUERY_LENGTH} characters.` }],\n details: { mode: \"search\", error: \"query_too_long\", query, maxLength: MAX_REGEX_SEARCH_QUERY_LENGTH },\n };\n }\n\n pattern = new RegExp(query, \"i\");\n let safety;\n try {\n safety = checkSync(query, \"i\", REGEX_SAFETY_CHECK_PARAMS);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: \"Regex query rejected because safety analysis failed.\" }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, reason: message },\n };\n }\n if (safety.status !== \"safe\") {\n return {\n content: [{ type: \"text\" as const, text: `Regex query rejected as unsafe (${safety.status}).` }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, safetyStatus: safety.status },\n };\n }\n } else {\n const terms = query.trim().split(/\\s+/).filter(t => t.length > 0);\n if (terms.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"Search query cannot be empty\" }],\n details: { mode: \"search\", error: \"empty_query\" },\n };\n }\n const escaped = terms.map(t => t.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\n pattern = new RegExp(escaped.join(\"|\"), \"i\");\n }\n } catch {\n return {\n content: [{ type: \"text\" as const, text: `Invalid regex: ${query}` }],\n details: { mode: \"search\", error: \"invalid_pattern\", query },\n };\n }\n\n for (const [serverName, metadata] of state.toolMetadata.entries()) {\n if (server && serverName !== server) continue;\n for (const tool of metadata) {\n if (pattern.test(tool.name) || pattern.test(tool.description)) {\n matches.push({\n server: serverName,\n tool,\n });\n }\n }\n }\n\n const totalCount = matches.length;\n\n if (totalCount === 0) {\n const msg = server\n ? `No tools matching \"${query}\" in \"${server}\"`\n : `No tools matching \"${query}\"`;\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"search\", matches: [], count: 0, query },\n };\n }\n\n let text = `Found ${totalCount} tool${totalCount === 1 ? \"\" : \"s\"} matching \"${query}\":\\n\\n`;\n\n for (const match of matches) {\n if (showSchemas) {\n text += `${match.tool.name}\\n`;\n text += ` ${match.tool.description || \"(no description)\"}\\n`;\n if (match.tool.inputSchema && !match.tool.resourceUri) {\n text += `\\n Parameters:\\n${formatSchema(match.tool.inputSchema, \" \")}\\n`;\n } else if (match.tool.resourceUri) {\n text += ` No parameters (resource tool).\\n`;\n }\n text += \"\\n\";\n } else {\n text += `- ${match.tool.name}`;\n if (match.tool.description) {\n text += ` - ${truncateAtWord(match.tool.description, 50)}`;\n }\n text += \"\\n\";\n }\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: {\n mode: \"search\",\n matches: matches.map(m => ({ server: m.server, tool: m.tool.name })),\n count: totalCount,\n query,\n },\n };\n}\n\nexport function executeList(state: McpExtensionState, server: string): ProxyToolResult {\n if (!state.config.mcpServers[server]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_found\" },\n };\n }\n\n const metadata = state.toolMetadata.get(server);\n const toolNames = metadata?.map(m => m.name) ?? [];\n const connection = state.manager.getConnection(server);\n\n if (toolNames.length === 0) {\n if (connection?.status === \"connected\") {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no tools.` }],\n details: { mode: \"list\", server, tools: [], count: 0 },\n };\n }\n if (metadata !== undefined) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no cached tools (not connected).` }],\n details: { mode: \"list\", server, tools: [], count: 0, cached: true },\n };\n }\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" is configured but not connected. Use mcp({ connect: \"${server}\" }) or /mcp reconnect ${server} to retry.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_connected\" },\n };\n }\n\n const cachedNote = connection?.status === \"connected\" ? \"\" : \" (not connected, cached)\";\n let text = `${server} (${toolNames.length} tools${cachedNote}):\\n\\n`;\n\n const descMap = new Map<string, string>();\n if (metadata) {\n for (const m of metadata) {\n descMap.set(m.name, m.description);\n }\n }\n\n for (const tool of toolNames) {\n const desc = descMap.get(tool) ?? \"\";\n const truncated = truncateAtWord(desc, 50);\n text += `- ${tool}`;\n if (truncated) text += ` - ${truncated}`;\n text += \"\\n\";\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"list\", server, tools: toolNames, count: toolNames.length },\n };\n}\n\nexport async function executeConnect(state: McpExtensionState, serverName: string, signal?: AbortSignal): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"connect\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n let connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n const prefix = state.config.settings?.toolPrefix ?? \"server\";\n const { metadata } = buildToolMetadata(connection.tools, connection.resources, definition, serverName, prefix);\n state.toolMetadata.set(serverName, metadata);\n updateMetadataCache(state, serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return executeList(state, serverName);\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"connect\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeCall(\n state: McpExtensionState,\n toolName: string,\n args?: Record<string, unknown>,\n serverOverride?: string,\n getPiTools?: () => ToolInfo[],\n signal?: AbortSignal,\n): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n let serverName: string | undefined = serverOverride;\n let toolMeta: ToolMetadata | undefined;\n let autoAuthAttempted = false;\n const prefixMode = state.config.settings?.toolPrefix ?? \"server\";\n\n if (serverName && !state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"call\", error: \"server_not_found\", server: serverName },\n };\n }\n\n if (serverName) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n }\n\n if (serverName && !toolMeta) {\n const connected = await lazyConnect(state, serverName, signal);\n if (connected) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n const needsAuthConnection = state.manager.getConnection(serverName);\n if (needsAuthConnection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n const connectedAfterAuth = await lazyConnect(state, serverName, signal);\n if (connectedAfterAuth) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect.` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n }\n }\n }\n\n if (!toolMeta && state.manager.getConnection(serverName)?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n\n if (!toolMeta) {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n }\n }\n }\n\n let prefixMatchedServer: string | undefined;\n\n if (!serverName && !toolMeta && prefixMode !== \"none\") {\n const candidates = Object.keys(state.config.mcpServers)\n .map(name => ({ name, prefix: getServerPrefix(name, prefixMode) }))\n .filter(c => c.prefix && toolName.startsWith(c.prefix + \"_\"))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n\n for (const { name: configuredServer } of candidates) {\n const existingConnection = state.manager.getConnection(configuredServer);\n const failedAgo = getFailureAgeSeconds(state, configuredServer);\n if (failedAgo !== null && existingConnection?.status !== \"needs-auth\") continue;\n\n let connected = await lazyConnect(state, configuredServer, signal);\n if (!connected && state.manager.getConnection(configuredServer)?.status === \"needs-auth\" && !autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, configuredServer);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: configuredServer, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(configuredServer);\n state.failureTracker.delete(configuredServer);\n connected = await lazyConnect(state, configuredServer, signal);\n }\n }\n\n if (!connected) continue;\n if (!prefixMatchedServer) prefixMatchedServer = configuredServer;\n toolMeta = findToolByName(state.toolMetadata.get(configuredServer), toolName);\n if (toolMeta) {\n serverName = configuredServer;\n break;\n }\n }\n }\n\n if (!serverName || !toolMeta) {\n const nativeTool = !serverOverride\n ? getPiTools?.().find((tool) => tool.name === toolName && tool.name !== \"mcp\")\n : undefined;\n if (nativeTool) {\n return {\n content: [{ type: \"text\" as const, text: `\"${toolName}\" is a native Pi tool. Call ${toolName} directly instead of using mcp({ tool: \"${toolName}\" }).` }],\n details: { mode: \"call\", error: \"native_tool\", requestedTool: toolName },\n };\n }\n\n const hintServer = serverName ?? prefixMatchedServer;\n const available = hintServer ? getToolNames(state, hintServer) : [];\n let msg = `Tool \"${toolName}\" not found.`;\n if (available.length > 0) {\n msg += ` Server \"${hintServer}\" has: ${available.join(\", \")}`;\n } else {\n msg += ` Use mcp({ search: \"...\" }) to search.`;\n }\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"call\", error: \"tool_not_found\", requestedTool: toolName, hintServer },\n };\n }\n\n let connection = state.manager.getConnection(serverName);\n if (connection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n connection = state.manager.getConnection(serverName);\n }\n }\n\n if (connection?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n if (!connection || connection.status !== \"connected\") {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not connected` }],\n details: { mode: \"call\", error: \"server_not_connected\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n }\n\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n state.failureTracker.delete(serverName);\n updateServerMetadata(state, serverName);\n updateMetadataCache(state, serverName);\n updateStatusBar(state);\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n const available = getToolNames(state, serverName);\n const hint = available.length > 0\n ? `Available tools on \"${serverName}\": ${available.join(\", \")}`\n : `Server \"${serverName}\" has no tools.`;\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect. ${hint}` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"call\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", message },\n };\n }\n }\n\n let uiSession: UiSessionRuntime | null = null;\n const requestOptions = state.manager.getRequestOptions?.(serverName, signal) ?? (signal ? { signal } : undefined);\n\n const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);\n\n try {\n state.manager.touch(serverName);\n state.manager.incrementInFlight(serverName);\n\n if (toolMeta.resourceUri) {\n const result = await connection.client.readResource({ uri: toolMeta.resourceUri }, requestOptions);\n const content = (result.contents ?? []).map(c => ({\n type: \"text\" as const,\n text: \"text\" in c ? c.text : (\"blob\" in c ? `[Binary data: ${(c as { mimeType?: string }).mimeType ?? \"unknown\"}]` : JSON.stringify(c)),\n }));\n const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty resource)\" }], outputGuardOptions);\n return {\n content: guarded.content,\n details: { mode: \"call\", resourceUri: toolMeta.resourceUri, server: serverName, ...guardedMcpDetails(guarded) },\n };\n }\n\n uiSession = toolMeta.uiResourceUri\n ? await maybeStartUiSession(state, {\n serverName,\n toolName: toolMeta.originalName,\n toolArgs: args ?? {},\n uiResourceUri: toolMeta.uiResourceUri,\n streamMode: toolMeta.uiStreamMode,\n })\n : null;\n\n const resultPromise = connection.client.callTool({\n name: toolMeta.originalName,\n arguments: args ?? {},\n _meta: uiSession?.requestMeta,\n }, undefined, requestOptions);\n\n if (toolMeta.uiResourceUri) {\n const result = await abortable(resultPromise, signal);\n uiSession?.sendToolResult(result as unknown as import(\"@modelcontextprotocol/sdk/types.js\").CallToolResult);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const uiMessage = uiSession?.reused\n ? \"Updated the open UI.\"\n : \"📺 Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `\\n\\n${uiMessage}`, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName, uiOpen: true },\n };\n }\n\n const result = await abortable(resultPromise, signal);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName },\n };\n } catch (error) {\n if (error instanceof UrlElicitationRequiredError) {\n const action = await state.manager.handleUrlElicitationRequired(serverName, error);\n const message = action === \"accept\"\n ? \"The original MCP tool did not run. Complete the opened browser interaction, then retry the tool.\"\n : `The URL interaction was ${action === \"decline\" ? \"declined\" : \"cancelled\"}.`;\n uiSession?.sendToolCancelled(message);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"url_elicitation_required\", server: serverName, action },\n };\n }\n const message = error instanceof Error ? error.message : String(error);\n uiSession?.sendToolCancelled(message);\n\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput([{ type: \"text\" as const, text: message }], { ...outputGuardOptions, prefix: \"Failed to call tool: \", suffix: schemaText });\n\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"call_failed\", message: guarded.outputGuard ? \"output truncated; see outputGuard.fullOutputPath\" : message, ...guardedMcpDetails(guarded) },\n };\n } finally {\n if (uiSession?.reused) {\n uiSession.close();\n }\n state.manager.decrementInFlight(serverName);\n state.manager.touch(serverName);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"proxy-modes.d.ts","sourceRoot":"","sources":["../../../src/builtin-extensions/pi-mcp-adapter/proxy-modes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAYpD,KAAK,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAmGhE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,CA4E3E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,CAsDvE;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAoC7G;AAED,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA+B/H;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAuC3F;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,OAAO,GACvB,eAAe,CAwGjB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAqDrF;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAqDjI;AAED,wBAAsB,WAAW,CAC/B,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,cAAc,CAAC,EAAE,MAAM,EACvB,UAAU,CAAC,EAAE,MAAM,QAAQ,EAAE,EAC7B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,eAAe,CAAC,CAyW1B","sourcesContent":["// @ts-nocheck\nimport type { AgentToolResult, ToolInfo } from \"@ashx-j/lunr\";\nimport { UrlElicitationRequiredError } from \"@modelcontextprotocol/sdk/types.js\";\nimport { checkSync } from \"recheck\";\nimport type { McpExtensionState } from \"./state.ts\";\nimport type { ToolMetadata, McpContent } from \"./types.ts\";\nimport { getServerPrefix, parseUiPromptHandoff } from \"./types.ts\";\nimport { lazyConnect, updateServerMetadata, updateMetadataCache, getFailureAgeSeconds, updateStatusBar } from \"./init.ts\";\nimport { abortable, throwIfAborted } from \"./abort.ts\";\nimport { buildToolMetadata, getToolNames, findToolByName, formatSchema } from \"./tool-metadata.ts\";\nimport { resolveMcpResultContent, transformMcpContent } from \"./tool-registrar.ts\";\nimport { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from \"./mcp-output-guard.ts\";\nimport { maybeStartUiSession, type UiSessionRuntime } from \"./ui-session.ts\";\nimport { formatAuthRequiredMessage, truncateAtWord } from \"./utils.ts\";\nimport { authenticate, completeAuthFromInput, startAuth, supportsOAuth } from \"./mcp-auth-flow.ts\";\n\ntype ProxyToolResult = AgentToolResult<Record<string, unknown>>;\n\nconst MAX_REGEX_SEARCH_QUERY_LENGTH = 256;\nconst REGEX_SAFETY_CHECK_PARAMS = {\n attackTimeout: 50,\n incubationTimeout: 50,\n timeout: 250,\n} as const;\n\ntype AutoAuthResult =\n | { status: \"skipped\" }\n | { status: \"success\" }\n | { status: \"failed\"; message: string };\n\nfunction getAuthRequiredMessage(\n state: McpExtensionState,\n serverName: string,\n defaultMessage = `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n): string {\n return formatAuthRequiredMessage(state.config, serverName, defaultMessage);\n}\n\nfunction getAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {\n const customGuidance = state.config.settings?.authRequiredMessage;\n if (customGuidance) {\n return `OAuth authentication failed for \"${serverName}\": ${message}. ${getAuthRequiredMessage(state, serverName)}`;\n }\n return `OAuth authentication failed for \"${serverName}\": ${message}. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;\n}\n\nfunction getRedirectPort(authorizationUrl: string): number | undefined {\n try {\n const redirectUri = new URL(authorizationUrl).searchParams.get(\"redirect_uri\");\n if (!redirectUri) return undefined;\n const port = Number.parseInt(new URL(redirectUri).port, 10);\n return Number.isInteger(port) ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction formatManualAuthInstructions(serverName: string, authorizationUrl: string): string {\n const port = getRedirectPort(authorizationUrl);\n const portNote = port\n ? `\\nThe redirect URL will use local port ${port}. On a remote server it is expected for that localhost page to fail locally; copy the address bar URL anyway.`\n : \"\";\n\n return [\n `MCP OAuth required for \"${serverName}\".`,\n \"\",\n \"Open this URL in your local browser:\",\n \"\",\n authorizationUrl,\n \"\",\n \"After approving, copy the full redirected localhost URL from your browser address bar and send it back with:\",\n `mcp({ action: \"auth-complete\", server: \"${serverName}\", args: '{\"redirectUrl\":\"PASTE_REDIRECT_URL_HERE\"}' })`,\n \"\",\n \"You can also pass just the `code` query parameter as `args: '{\\\"code\\\":\\\"PASTE_CODE_HERE\\\"}'`.\",\n portNote.trimEnd(),\n ].filter(Boolean).join(\"\\n\");\n}\n\nasync function attemptAutoAuth(\n state: McpExtensionState,\n serverName: string,\n): Promise<AutoAuthResult> {\n if (state.config.settings?.autoAuth !== true) {\n return { status: \"skipped\" };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition || !supportsOAuth(definition) || !definition.url) {\n return { status: \"skipped\" };\n }\n\n const grantType = definition.oauth ? definition.oauth.grantType ?? \"authorization_code\" : \"authorization_code\";\n if (!state.ui && grantType !== \"client_credentials\") {\n return {\n status: \"failed\",\n message: getAuthRequiredMessage(\n state,\n serverName,\n `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n ),\n };\n }\n\n try {\n await authenticate(serverName, definition.url, definition);\n return { status: \"success\" };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n message: getAuthFailedMessage(state, serverName, message),\n };\n }\n}\n\nexport function executeUiMessages(state: McpExtensionState): ProxyToolResult {\n const sessions = state.completedUiSessions;\n\n if (sessions.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"No UI session messages available.\" }],\n details: { sessions: 0 },\n };\n }\n\n const output: string[] = [];\n output.push(`UI Session Messages (${sessions.length} session${sessions.length > 1 ? \"s\" : \"\"}):\\n`);\n\n const allPrompts: string[] = [];\n const allIntents = sessions.flatMap((session) => session.messages.intents);\n const parsedHandoffs: Array<{ intent: string; params: Record<string, unknown>; raw: string }> = [];\n\n for (const session of sessions) {\n const timestamp = session.completedAt.toLocaleTimeString();\n output.push(`\\n## ${session.serverName} / ${session.toolName} (${timestamp}, ${session.reason})`);\n\n const plainPrompts: string[] = [];\n for (const prompt of session.messages.prompts) {\n allPrompts.push(prompt);\n const handoff = parseUiPromptHandoff(prompt);\n if (handoff) {\n parsedHandoffs.push(handoff);\n } else {\n plainPrompts.push(prompt);\n }\n }\n\n if (plainPrompts.length > 0) {\n output.push(\"\\n### Prompts:\");\n for (const prompt of plainPrompts) {\n output.push(`- ${prompt}`);\n }\n }\n\n const intentsForSession = [\n ...session.messages.intents,\n ...session.messages.prompts\n .map((prompt) => parseUiPromptHandoff(prompt))\n .filter((handoff): handoff is NonNullable<typeof handoff> => !!handoff)\n .map((handoff) => ({ intent: handoff.intent, params: handoff.params })),\n ];\n\n if (intentsForSession.length > 0) {\n output.push(\"\\n### Intents:\");\n for (const intent of intentsForSession) {\n const params = intent.params ? ` (${JSON.stringify(intent.params)})` : \"\";\n output.push(`- ${intent.intent}${params}`);\n }\n }\n\n if (session.messages.notifications.length > 0) {\n output.push(\"\\n### Notifications:\");\n for (const notification of session.messages.notifications) {\n output.push(`- ${notification}`);\n }\n }\n }\n\n const count = sessions.length;\n state.completedUiSessions = [];\n\n return {\n content: [{ type: \"text\" as const, text: output.join(\"\\n\") }],\n details: {\n sessions: count,\n prompts: allPrompts,\n intents: [...allIntents, ...parsedHandoffs.map(({ intent, params }) => ({ intent, params }))],\n handoffs: parsedHandoffs,\n cleared: true,\n },\n };\n}\n\nexport function executeStatus(state: McpExtensionState): ProxyToolResult {\n const servers: Array<{ name: string; status: string; toolCount: number; failedAgo: number | null }> = [];\n\n for (const name of Object.keys(state.config.mcpServers)) {\n const connection = state.manager.getConnection(name);\n const metadata = state.toolMetadata.get(name);\n const toolCount = metadata?.length ?? 0;\n const failedAgo = getFailureAgeSeconds(state, name);\n let status = \"not connected\";\n if (connection?.status === \"connected\") {\n status = \"connected\";\n } else if (connection?.status === \"needs-auth\") {\n status = \"needs-auth\";\n } else if (failedAgo !== null) {\n status = \"failed\";\n } else if (metadata !== undefined) {\n status = \"cached\";\n }\n\n servers.push({ name, status, toolCount, failedAgo });\n }\n\n const totalTools = servers.reduce((sum, s) => sum + s.toolCount, 0);\n const connectedCount = servers.filter(s => s.status === \"connected\").length;\n\n let text = `MCP: ${connectedCount}/${servers.length} servers, ${totalTools} tools\\n\\n`;\n for (const server of servers) {\n if (server.status === \"connected\") {\n text += `✓ ${server.name} (${server.toolCount} tools)\\n`;\n continue;\n }\n if (server.status === \"needs-auth\") {\n text += `⚠ ${server.name} (needs auth)\\n`;\n continue;\n }\n if (server.status === \"cached\") {\n text += `○ ${server.name} (${server.toolCount} tools, cached)\\n`;\n continue;\n }\n if (server.status === \"failed\") {\n text += `✗ ${server.name} (failed ${server.failedAgo ?? 0}s ago)\\n`;\n continue;\n }\n text += `○ ${server.name} (not connected)\\n`;\n }\n\n if (servers.length > 0) {\n text += `\\nmcp({ server: \"name\" }) to list tools, mcp({ search: \"...\" }) to search`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"status\", servers, totalTools, connectedCount },\n };\n}\n\nexport async function executeAuthStart(state: McpExtensionState, serverName: string): Promise<ProxyToolResult> {\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-start\", error: \"not_found\", server: serverName },\n };\n }\n\n if (!definition.url || !supportsOAuth(definition)) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" is not configured for OAuth over HTTP.` }],\n details: { mode: \"auth-start\", error: \"oauth_not_supported\", server: serverName },\n };\n }\n\n try {\n const { authorizationUrl } = await startAuth(serverName, definition.url, definition);\n if (!authorizationUrl) {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\".` }],\n details: { mode: \"auth-start\", server: serverName, authenticated: true },\n };\n }\n\n return {\n content: [{ type: \"text\" as const, text: formatManualAuthInstructions(serverName, authorizationUrl) }],\n details: { mode: \"auth-start\", server: serverName, authorizationUrl },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to start OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-start\", error: \"auth_start_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeAuthComplete(state: McpExtensionState, serverName: string, input: string): Promise<ProxyToolResult> {\n if (!state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-complete\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n const status = await completeAuthFromInput(serverName, input);\n if (status !== \"authenticated\") {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication did not complete for \"${serverName}\".` }],\n details: { mode: \"auth-complete\", error: \"not_authenticated\", server: serverName, status },\n };\n }\n\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\". Run mcp({ connect: \"${serverName}\" }) to connect with the new token.` }],\n details: { mode: \"auth-complete\", server: serverName, authenticated: true },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to complete OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-complete\", error: \"auth_complete_failed\", server: serverName, message },\n };\n }\n}\n\nexport function executeDescribe(state: McpExtensionState, toolName: string): ProxyToolResult {\n let serverName: string | undefined;\n let toolMeta: ToolMetadata | undefined;\n\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n\n if (!serverName || !toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found. Use mcp({ search: \"...\" }) to search.` }],\n details: { mode: \"describe\", error: \"tool_not_found\", requestedTool: toolName },\n };\n }\n\n let text = `${toolMeta.name}\\n`;\n text += `Server: ${serverName}\\n`;\n if (toolMeta.resourceUri) {\n text += `Type: Resource (reads from ${toolMeta.resourceUri})\\n`;\n }\n text += `\\n${toolMeta.description || \"(no description)\"}\\n`;\n\n if (toolMeta.inputSchema && !toolMeta.resourceUri) {\n text += `\\nParameters:\\n${formatSchema(toolMeta.inputSchema)}`;\n } else if (toolMeta.resourceUri) {\n text += `\\nNo parameters required (resource tool).`;\n } else {\n text += `\\nNo parameters defined.`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"describe\", tool: toolMeta, server: serverName },\n };\n}\n\nexport function executeSearch(\n state: McpExtensionState,\n query: string,\n regex?: boolean,\n server?: string,\n includeSchemas?: boolean,\n): ProxyToolResult {\n const showSchemas = includeSchemas !== false;\n\n const matches: Array<{ server: string; tool: ToolMetadata }> = [];\n\n let pattern: RegExp;\n try {\n if (regex) {\n if (query.length > MAX_REGEX_SEARCH_QUERY_LENGTH) {\n return {\n content: [{ type: \"text\" as const, text: `Regex query is too long; maximum length is ${MAX_REGEX_SEARCH_QUERY_LENGTH} characters.` }],\n details: { mode: \"search\", error: \"query_too_long\", query, maxLength: MAX_REGEX_SEARCH_QUERY_LENGTH },\n };\n }\n\n pattern = new RegExp(query, \"i\");\n let safety;\n try {\n safety = checkSync(query, \"i\", REGEX_SAFETY_CHECK_PARAMS);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: \"Regex query rejected because safety analysis failed.\" }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, reason: message },\n };\n }\n if (safety.status !== \"safe\") {\n return {\n content: [{ type: \"text\" as const, text: `Regex query rejected as unsafe (${safety.status}).` }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, safetyStatus: safety.status },\n };\n }\n } else {\n const terms = query.trim().split(/\\s+/).filter(t => t.length > 0);\n if (terms.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"Search query cannot be empty\" }],\n details: { mode: \"search\", error: \"empty_query\" },\n };\n }\n const escaped = terms.map(t => t.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\n pattern = new RegExp(escaped.join(\"|\"), \"i\");\n }\n } catch {\n return {\n content: [{ type: \"text\" as const, text: `Invalid regex: ${query}` }],\n details: { mode: \"search\", error: \"invalid_pattern\", query },\n };\n }\n\n for (const [serverName, metadata] of state.toolMetadata.entries()) {\n if (server && serverName !== server) continue;\n for (const tool of metadata) {\n if (pattern.test(tool.name) || pattern.test(tool.description)) {\n matches.push({\n server: serverName,\n tool,\n });\n }\n }\n }\n\n const totalCount = matches.length;\n\n if (totalCount === 0) {\n const msg = server\n ? `No tools matching \"${query}\" in \"${server}\"`\n : `No tools matching \"${query}\"`;\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"search\", matches: [], count: 0, query },\n };\n }\n\n let text = `Found ${totalCount} tool${totalCount === 1 ? \"\" : \"s\"} matching \"${query}\":\\n\\n`;\n\n for (const match of matches) {\n if (showSchemas) {\n text += `${match.tool.name}\\n`;\n text += ` ${match.tool.description || \"(no description)\"}\\n`;\n if (match.tool.inputSchema && !match.tool.resourceUri) {\n text += `\\n Parameters:\\n${formatSchema(match.tool.inputSchema, \" \")}\\n`;\n } else if (match.tool.resourceUri) {\n text += ` No parameters (resource tool).\\n`;\n }\n text += \"\\n\";\n } else {\n text += `- ${match.tool.name}`;\n if (match.tool.description) {\n text += ` - ${truncateAtWord(match.tool.description, 50)}`;\n }\n text += \"\\n\";\n }\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: {\n mode: \"search\",\n matches: matches.map(m => ({ server: m.server, tool: m.tool.name })),\n count: totalCount,\n query,\n },\n };\n}\n\nexport function executeList(state: McpExtensionState, server: string): ProxyToolResult {\n if (!state.config.mcpServers[server]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_found\" },\n };\n }\n\n const metadata = state.toolMetadata.get(server);\n const toolNames = metadata?.map(m => m.name) ?? [];\n const connection = state.manager.getConnection(server);\n\n if (toolNames.length === 0) {\n if (connection?.status === \"connected\") {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no tools.` }],\n details: { mode: \"list\", server, tools: [], count: 0 },\n };\n }\n if (metadata !== undefined) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no cached tools (not connected).` }],\n details: { mode: \"list\", server, tools: [], count: 0, cached: true },\n };\n }\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" is configured but not connected. Use mcp({ connect: \"${server}\" }) or /mcp reconnect ${server} to retry.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_connected\" },\n };\n }\n\n const cachedNote = connection?.status === \"connected\" ? \"\" : \" (not connected, cached)\";\n let text = `${server} (${toolNames.length} tools${cachedNote}):\\n\\n`;\n\n const descMap = new Map<string, string>();\n if (metadata) {\n for (const m of metadata) {\n descMap.set(m.name, m.description);\n }\n }\n\n for (const tool of toolNames) {\n const desc = descMap.get(tool) ?? \"\";\n const truncated = truncateAtWord(desc, 50);\n text += `- ${tool}`;\n if (truncated) text += ` - ${truncated}`;\n text += \"\\n\";\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"list\", server, tools: toolNames, count: toolNames.length },\n };\n}\n\nexport async function executeConnect(state: McpExtensionState, serverName: string, signal?: AbortSignal): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"connect\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n let connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n const prefix = state.config.settings?.toolPrefix ?? \"server\";\n const { metadata } = buildToolMetadata(connection.tools, connection.resources, definition, serverName, prefix);\n state.toolMetadata.set(serverName, metadata);\n updateMetadataCache(state, serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return executeList(state, serverName);\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"connect\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeCall(\n state: McpExtensionState,\n toolName: string,\n args?: Record<string, unknown>,\n serverOverride?: string,\n getPiTools?: () => ToolInfo[],\n signal?: AbortSignal,\n): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n let serverName: string | undefined = serverOverride;\n let toolMeta: ToolMetadata | undefined;\n let autoAuthAttempted = false;\n const prefixMode = state.config.settings?.toolPrefix ?? \"server\";\n\n if (serverName && !state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"call\", error: \"server_not_found\", server: serverName },\n };\n }\n\n if (serverName) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n }\n\n if (serverName && !toolMeta) {\n const connected = await lazyConnect(state, serverName, signal);\n if (connected) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n const needsAuthConnection = state.manager.getConnection(serverName);\n if (needsAuthConnection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n const connectedAfterAuth = await lazyConnect(state, serverName, signal);\n if (connectedAfterAuth) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect.` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n }\n }\n }\n\n if (!toolMeta && state.manager.getConnection(serverName)?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n\n if (!toolMeta) {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n }\n }\n }\n\n let prefixMatchedServer: string | undefined;\n\n if (!serverName && !toolMeta && prefixMode !== \"none\") {\n const candidates = Object.keys(state.config.mcpServers)\n .map(name => ({ name, prefix: getServerPrefix(name, prefixMode) }))\n .filter(c => c.prefix && toolName.startsWith(c.prefix + \"_\"))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n\n for (const { name: configuredServer } of candidates) {\n const existingConnection = state.manager.getConnection(configuredServer);\n const failedAgo = getFailureAgeSeconds(state, configuredServer);\n if (failedAgo !== null && existingConnection?.status !== \"needs-auth\") continue;\n\n let connected = await lazyConnect(state, configuredServer, signal);\n if (!connected && state.manager.getConnection(configuredServer)?.status === \"needs-auth\" && !autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, configuredServer);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: configuredServer, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(configuredServer);\n state.failureTracker.delete(configuredServer);\n connected = await lazyConnect(state, configuredServer, signal);\n }\n }\n\n if (!connected) continue;\n if (!prefixMatchedServer) prefixMatchedServer = configuredServer;\n toolMeta = findToolByName(state.toolMetadata.get(configuredServer), toolName);\n if (toolMeta) {\n serverName = configuredServer;\n break;\n }\n }\n }\n\n if (!serverName || !toolMeta) {\n const nativeTool = !serverOverride\n ? getPiTools?.().find((tool) => tool.name === toolName && tool.name !== \"mcp\")\n : undefined;\n if (nativeTool) {\n return {\n content: [{ type: \"text\" as const, text: `\"${toolName}\" is a native Pi tool. Call ${toolName} directly instead of using mcp({ tool: \"${toolName}\" }).` }],\n details: { mode: \"call\", error: \"native_tool\", requestedTool: toolName },\n };\n }\n\n const hintServer = serverName ?? prefixMatchedServer;\n const available = hintServer ? getToolNames(state, hintServer) : [];\n let msg = `Tool \"${toolName}\" not found.`;\n if (available.length > 0) {\n msg += ` Server \"${hintServer}\" has: ${available.join(\", \")}`;\n } else {\n msg += ` Use mcp({ search: \"...\" }) to search.`;\n }\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"call\", error: \"tool_not_found\", requestedTool: toolName, hintServer },\n };\n }\n\n let connection = state.manager.getConnection(serverName);\n if (connection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n connection = state.manager.getConnection(serverName);\n }\n }\n\n if (connection?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n if (!connection || connection.status !== \"connected\") {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not connected` }],\n details: { mode: \"call\", error: \"server_not_connected\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n }\n\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n state.failureTracker.delete(serverName);\n updateServerMetadata(state, serverName);\n updateMetadataCache(state, serverName);\n updateStatusBar(state);\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n const available = getToolNames(state, serverName);\n const hint = available.length > 0\n ? `Available tools on \"${serverName}\": ${available.join(\", \")}`\n : `Server \"${serverName}\" has no tools.`;\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect. ${hint}` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"call\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", message },\n };\n }\n }\n\n let uiSession: UiSessionRuntime | null = null;\n const requestOptions = state.manager.getRequestOptions?.(serverName, signal) ?? (signal ? { signal } : undefined);\n\n const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);\n\n try {\n state.manager.touch(serverName);\n state.manager.incrementInFlight(serverName);\n\n if (toolMeta.resourceUri) {\n const result = await connection.client.readResource({ uri: toolMeta.resourceUri }, requestOptions);\n const content = (result.contents ?? []).map(c => ({\n type: \"text\" as const,\n text: \"text\" in c ? c.text : (\"blob\" in c ? `[Binary data: ${(c as { mimeType?: string }).mimeType ?? \"unknown\"}]` : JSON.stringify(c)),\n }));\n const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty resource)\" }], outputGuardOptions);\n return {\n content: guarded.content,\n details: { mode: \"call\", resourceUri: toolMeta.resourceUri, server: serverName, ...guardedMcpDetails(guarded) },\n };\n }\n\n uiSession = toolMeta.uiResourceUri\n ? await maybeStartUiSession(state, {\n serverName,\n toolName: toolMeta.originalName,\n toolArgs: args ?? {},\n uiResourceUri: toolMeta.uiResourceUri,\n streamMode: toolMeta.uiStreamMode,\n })\n : null;\n\n const resultPromise = connection.client.callTool({\n name: toolMeta.originalName,\n arguments: args ?? {},\n _meta: uiSession?.requestMeta,\n }, undefined, requestOptions);\n\n if (toolMeta.uiResourceUri) {\n const result = await abortable(resultPromise, signal);\n uiSession?.sendToolResult(result as unknown as import(\"@modelcontextprotocol/sdk/types.js\").CallToolResult);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const uiMessage = uiSession?.reused\n ? \"Updated the open UI.\"\n : \"📺 Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `\\n\\n${uiMessage}`, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName, uiOpen: true },\n };\n }\n\n const result = await abortable(resultPromise, signal);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName },\n };\n } catch (error) {\n if (error instanceof UrlElicitationRequiredError) {\n const action = await state.manager.handleUrlElicitationRequired(serverName, error);\n const message = action === \"accept\"\n ? \"The original MCP tool did not run. Complete the opened browser interaction, then retry the tool.\"\n : `The URL interaction was ${action === \"decline\" ? \"declined\" : \"cancelled\"}.`;\n uiSession?.sendToolCancelled(message);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"url_elicitation_required\", server: serverName, action },\n };\n }\n const message = error instanceof Error ? error.message : String(error);\n uiSession?.sendToolCancelled(message);\n\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput([{ type: \"text\" as const, text: message }], { ...outputGuardOptions, prefix: \"Failed to call tool: \", suffix: schemaText });\n\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"call_failed\", message: guarded.outputGuard ? \"output truncated; see outputGuard.fullOutputPath\" : message, ...guardedMcpDetails(guarded) },\n };\n } finally {\n if (uiSession?.reused) {\n uiSession.close();\n }\n state.manager.decrementInFlight(serverName);\n state.manager.touch(serverName);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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AAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,GAAG,kBAAkB,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAEjK,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,EAAE;SAC5K,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;YACtB,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC5C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AAAA,CACF","sourcesContent":["// @ts-nocheck\nimport type { AgentToolResult, ToolInfo } from \"@earendil-works/pi-coding-agent\";\nimport { UrlElicitationRequiredError } from \"@modelcontextprotocol/sdk/types.js\";\nimport { checkSync } from \"recheck\";\nimport type { McpExtensionState } from \"./state.ts\";\nimport type { ToolMetadata, McpContent } from \"./types.ts\";\nimport { getServerPrefix, parseUiPromptHandoff } from \"./types.ts\";\nimport { lazyConnect, updateServerMetadata, updateMetadataCache, getFailureAgeSeconds, updateStatusBar } from \"./init.ts\";\nimport { abortable, throwIfAborted } from \"./abort.ts\";\nimport { buildToolMetadata, getToolNames, findToolByName, formatSchema } from \"./tool-metadata.ts\";\nimport { resolveMcpResultContent, transformMcpContent } from \"./tool-registrar.ts\";\nimport { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from \"./mcp-output-guard.ts\";\nimport { maybeStartUiSession, type UiSessionRuntime } from \"./ui-session.ts\";\nimport { formatAuthRequiredMessage, truncateAtWord } from \"./utils.ts\";\nimport { authenticate, completeAuthFromInput, startAuth, supportsOAuth } from \"./mcp-auth-flow.ts\";\n\ntype ProxyToolResult = AgentToolResult<Record<string, unknown>>;\n\nconst MAX_REGEX_SEARCH_QUERY_LENGTH = 256;\nconst REGEX_SAFETY_CHECK_PARAMS = {\n attackTimeout: 50,\n incubationTimeout: 50,\n timeout: 250,\n} as const;\n\ntype AutoAuthResult =\n | { status: \"skipped\" }\n | { status: \"success\" }\n | { status: \"failed\"; message: string };\n\nfunction getAuthRequiredMessage(\n state: McpExtensionState,\n serverName: string,\n defaultMessage = `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n): string {\n return formatAuthRequiredMessage(state.config, serverName, defaultMessage);\n}\n\nfunction getAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {\n const customGuidance = state.config.settings?.authRequiredMessage;\n if (customGuidance) {\n return `OAuth authentication failed for \"${serverName}\": ${message}. ${getAuthRequiredMessage(state, serverName)}`;\n }\n return `OAuth authentication failed for \"${serverName}\": ${message}. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;\n}\n\nfunction getRedirectPort(authorizationUrl: string): number | undefined {\n try {\n const redirectUri = new URL(authorizationUrl).searchParams.get(\"redirect_uri\");\n if (!redirectUri) return undefined;\n const port = Number.parseInt(new URL(redirectUri).port, 10);\n return Number.isInteger(port) ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction formatManualAuthInstructions(serverName: string, authorizationUrl: string): string {\n const port = getRedirectPort(authorizationUrl);\n const portNote = port\n ? `\\nThe redirect URL will use local port ${port}. On a remote server it is expected for that localhost page to fail locally; copy the address bar URL anyway.`\n : \"\";\n\n return [\n `MCP OAuth required for \"${serverName}\".`,\n \"\",\n \"Open this URL in your local browser:\",\n \"\",\n authorizationUrl,\n \"\",\n \"After approving, copy the full redirected localhost URL from your browser address bar and send it back with:\",\n `mcp({ action: \"auth-complete\", server: \"${serverName}\", args: '{\"redirectUrl\":\"PASTE_REDIRECT_URL_HERE\"}' })`,\n \"\",\n \"You can also pass just the `code` query parameter as `args: '{\\\"code\\\":\\\"PASTE_CODE_HERE\\\"}'`.\",\n portNote.trimEnd(),\n ].filter(Boolean).join(\"\\n\");\n}\n\nasync function attemptAutoAuth(\n state: McpExtensionState,\n serverName: string,\n): Promise<AutoAuthResult> {\n if (state.config.settings?.autoAuth !== true) {\n return { status: \"skipped\" };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition || !supportsOAuth(definition) || !definition.url) {\n return { status: \"skipped\" };\n }\n\n const grantType = definition.oauth ? definition.oauth.grantType ?? \"authorization_code\" : \"authorization_code\";\n if (!state.ui && grantType !== \"client_credentials\") {\n return {\n status: \"failed\",\n message: getAuthRequiredMessage(\n state,\n serverName,\n `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n ),\n };\n }\n\n try {\n await authenticate(serverName, definition.url, definition);\n return { status: \"success\" };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n message: getAuthFailedMessage(state, serverName, message),\n };\n }\n}\n\nexport function executeUiMessages(state: McpExtensionState): ProxyToolResult {\n const sessions = state.completedUiSessions;\n\n if (sessions.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"No UI session messages available.\" }],\n details: { sessions: 0 },\n };\n }\n\n const output: string[] = [];\n output.push(`UI Session Messages (${sessions.length} session${sessions.length > 1 ? \"s\" : \"\"}):\\n`);\n\n const allPrompts: string[] = [];\n const allIntents = sessions.flatMap((session) => session.messages.intents);\n const parsedHandoffs: Array<{ intent: string; params: Record<string, unknown>; raw: string }> = [];\n\n for (const session of sessions) {\n const timestamp = session.completedAt.toLocaleTimeString();\n output.push(`\\n## ${session.serverName} / ${session.toolName} (${timestamp}, ${session.reason})`);\n\n const plainPrompts: string[] = [];\n for (const prompt of session.messages.prompts) {\n allPrompts.push(prompt);\n const handoff = parseUiPromptHandoff(prompt);\n if (handoff) {\n parsedHandoffs.push(handoff);\n } else {\n plainPrompts.push(prompt);\n }\n }\n\n if (plainPrompts.length > 0) {\n output.push(\"\\n### Prompts:\");\n for (const prompt of plainPrompts) {\n output.push(`- ${prompt}`);\n }\n }\n\n const intentsForSession = [\n ...session.messages.intents,\n ...session.messages.prompts\n .map((prompt) => parseUiPromptHandoff(prompt))\n .filter((handoff): handoff is NonNullable<typeof handoff> => !!handoff)\n .map((handoff) => ({ intent: handoff.intent, params: handoff.params })),\n ];\n\n if (intentsForSession.length > 0) {\n output.push(\"\\n### Intents:\");\n for (const intent of intentsForSession) {\n const params = intent.params ? ` (${JSON.stringify(intent.params)})` : \"\";\n output.push(`- ${intent.intent}${params}`);\n }\n }\n\n if (session.messages.notifications.length > 0) {\n output.push(\"\\n### Notifications:\");\n for (const notification of session.messages.notifications) {\n output.push(`- ${notification}`);\n }\n }\n }\n\n const count = sessions.length;\n state.completedUiSessions = [];\n\n return {\n content: [{ type: \"text\" as const, text: output.join(\"\\n\") }],\n details: {\n sessions: count,\n prompts: allPrompts,\n intents: [...allIntents, ...parsedHandoffs.map(({ intent, params }) => ({ intent, params }))],\n handoffs: parsedHandoffs,\n cleared: true,\n },\n };\n}\n\nexport function executeStatus(state: McpExtensionState): ProxyToolResult {\n const servers: Array<{ name: string; status: string; toolCount: number; failedAgo: number | null }> = [];\n\n for (const name of Object.keys(state.config.mcpServers)) {\n const connection = state.manager.getConnection(name);\n const metadata = state.toolMetadata.get(name);\n const toolCount = metadata?.length ?? 0;\n const failedAgo = getFailureAgeSeconds(state, name);\n let status = \"not connected\";\n if (connection?.status === \"connected\") {\n status = \"connected\";\n } else if (connection?.status === \"needs-auth\") {\n status = \"needs-auth\";\n } else if (failedAgo !== null) {\n status = \"failed\";\n } else if (metadata !== undefined) {\n status = \"cached\";\n }\n\n servers.push({ name, status, toolCount, failedAgo });\n }\n\n const totalTools = servers.reduce((sum, s) => sum + s.toolCount, 0);\n const connectedCount = servers.filter(s => s.status === \"connected\").length;\n\n let text = `MCP: ${connectedCount}/${servers.length} servers, ${totalTools} tools\\n\\n`;\n for (const server of servers) {\n if (server.status === \"connected\") {\n text += `✓ ${server.name} (${server.toolCount} tools)\\n`;\n continue;\n }\n if (server.status === \"needs-auth\") {\n text += `⚠ ${server.name} (needs auth)\\n`;\n continue;\n }\n if (server.status === \"cached\") {\n text += `○ ${server.name} (${server.toolCount} tools, cached)\\n`;\n continue;\n }\n if (server.status === \"failed\") {\n text += `✗ ${server.name} (failed ${server.failedAgo ?? 0}s ago)\\n`;\n continue;\n }\n text += `○ ${server.name} (not connected)\\n`;\n }\n\n if (servers.length > 0) {\n text += `\\nmcp({ server: \"name\" }) to list tools, mcp({ search: \"...\" }) to search`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"status\", servers, totalTools, connectedCount },\n };\n}\n\nexport async function executeAuthStart(state: McpExtensionState, serverName: string): Promise<ProxyToolResult> {\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-start\", error: \"not_found\", server: serverName },\n };\n }\n\n if (!definition.url || !supportsOAuth(definition)) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" is not configured for OAuth over HTTP.` }],\n details: { mode: \"auth-start\", error: \"oauth_not_supported\", server: serverName },\n };\n }\n\n try {\n const { authorizationUrl } = await startAuth(serverName, definition.url, definition);\n if (!authorizationUrl) {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\".` }],\n details: { mode: \"auth-start\", server: serverName, authenticated: true },\n };\n }\n\n return {\n content: [{ type: \"text\" as const, text: formatManualAuthInstructions(serverName, authorizationUrl) }],\n details: { mode: \"auth-start\", server: serverName, authorizationUrl },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to start OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-start\", error: \"auth_start_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeAuthComplete(state: McpExtensionState, serverName: string, input: string): Promise<ProxyToolResult> {\n if (!state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-complete\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n const status = await completeAuthFromInput(serverName, input);\n if (status !== \"authenticated\") {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication did not complete for \"${serverName}\".` }],\n details: { mode: \"auth-complete\", error: \"not_authenticated\", server: serverName, status },\n };\n }\n\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\". Run mcp({ connect: \"${serverName}\" }) to connect with the new token.` }],\n details: { mode: \"auth-complete\", server: serverName, authenticated: true },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to complete OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-complete\", error: \"auth_complete_failed\", server: serverName, message },\n };\n }\n}\n\nexport function executeDescribe(state: McpExtensionState, toolName: string): ProxyToolResult {\n let serverName: string | undefined;\n let toolMeta: ToolMetadata | undefined;\n\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n\n if (!serverName || !toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found. Use mcp({ search: \"...\" }) to search.` }],\n details: { mode: \"describe\", error: \"tool_not_found\", requestedTool: toolName },\n };\n }\n\n let text = `${toolMeta.name}\\n`;\n text += `Server: ${serverName}\\n`;\n if (toolMeta.resourceUri) {\n text += `Type: Resource (reads from ${toolMeta.resourceUri})\\n`;\n }\n text += `\\n${toolMeta.description || \"(no description)\"}\\n`;\n\n if (toolMeta.inputSchema && !toolMeta.resourceUri) {\n text += `\\nParameters:\\n${formatSchema(toolMeta.inputSchema)}`;\n } else if (toolMeta.resourceUri) {\n text += `\\nNo parameters required (resource tool).`;\n } else {\n text += `\\nNo parameters defined.`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"describe\", tool: toolMeta, server: serverName },\n };\n}\n\nexport function executeSearch(\n state: McpExtensionState,\n query: string,\n regex?: boolean,\n server?: string,\n includeSchemas?: boolean,\n): ProxyToolResult {\n const showSchemas = includeSchemas !== false;\n\n const matches: Array<{ server: string; tool: ToolMetadata }> = [];\n\n let pattern: RegExp;\n try {\n if (regex) {\n if (query.length > MAX_REGEX_SEARCH_QUERY_LENGTH) {\n return {\n content: [{ type: \"text\" as const, text: `Regex query is too long; maximum length is ${MAX_REGEX_SEARCH_QUERY_LENGTH} characters.` }],\n details: { mode: \"search\", error: \"query_too_long\", query, maxLength: MAX_REGEX_SEARCH_QUERY_LENGTH },\n };\n }\n\n pattern = new RegExp(query, \"i\");\n let safety;\n try {\n safety = checkSync(query, \"i\", REGEX_SAFETY_CHECK_PARAMS);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: \"Regex query rejected because safety analysis failed.\" }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, reason: message },\n };\n }\n if (safety.status !== \"safe\") {\n return {\n content: [{ type: \"text\" as const, text: `Regex query rejected as unsafe (${safety.status}).` }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, safetyStatus: safety.status },\n };\n }\n } else {\n const terms = query.trim().split(/\\s+/).filter(t => t.length > 0);\n if (terms.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"Search query cannot be empty\" }],\n details: { mode: \"search\", error: \"empty_query\" },\n };\n }\n const escaped = terms.map(t => t.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\n pattern = new RegExp(escaped.join(\"|\"), \"i\");\n }\n } catch {\n return {\n content: [{ type: \"text\" as const, text: `Invalid regex: ${query}` }],\n details: { mode: \"search\", error: \"invalid_pattern\", query },\n };\n }\n\n for (const [serverName, metadata] of state.toolMetadata.entries()) {\n if (server && serverName !== server) continue;\n for (const tool of metadata) {\n if (pattern.test(tool.name) || pattern.test(tool.description)) {\n matches.push({\n server: serverName,\n tool,\n });\n }\n }\n }\n\n const totalCount = matches.length;\n\n if (totalCount === 0) {\n const msg = server\n ? `No tools matching \"${query}\" in \"${server}\"`\n : `No tools matching \"${query}\"`;\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"search\", matches: [], count: 0, query },\n };\n }\n\n let text = `Found ${totalCount} tool${totalCount === 1 ? \"\" : \"s\"} matching \"${query}\":\\n\\n`;\n\n for (const match of matches) {\n if (showSchemas) {\n text += `${match.tool.name}\\n`;\n text += ` ${match.tool.description || \"(no description)\"}\\n`;\n if (match.tool.inputSchema && !match.tool.resourceUri) {\n text += `\\n Parameters:\\n${formatSchema(match.tool.inputSchema, \" \")}\\n`;\n } else if (match.tool.resourceUri) {\n text += ` No parameters (resource tool).\\n`;\n }\n text += \"\\n\";\n } else {\n text += `- ${match.tool.name}`;\n if (match.tool.description) {\n text += ` - ${truncateAtWord(match.tool.description, 50)}`;\n }\n text += \"\\n\";\n }\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: {\n mode: \"search\",\n matches: matches.map(m => ({ server: m.server, tool: m.tool.name })),\n count: totalCount,\n query,\n },\n };\n}\n\nexport function executeList(state: McpExtensionState, server: string): ProxyToolResult {\n if (!state.config.mcpServers[server]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_found\" },\n };\n }\n\n const metadata = state.toolMetadata.get(server);\n const toolNames = metadata?.map(m => m.name) ?? [];\n const connection = state.manager.getConnection(server);\n\n if (toolNames.length === 0) {\n if (connection?.status === \"connected\") {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no tools.` }],\n details: { mode: \"list\", server, tools: [], count: 0 },\n };\n }\n if (metadata !== undefined) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no cached tools (not connected).` }],\n details: { mode: \"list\", server, tools: [], count: 0, cached: true },\n };\n }\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" is configured but not connected. Use mcp({ connect: \"${server}\" }) or /mcp reconnect ${server} to retry.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_connected\" },\n };\n }\n\n const cachedNote = connection?.status === \"connected\" ? \"\" : \" (not connected, cached)\";\n let text = `${server} (${toolNames.length} tools${cachedNote}):\\n\\n`;\n\n const descMap = new Map<string, string>();\n if (metadata) {\n for (const m of metadata) {\n descMap.set(m.name, m.description);\n }\n }\n\n for (const tool of toolNames) {\n const desc = descMap.get(tool) ?? \"\";\n const truncated = truncateAtWord(desc, 50);\n text += `- ${tool}`;\n if (truncated) text += ` - ${truncated}`;\n text += \"\\n\";\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"list\", server, tools: toolNames, count: toolNames.length },\n };\n}\n\nexport async function executeConnect(state: McpExtensionState, serverName: string, signal?: AbortSignal): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"connect\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n let connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n const prefix = state.config.settings?.toolPrefix ?? \"server\";\n const { metadata } = buildToolMetadata(connection.tools, connection.resources, definition, serverName, prefix);\n state.toolMetadata.set(serverName, metadata);\n updateMetadataCache(state, serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return executeList(state, serverName);\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"connect\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeCall(\n state: McpExtensionState,\n toolName: string,\n args?: Record<string, unknown>,\n serverOverride?: string,\n getPiTools?: () => ToolInfo[],\n signal?: AbortSignal,\n): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n let serverName: string | undefined = serverOverride;\n let toolMeta: ToolMetadata | undefined;\n let autoAuthAttempted = false;\n const prefixMode = state.config.settings?.toolPrefix ?? \"server\";\n\n if (serverName && !state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"call\", error: \"server_not_found\", server: serverName },\n };\n }\n\n if (serverName) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n }\n\n if (serverName && !toolMeta) {\n const connected = await lazyConnect(state, serverName, signal);\n if (connected) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n const needsAuthConnection = state.manager.getConnection(serverName);\n if (needsAuthConnection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n const connectedAfterAuth = await lazyConnect(state, serverName, signal);\n if (connectedAfterAuth) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect.` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n }\n }\n }\n\n if (!toolMeta && state.manager.getConnection(serverName)?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n\n if (!toolMeta) {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n }\n }\n }\n\n let prefixMatchedServer: string | undefined;\n\n if (!serverName && !toolMeta && prefixMode !== \"none\") {\n const candidates = Object.keys(state.config.mcpServers)\n .map(name => ({ name, prefix: getServerPrefix(name, prefixMode) }))\n .filter(c => c.prefix && toolName.startsWith(c.prefix + \"_\"))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n\n for (const { name: configuredServer } of candidates) {\n const existingConnection = state.manager.getConnection(configuredServer);\n const failedAgo = getFailureAgeSeconds(state, configuredServer);\n if (failedAgo !== null && existingConnection?.status !== \"needs-auth\") continue;\n\n let connected = await lazyConnect(state, configuredServer, signal);\n if (!connected && state.manager.getConnection(configuredServer)?.status === \"needs-auth\" && !autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, configuredServer);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: configuredServer, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(configuredServer);\n state.failureTracker.delete(configuredServer);\n connected = await lazyConnect(state, configuredServer, signal);\n }\n }\n\n if (!connected) continue;\n if (!prefixMatchedServer) prefixMatchedServer = configuredServer;\n toolMeta = findToolByName(state.toolMetadata.get(configuredServer), toolName);\n if (toolMeta) {\n serverName = configuredServer;\n break;\n }\n }\n }\n\n if (!serverName || !toolMeta) {\n const nativeTool = !serverOverride\n ? getPiTools?.().find((tool) => tool.name === toolName && tool.name !== \"mcp\")\n : undefined;\n if (nativeTool) {\n return {\n content: [{ type: \"text\" as const, text: `\"${toolName}\" is a native Pi tool. Call ${toolName} directly instead of using mcp({ tool: \"${toolName}\" }).` }],\n details: { mode: \"call\", error: \"native_tool\", requestedTool: toolName },\n };\n }\n\n const hintServer = serverName ?? prefixMatchedServer;\n const available = hintServer ? getToolNames(state, hintServer) : [];\n let msg = `Tool \"${toolName}\" not found.`;\n if (available.length > 0) {\n msg += ` Server \"${hintServer}\" has: ${available.join(\", \")}`;\n } else {\n msg += ` Use mcp({ search: \"...\" }) to search.`;\n }\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"call\", error: \"tool_not_found\", requestedTool: toolName, hintServer },\n };\n }\n\n let connection = state.manager.getConnection(serverName);\n if (connection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n connection = state.manager.getConnection(serverName);\n }\n }\n\n if (connection?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n if (!connection || connection.status !== \"connected\") {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not connected` }],\n details: { mode: \"call\", error: \"server_not_connected\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n }\n\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n state.failureTracker.delete(serverName);\n updateServerMetadata(state, serverName);\n updateMetadataCache(state, serverName);\n updateStatusBar(state);\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n const available = getToolNames(state, serverName);\n const hint = available.length > 0\n ? `Available tools on \"${serverName}\": ${available.join(\", \")}`\n : `Server \"${serverName}\" has no tools.`;\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect. ${hint}` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"call\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", message },\n };\n }\n }\n\n let uiSession: UiSessionRuntime | null = null;\n const requestOptions = state.manager.getRequestOptions?.(serverName, signal) ?? (signal ? { signal } : undefined);\n\n const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);\n\n try {\n state.manager.touch(serverName);\n state.manager.incrementInFlight(serverName);\n\n if (toolMeta.resourceUri) {\n const result = await connection.client.readResource({ uri: toolMeta.resourceUri }, requestOptions);\n const content = (result.contents ?? []).map(c => ({\n type: \"text\" as const,\n text: \"text\" in c ? c.text : (\"blob\" in c ? `[Binary data: ${(c as { mimeType?: string }).mimeType ?? \"unknown\"}]` : JSON.stringify(c)),\n }));\n const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty resource)\" }], outputGuardOptions);\n return {\n content: guarded.content,\n details: { mode: \"call\", resourceUri: toolMeta.resourceUri, server: serverName, ...guardedMcpDetails(guarded) },\n };\n }\n\n uiSession = toolMeta.uiResourceUri\n ? await maybeStartUiSession(state, {\n serverName,\n toolName: toolMeta.originalName,\n toolArgs: args ?? {},\n uiResourceUri: toolMeta.uiResourceUri,\n streamMode: toolMeta.uiStreamMode,\n })\n : null;\n\n const resultPromise = connection.client.callTool({\n name: toolMeta.originalName,\n arguments: args ?? {},\n _meta: uiSession?.requestMeta,\n }, undefined, requestOptions);\n\n if (toolMeta.uiResourceUri) {\n const result = await abortable(resultPromise, signal);\n uiSession?.sendToolResult(result as unknown as import(\"@modelcontextprotocol/sdk/types.js\").CallToolResult);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const uiMessage = uiSession?.reused\n ? \"Updated the open UI.\"\n : \"📺 Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `\\n\\n${uiMessage}`, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName, uiOpen: true },\n };\n }\n\n const result = await abortable(resultPromise, signal);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName },\n };\n } catch (error) {\n if (error instanceof UrlElicitationRequiredError) {\n const action = await state.manager.handleUrlElicitationRequired(serverName, error);\n const message = action === \"accept\"\n ? \"The original MCP tool did not run. Complete the opened browser interaction, then retry the tool.\"\n : `The URL interaction was ${action === \"decline\" ? \"declined\" : \"cancelled\"}.`;\n uiSession?.sendToolCancelled(message);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"url_elicitation_required\", server: serverName, action },\n };\n }\n const message = error instanceof Error ? error.message : String(error);\n uiSession?.sendToolCancelled(message);\n\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput([{ type: \"text\" as const, text: message }], { ...outputGuardOptions, prefix: \"Failed to call tool: \", suffix: schemaText });\n\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"call_failed\", message: guarded.outputGuard ? \"output truncated; see outputGuard.fullOutputPath\" : message, ...guardedMcpDetails(guarded) },\n };\n } finally {\n if (uiSession?.reused) {\n uiSession.close();\n }\n state.manager.decrementInFlight(serverName);\n state.manager.touch(serverName);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"proxy-modes.js","sourceRoot":"","sources":["../../../src/builtin-extensions/pi-mcp-adapter/proxy-modes.ts"],"names":[],"mappings":"AAE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,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAEjK,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,EAAE;SAC5K,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;YACtB,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC5C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AAAA,CACF","sourcesContent":["// @ts-nocheck\nimport type { AgentToolResult, ToolInfo } from \"@ashx-j/lunr\";\nimport { UrlElicitationRequiredError } from \"@modelcontextprotocol/sdk/types.js\";\nimport { checkSync } from \"recheck\";\nimport type { McpExtensionState } from \"./state.ts\";\nimport type { ToolMetadata, McpContent } from \"./types.ts\";\nimport { getServerPrefix, parseUiPromptHandoff } from \"./types.ts\";\nimport { lazyConnect, updateServerMetadata, updateMetadataCache, getFailureAgeSeconds, updateStatusBar } from \"./init.ts\";\nimport { abortable, throwIfAborted } from \"./abort.ts\";\nimport { buildToolMetadata, getToolNames, findToolByName, formatSchema } from \"./tool-metadata.ts\";\nimport { resolveMcpResultContent, transformMcpContent } from \"./tool-registrar.ts\";\nimport { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from \"./mcp-output-guard.ts\";\nimport { maybeStartUiSession, type UiSessionRuntime } from \"./ui-session.ts\";\nimport { formatAuthRequiredMessage, truncateAtWord } from \"./utils.ts\";\nimport { authenticate, completeAuthFromInput, startAuth, supportsOAuth } from \"./mcp-auth-flow.ts\";\n\ntype ProxyToolResult = AgentToolResult<Record<string, unknown>>;\n\nconst MAX_REGEX_SEARCH_QUERY_LENGTH = 256;\nconst REGEX_SAFETY_CHECK_PARAMS = {\n attackTimeout: 50,\n incubationTimeout: 50,\n timeout: 250,\n} as const;\n\ntype AutoAuthResult =\n | { status: \"skipped\" }\n | { status: \"success\" }\n | { status: \"failed\"; message: string };\n\nfunction getAuthRequiredMessage(\n state: McpExtensionState,\n serverName: string,\n defaultMessage = `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n): string {\n return formatAuthRequiredMessage(state.config, serverName, defaultMessage);\n}\n\nfunction getAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {\n const customGuidance = state.config.settings?.authRequiredMessage;\n if (customGuidance) {\n return `OAuth authentication failed for \"${serverName}\": ${message}. ${getAuthRequiredMessage(state, serverName)}`;\n }\n return `OAuth authentication failed for \"${serverName}\": ${message}. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;\n}\n\nfunction getRedirectPort(authorizationUrl: string): number | undefined {\n try {\n const redirectUri = new URL(authorizationUrl).searchParams.get(\"redirect_uri\");\n if (!redirectUri) return undefined;\n const port = Number.parseInt(new URL(redirectUri).port, 10);\n return Number.isInteger(port) ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction formatManualAuthInstructions(serverName: string, authorizationUrl: string): string {\n const port = getRedirectPort(authorizationUrl);\n const portNote = port\n ? `\\nThe redirect URL will use local port ${port}. On a remote server it is expected for that localhost page to fail locally; copy the address bar URL anyway.`\n : \"\";\n\n return [\n `MCP OAuth required for \"${serverName}\".`,\n \"\",\n \"Open this URL in your local browser:\",\n \"\",\n authorizationUrl,\n \"\",\n \"After approving, copy the full redirected localhost URL from your browser address bar and send it back with:\",\n `mcp({ action: \"auth-complete\", server: \"${serverName}\", args: '{\"redirectUrl\":\"PASTE_REDIRECT_URL_HERE\"}' })`,\n \"\",\n \"You can also pass just the `code` query parameter as `args: '{\\\"code\\\":\\\"PASTE_CODE_HERE\\\"}'`.\",\n portNote.trimEnd(),\n ].filter(Boolean).join(\"\\n\");\n}\n\nasync function attemptAutoAuth(\n state: McpExtensionState,\n serverName: string,\n): Promise<AutoAuthResult> {\n if (state.config.settings?.autoAuth !== true) {\n return { status: \"skipped\" };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition || !supportsOAuth(definition) || !definition.url) {\n return { status: \"skipped\" };\n }\n\n const grantType = definition.oauth ? definition.oauth.grantType ?? \"authorization_code\" : \"authorization_code\";\n if (!state.ui && grantType !== \"client_credentials\") {\n return {\n status: \"failed\",\n message: getAuthRequiredMessage(\n state,\n serverName,\n `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n ),\n };\n }\n\n try {\n await authenticate(serverName, definition.url, definition);\n return { status: \"success\" };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n message: getAuthFailedMessage(state, serverName, message),\n };\n }\n}\n\nexport function executeUiMessages(state: McpExtensionState): ProxyToolResult {\n const sessions = state.completedUiSessions;\n\n if (sessions.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"No UI session messages available.\" }],\n details: { sessions: 0 },\n };\n }\n\n const output: string[] = [];\n output.push(`UI Session Messages (${sessions.length} session${sessions.length > 1 ? \"s\" : \"\"}):\\n`);\n\n const allPrompts: string[] = [];\n const allIntents = sessions.flatMap((session) => session.messages.intents);\n const parsedHandoffs: Array<{ intent: string; params: Record<string, unknown>; raw: string }> = [];\n\n for (const session of sessions) {\n const timestamp = session.completedAt.toLocaleTimeString();\n output.push(`\\n## ${session.serverName} / ${session.toolName} (${timestamp}, ${session.reason})`);\n\n const plainPrompts: string[] = [];\n for (const prompt of session.messages.prompts) {\n allPrompts.push(prompt);\n const handoff = parseUiPromptHandoff(prompt);\n if (handoff) {\n parsedHandoffs.push(handoff);\n } else {\n plainPrompts.push(prompt);\n }\n }\n\n if (plainPrompts.length > 0) {\n output.push(\"\\n### Prompts:\");\n for (const prompt of plainPrompts) {\n output.push(`- ${prompt}`);\n }\n }\n\n const intentsForSession = [\n ...session.messages.intents,\n ...session.messages.prompts\n .map((prompt) => parseUiPromptHandoff(prompt))\n .filter((handoff): handoff is NonNullable<typeof handoff> => !!handoff)\n .map((handoff) => ({ intent: handoff.intent, params: handoff.params })),\n ];\n\n if (intentsForSession.length > 0) {\n output.push(\"\\n### Intents:\");\n for (const intent of intentsForSession) {\n const params = intent.params ? ` (${JSON.stringify(intent.params)})` : \"\";\n output.push(`- ${intent.intent}${params}`);\n }\n }\n\n if (session.messages.notifications.length > 0) {\n output.push(\"\\n### Notifications:\");\n for (const notification of session.messages.notifications) {\n output.push(`- ${notification}`);\n }\n }\n }\n\n const count = sessions.length;\n state.completedUiSessions = [];\n\n return {\n content: [{ type: \"text\" as const, text: output.join(\"\\n\") }],\n details: {\n sessions: count,\n prompts: allPrompts,\n intents: [...allIntents, ...parsedHandoffs.map(({ intent, params }) => ({ intent, params }))],\n handoffs: parsedHandoffs,\n cleared: true,\n },\n };\n}\n\nexport function executeStatus(state: McpExtensionState): ProxyToolResult {\n const servers: Array<{ name: string; status: string; toolCount: number; failedAgo: number | null }> = [];\n\n for (const name of Object.keys(state.config.mcpServers)) {\n const connection = state.manager.getConnection(name);\n const metadata = state.toolMetadata.get(name);\n const toolCount = metadata?.length ?? 0;\n const failedAgo = getFailureAgeSeconds(state, name);\n let status = \"not connected\";\n if (connection?.status === \"connected\") {\n status = \"connected\";\n } else if (connection?.status === \"needs-auth\") {\n status = \"needs-auth\";\n } else if (failedAgo !== null) {\n status = \"failed\";\n } else if (metadata !== undefined) {\n status = \"cached\";\n }\n\n servers.push({ name, status, toolCount, failedAgo });\n }\n\n const totalTools = servers.reduce((sum, s) => sum + s.toolCount, 0);\n const connectedCount = servers.filter(s => s.status === \"connected\").length;\n\n let text = `MCP: ${connectedCount}/${servers.length} servers, ${totalTools} tools\\n\\n`;\n for (const server of servers) {\n if (server.status === \"connected\") {\n text += `✓ ${server.name} (${server.toolCount} tools)\\n`;\n continue;\n }\n if (server.status === \"needs-auth\") {\n text += `⚠ ${server.name} (needs auth)\\n`;\n continue;\n }\n if (server.status === \"cached\") {\n text += `○ ${server.name} (${server.toolCount} tools, cached)\\n`;\n continue;\n }\n if (server.status === \"failed\") {\n text += `✗ ${server.name} (failed ${server.failedAgo ?? 0}s ago)\\n`;\n continue;\n }\n text += `○ ${server.name} (not connected)\\n`;\n }\n\n if (servers.length > 0) {\n text += `\\nmcp({ server: \"name\" }) to list tools, mcp({ search: \"...\" }) to search`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"status\", servers, totalTools, connectedCount },\n };\n}\n\nexport async function executeAuthStart(state: McpExtensionState, serverName: string): Promise<ProxyToolResult> {\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-start\", error: \"not_found\", server: serverName },\n };\n }\n\n if (!definition.url || !supportsOAuth(definition)) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" is not configured for OAuth over HTTP.` }],\n details: { mode: \"auth-start\", error: \"oauth_not_supported\", server: serverName },\n };\n }\n\n try {\n const { authorizationUrl } = await startAuth(serverName, definition.url, definition);\n if (!authorizationUrl) {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\".` }],\n details: { mode: \"auth-start\", server: serverName, authenticated: true },\n };\n }\n\n return {\n content: [{ type: \"text\" as const, text: formatManualAuthInstructions(serverName, authorizationUrl) }],\n details: { mode: \"auth-start\", server: serverName, authorizationUrl },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to start OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-start\", error: \"auth_start_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeAuthComplete(state: McpExtensionState, serverName: string, input: string): Promise<ProxyToolResult> {\n if (!state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-complete\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n const status = await completeAuthFromInput(serverName, input);\n if (status !== \"authenticated\") {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication did not complete for \"${serverName}\".` }],\n details: { mode: \"auth-complete\", error: \"not_authenticated\", server: serverName, status },\n };\n }\n\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\". Run mcp({ connect: \"${serverName}\" }) to connect with the new token.` }],\n details: { mode: \"auth-complete\", server: serverName, authenticated: true },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to complete OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-complete\", error: \"auth_complete_failed\", server: serverName, message },\n };\n }\n}\n\nexport function executeDescribe(state: McpExtensionState, toolName: string): ProxyToolResult {\n let serverName: string | undefined;\n let toolMeta: ToolMetadata | undefined;\n\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n\n if (!serverName || !toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found. Use mcp({ search: \"...\" }) to search.` }],\n details: { mode: \"describe\", error: \"tool_not_found\", requestedTool: toolName },\n };\n }\n\n let text = `${toolMeta.name}\\n`;\n text += `Server: ${serverName}\\n`;\n if (toolMeta.resourceUri) {\n text += `Type: Resource (reads from ${toolMeta.resourceUri})\\n`;\n }\n text += `\\n${toolMeta.description || \"(no description)\"}\\n`;\n\n if (toolMeta.inputSchema && !toolMeta.resourceUri) {\n text += `\\nParameters:\\n${formatSchema(toolMeta.inputSchema)}`;\n } else if (toolMeta.resourceUri) {\n text += `\\nNo parameters required (resource tool).`;\n } else {\n text += `\\nNo parameters defined.`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"describe\", tool: toolMeta, server: serverName },\n };\n}\n\nexport function executeSearch(\n state: McpExtensionState,\n query: string,\n regex?: boolean,\n server?: string,\n includeSchemas?: boolean,\n): ProxyToolResult {\n const showSchemas = includeSchemas !== false;\n\n const matches: Array<{ server: string; tool: ToolMetadata }> = [];\n\n let pattern: RegExp;\n try {\n if (regex) {\n if (query.length > MAX_REGEX_SEARCH_QUERY_LENGTH) {\n return {\n content: [{ type: \"text\" as const, text: `Regex query is too long; maximum length is ${MAX_REGEX_SEARCH_QUERY_LENGTH} characters.` }],\n details: { mode: \"search\", error: \"query_too_long\", query, maxLength: MAX_REGEX_SEARCH_QUERY_LENGTH },\n };\n }\n\n pattern = new RegExp(query, \"i\");\n let safety;\n try {\n safety = checkSync(query, \"i\", REGEX_SAFETY_CHECK_PARAMS);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: \"Regex query rejected because safety analysis failed.\" }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, reason: message },\n };\n }\n if (safety.status !== \"safe\") {\n return {\n content: [{ type: \"text\" as const, text: `Regex query rejected as unsafe (${safety.status}).` }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, safetyStatus: safety.status },\n };\n }\n } else {\n const terms = query.trim().split(/\\s+/).filter(t => t.length > 0);\n if (terms.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"Search query cannot be empty\" }],\n details: { mode: \"search\", error: \"empty_query\" },\n };\n }\n const escaped = terms.map(t => t.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\n pattern = new RegExp(escaped.join(\"|\"), \"i\");\n }\n } catch {\n return {\n content: [{ type: \"text\" as const, text: `Invalid regex: ${query}` }],\n details: { mode: \"search\", error: \"invalid_pattern\", query },\n };\n }\n\n for (const [serverName, metadata] of state.toolMetadata.entries()) {\n if (server && serverName !== server) continue;\n for (const tool of metadata) {\n if (pattern.test(tool.name) || pattern.test(tool.description)) {\n matches.push({\n server: serverName,\n tool,\n });\n }\n }\n }\n\n const totalCount = matches.length;\n\n if (totalCount === 0) {\n const msg = server\n ? `No tools matching \"${query}\" in \"${server}\"`\n : `No tools matching \"${query}\"`;\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"search\", matches: [], count: 0, query },\n };\n }\n\n let text = `Found ${totalCount} tool${totalCount === 1 ? \"\" : \"s\"} matching \"${query}\":\\n\\n`;\n\n for (const match of matches) {\n if (showSchemas) {\n text += `${match.tool.name}\\n`;\n text += ` ${match.tool.description || \"(no description)\"}\\n`;\n if (match.tool.inputSchema && !match.tool.resourceUri) {\n text += `\\n Parameters:\\n${formatSchema(match.tool.inputSchema, \" \")}\\n`;\n } else if (match.tool.resourceUri) {\n text += ` No parameters (resource tool).\\n`;\n }\n text += \"\\n\";\n } else {\n text += `- ${match.tool.name}`;\n if (match.tool.description) {\n text += ` - ${truncateAtWord(match.tool.description, 50)}`;\n }\n text += \"\\n\";\n }\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: {\n mode: \"search\",\n matches: matches.map(m => ({ server: m.server, tool: m.tool.name })),\n count: totalCount,\n query,\n },\n };\n}\n\nexport function executeList(state: McpExtensionState, server: string): ProxyToolResult {\n if (!state.config.mcpServers[server]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_found\" },\n };\n }\n\n const metadata = state.toolMetadata.get(server);\n const toolNames = metadata?.map(m => m.name) ?? [];\n const connection = state.manager.getConnection(server);\n\n if (toolNames.length === 0) {\n if (connection?.status === \"connected\") {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no tools.` }],\n details: { mode: \"list\", server, tools: [], count: 0 },\n };\n }\n if (metadata !== undefined) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no cached tools (not connected).` }],\n details: { mode: \"list\", server, tools: [], count: 0, cached: true },\n };\n }\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" is configured but not connected. Use mcp({ connect: \"${server}\" }) or /mcp reconnect ${server} to retry.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_connected\" },\n };\n }\n\n const cachedNote = connection?.status === \"connected\" ? \"\" : \" (not connected, cached)\";\n let text = `${server} (${toolNames.length} tools${cachedNote}):\\n\\n`;\n\n const descMap = new Map<string, string>();\n if (metadata) {\n for (const m of metadata) {\n descMap.set(m.name, m.description);\n }\n }\n\n for (const tool of toolNames) {\n const desc = descMap.get(tool) ?? \"\";\n const truncated = truncateAtWord(desc, 50);\n text += `- ${tool}`;\n if (truncated) text += ` - ${truncated}`;\n text += \"\\n\";\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"list\", server, tools: toolNames, count: toolNames.length },\n };\n}\n\nexport async function executeConnect(state: McpExtensionState, serverName: string, signal?: AbortSignal): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"connect\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n let connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n const prefix = state.config.settings?.toolPrefix ?? \"server\";\n const { metadata } = buildToolMetadata(connection.tools, connection.resources, definition, serverName, prefix);\n state.toolMetadata.set(serverName, metadata);\n updateMetadataCache(state, serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return executeList(state, serverName);\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"connect\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeCall(\n state: McpExtensionState,\n toolName: string,\n args?: Record<string, unknown>,\n serverOverride?: string,\n getPiTools?: () => ToolInfo[],\n signal?: AbortSignal,\n): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n let serverName: string | undefined = serverOverride;\n let toolMeta: ToolMetadata | undefined;\n let autoAuthAttempted = false;\n const prefixMode = state.config.settings?.toolPrefix ?? \"server\";\n\n if (serverName && !state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"call\", error: \"server_not_found\", server: serverName },\n };\n }\n\n if (serverName) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n }\n\n if (serverName && !toolMeta) {\n const connected = await lazyConnect(state, serverName, signal);\n if (connected) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n const needsAuthConnection = state.manager.getConnection(serverName);\n if (needsAuthConnection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n const connectedAfterAuth = await lazyConnect(state, serverName, signal);\n if (connectedAfterAuth) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect.` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n }\n }\n }\n\n if (!toolMeta && state.manager.getConnection(serverName)?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n\n if (!toolMeta) {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n }\n }\n }\n\n let prefixMatchedServer: string | undefined;\n\n if (!serverName && !toolMeta && prefixMode !== \"none\") {\n const candidates = Object.keys(state.config.mcpServers)\n .map(name => ({ name, prefix: getServerPrefix(name, prefixMode) }))\n .filter(c => c.prefix && toolName.startsWith(c.prefix + \"_\"))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n\n for (const { name: configuredServer } of candidates) {\n const existingConnection = state.manager.getConnection(configuredServer);\n const failedAgo = getFailureAgeSeconds(state, configuredServer);\n if (failedAgo !== null && existingConnection?.status !== \"needs-auth\") continue;\n\n let connected = await lazyConnect(state, configuredServer, signal);\n if (!connected && state.manager.getConnection(configuredServer)?.status === \"needs-auth\" && !autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, configuredServer);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: configuredServer, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(configuredServer);\n state.failureTracker.delete(configuredServer);\n connected = await lazyConnect(state, configuredServer, signal);\n }\n }\n\n if (!connected) continue;\n if (!prefixMatchedServer) prefixMatchedServer = configuredServer;\n toolMeta = findToolByName(state.toolMetadata.get(configuredServer), toolName);\n if (toolMeta) {\n serverName = configuredServer;\n break;\n }\n }\n }\n\n if (!serverName || !toolMeta) {\n const nativeTool = !serverOverride\n ? getPiTools?.().find((tool) => tool.name === toolName && tool.name !== \"mcp\")\n : undefined;\n if (nativeTool) {\n return {\n content: [{ type: \"text\" as const, text: `\"${toolName}\" is a native Pi tool. Call ${toolName} directly instead of using mcp({ tool: \"${toolName}\" }).` }],\n details: { mode: \"call\", error: \"native_tool\", requestedTool: toolName },\n };\n }\n\n const hintServer = serverName ?? prefixMatchedServer;\n const available = hintServer ? getToolNames(state, hintServer) : [];\n let msg = `Tool \"${toolName}\" not found.`;\n if (available.length > 0) {\n msg += ` Server \"${hintServer}\" has: ${available.join(\", \")}`;\n } else {\n msg += ` Use mcp({ search: \"...\" }) to search.`;\n }\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"call\", error: \"tool_not_found\", requestedTool: toolName, hintServer },\n };\n }\n\n let connection = state.manager.getConnection(serverName);\n if (connection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n connection = state.manager.getConnection(serverName);\n }\n }\n\n if (connection?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n if (!connection || connection.status !== \"connected\") {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not connected` }],\n details: { mode: \"call\", error: \"server_not_connected\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n }\n\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n state.failureTracker.delete(serverName);\n updateServerMetadata(state, serverName);\n updateMetadataCache(state, serverName);\n updateStatusBar(state);\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n const available = getToolNames(state, serverName);\n const hint = available.length > 0\n ? `Available tools on \"${serverName}\": ${available.join(\", \")}`\n : `Server \"${serverName}\" has no tools.`;\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect. ${hint}` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"call\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", message },\n };\n }\n }\n\n let uiSession: UiSessionRuntime | null = null;\n const requestOptions = state.manager.getRequestOptions?.(serverName, signal) ?? (signal ? { signal } : undefined);\n\n const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);\n\n try {\n state.manager.touch(serverName);\n state.manager.incrementInFlight(serverName);\n\n if (toolMeta.resourceUri) {\n const result = await connection.client.readResource({ uri: toolMeta.resourceUri }, requestOptions);\n const content = (result.contents ?? []).map(c => ({\n type: \"text\" as const,\n text: \"text\" in c ? c.text : (\"blob\" in c ? `[Binary data: ${(c as { mimeType?: string }).mimeType ?? \"unknown\"}]` : JSON.stringify(c)),\n }));\n const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty resource)\" }], outputGuardOptions);\n return {\n content: guarded.content,\n details: { mode: \"call\", resourceUri: toolMeta.resourceUri, server: serverName, ...guardedMcpDetails(guarded) },\n };\n }\n\n uiSession = toolMeta.uiResourceUri\n ? await maybeStartUiSession(state, {\n serverName,\n toolName: toolMeta.originalName,\n toolArgs: args ?? {},\n uiResourceUri: toolMeta.uiResourceUri,\n streamMode: toolMeta.uiStreamMode,\n })\n : null;\n\n const resultPromise = connection.client.callTool({\n name: toolMeta.originalName,\n arguments: args ?? {},\n _meta: uiSession?.requestMeta,\n }, undefined, requestOptions);\n\n if (toolMeta.uiResourceUri) {\n const result = await abortable(resultPromise, signal);\n uiSession?.sendToolResult(result as unknown as import(\"@modelcontextprotocol/sdk/types.js\").CallToolResult);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const uiMessage = uiSession?.reused\n ? \"Updated the open UI.\"\n : \"📺 Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `\\n\\n${uiMessage}`, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName, uiOpen: true },\n };\n }\n\n const result = await abortable(resultPromise, signal);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName },\n };\n } catch (error) {\n if (error instanceof UrlElicitationRequiredError) {\n const action = await state.manager.handleUrlElicitationRequired(serverName, error);\n const message = action === \"accept\"\n ? \"The original MCP tool did not run. Complete the opened browser interaction, then retry the tool.\"\n : `The URL interaction was ${action === \"decline\" ? \"declined\" : \"cancelled\"}.`;\n uiSession?.sendToolCancelled(message);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"url_elicitation_required\", server: serverName, action },\n };\n }\n const message = error instanceof Error ? error.message : String(error);\n uiSession?.sendToolCancelled(message);\n\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput([{ type: \"text\" as const, text: message }], { ...outputGuardOptions, prefix: \"Failed to call tool: \", suffix: schemaText });\n\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"call_failed\", message: guarded.outputGuard ? \"output truncated; see outputGuard.fullOutputPath\" : message, ...guardedMcpDetails(guarded) },\n };\n } finally {\n if (uiSession?.reused) {\n uiSession.close();\n }\n state.manager.decrementInFlight(serverName);\n state.manager.touch(serverName);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Api, type Model } from "@
|
|
2
|
-
import type { ExtensionUIContext, ModelRegistry } from "@
|
|
1
|
+
import { type Api, type Model } from "@ashx-j/lunr-ai/compat";
|
|
2
|
+
import type { ExtensionUIContext, ModelRegistry } from "@ashx-j/lunr";
|
|
3
3
|
import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
4
|
import { type CreateMessageRequest, type CreateMessageResult } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
export interface SamplingHandlerOptions {
|