@ashx-j/lunr 0.2.26 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/LICENSE +22 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +11 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +6 -10
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/lunr-cron.d.ts +4 -5
- package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-cron.js +94 -108
- package/dist/builtin-extensions/lunr-cron.js.map +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 +3 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js +2 -2
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js.map +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 +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.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.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-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 +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.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +1 -15
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts +6 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js +187 -132
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts +8 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js +142 -112
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts +12 -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 +14 -7
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts +11 -3
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js +67 -41
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts +4 -2
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js +3 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts +2 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js +6 -6
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.js +11 -5
- package/dist/builtin-extensions/pi-mcp-adapter/config.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js +2 -2
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +48 -40
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js +3 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts +12 -40
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js +166 -235
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts +5 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js +43 -13
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts +14 -3
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js +73 -21
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js.map +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 +4 -4
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +2 -2
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts +2 -0
- 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-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 +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts +11 -5
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.js +12 -32
- package/dist/builtin-extensions/pi-ollama-cloud/models.js.map +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 +5 -3
- package/dist/builtin-extensions/pi-prompt-template-model/index.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts +2 -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 +21 -12
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +7 -24
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +39 -77
- package/dist/builtin-extensions/pi-subagents/src/extension/index.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 +15 -31
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +7 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.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 +10 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- 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 +8 -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 +106 -24
- 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.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +25 -5
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +7 -8
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js +60 -32
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.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 +15 -5
- 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.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +4 -3
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +17 -8
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +3 -3
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
- package/dist/builtin-extensions/pi-tps.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-tps.js +20 -17
- package/dist/builtin-extensions/pi-tps.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/activity.d.ts +1 -0
- package/dist/builtin-extensions/pi-web-access/activity.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/activity.js +27 -5
- package/dist/builtin-extensions/pi-web-access/activity.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/bounded-body.d.ts +3 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.js +43 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/content-page.d.ts +24 -0
- package/dist/builtin-extensions/pi-web-access/content-page.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/content-page.js +57 -0
- package/dist/builtin-extensions/pi-web-access/content-page.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.js +7 -2
- package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts +0 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.js +147 -36
- package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +48 -73
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts +12 -4
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js +35 -12
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.d.ts +9 -6
- package/dist/builtin-extensions/pi-web-access/storage.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.js +36 -24
- package/dist/builtin-extensions/pi-web-access/storage.js.map +1 -1
- package/dist/builtin-extensions/simple-pi-memory.d.ts +1 -1
- package/dist/builtin-extensions/simple-pi-memory.d.ts.map +1 -1
- package/dist/builtin-extensions/simple-pi-memory.js +1 -1
- package/dist/builtin-extensions/simple-pi-memory.js.map +1 -1
- package/dist/cli/install-cli.d.ts.map +1 -1
- package/dist/cli/install-cli.js +38 -30
- package/dist/cli/install-cli.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +13 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +75 -11
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +40 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +309 -76
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/browser/runtime.d.ts +2 -0
- package/dist/core/browser/runtime.d.ts.map +1 -1
- package/dist/core/browser/runtime.js +80 -45
- package/dist/core/browser/runtime.js.map +1 -1
- package/dist/core/browser/setup.d.ts.map +1 -1
- package/dist/core/browser/setup.js +12 -1
- package/dist/core/browser/setup.js.map +1 -1
- package/dist/core/computer-use/adapter.d.ts.map +1 -1
- package/dist/core/computer-use/adapter.js +7 -2
- package/dist/core/computer-use/adapter.js.map +1 -1
- package/dist/core/computer-use/image.d.ts.map +1 -1
- package/dist/core/computer-use/image.js +17 -5
- package/dist/core/computer-use/image.js.map +1 -1
- package/dist/core/computer-use/schemas.d.ts.map +1 -1
- package/dist/core/computer-use/schemas.js +23 -6
- package/dist/core/computer-use/schemas.js.map +1 -1
- package/dist/core/computer-use/workflow.d.ts.map +1 -1
- package/dist/core/computer-use/workflow.js +459 -119
- package/dist/core/computer-use/workflow.js.map +1 -1
- package/dist/core/cron/jobs.d.ts +26 -8
- package/dist/core/cron/jobs.d.ts.map +1 -1
- package/dist/core/cron/jobs.js +357 -232
- package/dist/core/cron/jobs.js.map +1 -1
- package/dist/core/cron/origin-context.d.ts +1 -0
- package/dist/core/cron/origin-context.d.ts.map +1 -1
- package/dist/core/cron/origin-context.js.map +1 -1
- package/dist/core/cron/scheduler.d.ts +22 -17
- package/dist/core/cron/scheduler.d.ts.map +1 -1
- package/dist/core/cron/scheduler.js +153 -73
- package/dist/core/cron/scheduler.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +8 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +8 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +4 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +22 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/large-subagent-launch.d.ts +1 -1
- package/dist/core/large-subagent-launch.d.ts.map +1 -1
- package/dist/core/large-subagent-launch.js +7 -7
- package/dist/core/large-subagent-launch.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +5 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime.d.ts +4 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +40 -4
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/permissions.d.ts +3 -3
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +11 -35
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts +5 -13
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +126 -116
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-resource-bridge.d.ts +12 -0
- package/dist/core/prompt-resource-bridge.d.ts.map +1 -0
- package/dist/core/prompt-resource-bridge.js +9 -0
- package/dist/core/prompt-resource-bridge.js.map +1 -0
- package/dist/core/protected-targets.d.ts +6 -0
- package/dist/core/protected-targets.d.ts.map +1 -0
- package/dist/core/protected-targets.js +45 -0
- package/dist/core/protected-targets.js.map +1 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +7 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/rollback.d.ts +19 -3
- package/dist/core/rollback.d.ts.map +1 -1
- package/dist/core/rollback.js +172 -56
- package/dist/core/rollback.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +3 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +14 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts +3 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +6 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +95 -32
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-ownership.d.ts.map +1 -1
- package/dist/core/session-ownership.js +8 -3
- package/dist/core/session-ownership.js.map +1 -1
- package/dist/core/session-retention.d.ts.map +1 -1
- package/dist/core/session-retention.js +18 -7
- package/dist/core/session-retention.js.map +1 -1
- package/dist/core/session-startup-settings.d.ts +10 -0
- package/dist/core/session-startup-settings.d.ts.map +1 -0
- package/dist/core/session-startup-settings.js +70 -0
- package/dist/core/session-startup-settings.js.map +1 -0
- package/dist/core/subscriptions.d.ts +16 -7
- package/dist/core/subscriptions.d.ts.map +1 -1
- package/dist/core/subscriptions.js +96 -55
- package/dist/core/subscriptions.js.map +1 -1
- package/dist/core/trust-manager.d.ts +2 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +6 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/update-check.d.ts.map +1 -1
- package/dist/core/update-check.js.map +1 -1
- package/dist/core/usage-adapters/kimi-coding.d.ts +2 -2
- package/dist/core/usage-adapters/kimi-coding.d.ts.map +1 -1
- package/dist/core/usage-adapters/kimi-coding.js +2 -2
- package/dist/core/usage-adapters/kimi-coding.js.map +1 -1
- package/dist/core/usage-adapters/openai-codex.d.ts +3 -2
- package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -1
- package/dist/core/usage-adapters/openai-codex.js +3 -3
- package/dist/core/usage-adapters/openai-codex.js.map +1 -1
- package/dist/core/usage-adapters/xai.d.ts +2 -2
- package/dist/core/usage-adapters/xai.d.ts.map +1 -1
- package/dist/core/usage-adapters/xai.js +3 -3
- package/dist/core/usage-adapters/xai.js.map +1 -1
- package/dist/core/usage-adapters/zai.d.ts +2 -2
- package/dist/core/usage-adapters/zai.d.ts.map +1 -1
- package/dist/core/usage-adapters/zai.js +2 -2
- package/dist/core/usage-adapters/zai.js.map +1 -1
- package/dist/core/usage-service.d.ts +9 -2
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +95 -50
- package/dist/core/usage-service.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +9 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +91 -37
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/buttons.d.ts +8 -1
- package/dist/gateway/buttons.d.ts.map +1 -1
- package/dist/gateway/buttons.js +76 -18
- package/dist/gateway/buttons.js.map +1 -1
- package/dist/gateway/commands.d.ts +1 -0
- package/dist/gateway/commands.d.ts.map +1 -1
- package/dist/gateway/commands.js +10 -4
- package/dist/gateway/commands.js.map +1 -1
- package/dist/gateway/cron.d.ts +12 -11
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +65 -56
- package/dist/gateway/cron.js.map +1 -1
- package/dist/gateway/index.d.ts.map +1 -1
- package/dist/gateway/index.js +2 -1
- package/dist/gateway/index.js.map +1 -1
- package/dist/gateway/mobile-commands.d.ts +1 -0
- package/dist/gateway/mobile-commands.d.ts.map +1 -1
- package/dist/gateway/mobile-commands.js +56 -14
- package/dist/gateway/mobile-commands.js.map +1 -1
- package/dist/gateway/presenter.d.ts +12 -2
- package/dist/gateway/presenter.d.ts.map +1 -1
- package/dist/gateway/presenter.js +73 -38
- package/dist/gateway/presenter.js.map +1 -1
- package/dist/gateway/router.d.ts +2 -2
- package/dist/gateway/router.d.ts.map +1 -1
- package/dist/gateway/router.js +17 -2
- package/dist/gateway/router.js.map +1 -1
- package/dist/gateway/service.d.ts +2 -0
- package/dist/gateway/service.d.ts.map +1 -1
- package/dist/gateway/service.js +153 -0
- package/dist/gateway/service.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +86 -33
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +6 -4
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/copyable-text.js +3 -2
- package/dist/modes/interactive/components/copyable-text.js.map +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/interactive-mode.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +96 -109
- package/dist/modes/interactive/interactive-mode.js.map +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/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/node-runtime/{adapter-VFG7WNPX.js → adapter-247RTYLS.js} +4 -5
- package/dist/node-runtime/agent-session-services-KDMSPQDY.js +53 -0
- package/dist/node-runtime/{brave-UWDA3I22.js → brave-2AFFAXNN.js} +1 -1
- package/dist/node-runtime/{builtin-extensions-I2HIFEMY.js → builtin-extensions-OX6KELNX.js} +8 -7
- package/dist/node-runtime/{chunk-QH6YL7VK.js → chunk-252ZVPPF.js} +3 -3
- package/dist/node-runtime/{chunk-PCEW76PM.js → chunk-2OIPYKLZ.js} +6 -6
- package/dist/node-runtime/{chunk-XBWPBZBN.js → chunk-2SWW7KMW.js} +1 -1
- package/dist/node-runtime/{chunk-UQUCFAJ3.js → chunk-2VIW3IMF.js} +40 -7
- package/dist/node-runtime/{chunk-UOEDI7RP.js → chunk-4KNKQGHM.js} +2 -2
- package/dist/node-runtime/{chunk-FQMM2EZ2.js → chunk-64XTQNLA.js} +29 -7
- package/dist/node-runtime/{chunk-SPVDBUOS.js → chunk-6O3IW3IA.js} +2 -2
- package/dist/node-runtime/{chunk-5ZQXRPMC.js → chunk-6ZZHGUSA.js} +2 -2
- package/dist/node-runtime/chunk-A2WO6WIN.js +1197 -0
- package/dist/node-runtime/{chunk-WIF24I7G.js → chunk-APVM5NEU.js} +149 -144
- package/dist/node-runtime/{chunk-RCR3XAQY.js → chunk-AYHH7YSD.js} +177 -144
- package/dist/node-runtime/{chunk-LWYIVUGV.js → chunk-B2IBAXNX.js} +48 -31
- package/dist/node-runtime/{chunk-M3LZLQW2.js → chunk-BDRGN3L2.js} +1 -0
- package/dist/node-runtime/{chunk-GJ2RDBRL.js → chunk-BYC6RKCN.js} +4 -2
- package/dist/node-runtime/{chunk-UVWCDQYF.js → chunk-C3P6Q3B2.js} +455 -278
- package/dist/node-runtime/{chunk-SN2KSMPQ.js → chunk-DQSCFU7R.js} +13 -7
- package/dist/node-runtime/{chunk-4SBQAI4T.js → chunk-EBLAZVSA.js} +2058 -73
- package/dist/node-runtime/{chunk-2KIPT4HJ.js → chunk-EPR2F3GU.js} +68 -20
- package/dist/node-runtime/{chunk-CSFI6YXL.js → chunk-ES6PBSIE.js} +1 -1
- package/dist/node-runtime/{chunk-IF24A3FH.js → chunk-EVM653DD.js} +4 -4
- package/dist/node-runtime/{chunk-HTFRRDSF.js → chunk-F2SMQ6ES.js} +3 -2
- package/dist/node-runtime/chunk-F2V2F4ZG.js +114 -0
- package/dist/node-runtime/{chunk-IKU6Y7DL.js → chunk-FE3WZI7F.js} +9 -6
- package/dist/node-runtime/{chunk-GYIXXQAO.js → chunk-FIRA54AC.js} +2 -5
- package/dist/node-runtime/{chunk-6VYZ5UFP.js → chunk-FLGEEH27.js} +1 -1
- package/dist/node-runtime/{chunk-5EFIU3OM.js → chunk-FTKEZL27.js} +1 -1
- package/dist/node-runtime/{chunk-RGQAEOM5.js → chunk-FYIFPFXE.js} +23 -6
- package/dist/node-runtime/{chunk-HMBGROQK.js → chunk-GLDXBBL6.js} +3 -3
- package/dist/node-runtime/{chunk-KWA4OC2J.js → chunk-H6YBCWKG.js} +1 -1
- package/dist/node-runtime/{chunk-2MI5OPMN.js → chunk-HNNHHJAB.js} +68 -50
- package/dist/node-runtime/{chunk-I74LN5JG.js → chunk-HUD2RFJW.js} +2 -2
- package/dist/node-runtime/{chunk-I54LGHWM.js → chunk-I2H5QMWW.js} +3 -3
- package/dist/node-runtime/{chunk-XHIRAZ26.js → chunk-IAZSK7KK.js} +1 -1
- package/dist/node-runtime/{chunk-X3PGBLQ7.js → chunk-IHHTWSXN.js} +9 -9
- package/dist/node-runtime/{chunk-DAPBPCBP.js → chunk-IPP5BIV5.js} +25 -3
- package/dist/node-runtime/{chunk-QFWG2RVL.js → chunk-IXG6F4NT.js} +11 -0
- package/dist/node-runtime/{chunk-RDDAZOMU.js → chunk-JL4HYQXK.js} +1 -1
- package/dist/node-runtime/{chunk-CDVHZOOK.js → chunk-JQYNHAKX.js} +1 -1
- package/dist/node-runtime/{chunk-L24TPBS4.js → chunk-JWEVT363.js} +37 -29
- package/dist/node-runtime/{chunk-2HMIRK7W.js → chunk-LHV3V67B.js} +5 -5
- package/dist/node-runtime/{chunk-UAEOTO52.js → chunk-MNQXDFPV.js} +6 -2
- package/dist/node-runtime/{chunk-T4DA4XE7.js → chunk-MQPKUHRN.js} +162 -82
- package/dist/node-runtime/{chunk-MPKSOJBT.js → chunk-NHATCSOI.js} +4 -7
- package/dist/node-runtime/{chunk-RMQZU2YU.js → chunk-NNNR3QIY.js} +1 -1
- package/dist/node-runtime/{chunk-RWTKOC3B.js → chunk-QBTJG3UM.js} +1 -1
- package/dist/node-runtime/{chunk-P7XBVXGT.js → chunk-QNVMKNNN.js} +18 -14
- package/dist/node-runtime/{chunk-GS42T6MX.js → chunk-QW3AAHWN.js} +1 -1
- package/dist/node-runtime/{chunk-DVQSHCVP.js → chunk-R4WSB2MQ.js} +5 -5
- package/dist/node-runtime/{chunk-B4HP6ZWM.js → chunk-RHCGYWO7.js} +1 -1
- package/dist/node-runtime/{chunk-2CFDTH5B.js → chunk-RLGY2QIL.js} +45 -59
- package/dist/node-runtime/{chunk-KKUTQQV7.js → chunk-RYRGL7P4.js} +1 -1
- package/dist/node-runtime/{chunk-5Q4A37RB.js → chunk-TCT6PCUR.js} +32 -11
- package/dist/node-runtime/{chunk-D5UCKPBQ.js → chunk-UBWW2PID.js} +1 -1
- package/dist/node-runtime/{chunk-E75WFZ33.js → chunk-UNUZICC4.js} +3 -3
- package/dist/node-runtime/{chunk-RAK2QA2B.js → chunk-UYRKUKFE.js} +4 -4
- package/dist/node-runtime/{chunk-LWJXTA6Z.js → chunk-VSUEAI7O.js} +1377 -45
- package/dist/node-runtime/{chunk-NAY6UUQZ.js → chunk-WDIVLMOH.js} +1 -1
- package/dist/node-runtime/{chunk-E24EO34J.js → chunk-WPXUR3HE.js} +1 -1
- package/dist/node-runtime/{chunk-SLVOAQOY.js → chunk-WXYNALHD.js} +113 -1
- package/dist/node-runtime/{chunk-KJ6DWS3K.js → chunk-XEOCUEUJ.js} +121 -60
- package/dist/node-runtime/chunk-YD3IZAZ7.js +47 -0
- package/dist/node-runtime/chunk-YSB6URMT.js +41 -0
- package/dist/node-runtime/{chunk-LJTIVM7I.js → chunk-ZDJUR45D.js} +427 -126
- package/dist/node-runtime/{chunk-YWOJIGFY.js → chunk-ZEVFBFNF.js} +95 -142
- package/dist/node-runtime/{chunk-5B6VKFEV.js → chunk-ZIQUS5QO.js} +1 -1
- package/dist/node-runtime/cli-runtime.js +4 -4
- package/dist/node-runtime/{command-FSBU2EVZ.js → command-3HMSY6W2.js} +5 -5
- package/dist/node-runtime/{commands-EMBQQVVT.js → commands-D6A6H4TS.js} +11 -18
- package/dist/node-runtime/{commands-NAAL7KNT.js → commands-OCSSEEWJ.js} +16 -16
- package/dist/node-runtime/{config-QDD5PUE2.js → config-CU7M7BTK.js} +1 -1
- package/dist/node-runtime/{config-D4QUPAHX.js → config-DS7XLMEM.js} +2 -2
- package/dist/node-runtime/{direct-tool-executor-4D7UXYU4.js → direct-tool-executor-2QJXVQD2.js} +6 -11
- package/dist/node-runtime/{exa-LL64QZR2.js → exa-6VBZNPGE.js} +1 -1
- package/dist/node-runtime/{export-html-VM4J2MNR.js → export-html-BRWF5AHI.js} +4 -4
- package/dist/node-runtime/{extension-input-E7BJZ35H.js → extension-input-VBBMX7YV.js} +5 -5
- package/dist/node-runtime/{extension-selector-WU42XDTU.js → extension-selector-T5AOG5XB.js} +5 -5
- package/dist/node-runtime/{extract-EQJE7FZZ.js → extract-BFX2N35A.js} +3 -3
- package/dist/node-runtime/{gateway-DQM333YV.js → gateway-6623C2U3.js} +51 -42
- package/dist/node-runtime/{gemini-search-35OCRFLN.js → gemini-search-C66QHDT6.js} +2 -2
- package/dist/node-runtime/{gemini-url-context-UQY3PHHW.js → gemini-url-context-T7DEK73R.js} +3 -3
- package/dist/node-runtime/{github-extract-F64RZOEA.js → github-extract-HOGE3D6F.js} +107 -38
- package/dist/node-runtime/{goal-NJEE5CTU.js → goal-AIHEDUYA.js} +5 -5
- package/dist/node-runtime/index.js +50 -48
- package/dist/node-runtime/{init-P5AUV77I.js → init-JBQJIPYI.js} +3 -6
- package/dist/node-runtime/{install-cli-NN4YAU44.js → install-cli-INGHIVBY.js} +30 -25
- package/dist/node-runtime/interactive-mode-FM5DNUSW.js +74 -0
- package/dist/node-runtime/{interactive-view-NGFAMHPW.js → interactive-view-K33PM4OS.js} +8 -8
- package/dist/node-runtime/{lsp-manager-3ASUSO4T.js → lsp-manager-S554V5HR.js} +240 -155
- package/dist/node-runtime/{lunr-browser-IR7TL3J7.js → lunr-browser-H4FDOR3C.js} +7 -7
- package/dist/node-runtime/{lunr-computer-use-Y23CCDIJ.js → lunr-computer-use-VDP2QNRQ.js} +9 -9
- package/dist/node-runtime/{lunr-cron-USHC4LXH.js → lunr-cron-LKVA5CZZ.js} +93 -80
- package/dist/node-runtime/main.js +42 -41
- package/dist/node-runtime/{mobile-commands-O5LCHL32.js → mobile-commands-XT3NQXLD.js} +12 -12
- package/dist/node-runtime/{model-runtime-OO5HFLWE.js → model-runtime-MZ2JMDV4.js} +4 -4
- package/dist/node-runtime/{openai-search-B3MSNCQA.js → openai-search-K72LJDYN.js} +1 -1
- package/dist/node-runtime/{package-manager-cli-Q7BL6KZO.js → package-manager-cli-CYM262SI.js} +20 -20
- package/dist/node-runtime/{parallel-AI2MNSCU.js → parallel-X724NCNU.js} +1 -1
- package/dist/node-runtime/{perplexity-QVJW3I35.js → perplexity-RDHQHVMK.js} +2 -2
- package/dist/node-runtime/{pi-intercom-QM53RLTS.js → pi-intercom-NHHEPBMI.js} +2 -2
- package/dist/node-runtime/{pi-mcp-adapter-3PHF4KZ4.js → pi-mcp-adapter-PP3GQJQ2.js} +98 -94
- package/dist/node-runtime/{pi-ollama-cloud-2F3Y2QNM.js → pi-ollama-cloud-4MNWIMFN.js} +11 -24
- package/dist/node-runtime/{pi-prompt-template-model-QWTCGLJU.js → pi-prompt-template-model-FTGELLS5.js} +32 -36
- package/dist/node-runtime/{pi-subagents-7IBSSGEW.js → pi-subagents-LT3CTO4E.js} +98 -106
- package/dist/node-runtime/{pi-web-access-WTGMNZ32.js → pi-web-access-Z3LP246C.js} +144 -108
- package/dist/node-runtime/{print-mode-XQ76CYMT.js → print-mode-2XHN5SUA.js} +3 -3
- package/dist/node-runtime/{process-registry-4FAKZQOL.js → process-registry-Q4QWIU33.js} +3 -3
- package/dist/node-runtime/{proxy-modes-5FAPSZEZ.js → proxy-modes-VEGC6QG5.js} +8 -15
- package/dist/node-runtime/rpc-entry.js +42 -41
- package/dist/node-runtime/{rpc-mode-O3XV4SID.js → rpc-mode-32DHJPEJ.js} +4 -4
- package/dist/node-runtime/{runtime-4VA6JKNF.js → runtime-EDUUGAQD.js} +56 -46
- package/dist/node-runtime/{runtime-EFPPD2UW.js → runtime-UGXM4NPQ.js} +2 -2
- package/dist/node-runtime/{runtime-bridges-7WVCLI76.js → runtime-bridges-DNKMNJCF.js} +7 -7
- package/dist/node-runtime/{service-MDQIPQ26.js → service-IHLGFLBT.js} +6 -4
- package/dist/node-runtime/{session-handoff-GWARVEWT.js → session-handoff-LNSPDTKY.js} +4 -4
- package/dist/node-runtime/{session-manager-JB5J6XBN.js → session-manager-YIFIAVGC.js} +3 -3
- package/dist/node-runtime/{session-selector-GIM4DHQ2.js → session-selector-I73U3EIO.js} +7 -7
- package/dist/node-runtime/{settings-manager-DJDM5AHM.js → settings-manager-P2TKGYTR.js} +5 -5
- package/dist/node-runtime/{setup-JBKOLJ6F.js → setup-H7CCELIL.js} +15 -1
- package/dist/node-runtime/{setup-PFBWRNUI.js → setup-OLQ4GXWS.js} +17 -17
- package/dist/node-runtime/{src-IVPNZ2BX.js → src-6RV4PXKJ.js} +64 -36
- package/dist/node-runtime/{subagent-executor-LPZ4BHWE.js → subagent-executor-Q5F7DBVM.js} +119 -58
- package/dist/node-runtime/{tavily-WEZFVFP7.js → tavily-KZBFYQB6.js} +1 -1
- package/dist/node-runtime/{theme-UOO5RVFN.js → theme-YLVZKKZD.js} +2 -2
- package/dist/node-runtime/{trust-manager-MMISNCYO.js → trust-manager-ZCU76D23.js} +2 -2
- package/dist/node-runtime/{update-cli-HNMOTNGX.js → update-cli-F3XXJANQ.js} +6 -6
- package/dist/node-runtime/{usage-service-LFB2SWYV.js → usage-service-CPAGBED5.js} +1 -1
- package/dist/node-runtime/{video-extract-OOZHR7SU.js → video-extract-UPKYIBW3.js} +3 -3
- package/dist/node-runtime/{workflow-OHPBEFO4.js → workflow-ICDI4N3J.js} +208 -78
- package/dist/node-runtime/{youtube-extract-FNPAUNHU.js → youtube-extract-77NT7FWH.js} +4 -4
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +25 -10
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +2 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/paths.d.ts +4 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +33 -2
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/sanitize-terminal-text.d.ts +7 -0
- package/dist/utils/sanitize-terminal-text.d.ts.map +1 -0
- package/dist/utils/sanitize-terminal-text.js +67 -0
- package/dist/utils/sanitize-terminal-text.js.map +1 -0
- package/docs/browser.md +1 -1
- package/docs/custom-provider.md +3 -3
- package/docs/extensions.md +8 -4
- package/docs/features.md +15 -7
- package/docs/keybindings.md +1 -1
- package/docs/models.md +5 -5
- package/docs/packages.md +1 -1
- package/docs/providers.md +2 -2
- package/docs/rpc.md +7 -7
- package/docs/security.md +10 -5
- package/docs/sessions.md +2 -2
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +7 -7
- package/docs/themes.md +1 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/auto-commit-on-exit.ts +1 -1
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +1 -1
- package/examples/extensions/claude-rules.ts +1 -1
- package/examples/extensions/commands.ts +1 -1
- package/examples/extensions/custom-compaction.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +3 -3
- 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 +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/git-merge-and-resolve.ts +2 -2
- package/examples/extensions/gondolin/index.ts +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/inline-bash.ts +2 -2
- package/examples/extensions/input-transform-streaming.ts +2 -2
- package/examples/extensions/input-transform.ts +2 -2
- 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/minimal-mode.ts +1 -1
- package/examples/extensions/modal-editor.ts +1 -1
- package/examples/extensions/model-status.ts +1 -1
- package/examples/extensions/notify.ts +3 -3
- package/examples/extensions/overlay-qa-tests.ts +1 -1
- package/examples/extensions/overlay-test.ts +1 -1
- package/examples/extensions/pirate.ts +1 -1
- package/examples/extensions/preset.ts +3 -3
- package/examples/extensions/project-trust.ts +4 -4
- package/examples/extensions/prompt-customizer.ts +1 -1
- package/examples/extensions/rainbow-editor.ts +1 -1
- package/examples/extensions/rpc-demo.ts +1 -1
- package/examples/extensions/sandbox/index.ts +7 -7
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/shutdown-command.ts +5 -5
- package/examples/extensions/ssh.ts +2 -2
- package/examples/extensions/subagent/README.md +3 -3
- package/examples/extensions/subagent/index.ts +2 -2
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/extensions/tools.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/sdk/01-minimal.ts +1 -1
- package/examples/sdk/03-custom-prompt.ts +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/examples/sdk/06-extensions.ts +2 -2
- package/examples/sdk/08-prompt-templates.ts +1 -1
- package/install-lock/package-lock.json +24 -24
- package/install-lock/package.json +2 -2
- package/npm-shrinkwrap.json +60 -24
- package/package.json +9 -9
- package/dist/modes/interactive/components/exit-card.d.ts +0 -22
- package/dist/modes/interactive/components/exit-card.d.ts.map +0 -1
- package/dist/modes/interactive/components/exit-card.js +0 -69
- package/dist/modes/interactive/components/exit-card.js.map +0 -1
- package/dist/node-runtime/agent-session-services-5YXS2PLF.js +0 -51
- package/dist/node-runtime/chunk-2IDTZAG5.js +0 -1415
- package/dist/node-runtime/chunk-3MISGG4S.js +0 -769
- package/dist/node-runtime/chunk-4HXHDDCF.js +0 -16
- package/dist/node-runtime/chunk-5B5QN3ZQ.js +0 -356
- package/dist/node-runtime/chunk-7IQGBKBJ.js +0 -2033
- package/dist/node-runtime/chunk-AUXVGBO4.js +0 -19
- package/dist/node-runtime/chunk-PTFBPO3C.js +0 -50
- package/dist/node-runtime/interactive-mode-YOHZVMKX.js +0 -74
- package/dist/node-runtime/mcp-auth-flow-QVLFVLEO.js +0 -33
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
AjvJsonSchemaValidator,
|
|
4
|
-
Client,
|
|
5
|
-
StdioClientTransport
|
|
6
|
-
} from "./chunk-LWJXTA6Z.js";
|
|
7
|
-
import {
|
|
8
|
-
McpOAuthProvider,
|
|
9
|
-
StreamableHTTPClientTransport,
|
|
10
|
-
UnauthorizedError,
|
|
11
|
-
auth,
|
|
12
|
-
createFetchWithInit,
|
|
13
|
-
createParser,
|
|
14
|
-
extractOAuthConfig,
|
|
15
|
-
extractWWWAuthenticateParams,
|
|
16
|
-
normalizeHeaders,
|
|
17
|
-
supportsOAuth
|
|
18
|
-
} from "./chunk-7IQGBKBJ.js";
|
|
19
|
-
import {
|
|
20
4
|
CallToolResultSchema,
|
|
5
|
+
Client,
|
|
21
6
|
ContentBlockSchema,
|
|
22
7
|
CreateMessageRequestSchema,
|
|
23
8
|
ElicitRequestSchema,
|
|
@@ -26,16 +11,22 @@ import {
|
|
|
26
11
|
ErrorCode,
|
|
27
12
|
ImplementationSchema,
|
|
28
13
|
JSONRPCMessageSchema,
|
|
14
|
+
LATEST_PROTOCOL_VERSION,
|
|
29
15
|
McpError,
|
|
30
16
|
RequestIdSchema,
|
|
31
17
|
ResourceLinkSchema,
|
|
18
|
+
StdioClientTransport,
|
|
32
19
|
ToolSchema,
|
|
33
|
-
UrlElicitationRequiredError
|
|
34
|
-
|
|
20
|
+
UrlElicitationRequiredError,
|
|
21
|
+
isInitializedNotification,
|
|
22
|
+
isJSONRPCRequest,
|
|
23
|
+
isJSONRPCResultResponse
|
|
24
|
+
} from "./chunk-VSUEAI7O.js";
|
|
35
25
|
import {
|
|
36
26
|
abortable,
|
|
37
27
|
computeServerHash,
|
|
38
28
|
extractToolUiStreamMode,
|
|
29
|
+
getAgentPath,
|
|
39
30
|
getMetadataCachePath,
|
|
40
31
|
getMissingConfiguredDirectToolServers,
|
|
41
32
|
interpolateEnvRecord,
|
|
@@ -52,10 +43,7 @@ import {
|
|
|
52
43
|
serializeTools,
|
|
53
44
|
throwIfAborted,
|
|
54
45
|
truncateAtWord
|
|
55
|
-
} from "./chunk-
|
|
56
|
-
import {
|
|
57
|
-
getAgentPath
|
|
58
|
-
} from "./chunk-4HXHDDCF.js";
|
|
46
|
+
} from "./chunk-B2IBAXNX.js";
|
|
59
47
|
import {
|
|
60
48
|
formatToolName,
|
|
61
49
|
isToolExcluded,
|
|
@@ -63,14 +51,1999 @@ import {
|
|
|
63
51
|
serverStreamResultPatchNotificationSchema
|
|
64
52
|
} from "./chunk-ARC4KOTI.js";
|
|
65
53
|
import {
|
|
66
|
-
|
|
54
|
+
NEVER,
|
|
55
|
+
ZodIssueCode,
|
|
56
|
+
any,
|
|
57
|
+
array,
|
|
58
|
+
boolean,
|
|
59
|
+
coerce_exports,
|
|
60
|
+
external_exports,
|
|
61
|
+
literal,
|
|
62
|
+
looseObject,
|
|
63
|
+
number,
|
|
64
|
+
object,
|
|
65
|
+
string,
|
|
66
|
+
url
|
|
67
67
|
} from "./chunk-BI3DHYCN.js";
|
|
68
68
|
import {
|
|
69
|
-
|
|
69
|
+
__commonJS,
|
|
70
|
+
__require,
|
|
71
|
+
__toESM
|
|
70
72
|
} from "./chunk-BRJX2PRC.js";
|
|
71
73
|
|
|
74
|
+
// node_modules/content-type/index.js
|
|
75
|
+
var require_content_type = __commonJS({
|
|
76
|
+
"node_modules/content-type/index.js"(exports) {
|
|
77
|
+
"use strict";
|
|
78
|
+
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g, TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/, TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g, QUOTE_REGEXP = /([\\"])/g, TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
79
|
+
exports.format = format;
|
|
80
|
+
exports.parse = parse;
|
|
81
|
+
function format(obj) {
|
|
82
|
+
if (!obj || typeof obj != "object")
|
|
83
|
+
throw new TypeError("argument obj is required");
|
|
84
|
+
var parameters = obj.parameters, type = obj.type;
|
|
85
|
+
if (!type || !TYPE_REGEXP.test(type))
|
|
86
|
+
throw new TypeError("invalid type");
|
|
87
|
+
var string2 = type;
|
|
88
|
+
if (parameters && typeof parameters == "object")
|
|
89
|
+
for (var param, params = Object.keys(parameters).sort(), i2 = 0; i2 < params.length; i2++) {
|
|
90
|
+
if (param = params[i2], !TOKEN_REGEXP.test(param))
|
|
91
|
+
throw new TypeError("invalid parameter name");
|
|
92
|
+
string2 += "; " + param + "=" + qstring(parameters[param]);
|
|
93
|
+
}
|
|
94
|
+
return string2;
|
|
95
|
+
}
|
|
96
|
+
function parse(string2) {
|
|
97
|
+
if (!string2)
|
|
98
|
+
throw new TypeError("argument string is required");
|
|
99
|
+
var header = typeof string2 == "object" ? getcontenttype(string2) : string2;
|
|
100
|
+
if (typeof header != "string")
|
|
101
|
+
throw new TypeError("argument string is required to be a string");
|
|
102
|
+
var index = header.indexOf(";"), type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
103
|
+
if (!TYPE_REGEXP.test(type))
|
|
104
|
+
throw new TypeError("invalid media type");
|
|
105
|
+
var obj = new ContentType(type.toLowerCase());
|
|
106
|
+
if (index !== -1) {
|
|
107
|
+
var key, match, value;
|
|
108
|
+
for (PARAM_REGEXP.lastIndex = index; match = PARAM_REGEXP.exec(header); ) {
|
|
109
|
+
if (match.index !== index)
|
|
110
|
+
throw new TypeError("invalid parameter format");
|
|
111
|
+
index += match[0].length, key = match[1].toLowerCase(), value = match[2], value.charCodeAt(0) === 34 && (value = value.slice(1, -1), value.indexOf("\\") !== -1 && (value = value.replace(QESC_REGEXP, "$1"))), obj.parameters[key] = value;
|
|
112
|
+
}
|
|
113
|
+
if (index !== header.length)
|
|
114
|
+
throw new TypeError("invalid parameter format");
|
|
115
|
+
}
|
|
116
|
+
return obj;
|
|
117
|
+
}
|
|
118
|
+
function getcontenttype(obj) {
|
|
119
|
+
var header;
|
|
120
|
+
if (typeof obj.getHeader == "function" ? header = obj.getHeader("content-type") : typeof obj.headers == "object" && (header = obj.headers && obj.headers["content-type"]), typeof header != "string")
|
|
121
|
+
throw new TypeError("content-type header is missing from object");
|
|
122
|
+
return header;
|
|
123
|
+
}
|
|
124
|
+
function qstring(val) {
|
|
125
|
+
var str = String(val);
|
|
126
|
+
if (TOKEN_REGEXP.test(str))
|
|
127
|
+
return str;
|
|
128
|
+
if (str.length > 0 && !TEXT_REGEXP.test(str))
|
|
129
|
+
throw new TypeError("invalid parameter value");
|
|
130
|
+
return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
|
|
131
|
+
}
|
|
132
|
+
function ContentType(type) {
|
|
133
|
+
this.parameters = /* @__PURE__ */ Object.create(null), this.type = type;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// node_modules/pkce-challenge/dist/index.node.js
|
|
139
|
+
var crypto2;
|
|
140
|
+
crypto2 = globalThis.crypto?.webcrypto ?? // Node.js [18-16] REPL
|
|
141
|
+
globalThis.crypto ?? // Node.js >18
|
|
142
|
+
import("node:crypto").then((m) => m.webcrypto);
|
|
143
|
+
async function getRandomValues(size) {
|
|
144
|
+
return (await crypto2).getRandomValues(new Uint8Array(size));
|
|
145
|
+
}
|
|
146
|
+
async function random(size) {
|
|
147
|
+
let mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length, result = "";
|
|
148
|
+
for (; result.length < size; ) {
|
|
149
|
+
let randomBytes = await getRandomValues(size - result.length);
|
|
150
|
+
for (let randomByte of randomBytes)
|
|
151
|
+
randomByte < evenDistCutoff && (result += mask[randomByte % mask.length]);
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
async function generateVerifier(length) {
|
|
156
|
+
return await random(length);
|
|
157
|
+
}
|
|
158
|
+
async function generateChallenge(code_verifier) {
|
|
159
|
+
let buffer = await (await crypto2).subtle.digest("SHA-256", new TextEncoder().encode(code_verifier));
|
|
160
|
+
return btoa(String.fromCharCode(...new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
|
|
161
|
+
}
|
|
162
|
+
async function pkceChallenge(length) {
|
|
163
|
+
if (length || (length = 43), length < 43 || length > 128)
|
|
164
|
+
throw `Expected a length between 43 and 128. Received ${length}.`;
|
|
165
|
+
let verifier = await generateVerifier(length), challenge = await generateChallenge(verifier);
|
|
166
|
+
return {
|
|
167
|
+
code_verifier: verifier,
|
|
168
|
+
code_challenge: challenge
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
|
|
173
|
+
var SafeUrlSchema = url().superRefine((val, ctx) => {
|
|
174
|
+
if (!URL.canParse(val))
|
|
175
|
+
return ctx.addIssue({
|
|
176
|
+
code: ZodIssueCode.custom,
|
|
177
|
+
message: "URL must be parseable",
|
|
178
|
+
fatal: !0
|
|
179
|
+
}), NEVER;
|
|
180
|
+
}).refine((url2) => {
|
|
181
|
+
let u2 = new URL(url2);
|
|
182
|
+
return u2.protocol !== "javascript:" && u2.protocol !== "data:" && u2.protocol !== "vbscript:";
|
|
183
|
+
}, { message: "URL cannot use javascript:, data:, or vbscript: scheme" }), OAuthProtectedResourceMetadataSchema = looseObject({
|
|
184
|
+
resource: string().url(),
|
|
185
|
+
authorization_servers: array(SafeUrlSchema).optional(),
|
|
186
|
+
jwks_uri: string().url().optional(),
|
|
187
|
+
scopes_supported: array(string()).optional(),
|
|
188
|
+
bearer_methods_supported: array(string()).optional(),
|
|
189
|
+
resource_signing_alg_values_supported: array(string()).optional(),
|
|
190
|
+
resource_name: string().optional(),
|
|
191
|
+
resource_documentation: string().optional(),
|
|
192
|
+
resource_policy_uri: string().url().optional(),
|
|
193
|
+
resource_tos_uri: string().url().optional(),
|
|
194
|
+
tls_client_certificate_bound_access_tokens: boolean().optional(),
|
|
195
|
+
authorization_details_types_supported: array(string()).optional(),
|
|
196
|
+
dpop_signing_alg_values_supported: array(string()).optional(),
|
|
197
|
+
dpop_bound_access_tokens_required: boolean().optional()
|
|
198
|
+
}), OAuthMetadataSchema = looseObject({
|
|
199
|
+
issuer: string(),
|
|
200
|
+
authorization_endpoint: SafeUrlSchema,
|
|
201
|
+
token_endpoint: SafeUrlSchema,
|
|
202
|
+
registration_endpoint: SafeUrlSchema.optional(),
|
|
203
|
+
scopes_supported: array(string()).optional(),
|
|
204
|
+
response_types_supported: array(string()),
|
|
205
|
+
response_modes_supported: array(string()).optional(),
|
|
206
|
+
grant_types_supported: array(string()).optional(),
|
|
207
|
+
token_endpoint_auth_methods_supported: array(string()).optional(),
|
|
208
|
+
token_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
209
|
+
service_documentation: SafeUrlSchema.optional(),
|
|
210
|
+
revocation_endpoint: SafeUrlSchema.optional(),
|
|
211
|
+
revocation_endpoint_auth_methods_supported: array(string()).optional(),
|
|
212
|
+
revocation_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
213
|
+
introspection_endpoint: string().optional(),
|
|
214
|
+
introspection_endpoint_auth_methods_supported: array(string()).optional(),
|
|
215
|
+
introspection_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
216
|
+
code_challenge_methods_supported: array(string()).optional(),
|
|
217
|
+
client_id_metadata_document_supported: boolean().optional()
|
|
218
|
+
}), OpenIdProviderMetadataSchema = looseObject({
|
|
219
|
+
issuer: string(),
|
|
220
|
+
authorization_endpoint: SafeUrlSchema,
|
|
221
|
+
token_endpoint: SafeUrlSchema,
|
|
222
|
+
userinfo_endpoint: SafeUrlSchema.optional(),
|
|
223
|
+
jwks_uri: SafeUrlSchema,
|
|
224
|
+
registration_endpoint: SafeUrlSchema.optional(),
|
|
225
|
+
scopes_supported: array(string()).optional(),
|
|
226
|
+
response_types_supported: array(string()),
|
|
227
|
+
response_modes_supported: array(string()).optional(),
|
|
228
|
+
grant_types_supported: array(string()).optional(),
|
|
229
|
+
acr_values_supported: array(string()).optional(),
|
|
230
|
+
subject_types_supported: array(string()),
|
|
231
|
+
id_token_signing_alg_values_supported: array(string()),
|
|
232
|
+
id_token_encryption_alg_values_supported: array(string()).optional(),
|
|
233
|
+
id_token_encryption_enc_values_supported: array(string()).optional(),
|
|
234
|
+
userinfo_signing_alg_values_supported: array(string()).optional(),
|
|
235
|
+
userinfo_encryption_alg_values_supported: array(string()).optional(),
|
|
236
|
+
userinfo_encryption_enc_values_supported: array(string()).optional(),
|
|
237
|
+
request_object_signing_alg_values_supported: array(string()).optional(),
|
|
238
|
+
request_object_encryption_alg_values_supported: array(string()).optional(),
|
|
239
|
+
request_object_encryption_enc_values_supported: array(string()).optional(),
|
|
240
|
+
token_endpoint_auth_methods_supported: array(string()).optional(),
|
|
241
|
+
token_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
242
|
+
display_values_supported: array(string()).optional(),
|
|
243
|
+
claim_types_supported: array(string()).optional(),
|
|
244
|
+
claims_supported: array(string()).optional(),
|
|
245
|
+
service_documentation: string().optional(),
|
|
246
|
+
claims_locales_supported: array(string()).optional(),
|
|
247
|
+
ui_locales_supported: array(string()).optional(),
|
|
248
|
+
claims_parameter_supported: boolean().optional(),
|
|
249
|
+
request_parameter_supported: boolean().optional(),
|
|
250
|
+
request_uri_parameter_supported: boolean().optional(),
|
|
251
|
+
require_request_uri_registration: boolean().optional(),
|
|
252
|
+
op_policy_uri: SafeUrlSchema.optional(),
|
|
253
|
+
op_tos_uri: SafeUrlSchema.optional(),
|
|
254
|
+
client_id_metadata_document_supported: boolean().optional()
|
|
255
|
+
}), OpenIdProviderDiscoveryMetadataSchema = object({
|
|
256
|
+
...OpenIdProviderMetadataSchema.shape,
|
|
257
|
+
...OAuthMetadataSchema.pick({
|
|
258
|
+
code_challenge_methods_supported: !0
|
|
259
|
+
}).shape
|
|
260
|
+
}), OAuthTokensSchema = object({
|
|
261
|
+
access_token: string(),
|
|
262
|
+
id_token: string().optional(),
|
|
263
|
+
// Optional for OAuth 2.1, but necessary in OpenID Connect
|
|
264
|
+
token_type: string(),
|
|
265
|
+
expires_in: coerce_exports.number().optional(),
|
|
266
|
+
scope: string().optional(),
|
|
267
|
+
refresh_token: string().optional()
|
|
268
|
+
}).strip(), OAuthErrorResponseSchema = object({
|
|
269
|
+
error: string(),
|
|
270
|
+
error_description: string().optional(),
|
|
271
|
+
error_uri: string().optional()
|
|
272
|
+
}), OptionalSafeUrlSchema = SafeUrlSchema.optional().or(literal("").transform(() => {
|
|
273
|
+
})), OAuthClientMetadataSchema = object({
|
|
274
|
+
redirect_uris: array(SafeUrlSchema),
|
|
275
|
+
token_endpoint_auth_method: string().optional(),
|
|
276
|
+
grant_types: array(string()).optional(),
|
|
277
|
+
response_types: array(string()).optional(),
|
|
278
|
+
client_name: string().optional(),
|
|
279
|
+
client_uri: SafeUrlSchema.optional(),
|
|
280
|
+
logo_uri: OptionalSafeUrlSchema,
|
|
281
|
+
scope: string().optional(),
|
|
282
|
+
contacts: array(string()).optional(),
|
|
283
|
+
tos_uri: OptionalSafeUrlSchema,
|
|
284
|
+
policy_uri: string().optional(),
|
|
285
|
+
jwks_uri: SafeUrlSchema.optional(),
|
|
286
|
+
jwks: any().optional(),
|
|
287
|
+
software_id: string().optional(),
|
|
288
|
+
software_version: string().optional(),
|
|
289
|
+
software_statement: string().optional()
|
|
290
|
+
}).strip(), OAuthClientInformationSchema = object({
|
|
291
|
+
client_id: string(),
|
|
292
|
+
client_secret: string().optional(),
|
|
293
|
+
client_id_issued_at: number().optional(),
|
|
294
|
+
client_secret_expires_at: number().optional()
|
|
295
|
+
}).strip(), OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema), OAuthClientRegistrationErrorSchema = object({
|
|
296
|
+
error: string(),
|
|
297
|
+
error_description: string().optional()
|
|
298
|
+
}).strip(), OAuthTokenRevocationRequestSchema = object({
|
|
299
|
+
token: string(),
|
|
300
|
+
token_type_hint: string().optional()
|
|
301
|
+
}).strip();
|
|
302
|
+
|
|
303
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js
|
|
304
|
+
function resourceUrlFromServerUrl(url2) {
|
|
305
|
+
let resourceURL = typeof url2 == "string" ? new URL(url2) : new URL(url2.href);
|
|
306
|
+
return resourceURL.hash = "", resourceURL;
|
|
307
|
+
}
|
|
308
|
+
function checkResourceAllowed({ requestedResource, configuredResource }) {
|
|
309
|
+
let requested = typeof requestedResource == "string" ? new URL(requestedResource) : new URL(requestedResource.href), configured = typeof configuredResource == "string" ? new URL(configuredResource) : new URL(configuredResource.href);
|
|
310
|
+
if (requested.origin !== configured.origin || requested.pathname.length < configured.pathname.length)
|
|
311
|
+
return !1;
|
|
312
|
+
let requestedPath = requested.pathname.endsWith("/") ? requested.pathname : requested.pathname + "/", configuredPath = configured.pathname.endsWith("/") ? configured.pathname : configured.pathname + "/";
|
|
313
|
+
return requestedPath.startsWith(configuredPath);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js
|
|
317
|
+
var OAuthError = class extends Error {
|
|
318
|
+
constructor(message, errorUri) {
|
|
319
|
+
super(message), this.errorUri = errorUri, this.name = this.constructor.name;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Converts the error to a standard OAuth error response object
|
|
323
|
+
*/
|
|
324
|
+
toResponseObject() {
|
|
325
|
+
let response = {
|
|
326
|
+
error: this.errorCode,
|
|
327
|
+
error_description: this.message
|
|
328
|
+
};
|
|
329
|
+
return this.errorUri && (response.error_uri = this.errorUri), response;
|
|
330
|
+
}
|
|
331
|
+
get errorCode() {
|
|
332
|
+
return this.constructor.errorCode;
|
|
333
|
+
}
|
|
334
|
+
}, InvalidRequestError = class extends OAuthError {
|
|
335
|
+
};
|
|
336
|
+
InvalidRequestError.errorCode = "invalid_request";
|
|
337
|
+
var InvalidClientError = class extends OAuthError {
|
|
338
|
+
};
|
|
339
|
+
InvalidClientError.errorCode = "invalid_client";
|
|
340
|
+
var InvalidGrantError = class extends OAuthError {
|
|
341
|
+
};
|
|
342
|
+
InvalidGrantError.errorCode = "invalid_grant";
|
|
343
|
+
var UnauthorizedClientError = class extends OAuthError {
|
|
344
|
+
};
|
|
345
|
+
UnauthorizedClientError.errorCode = "unauthorized_client";
|
|
346
|
+
var UnsupportedGrantTypeError = class extends OAuthError {
|
|
347
|
+
};
|
|
348
|
+
UnsupportedGrantTypeError.errorCode = "unsupported_grant_type";
|
|
349
|
+
var InvalidScopeError = class extends OAuthError {
|
|
350
|
+
};
|
|
351
|
+
InvalidScopeError.errorCode = "invalid_scope";
|
|
352
|
+
var AccessDeniedError = class extends OAuthError {
|
|
353
|
+
};
|
|
354
|
+
AccessDeniedError.errorCode = "access_denied";
|
|
355
|
+
var ServerError = class extends OAuthError {
|
|
356
|
+
};
|
|
357
|
+
ServerError.errorCode = "server_error";
|
|
358
|
+
var TemporarilyUnavailableError = class extends OAuthError {
|
|
359
|
+
};
|
|
360
|
+
TemporarilyUnavailableError.errorCode = "temporarily_unavailable";
|
|
361
|
+
var UnsupportedResponseTypeError = class extends OAuthError {
|
|
362
|
+
};
|
|
363
|
+
UnsupportedResponseTypeError.errorCode = "unsupported_response_type";
|
|
364
|
+
var UnsupportedTokenTypeError = class extends OAuthError {
|
|
365
|
+
};
|
|
366
|
+
UnsupportedTokenTypeError.errorCode = "unsupported_token_type";
|
|
367
|
+
var InvalidTokenError = class extends OAuthError {
|
|
368
|
+
};
|
|
369
|
+
InvalidTokenError.errorCode = "invalid_token";
|
|
370
|
+
var MethodNotAllowedError = class extends OAuthError {
|
|
371
|
+
};
|
|
372
|
+
MethodNotAllowedError.errorCode = "method_not_allowed";
|
|
373
|
+
var TooManyRequestsError = class extends OAuthError {
|
|
374
|
+
};
|
|
375
|
+
TooManyRequestsError.errorCode = "too_many_requests";
|
|
376
|
+
var InvalidClientMetadataError = class extends OAuthError {
|
|
377
|
+
};
|
|
378
|
+
InvalidClientMetadataError.errorCode = "invalid_client_metadata";
|
|
379
|
+
var InsufficientScopeError = class extends OAuthError {
|
|
380
|
+
};
|
|
381
|
+
InsufficientScopeError.errorCode = "insufficient_scope";
|
|
382
|
+
var InvalidTargetError = class extends OAuthError {
|
|
383
|
+
};
|
|
384
|
+
InvalidTargetError.errorCode = "invalid_target";
|
|
385
|
+
var OAUTH_ERRORS = {
|
|
386
|
+
[InvalidRequestError.errorCode]: InvalidRequestError,
|
|
387
|
+
[InvalidClientError.errorCode]: InvalidClientError,
|
|
388
|
+
[InvalidGrantError.errorCode]: InvalidGrantError,
|
|
389
|
+
[UnauthorizedClientError.errorCode]: UnauthorizedClientError,
|
|
390
|
+
[UnsupportedGrantTypeError.errorCode]: UnsupportedGrantTypeError,
|
|
391
|
+
[InvalidScopeError.errorCode]: InvalidScopeError,
|
|
392
|
+
[AccessDeniedError.errorCode]: AccessDeniedError,
|
|
393
|
+
[ServerError.errorCode]: ServerError,
|
|
394
|
+
[TemporarilyUnavailableError.errorCode]: TemporarilyUnavailableError,
|
|
395
|
+
[UnsupportedResponseTypeError.errorCode]: UnsupportedResponseTypeError,
|
|
396
|
+
[UnsupportedTokenTypeError.errorCode]: UnsupportedTokenTypeError,
|
|
397
|
+
[InvalidTokenError.errorCode]: InvalidTokenError,
|
|
398
|
+
[MethodNotAllowedError.errorCode]: MethodNotAllowedError,
|
|
399
|
+
[TooManyRequestsError.errorCode]: TooManyRequestsError,
|
|
400
|
+
[InvalidClientMetadataError.errorCode]: InvalidClientMetadataError,
|
|
401
|
+
[InsufficientScopeError.errorCode]: InsufficientScopeError,
|
|
402
|
+
[InvalidTargetError.errorCode]: InvalidTargetError
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js
|
|
406
|
+
var UnauthorizedError = class extends Error {
|
|
407
|
+
constructor(message) {
|
|
408
|
+
super(message ?? "Unauthorized");
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
function isClientAuthMethod(method) {
|
|
412
|
+
return ["client_secret_basic", "client_secret_post", "none"].includes(method);
|
|
413
|
+
}
|
|
414
|
+
var AUTHORIZATION_CODE_RESPONSE_TYPE = "code", AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
|
|
415
|
+
function selectClientAuthMethod(clientInformation, supportedMethods) {
|
|
416
|
+
let hasClientSecret = clientInformation.client_secret !== void 0;
|
|
417
|
+
return "token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && (supportedMethods.length === 0 || supportedMethods.includes(clientInformation.token_endpoint_auth_method)) ? clientInformation.token_endpoint_auth_method : supportedMethods.length === 0 ? hasClientSecret ? "client_secret_basic" : "none" : hasClientSecret && supportedMethods.includes("client_secret_basic") ? "client_secret_basic" : hasClientSecret && supportedMethods.includes("client_secret_post") ? "client_secret_post" : supportedMethods.includes("none") ? "none" : hasClientSecret ? "client_secret_post" : "none";
|
|
418
|
+
}
|
|
419
|
+
function applyClientAuthentication(method, clientInformation, headers, params) {
|
|
420
|
+
let { client_id, client_secret } = clientInformation;
|
|
421
|
+
switch (method) {
|
|
422
|
+
case "client_secret_basic":
|
|
423
|
+
applyBasicAuth(client_id, client_secret, headers);
|
|
424
|
+
return;
|
|
425
|
+
case "client_secret_post":
|
|
426
|
+
applyPostAuth(client_id, client_secret, params);
|
|
427
|
+
return;
|
|
428
|
+
case "none":
|
|
429
|
+
applyPublicAuth(client_id, params);
|
|
430
|
+
return;
|
|
431
|
+
default:
|
|
432
|
+
throw new Error(`Unsupported client authentication method: ${method}`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function applyBasicAuth(clientId, clientSecret, headers) {
|
|
436
|
+
if (!clientSecret)
|
|
437
|
+
throw new Error("client_secret_basic authentication requires a client_secret");
|
|
438
|
+
let credentials = btoa(`${clientId}:${clientSecret}`);
|
|
439
|
+
headers.set("Authorization", `Basic ${credentials}`);
|
|
440
|
+
}
|
|
441
|
+
function applyPostAuth(clientId, clientSecret, params) {
|
|
442
|
+
params.set("client_id", clientId), clientSecret && params.set("client_secret", clientSecret);
|
|
443
|
+
}
|
|
444
|
+
function applyPublicAuth(clientId, params) {
|
|
445
|
+
params.set("client_id", clientId);
|
|
446
|
+
}
|
|
447
|
+
async function parseErrorResponse(input) {
|
|
448
|
+
let statusCode = input instanceof Response ? input.status : void 0, body = input instanceof Response ? await input.text() : input;
|
|
449
|
+
try {
|
|
450
|
+
let result = OAuthErrorResponseSchema.parse(JSON.parse(body)), { error, error_description, error_uri } = result, errorClass = OAUTH_ERRORS[error] || ServerError;
|
|
451
|
+
return new errorClass(error_description || "", error_uri);
|
|
452
|
+
} catch (error) {
|
|
453
|
+
let errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}Invalid OAuth error response: ${error}. Raw body: ${body}`;
|
|
454
|
+
return new ServerError(errorMessage);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
async function auth(provider, options) {
|
|
458
|
+
try {
|
|
459
|
+
return await authInternal(provider, options);
|
|
460
|
+
} catch (error) {
|
|
461
|
+
if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError)
|
|
462
|
+
return await provider.invalidateCredentials?.("all"), await authInternal(provider, options);
|
|
463
|
+
if (error instanceof InvalidGrantError)
|
|
464
|
+
return await provider.invalidateCredentials?.("tokens"), await authInternal(provider, options);
|
|
465
|
+
throw error;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
|
|
469
|
+
let cachedState = await provider.discoveryState?.(), resourceMetadata, authorizationServerUrl, metadata, effectiveResourceMetadataUrl = resourceMetadataUrl;
|
|
470
|
+
if (!effectiveResourceMetadataUrl && cachedState?.resourceMetadataUrl && (effectiveResourceMetadataUrl = new URL(cachedState.resourceMetadataUrl)), cachedState?.authorizationServerUrl) {
|
|
471
|
+
if (authorizationServerUrl = cachedState.authorizationServerUrl, resourceMetadata = cachedState.resourceMetadata, metadata = cachedState.authorizationServerMetadata ?? await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn }), !resourceMetadata)
|
|
472
|
+
try {
|
|
473
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl }, fetchFn);
|
|
474
|
+
} catch {
|
|
475
|
+
}
|
|
476
|
+
(metadata !== cachedState.authorizationServerMetadata || resourceMetadata !== cachedState.resourceMetadata) && await provider.saveDiscoveryState?.({
|
|
477
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
478
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
479
|
+
resourceMetadata,
|
|
480
|
+
authorizationServerMetadata: metadata
|
|
481
|
+
});
|
|
482
|
+
} else {
|
|
483
|
+
let serverInfo = await discoverOAuthServerInfo(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl, fetchFn });
|
|
484
|
+
authorizationServerUrl = serverInfo.authorizationServerUrl, metadata = serverInfo.authorizationServerMetadata, resourceMetadata = serverInfo.resourceMetadata, await provider.saveDiscoveryState?.({
|
|
485
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
486
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
487
|
+
resourceMetadata,
|
|
488
|
+
authorizationServerMetadata: metadata
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
let resource = await selectResourceURL(serverUrl, provider, resourceMetadata), resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope, clientInformation = await Promise.resolve(provider.clientInformation());
|
|
492
|
+
if (!clientInformation) {
|
|
493
|
+
if (authorizationCode !== void 0)
|
|
494
|
+
throw new Error("Existing OAuth client information is required when exchanging an authorization code");
|
|
495
|
+
let supportsUrlBasedClientId = metadata?.client_id_metadata_document_supported === !0, clientMetadataUrl = provider.clientMetadataUrl;
|
|
496
|
+
if (clientMetadataUrl && !isHttpsUrl(clientMetadataUrl))
|
|
497
|
+
throw new InvalidClientMetadataError(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${clientMetadataUrl}`);
|
|
498
|
+
if (supportsUrlBasedClientId && clientMetadataUrl)
|
|
499
|
+
clientInformation = {
|
|
500
|
+
client_id: clientMetadataUrl
|
|
501
|
+
}, await provider.saveClientInformation?.(clientInformation);
|
|
502
|
+
else {
|
|
503
|
+
if (!provider.saveClientInformation)
|
|
504
|
+
throw new Error("OAuth client information must be saveable for dynamic registration");
|
|
505
|
+
let fullInformation = await registerClient(authorizationServerUrl, {
|
|
506
|
+
metadata,
|
|
507
|
+
clientMetadata: provider.clientMetadata,
|
|
508
|
+
scope: resolvedScope,
|
|
509
|
+
fetchFn
|
|
510
|
+
});
|
|
511
|
+
await provider.saveClientInformation(fullInformation), clientInformation = fullInformation;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
let nonInteractiveFlow = !provider.redirectUrl;
|
|
515
|
+
if (authorizationCode !== void 0 || nonInteractiveFlow) {
|
|
516
|
+
let tokens2 = await fetchToken(provider, authorizationServerUrl, {
|
|
517
|
+
metadata,
|
|
518
|
+
resource,
|
|
519
|
+
authorizationCode,
|
|
520
|
+
fetchFn
|
|
521
|
+
});
|
|
522
|
+
return await provider.saveTokens(tokens2), "AUTHORIZED";
|
|
523
|
+
}
|
|
524
|
+
let tokens = await provider.tokens();
|
|
525
|
+
if (tokens?.refresh_token)
|
|
526
|
+
try {
|
|
527
|
+
let newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
528
|
+
metadata,
|
|
529
|
+
clientInformation,
|
|
530
|
+
refreshToken: tokens.refresh_token,
|
|
531
|
+
resource,
|
|
532
|
+
addClientAuthentication: provider.addClientAuthentication,
|
|
533
|
+
fetchFn
|
|
534
|
+
});
|
|
535
|
+
return await provider.saveTokens(newTokens), "AUTHORIZED";
|
|
536
|
+
} catch (error) {
|
|
537
|
+
if (!(!(error instanceof OAuthError) || error instanceof ServerError))
|
|
538
|
+
throw error;
|
|
539
|
+
}
|
|
540
|
+
let state = provider.state ? await provider.state() : void 0, { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {
|
|
541
|
+
metadata,
|
|
542
|
+
clientInformation,
|
|
543
|
+
state,
|
|
544
|
+
redirectUrl: provider.redirectUrl,
|
|
545
|
+
scope: resolvedScope,
|
|
546
|
+
resource
|
|
547
|
+
});
|
|
548
|
+
return await provider.saveCodeVerifier(codeVerifier), await provider.redirectToAuthorization(authorizationUrl), "REDIRECT";
|
|
549
|
+
}
|
|
550
|
+
function isHttpsUrl(value) {
|
|
551
|
+
if (!value)
|
|
552
|
+
return !1;
|
|
553
|
+
try {
|
|
554
|
+
let url2 = new URL(value);
|
|
555
|
+
return url2.protocol === "https:" && url2.pathname !== "/";
|
|
556
|
+
} catch {
|
|
557
|
+
return !1;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
async function selectResourceURL(serverUrl, provider, resourceMetadata) {
|
|
561
|
+
let defaultResource = resourceUrlFromServerUrl(serverUrl);
|
|
562
|
+
if (provider.validateResourceURL)
|
|
563
|
+
return await provider.validateResourceURL(defaultResource, resourceMetadata?.resource);
|
|
564
|
+
if (resourceMetadata) {
|
|
565
|
+
if (!checkResourceAllowed({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource }))
|
|
566
|
+
throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);
|
|
567
|
+
return new URL(resourceMetadata.resource);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
function extractWWWAuthenticateParams(res) {
|
|
571
|
+
let authenticateHeader = res.headers.get("WWW-Authenticate");
|
|
572
|
+
if (!authenticateHeader)
|
|
573
|
+
return {};
|
|
574
|
+
let [type, scheme] = authenticateHeader.split(" ");
|
|
575
|
+
if (type.toLowerCase() !== "bearer" || !scheme)
|
|
576
|
+
return {};
|
|
577
|
+
let resourceMetadataMatch = extractFieldFromWwwAuth(res, "resource_metadata") || void 0, resourceMetadataUrl;
|
|
578
|
+
if (resourceMetadataMatch)
|
|
579
|
+
try {
|
|
580
|
+
resourceMetadataUrl = new URL(resourceMetadataMatch);
|
|
581
|
+
} catch {
|
|
582
|
+
}
|
|
583
|
+
let scope = extractFieldFromWwwAuth(res, "scope") || void 0, error = extractFieldFromWwwAuth(res, "error") || void 0;
|
|
584
|
+
return {
|
|
585
|
+
resourceMetadataUrl,
|
|
586
|
+
scope,
|
|
587
|
+
error
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function extractFieldFromWwwAuth(response, fieldName) {
|
|
591
|
+
let wwwAuthHeader = response.headers.get("WWW-Authenticate");
|
|
592
|
+
if (!wwwAuthHeader)
|
|
593
|
+
return null;
|
|
594
|
+
let pattern = new RegExp(`${fieldName}=(?:"([^"]+)"|([^\\s,]+))`), match = wwwAuthHeader.match(pattern);
|
|
595
|
+
return match ? match[1] || match[2] : null;
|
|
596
|
+
}
|
|
597
|
+
async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {
|
|
598
|
+
let response = await discoverMetadataWithFallback(serverUrl, "oauth-protected-resource", fetchFn, {
|
|
599
|
+
protocolVersion: opts?.protocolVersion,
|
|
600
|
+
metadataUrl: opts?.resourceMetadataUrl
|
|
601
|
+
});
|
|
602
|
+
if (!response || response.status === 404)
|
|
603
|
+
throw await response?.body?.cancel(), new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");
|
|
604
|
+
if (!response.ok)
|
|
605
|
+
throw await response.body?.cancel(), new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
|
|
606
|
+
return OAuthProtectedResourceMetadataSchema.parse(await response.json());
|
|
607
|
+
}
|
|
608
|
+
async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
|
|
609
|
+
try {
|
|
610
|
+
return await fetchFn(url2, { headers });
|
|
611
|
+
} catch (error) {
|
|
612
|
+
if (error instanceof TypeError)
|
|
613
|
+
return headers ? fetchWithCorsRetry(url2, void 0, fetchFn) : void 0;
|
|
614
|
+
throw error;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
function buildWellKnownPath(wellKnownPrefix, pathname = "", options = {}) {
|
|
618
|
+
return pathname.endsWith("/") && (pathname = pathname.slice(0, -1)), options.prependPathname ? `${pathname}/.well-known/${wellKnownPrefix}` : `/.well-known/${wellKnownPrefix}${pathname}`;
|
|
619
|
+
}
|
|
620
|
+
async function tryMetadataDiscovery(url2, protocolVersion, fetchFn = fetch) {
|
|
621
|
+
return await fetchWithCorsRetry(url2, {
|
|
622
|
+
"MCP-Protocol-Version": protocolVersion
|
|
623
|
+
}, fetchFn);
|
|
624
|
+
}
|
|
625
|
+
function shouldAttemptFallback(response, pathname) {
|
|
626
|
+
return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
|
|
627
|
+
}
|
|
628
|
+
async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
|
|
629
|
+
let issuer = new URL(serverUrl), protocolVersion = opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION, url2;
|
|
630
|
+
if (opts?.metadataUrl)
|
|
631
|
+
url2 = new URL(opts.metadataUrl);
|
|
632
|
+
else {
|
|
633
|
+
let wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
|
|
634
|
+
url2 = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer), url2.search = issuer.search;
|
|
635
|
+
}
|
|
636
|
+
let response = await tryMetadataDiscovery(url2, protocolVersion, fetchFn);
|
|
637
|
+
if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) {
|
|
638
|
+
let rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);
|
|
639
|
+
response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);
|
|
640
|
+
}
|
|
641
|
+
return response;
|
|
642
|
+
}
|
|
643
|
+
function buildDiscoveryUrls(authorizationServerUrl) {
|
|
644
|
+
let url2 = typeof authorizationServerUrl == "string" ? new URL(authorizationServerUrl) : authorizationServerUrl, hasPath = url2.pathname !== "/", urlsToTry = [];
|
|
645
|
+
if (!hasPath)
|
|
646
|
+
return urlsToTry.push({
|
|
647
|
+
url: new URL("/.well-known/oauth-authorization-server", url2.origin),
|
|
648
|
+
type: "oauth"
|
|
649
|
+
}), urlsToTry.push({
|
|
650
|
+
url: new URL("/.well-known/openid-configuration", url2.origin),
|
|
651
|
+
type: "oidc"
|
|
652
|
+
}), urlsToTry;
|
|
653
|
+
let pathname = url2.pathname;
|
|
654
|
+
return pathname.endsWith("/") && (pathname = pathname.slice(0, -1)), urlsToTry.push({
|
|
655
|
+
url: new URL(`/.well-known/oauth-authorization-server${pathname}`, url2.origin),
|
|
656
|
+
type: "oauth"
|
|
657
|
+
}), urlsToTry.push({
|
|
658
|
+
url: new URL(`/.well-known/openid-configuration${pathname}`, url2.origin),
|
|
659
|
+
type: "oidc"
|
|
660
|
+
}), urlsToTry.push({
|
|
661
|
+
url: new URL(`${pathname}/.well-known/openid-configuration`, url2.origin),
|
|
662
|
+
type: "oidc"
|
|
663
|
+
}), urlsToTry;
|
|
664
|
+
}
|
|
665
|
+
async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
|
|
666
|
+
let headers = {
|
|
667
|
+
"MCP-Protocol-Version": protocolVersion,
|
|
668
|
+
Accept: "application/json"
|
|
669
|
+
}, urlsToTry = buildDiscoveryUrls(authorizationServerUrl);
|
|
670
|
+
for (let { url: endpointUrl, type } of urlsToTry) {
|
|
671
|
+
let response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);
|
|
672
|
+
if (response) {
|
|
673
|
+
if (!response.ok) {
|
|
674
|
+
if (await response.body?.cancel(), response.status >= 400 && response.status < 500)
|
|
675
|
+
continue;
|
|
676
|
+
throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
|
|
677
|
+
}
|
|
678
|
+
return type === "oauth" ? OAuthMetadataSchema.parse(await response.json()) : OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
683
|
+
let resourceMetadata, authorizationServerUrl;
|
|
684
|
+
try {
|
|
685
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: opts?.resourceMetadataUrl }, opts?.fetchFn), resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0 && (authorizationServerUrl = resourceMetadata.authorization_servers[0]);
|
|
686
|
+
} catch {
|
|
687
|
+
}
|
|
688
|
+
authorizationServerUrl || (authorizationServerUrl = String(new URL("/", serverUrl)));
|
|
689
|
+
let authorizationServerMetadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn: opts?.fetchFn });
|
|
690
|
+
return {
|
|
691
|
+
authorizationServerUrl,
|
|
692
|
+
authorizationServerMetadata,
|
|
693
|
+
resourceMetadata
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
697
|
+
let authorizationUrl;
|
|
698
|
+
if (metadata) {
|
|
699
|
+
if (authorizationUrl = new URL(metadata.authorization_endpoint), !metadata.response_types_supported.includes(AUTHORIZATION_CODE_RESPONSE_TYPE))
|
|
700
|
+
throw new Error(`Incompatible auth server: does not support response type ${AUTHORIZATION_CODE_RESPONSE_TYPE}`);
|
|
701
|
+
if (metadata.code_challenge_methods_supported && !metadata.code_challenge_methods_supported.includes(AUTHORIZATION_CODE_CHALLENGE_METHOD))
|
|
702
|
+
throw new Error(`Incompatible auth server: does not support code challenge method ${AUTHORIZATION_CODE_CHALLENGE_METHOD}`);
|
|
703
|
+
} else
|
|
704
|
+
authorizationUrl = new URL("/authorize", authorizationServerUrl);
|
|
705
|
+
let challenge = await pkceChallenge(), codeVerifier = challenge.code_verifier, codeChallenge = challenge.code_challenge;
|
|
706
|
+
return authorizationUrl.searchParams.set("response_type", AUTHORIZATION_CODE_RESPONSE_TYPE), authorizationUrl.searchParams.set("client_id", clientInformation.client_id), authorizationUrl.searchParams.set("code_challenge", codeChallenge), authorizationUrl.searchParams.set("code_challenge_method", AUTHORIZATION_CODE_CHALLENGE_METHOD), authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl)), state && authorizationUrl.searchParams.set("state", state), scope && authorizationUrl.searchParams.set("scope", scope), scope?.includes("offline_access") && authorizationUrl.searchParams.append("prompt", "consent"), resource && authorizationUrl.searchParams.set("resource", resource.href), { authorizationUrl, codeVerifier };
|
|
707
|
+
}
|
|
708
|
+
function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redirectUri) {
|
|
709
|
+
return new URLSearchParams({
|
|
710
|
+
grant_type: "authorization_code",
|
|
711
|
+
code: authorizationCode,
|
|
712
|
+
code_verifier: codeVerifier,
|
|
713
|
+
redirect_uri: String(redirectUri)
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
|
|
717
|
+
let tokenUrl = metadata?.token_endpoint ? new URL(metadata.token_endpoint) : new URL("/token", authorizationServerUrl), headers = new Headers({
|
|
718
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
719
|
+
Accept: "application/json"
|
|
720
|
+
});
|
|
721
|
+
if (resource && tokenRequestParams.set("resource", resource.href), addClientAuthentication)
|
|
722
|
+
await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
|
|
723
|
+
else if (clientInformation) {
|
|
724
|
+
let supportedMethods = metadata?.token_endpoint_auth_methods_supported ?? [], authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
|
|
725
|
+
applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
|
|
726
|
+
}
|
|
727
|
+
let response = await (fetchFn ?? fetch)(tokenUrl, {
|
|
728
|
+
method: "POST",
|
|
729
|
+
headers,
|
|
730
|
+
body: tokenRequestParams
|
|
731
|
+
});
|
|
732
|
+
if (!response.ok)
|
|
733
|
+
throw await parseErrorResponse(response);
|
|
734
|
+
return OAuthTokensSchema.parse(await response.json());
|
|
735
|
+
}
|
|
736
|
+
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
|
|
737
|
+
let tokenRequestParams = new URLSearchParams({
|
|
738
|
+
grant_type: "refresh_token",
|
|
739
|
+
refresh_token: refreshToken
|
|
740
|
+
}), tokens = await executeTokenRequest(authorizationServerUrl, {
|
|
741
|
+
metadata,
|
|
742
|
+
tokenRequestParams,
|
|
743
|
+
clientInformation,
|
|
744
|
+
addClientAuthentication,
|
|
745
|
+
resource,
|
|
746
|
+
fetchFn
|
|
747
|
+
});
|
|
748
|
+
return { refresh_token: refreshToken, ...tokens };
|
|
749
|
+
}
|
|
750
|
+
async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
|
|
751
|
+
let scope = provider.clientMetadata.scope, tokenRequestParams;
|
|
752
|
+
if (provider.prepareTokenRequest && (tokenRequestParams = await provider.prepareTokenRequest(scope)), !tokenRequestParams) {
|
|
753
|
+
if (!authorizationCode)
|
|
754
|
+
throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");
|
|
755
|
+
if (!provider.redirectUrl)
|
|
756
|
+
throw new Error("redirectUrl is required for authorization_code flow");
|
|
757
|
+
let codeVerifier = await provider.codeVerifier();
|
|
758
|
+
tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
|
|
759
|
+
}
|
|
760
|
+
let clientInformation = await provider.clientInformation();
|
|
761
|
+
return executeTokenRequest(authorizationServerUrl, {
|
|
762
|
+
metadata,
|
|
763
|
+
tokenRequestParams,
|
|
764
|
+
clientInformation: clientInformation ?? void 0,
|
|
765
|
+
addClientAuthentication: provider.addClientAuthentication,
|
|
766
|
+
resource,
|
|
767
|
+
fetchFn
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
|
|
771
|
+
let registrationUrl;
|
|
772
|
+
if (metadata) {
|
|
773
|
+
if (!metadata.registration_endpoint)
|
|
774
|
+
throw new Error("Incompatible auth server: does not support dynamic client registration");
|
|
775
|
+
registrationUrl = new URL(metadata.registration_endpoint);
|
|
776
|
+
} else
|
|
777
|
+
registrationUrl = new URL("/register", authorizationServerUrl);
|
|
778
|
+
let response = await (fetchFn ?? fetch)(registrationUrl, {
|
|
779
|
+
method: "POST",
|
|
780
|
+
headers: {
|
|
781
|
+
"Content-Type": "application/json"
|
|
782
|
+
},
|
|
783
|
+
body: JSON.stringify({
|
|
784
|
+
...clientMetadata,
|
|
785
|
+
...scope !== void 0 ? { scope } : {}
|
|
786
|
+
})
|
|
787
|
+
});
|
|
788
|
+
if (!response.ok)
|
|
789
|
+
throw await parseErrorResponse(response);
|
|
790
|
+
return OAuthClientInformationFullSchema.parse(await response.json());
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
|
|
794
|
+
var import_content_type = __toESM(require_content_type(), 1);
|
|
795
|
+
function mediaTypeEssence(header) {
|
|
796
|
+
if (header)
|
|
797
|
+
try {
|
|
798
|
+
return import_content_type.default.parse(header).type;
|
|
799
|
+
} catch {
|
|
800
|
+
let essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
|
|
801
|
+
return essence === "" || header.slice(essence.length).includes(",") ? void 0 : essence;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
806
|
+
function normalizeHeaders(headers) {
|
|
807
|
+
return headers ? headers instanceof Headers ? Object.fromEntries(headers.entries()) : Array.isArray(headers) ? Object.fromEntries(headers) : { ...headers } : {};
|
|
808
|
+
}
|
|
809
|
+
function createFetchWithInit(baseFetch = fetch, baseInit) {
|
|
810
|
+
return baseInit ? async (url2, init) => {
|
|
811
|
+
let mergedInit = {
|
|
812
|
+
...baseInit,
|
|
813
|
+
...init,
|
|
814
|
+
// Headers need special handling - merge instead of replace
|
|
815
|
+
headers: init?.headers ? { ...normalizeHeaders(baseInit.headers), ...normalizeHeaders(init.headers) } : baseInit.headers
|
|
816
|
+
};
|
|
817
|
+
return baseFetch(url2, mergedInit);
|
|
818
|
+
} : baseFetch;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// node_modules/eventsource-parser/dist/index.js
|
|
822
|
+
var ParseError = class extends Error {
|
|
823
|
+
constructor(message, options) {
|
|
824
|
+
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
825
|
+
}
|
|
826
|
+
}, LF = 10, CR = 13, SPACE = 32;
|
|
827
|
+
function noop(_arg) {
|
|
828
|
+
}
|
|
829
|
+
function createParser(config) {
|
|
830
|
+
if (typeof config == "function")
|
|
831
|
+
throw new TypeError(
|
|
832
|
+
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
833
|
+
);
|
|
834
|
+
let { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config, pendingFragments = [], pendingFragmentsLength = 0, isFirstChunk = !0, id, data = "", dataLines = 0, eventType, terminated = !1;
|
|
835
|
+
function feed(chunk) {
|
|
836
|
+
if (terminated)
|
|
837
|
+
throw new Error(
|
|
838
|
+
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
839
|
+
);
|
|
840
|
+
if (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
841
|
+
let trailing2 = processLines(chunk);
|
|
842
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
if (chunk.indexOf(`
|
|
846
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
847
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
pendingFragments.push(chunk);
|
|
851
|
+
let input = pendingFragments.join("");
|
|
852
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
853
|
+
let trailing = processLines(input);
|
|
854
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
855
|
+
}
|
|
856
|
+
function checkBufferSize() {
|
|
857
|
+
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = !0, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
858
|
+
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
859
|
+
type: "max-buffer-size-exceeded"
|
|
860
|
+
})
|
|
861
|
+
)));
|
|
862
|
+
}
|
|
863
|
+
function processLines(chunk) {
|
|
864
|
+
let searchIndex = 0;
|
|
865
|
+
if (chunk.indexOf("\r") === -1) {
|
|
866
|
+
let lfIndex = chunk.indexOf(`
|
|
867
|
+
`, searchIndex);
|
|
868
|
+
for (; lfIndex !== -1; ) {
|
|
869
|
+
if (searchIndex === lfIndex) {
|
|
870
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
871
|
+
`, searchIndex);
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
874
|
+
let firstCharCode = chunk.charCodeAt(searchIndex);
|
|
875
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
876
|
+
let valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
877
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
878
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
879
|
+
`, searchIndex);
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
data = dataLines === 0 ? value : `${data}
|
|
883
|
+
${value}`, dataLines++;
|
|
884
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
885
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
886
|
+
lfIndex
|
|
887
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
888
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
889
|
+
`, searchIndex);
|
|
890
|
+
}
|
|
891
|
+
return chunk.slice(searchIndex);
|
|
892
|
+
}
|
|
893
|
+
for (; searchIndex < chunk.length; ) {
|
|
894
|
+
let crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
895
|
+
`, searchIndex), lineEnd = -1;
|
|
896
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
897
|
+
break;
|
|
898
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
899
|
+
}
|
|
900
|
+
return chunk.slice(searchIndex);
|
|
901
|
+
}
|
|
902
|
+
function parseLine(chunk, start, end) {
|
|
903
|
+
if (start === end) {
|
|
904
|
+
dispatchEvent();
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
let firstCharCode = chunk.charCodeAt(start);
|
|
908
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
909
|
+
let valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
910
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
911
|
+
${value2}`, dataLines++;
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
915
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
919
|
+
let value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
920
|
+
id = value2.includes("\0") ? void 0 : value2;
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
if (firstCharCode === 58) {
|
|
924
|
+
if (onComment) {
|
|
925
|
+
let line2 = chunk.slice(start, end);
|
|
926
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
927
|
+
}
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
let line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
931
|
+
if (fieldSeparatorIndex === -1) {
|
|
932
|
+
processField(line, "", line);
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
let field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
936
|
+
processField(field, value, line);
|
|
937
|
+
}
|
|
938
|
+
function processField(field, value, line) {
|
|
939
|
+
switch (field) {
|
|
940
|
+
case "event":
|
|
941
|
+
eventType = value || void 0;
|
|
942
|
+
break;
|
|
943
|
+
case "data":
|
|
944
|
+
data = dataLines === 0 ? value : `${data}
|
|
945
|
+
${value}`, dataLines++;
|
|
946
|
+
break;
|
|
947
|
+
case "id":
|
|
948
|
+
id = value.includes("\0") ? void 0 : value;
|
|
949
|
+
break;
|
|
950
|
+
case "retry":
|
|
951
|
+
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
952
|
+
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
953
|
+
type: "invalid-retry",
|
|
954
|
+
value,
|
|
955
|
+
line
|
|
956
|
+
})
|
|
957
|
+
);
|
|
958
|
+
break;
|
|
959
|
+
default:
|
|
960
|
+
onError(
|
|
961
|
+
new ParseError(
|
|
962
|
+
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
963
|
+
{ type: "unknown-field", field, value, line }
|
|
964
|
+
)
|
|
965
|
+
);
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
function dispatchEvent() {
|
|
970
|
+
dataLines > 0 && onEvent({
|
|
971
|
+
id,
|
|
972
|
+
event: eventType,
|
|
973
|
+
data
|
|
974
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
975
|
+
}
|
|
976
|
+
function reset(options = {}) {
|
|
977
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
978
|
+
let incompleteLine = pendingFragments.join("");
|
|
979
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
980
|
+
}
|
|
981
|
+
isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = !1;
|
|
982
|
+
}
|
|
983
|
+
return { feed, reset };
|
|
984
|
+
}
|
|
985
|
+
function isDataPrefix(chunk, i2, firstCharCode) {
|
|
986
|
+
return firstCharCode === 100 && chunk.charCodeAt(i2 + 1) === 97 && chunk.charCodeAt(i2 + 2) === 116 && chunk.charCodeAt(i2 + 3) === 97 && chunk.charCodeAt(i2 + 4) === 58;
|
|
987
|
+
}
|
|
988
|
+
function isEventPrefix(chunk, i2, firstCharCode) {
|
|
989
|
+
return firstCharCode === 101 && chunk.charCodeAt(i2 + 1) === 118 && chunk.charCodeAt(i2 + 2) === 101 && chunk.charCodeAt(i2 + 3) === 110 && chunk.charCodeAt(i2 + 4) === 116 && chunk.charCodeAt(i2 + 5) === 58;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// node_modules/eventsource-parser/dist/stream.js
|
|
993
|
+
var EventSourceParserStream = class extends TransformStream {
|
|
994
|
+
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
995
|
+
let parser;
|
|
996
|
+
super({
|
|
997
|
+
start(controller) {
|
|
998
|
+
parser = createParser({
|
|
999
|
+
onEvent: (event) => {
|
|
1000
|
+
controller.enqueue(event);
|
|
1001
|
+
},
|
|
1002
|
+
onError(error) {
|
|
1003
|
+
typeof onError == "function" && onError(error), (onError === "terminate" || error.type === "max-buffer-size-exceeded") && controller.error(error);
|
|
1004
|
+
},
|
|
1005
|
+
onRetry,
|
|
1006
|
+
onComment,
|
|
1007
|
+
maxBufferSize
|
|
1008
|
+
});
|
|
1009
|
+
},
|
|
1010
|
+
transform(chunk) {
|
|
1011
|
+
parser.feed(chunk);
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
|
|
1018
|
+
var DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
|
|
1019
|
+
initialReconnectionDelay: 1e3,
|
|
1020
|
+
maxReconnectionDelay: 3e4,
|
|
1021
|
+
reconnectionDelayGrowFactor: 1.5,
|
|
1022
|
+
maxRetries: 2
|
|
1023
|
+
}, StreamableHTTPError = class extends Error {
|
|
1024
|
+
constructor(code, message) {
|
|
1025
|
+
super(`Streamable HTTP error: ${message}`), this.code = code;
|
|
1026
|
+
}
|
|
1027
|
+
}, StreamableHTTPClientTransport = class {
|
|
1028
|
+
constructor(url2, opts) {
|
|
1029
|
+
this._hasCompletedAuthFlow = !1, this._url = url2, this._resourceMetadataUrl = void 0, this._scope = void 0, this._requestInit = opts?.requestInit, this._authProvider = opts?.authProvider, this._fetch = opts?.fetch, this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit), this._sessionId = opts?.sessionId, this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
|
|
1030
|
+
}
|
|
1031
|
+
async _authThenStart() {
|
|
1032
|
+
if (!this._authProvider)
|
|
1033
|
+
throw new UnauthorizedError("No auth provider");
|
|
1034
|
+
let result;
|
|
1035
|
+
try {
|
|
1036
|
+
result = await auth(this._authProvider, {
|
|
1037
|
+
serverUrl: this._url,
|
|
1038
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
1039
|
+
scope: this._scope,
|
|
1040
|
+
fetchFn: this._fetchWithInit
|
|
1041
|
+
});
|
|
1042
|
+
} catch (error) {
|
|
1043
|
+
throw this.onerror?.(error), error;
|
|
1044
|
+
}
|
|
1045
|
+
if (result !== "AUTHORIZED")
|
|
1046
|
+
throw new UnauthorizedError();
|
|
1047
|
+
return await this._startOrAuthSse({ resumptionToken: void 0 });
|
|
1048
|
+
}
|
|
1049
|
+
async _commonHeaders() {
|
|
1050
|
+
let headers = {};
|
|
1051
|
+
if (this._authProvider) {
|
|
1052
|
+
let tokens = await this._authProvider.tokens();
|
|
1053
|
+
tokens && (headers.Authorization = `Bearer ${tokens.access_token}`);
|
|
1054
|
+
}
|
|
1055
|
+
this._sessionId && (headers["mcp-session-id"] = this._sessionId), this._protocolVersion && (headers["mcp-protocol-version"] = this._protocolVersion);
|
|
1056
|
+
let extraHeaders = normalizeHeaders(this._requestInit?.headers);
|
|
1057
|
+
return new Headers({
|
|
1058
|
+
...headers,
|
|
1059
|
+
...extraHeaders
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
async _startOrAuthSse(options) {
|
|
1063
|
+
let { resumptionToken } = options;
|
|
1064
|
+
try {
|
|
1065
|
+
let headers = await this._commonHeaders();
|
|
1066
|
+
headers.set("Accept", "text/event-stream"), resumptionToken && headers.set("last-event-id", resumptionToken);
|
|
1067
|
+
let response = await (this._fetch ?? fetch)(this._url, {
|
|
1068
|
+
method: "GET",
|
|
1069
|
+
headers,
|
|
1070
|
+
signal: this._abortController?.signal
|
|
1071
|
+
});
|
|
1072
|
+
if (!response.ok) {
|
|
1073
|
+
if (await response.body?.cancel(), response.status === 401 && this._authProvider)
|
|
1074
|
+
return await this._authThenStart();
|
|
1075
|
+
if (response.status === 405)
|
|
1076
|
+
return;
|
|
1077
|
+
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
|
|
1078
|
+
}
|
|
1079
|
+
this._handleSseStream(response.body, options, !0);
|
|
1080
|
+
} catch (error) {
|
|
1081
|
+
throw this.onerror?.(error), error;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Calculates the next reconnection delay using backoff algorithm
|
|
1086
|
+
*
|
|
1087
|
+
* @param attempt Current reconnection attempt count for the specific stream
|
|
1088
|
+
* @returns Time to wait in milliseconds before next reconnection attempt
|
|
1089
|
+
*/
|
|
1090
|
+
_getNextReconnectionDelay(attempt) {
|
|
1091
|
+
if (this._serverRetryMs !== void 0)
|
|
1092
|
+
return this._serverRetryMs;
|
|
1093
|
+
let initialDelay = this._reconnectionOptions.initialReconnectionDelay, growFactor = this._reconnectionOptions.reconnectionDelayGrowFactor, maxDelay = this._reconnectionOptions.maxReconnectionDelay;
|
|
1094
|
+
return Math.min(initialDelay * Math.pow(growFactor, attempt), maxDelay);
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Schedule a reconnection attempt using server-provided retry interval or backoff
|
|
1098
|
+
*
|
|
1099
|
+
* @param lastEventId The ID of the last received event for resumability
|
|
1100
|
+
* @param attemptCount Current reconnection attempt count for this specific stream
|
|
1101
|
+
*/
|
|
1102
|
+
_scheduleReconnection(options, attemptCount = 0) {
|
|
1103
|
+
let maxRetries = this._reconnectionOptions.maxRetries;
|
|
1104
|
+
if (attemptCount >= maxRetries) {
|
|
1105
|
+
this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
let delay = this._getNextReconnectionDelay(attemptCount);
|
|
1109
|
+
this._reconnectionTimeout = setTimeout(() => {
|
|
1110
|
+
this._startOrAuthSse(options).catch((error) => {
|
|
1111
|
+
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`)), this._scheduleReconnection(options, attemptCount + 1);
|
|
1112
|
+
});
|
|
1113
|
+
}, delay);
|
|
1114
|
+
}
|
|
1115
|
+
_handleSseStream(stream, options, isReconnectable) {
|
|
1116
|
+
if (!stream)
|
|
1117
|
+
return;
|
|
1118
|
+
let { onresumptiontoken, replayMessageId } = options, lastEventId, hasPrimingEvent = !1, receivedResponse = !1;
|
|
1119
|
+
(async () => {
|
|
1120
|
+
try {
|
|
1121
|
+
let reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream({
|
|
1122
|
+
onRetry: (retryMs) => {
|
|
1123
|
+
this._serverRetryMs = retryMs;
|
|
1124
|
+
}
|
|
1125
|
+
})).getReader();
|
|
1126
|
+
for (; ; ) {
|
|
1127
|
+
let { value: event, done } = await reader.read();
|
|
1128
|
+
if (done)
|
|
1129
|
+
break;
|
|
1130
|
+
if (event.id && (lastEventId = event.id, hasPrimingEvent = !0, onresumptiontoken?.(event.id)), !!event.data && (!event.event || event.event === "message"))
|
|
1131
|
+
try {
|
|
1132
|
+
let message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
|
|
1133
|
+
isJSONRPCResultResponse(message) && (receivedResponse = !0, replayMessageId !== void 0 && (message.id = replayMessageId)), this.onmessage?.(message);
|
|
1134
|
+
} catch (error) {
|
|
1135
|
+
this.onerror?.(error);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
(isReconnectable || hasPrimingEvent) && !receivedResponse && this._abortController && !this._abortController.signal.aborted && this._scheduleReconnection({
|
|
1139
|
+
resumptionToken: lastEventId,
|
|
1140
|
+
onresumptiontoken,
|
|
1141
|
+
replayMessageId
|
|
1142
|
+
}, 0);
|
|
1143
|
+
} catch (error) {
|
|
1144
|
+
if (this.onerror?.(new Error(`SSE stream disconnected: ${error}`)), (isReconnectable || hasPrimingEvent) && !receivedResponse && this._abortController && !this._abortController.signal.aborted)
|
|
1145
|
+
try {
|
|
1146
|
+
this._scheduleReconnection({
|
|
1147
|
+
resumptionToken: lastEventId,
|
|
1148
|
+
onresumptiontoken,
|
|
1149
|
+
replayMessageId
|
|
1150
|
+
}, 0);
|
|
1151
|
+
} catch (error2) {
|
|
1152
|
+
this.onerror?.(new Error(`Failed to reconnect: ${error2 instanceof Error ? error2.message : String(error2)}`));
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
})();
|
|
1156
|
+
}
|
|
1157
|
+
async start() {
|
|
1158
|
+
if (this._abortController)
|
|
1159
|
+
throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
1160
|
+
this._abortController = new AbortController();
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
1164
|
+
*/
|
|
1165
|
+
async finishAuth(authorizationCode) {
|
|
1166
|
+
if (!this._authProvider)
|
|
1167
|
+
throw new UnauthorizedError("No auth provider");
|
|
1168
|
+
if (await auth(this._authProvider, {
|
|
1169
|
+
serverUrl: this._url,
|
|
1170
|
+
authorizationCode,
|
|
1171
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
1172
|
+
scope: this._scope,
|
|
1173
|
+
fetchFn: this._fetchWithInit
|
|
1174
|
+
}) !== "AUTHORIZED")
|
|
1175
|
+
throw new UnauthorizedError("Failed to authorize");
|
|
1176
|
+
}
|
|
1177
|
+
async close() {
|
|
1178
|
+
this._reconnectionTimeout && (clearTimeout(this._reconnectionTimeout), this._reconnectionTimeout = void 0), this._abortController?.abort(), this.onclose?.();
|
|
1179
|
+
}
|
|
1180
|
+
async send(message, options) {
|
|
1181
|
+
try {
|
|
1182
|
+
let { resumptionToken, onresumptiontoken } = options || {};
|
|
1183
|
+
if (resumptionToken) {
|
|
1184
|
+
this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : void 0 }).catch((err) => this.onerror?.(err));
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
let headers = await this._commonHeaders();
|
|
1188
|
+
headers.set("content-type", "application/json"), headers.set("accept", "application/json, text/event-stream");
|
|
1189
|
+
let init = {
|
|
1190
|
+
...this._requestInit,
|
|
1191
|
+
method: "POST",
|
|
1192
|
+
headers,
|
|
1193
|
+
body: JSON.stringify(message),
|
|
1194
|
+
signal: this._abortController?.signal
|
|
1195
|
+
}, response = await (this._fetch ?? fetch)(this._url, init), sessionId = response.headers.get("mcp-session-id");
|
|
1196
|
+
if (sessionId && (this._sessionId = sessionId), !response.ok) {
|
|
1197
|
+
let text = await response.text().catch(() => null);
|
|
1198
|
+
if (response.status === 401 && this._authProvider) {
|
|
1199
|
+
if (this._hasCompletedAuthFlow)
|
|
1200
|
+
throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
|
|
1201
|
+
let { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
|
|
1202
|
+
if (this._resourceMetadataUrl = resourceMetadataUrl, this._scope = scope, await auth(this._authProvider, {
|
|
1203
|
+
serverUrl: this._url,
|
|
1204
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
1205
|
+
scope: this._scope,
|
|
1206
|
+
fetchFn: this._fetchWithInit
|
|
1207
|
+
}) !== "AUTHORIZED")
|
|
1208
|
+
throw new UnauthorizedError();
|
|
1209
|
+
return this._hasCompletedAuthFlow = !0, this.send(message);
|
|
1210
|
+
}
|
|
1211
|
+
if (response.status === 403 && this._authProvider) {
|
|
1212
|
+
let { resourceMetadataUrl, scope, error } = extractWWWAuthenticateParams(response);
|
|
1213
|
+
if (error === "insufficient_scope") {
|
|
1214
|
+
let wwwAuthHeader = response.headers.get("WWW-Authenticate");
|
|
1215
|
+
if (this._lastUpscopingHeader === wwwAuthHeader)
|
|
1216
|
+
throw new StreamableHTTPError(403, "Server returned 403 after trying upscoping");
|
|
1217
|
+
if (scope && (this._scope = scope), resourceMetadataUrl && (this._resourceMetadataUrl = resourceMetadataUrl), this._lastUpscopingHeader = wwwAuthHeader ?? void 0, await auth(this._authProvider, {
|
|
1218
|
+
serverUrl: this._url,
|
|
1219
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
1220
|
+
scope: this._scope,
|
|
1221
|
+
fetchFn: this._fetch
|
|
1222
|
+
}) !== "AUTHORIZED")
|
|
1223
|
+
throw new UnauthorizedError();
|
|
1224
|
+
return this.send(message);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
|
|
1228
|
+
}
|
|
1229
|
+
if (this._hasCompletedAuthFlow = !1, this._lastUpscopingHeader = void 0, response.status === 202) {
|
|
1230
|
+
await response.body?.cancel(), isInitializedNotification(message) && this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => this.onerror?.(err));
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
let hasRequests = (Array.isArray(message) ? message : [message]).filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0, contentType2 = response.headers.get("content-type"), responseMediaType = mediaTypeEssence(contentType2);
|
|
1234
|
+
if (hasRequests)
|
|
1235
|
+
if (responseMediaType === "text/event-stream")
|
|
1236
|
+
this._handleSseStream(response.body, { onresumptiontoken }, !1);
|
|
1237
|
+
else if (responseMediaType === "application/json") {
|
|
1238
|
+
let data = await response.json(), responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
|
|
1239
|
+
for (let msg of responseMessages)
|
|
1240
|
+
this.onmessage?.(msg);
|
|
1241
|
+
} else
|
|
1242
|
+
throw await response.body?.cancel(), new StreamableHTTPError(-1, `Unexpected content type: ${contentType2}`);
|
|
1243
|
+
else
|
|
1244
|
+
await response.body?.cancel();
|
|
1245
|
+
} catch (error) {
|
|
1246
|
+
throw this.onerror?.(error), error;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
get sessionId() {
|
|
1250
|
+
return this._sessionId;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Terminates the current session by sending a DELETE request to the server.
|
|
1254
|
+
*
|
|
1255
|
+
* Clients that no longer need a particular session
|
|
1256
|
+
* (e.g., because the user is leaving the client application) SHOULD send an
|
|
1257
|
+
* HTTP DELETE to the MCP endpoint with the Mcp-Session-Id header to explicitly
|
|
1258
|
+
* terminate the session.
|
|
1259
|
+
*
|
|
1260
|
+
* The server MAY respond with HTTP 405 Method Not Allowed, indicating that
|
|
1261
|
+
* the server does not allow clients to terminate sessions.
|
|
1262
|
+
*/
|
|
1263
|
+
async terminateSession() {
|
|
1264
|
+
if (this._sessionId)
|
|
1265
|
+
try {
|
|
1266
|
+
let headers = await this._commonHeaders(), init = {
|
|
1267
|
+
...this._requestInit,
|
|
1268
|
+
method: "DELETE",
|
|
1269
|
+
headers,
|
|
1270
|
+
signal: this._abortController?.signal
|
|
1271
|
+
}, response = await (this._fetch ?? fetch)(this._url, init);
|
|
1272
|
+
if (await response.body?.cancel(), !response.ok && response.status !== 405)
|
|
1273
|
+
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
|
|
1274
|
+
this._sessionId = void 0;
|
|
1275
|
+
} catch (error) {
|
|
1276
|
+
throw this.onerror?.(error), error;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
setProtocolVersion(version) {
|
|
1280
|
+
this._protocolVersion = version;
|
|
1281
|
+
}
|
|
1282
|
+
get protocolVersion() {
|
|
1283
|
+
return this._protocolVersion;
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Resume an SSE stream from a previous event ID.
|
|
1287
|
+
* Opens a GET SSE connection with Last-Event-ID header to replay missed events.
|
|
1288
|
+
*
|
|
1289
|
+
* @param lastEventId The event ID to resume from
|
|
1290
|
+
* @param options Optional callback to receive new resumption tokens
|
|
1291
|
+
*/
|
|
1292
|
+
async resumeStream(lastEventId, options) {
|
|
1293
|
+
await this._startOrAuthSse({
|
|
1294
|
+
resumptionToken: lastEventId,
|
|
1295
|
+
onresumptiontoken: options?.onresumptiontoken
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
|
|
1300
|
+
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js
|
|
1301
|
+
import open from "open";
|
|
1302
|
+
|
|
1303
|
+
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.js
|
|
1304
|
+
import { createHash } from "crypto";
|
|
1305
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync, rmSync } from "fs";
|
|
1306
|
+
import { join } from "path";
|
|
1307
|
+
function getAuthBaseDir() {
|
|
1308
|
+
let override = process.env.MCP_OAUTH_DIR?.trim();
|
|
1309
|
+
return override || getAgentPath("mcp-oauth");
|
|
1310
|
+
}
|
|
1311
|
+
function getServerDir(serverName) {
|
|
1312
|
+
if (typeof serverName != "string")
|
|
1313
|
+
throw new Error(`Invalid MCP server name: ${JSON.stringify(serverName)}`);
|
|
1314
|
+
let storageKey = createHash("sha256").update(serverName, "utf8").digest("hex");
|
|
1315
|
+
return join(getAuthBaseDir(), `sha256-${storageKey}`);
|
|
1316
|
+
}
|
|
1317
|
+
function getAuthEntryFilePath(serverName) {
|
|
1318
|
+
return join(getServerDir(serverName), "tokens.json");
|
|
1319
|
+
}
|
|
1320
|
+
function ensureServerDir(serverName) {
|
|
1321
|
+
let dir = getServerDir(serverName);
|
|
1322
|
+
existsSync(dir) || mkdirSync(dir, { recursive: !0, mode: 448 });
|
|
1323
|
+
}
|
|
1324
|
+
function readAuthEntry(serverName) {
|
|
1325
|
+
let filePath = getAuthEntryFilePath(serverName);
|
|
1326
|
+
try {
|
|
1327
|
+
if (!existsSync(filePath))
|
|
1328
|
+
return;
|
|
1329
|
+
let data = readFileSync(filePath, "utf-8");
|
|
1330
|
+
return JSON.parse(data);
|
|
1331
|
+
} catch (error) {
|
|
1332
|
+
console.error(`Failed to read auth entry for ${serverName}:`, error);
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
function writeAuthEntry(serverName, entry) {
|
|
1337
|
+
ensureServerDir(serverName);
|
|
1338
|
+
let filePath = getAuthEntryFilePath(serverName);
|
|
1339
|
+
writeFileSync(filePath, JSON.stringify(entry, null, 2), { mode: 384 });
|
|
1340
|
+
}
|
|
1341
|
+
function getAuthEntry(serverName) {
|
|
1342
|
+
return readAuthEntry(serverName);
|
|
1343
|
+
}
|
|
1344
|
+
function getAuthForUrl(serverName, serverUrl) {
|
|
1345
|
+
let entry = getAuthEntry(serverName);
|
|
1346
|
+
if (entry && entry.serverUrl && entry.serverUrl === serverUrl)
|
|
1347
|
+
return entry;
|
|
1348
|
+
}
|
|
1349
|
+
function saveAuthEntry(serverName, entry, serverUrl) {
|
|
1350
|
+
serverUrl && (entry.serverUrl = serverUrl), writeAuthEntry(serverName, entry);
|
|
1351
|
+
}
|
|
1352
|
+
function removeAuthEntry(serverName) {
|
|
1353
|
+
try {
|
|
1354
|
+
let filePath = getAuthEntryFilePath(serverName);
|
|
1355
|
+
existsSync(filePath) && writeFileSync(filePath, "{}", { mode: 384 });
|
|
1356
|
+
let dir = getServerDir(serverName);
|
|
1357
|
+
if (existsSync(dir))
|
|
1358
|
+
try {
|
|
1359
|
+
rmSync(dir, { recursive: !0 });
|
|
1360
|
+
} catch {
|
|
1361
|
+
}
|
|
1362
|
+
} catch (error) {
|
|
1363
|
+
console.error(`Failed to remove auth entry for ${serverName}:`, error);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
function updateTokens(serverName, tokens, serverUrl) {
|
|
1367
|
+
let entry = getAuthEntry(serverName) ?? {};
|
|
1368
|
+
serverUrl && entry.serverUrl !== serverUrl && (delete entry.clientInfo, delete entry.codeVerifier, delete entry.oauthState), entry.tokens = tokens, saveAuthEntry(serverName, entry, serverUrl);
|
|
1369
|
+
}
|
|
1370
|
+
function updateClientInfo(serverName, clientInfo, serverUrl) {
|
|
1371
|
+
let entry = getAuthEntry(serverName) ?? {};
|
|
1372
|
+
serverUrl && entry.serverUrl !== serverUrl && (delete entry.tokens, delete entry.codeVerifier, delete entry.oauthState), entry.clientInfo = clientInfo, saveAuthEntry(serverName, entry, serverUrl);
|
|
1373
|
+
}
|
|
1374
|
+
function updateCodeVerifier(serverName, codeVerifier, serverUrl) {
|
|
1375
|
+
let entry = getAuthEntry(serverName) ?? {};
|
|
1376
|
+
serverUrl && entry.serverUrl !== serverUrl && (delete entry.tokens, delete entry.clientInfo, delete entry.oauthState), entry.codeVerifier = codeVerifier, saveAuthEntry(serverName, entry, serverUrl);
|
|
1377
|
+
}
|
|
1378
|
+
function updateOAuthState(serverName, state, serverUrl) {
|
|
1379
|
+
let entry = getAuthEntry(serverName) ?? {};
|
|
1380
|
+
serverUrl && entry.serverUrl !== serverUrl && (delete entry.tokens, delete entry.clientInfo, delete entry.codeVerifier), entry.oauthState = state, saveAuthEntry(serverName, entry, serverUrl);
|
|
1381
|
+
}
|
|
1382
|
+
function clearAllCredentials(serverName) {
|
|
1383
|
+
removeAuthEntry(serverName);
|
|
1384
|
+
}
|
|
1385
|
+
function clearClientInfo(serverName) {
|
|
1386
|
+
let entry = getAuthEntry(serverName);
|
|
1387
|
+
entry && (delete entry.clientInfo, saveAuthEntry(serverName, entry));
|
|
1388
|
+
}
|
|
1389
|
+
function clearTokens(serverName) {
|
|
1390
|
+
let entry = getAuthEntry(serverName);
|
|
1391
|
+
entry && (delete entry.tokens, saveAuthEntry(serverName, entry));
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js
|
|
1395
|
+
var DEFAULT_OAUTH_CALLBACK_PORT = 19876, DEFAULT_OAUTH_CALLBACK_PATH = "/callback", configuredOAuthCallbackPort = DEFAULT_OAUTH_CALLBACK_PORT;
|
|
1396
|
+
if (process.env.MCP_OAUTH_CALLBACK_PORT) {
|
|
1397
|
+
let parsedPort = Number.parseInt(process.env.MCP_OAUTH_CALLBACK_PORT, 10);
|
|
1398
|
+
Number.isInteger(parsedPort) && parsedPort > 0 && parsedPort <= 65535 && (configuredOAuthCallbackPort = parsedPort);
|
|
1399
|
+
}
|
|
1400
|
+
var oauthCallbackPort = configuredOAuthCallbackPort, oauthCallbackPath = DEFAULT_OAUTH_CALLBACK_PATH;
|
|
1401
|
+
function getConfiguredOAuthCallbackPort() {
|
|
1402
|
+
return configuredOAuthCallbackPort;
|
|
1403
|
+
}
|
|
1404
|
+
function getOAuthCallbackPort() {
|
|
1405
|
+
return oauthCallbackPort;
|
|
1406
|
+
}
|
|
1407
|
+
function setOAuthCallbackPort(port) {
|
|
1408
|
+
oauthCallbackPort = port;
|
|
1409
|
+
}
|
|
1410
|
+
function getOAuthCallbackPath() {
|
|
1411
|
+
return oauthCallbackPath;
|
|
1412
|
+
}
|
|
1413
|
+
function setOAuthCallbackPath(path) {
|
|
1414
|
+
oauthCallbackPath = path.startsWith("/") ? path : `/${path}`;
|
|
1415
|
+
}
|
|
1416
|
+
var McpOAuthProvider = class {
|
|
1417
|
+
serverName;
|
|
1418
|
+
serverUrl;
|
|
1419
|
+
config;
|
|
1420
|
+
callbacks;
|
|
1421
|
+
flowState;
|
|
1422
|
+
redirectUrlSnapshot;
|
|
1423
|
+
flowClientInfo;
|
|
1424
|
+
flowClientInfoLoaded = !1;
|
|
1425
|
+
constructor(serverName, serverUrl, config, callbacks, flowState) {
|
|
1426
|
+
if (this.serverName = serverName, this.serverUrl = serverUrl, this.config = config, this.callbacks = callbacks, this.flowState = flowState, flowState) {
|
|
1427
|
+
let info = flowState.clientInfo;
|
|
1428
|
+
this.flowClientInfo = info?.clientSecretExpiresAt && info.clientSecretExpiresAt < Date.now() / 1e3 ? void 0 : info, this.flowClientInfoLoaded = !0;
|
|
1429
|
+
}
|
|
1430
|
+
this.redirectUrlSnapshot = config.grantType === "client_credentials" ? void 0 : config.redirectUri ?? `http://localhost:${getOAuthCallbackPort()}${getOAuthCallbackPath()}`;
|
|
1431
|
+
}
|
|
1432
|
+
get usesClientCredentials() {
|
|
1433
|
+
return this.config.grantType === "client_credentials";
|
|
1434
|
+
}
|
|
1435
|
+
/**
|
|
1436
|
+
* The redirect URL for OAuth callbacks.
|
|
1437
|
+
* This must match the redirect_uri in client metadata.
|
|
1438
|
+
*/
|
|
1439
|
+
get redirectUrl() {
|
|
1440
|
+
return this.redirectUrlSnapshot;
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Client metadata for dynamic registration.
|
|
1444
|
+
* Describes this client to the OAuth authorization server.
|
|
1445
|
+
*/
|
|
1446
|
+
get clientMetadata() {
|
|
1447
|
+
if (this.usesClientCredentials)
|
|
1448
|
+
return {
|
|
1449
|
+
client_name: this.config.clientName ?? "lunR",
|
|
1450
|
+
...this.config.clientUri ? { client_uri: this.config.clientUri } : {},
|
|
1451
|
+
redirect_uris: [],
|
|
1452
|
+
grant_types: ["client_credentials"],
|
|
1453
|
+
token_endpoint_auth_method: this.config.clientSecret ? "client_secret_post" : "none"
|
|
1454
|
+
};
|
|
1455
|
+
let redirectUrl = this.redirectUrl;
|
|
1456
|
+
if (!redirectUrl)
|
|
1457
|
+
throw new Error("redirectUrl is required for authorization_code flow");
|
|
1458
|
+
return {
|
|
1459
|
+
redirect_uris: [redirectUrl],
|
|
1460
|
+
client_name: this.config.clientName ?? "lunR",
|
|
1461
|
+
...this.config.clientUri ? { client_uri: this.config.clientUri } : {},
|
|
1462
|
+
grant_types: ["authorization_code", "refresh_token"],
|
|
1463
|
+
response_types: ["code"],
|
|
1464
|
+
token_endpoint_auth_method: this.config.clientSecret ? "client_secret_post" : "none",
|
|
1465
|
+
...this.config.scope !== void 0 ? { scope: this.config.scope } : {}
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Get client information (for pre-registered or dynamically registered clients).
|
|
1470
|
+
* Returns undefined if no client info exists or if the server URL has changed.
|
|
1471
|
+
*/
|
|
1472
|
+
async clientInformation() {
|
|
1473
|
+
if (this.config.clientId)
|
|
1474
|
+
return {
|
|
1475
|
+
client_id: this.config.clientId,
|
|
1476
|
+
client_secret: this.config.clientSecret
|
|
1477
|
+
};
|
|
1478
|
+
if (!this.flowState || !this.flowClientInfoLoaded) {
|
|
1479
|
+
let entry = await getAuthForUrl(this.serverName, this.serverUrl);
|
|
1480
|
+
throwIfAborted(this.flowState?.signal);
|
|
1481
|
+
let info = entry?.clientInfo;
|
|
1482
|
+
this.flowClientInfo = info?.clientSecretExpiresAt && info.clientSecretExpiresAt < Date.now() / 1e3 ? void 0 : info, this.flowClientInfoLoaded = !0;
|
|
1483
|
+
}
|
|
1484
|
+
if (this.flowClientInfo)
|
|
1485
|
+
return {
|
|
1486
|
+
client_id: this.flowClientInfo.clientId,
|
|
1487
|
+
client_secret: this.flowClientInfo.clientSecret
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Save client information from dynamic registration.
|
|
1492
|
+
*/
|
|
1493
|
+
async saveClientInformation(info) {
|
|
1494
|
+
throwIfAborted(this.flowState?.signal);
|
|
1495
|
+
let redirectUris = info.redirect_uris ?? (this.redirectUrl ? [this.redirectUrl] : void 0), clientInfo = {
|
|
1496
|
+
clientId: info.client_id,
|
|
1497
|
+
clientSecret: info.client_secret,
|
|
1498
|
+
clientIdIssuedAt: info.client_id_issued_at,
|
|
1499
|
+
clientSecretExpiresAt: info.client_secret_expires_at,
|
|
1500
|
+
redirectUris
|
|
1501
|
+
};
|
|
1502
|
+
this.flowState && (this.flowClientInfo = clientInfo, this.flowClientInfoLoaded = !0), updateClientInfo(this.serverName, clientInfo, this.serverUrl);
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Get stored OAuth tokens.
|
|
1506
|
+
* Returns undefined if no tokens exist or if the server URL has changed.
|
|
1507
|
+
*/
|
|
1508
|
+
async tokens() {
|
|
1509
|
+
let entry = await getAuthForUrl(this.serverName, this.serverUrl);
|
|
1510
|
+
if (entry?.tokens)
|
|
1511
|
+
return {
|
|
1512
|
+
access_token: entry.tokens.accessToken,
|
|
1513
|
+
token_type: "Bearer",
|
|
1514
|
+
refresh_token: entry.tokens.refreshToken,
|
|
1515
|
+
expires_in: entry.tokens.expiresAt ? Math.max(0, Math.floor(entry.tokens.expiresAt - Date.now() / 1e3)) : void 0,
|
|
1516
|
+
scope: entry.tokens.scope
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Save OAuth tokens.
|
|
1521
|
+
*/
|
|
1522
|
+
async saveTokens(tokens) {
|
|
1523
|
+
throwIfAborted(this.flowState?.signal);
|
|
1524
|
+
let storedTokens = {
|
|
1525
|
+
accessToken: tokens.access_token,
|
|
1526
|
+
refreshToken: tokens.refresh_token,
|
|
1527
|
+
expiresAt: tokens.expires_in ? Date.now() / 1e3 + tokens.expires_in : void 0,
|
|
1528
|
+
scope: tokens.scope
|
|
1529
|
+
};
|
|
1530
|
+
this.flowState && this.flowClientInfo && updateClientInfo(this.serverName, this.flowClientInfo, this.serverUrl), updateTokens(this.serverName, storedTokens, this.serverUrl);
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* Redirect the user to the authorization URL.
|
|
1534
|
+
* This opens the browser for the user to authenticate.
|
|
1535
|
+
*
|
|
1536
|
+
* Throws UnauthorizedError when called without owned or legacy flow state.
|
|
1537
|
+
* That path is reached when the SDK
|
|
1538
|
+
* falls through from a failed refresh into a fresh authorization_code
|
|
1539
|
+
* flow, which library hosts cannot complete in-process.
|
|
1540
|
+
*/
|
|
1541
|
+
async redirectToAuthorization(authorizationUrl) {
|
|
1542
|
+
if (this.usesClientCredentials)
|
|
1543
|
+
throw new Error("redirectToAuthorization is not used for client_credentials flow");
|
|
1544
|
+
if (throwIfAborted(this.flowState?.signal), this.flowState) {
|
|
1545
|
+
await this.callbacks.onRedirect(authorizationUrl);
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1548
|
+
if (!(await getAuthForUrl(this.serverName, this.serverUrl))?.oauthState)
|
|
1549
|
+
throw new UnauthorizedError(`Re-authentication required for MCP server: ${this.serverName}`);
|
|
1550
|
+
await this.callbacks.onRedirect(authorizationUrl);
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Save the PKCE code verifier.
|
|
1554
|
+
*/
|
|
1555
|
+
async saveCodeVerifier(codeVerifier) {
|
|
1556
|
+
if (throwIfAborted(this.flowState?.signal), this.flowState) {
|
|
1557
|
+
this.flowState.codeVerifier = codeVerifier;
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
updateCodeVerifier(this.serverName, codeVerifier, this.serverUrl);
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Get the stored PKCE code verifier.
|
|
1564
|
+
* @throws Error if no code verifier is stored
|
|
1565
|
+
*/
|
|
1566
|
+
async codeVerifier() {
|
|
1567
|
+
if (throwIfAborted(this.flowState?.signal), this.flowState) {
|
|
1568
|
+
if (!this.flowState.codeVerifier)
|
|
1569
|
+
throw new Error(`No code verifier saved for MCP server: ${this.serverName}`);
|
|
1570
|
+
return this.flowState.codeVerifier;
|
|
1571
|
+
}
|
|
1572
|
+
if (this.usesClientCredentials)
|
|
1573
|
+
throw new Error("codeVerifier is not used for client_credentials flow");
|
|
1574
|
+
let entry = await getAuthForUrl(this.serverName, this.serverUrl);
|
|
1575
|
+
if (!entry?.codeVerifier)
|
|
1576
|
+
throw new Error(`No code verifier saved for MCP server: ${this.serverName}`);
|
|
1577
|
+
return entry.codeVerifier;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Save the OAuth state parameter for CSRF protection.
|
|
1581
|
+
*/
|
|
1582
|
+
async saveState(state) {
|
|
1583
|
+
if (throwIfAborted(this.flowState?.signal), this.flowState) {
|
|
1584
|
+
this.flowState.oauthState = state;
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1587
|
+
updateOAuthState(this.serverName, state, this.serverUrl);
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Get the stored OAuth state parameter.
|
|
1591
|
+
* @throws UnauthorizedError if no flow is in progress (see redirectToAuthorization)
|
|
1592
|
+
*/
|
|
1593
|
+
async state() {
|
|
1594
|
+
if (throwIfAborted(this.flowState?.signal), this.flowState)
|
|
1595
|
+
return this.flowState.oauthState;
|
|
1596
|
+
if (this.usesClientCredentials)
|
|
1597
|
+
throw new Error("state is not used for client_credentials flow");
|
|
1598
|
+
let entry = await getAuthForUrl(this.serverName, this.serverUrl);
|
|
1599
|
+
if (!entry?.oauthState)
|
|
1600
|
+
throw new UnauthorizedError(`Re-authentication required for MCP server: ${this.serverName}`);
|
|
1601
|
+
return entry.oauthState;
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Invalidate credentials when authentication fails.
|
|
1605
|
+
* Clears tokens, client info, or all credentials based on the type.
|
|
1606
|
+
*/
|
|
1607
|
+
async invalidateCredentials(type) {
|
|
1608
|
+
switch (throwIfAborted(this.flowState?.signal), this.flowState && type !== "tokens" && (this.flowClientInfo = void 0, this.flowClientInfoLoaded = !0), type) {
|
|
1609
|
+
case "all":
|
|
1610
|
+
clearAllCredentials(this.serverName);
|
|
1611
|
+
break;
|
|
1612
|
+
case "client":
|
|
1613
|
+
clearClientInfo(this.serverName);
|
|
1614
|
+
break;
|
|
1615
|
+
case "tokens":
|
|
1616
|
+
clearTokens(this.serverName);
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Adds configured authorization-code scope without replacing the SDK's
|
|
1622
|
+
* default token endpoint authentication behavior.
|
|
1623
|
+
*/
|
|
1624
|
+
addClientAuthentication = async (headers, params, _url2, metadata) => {
|
|
1625
|
+
params.get("grant_type") === "authorization_code" && !params.has("scope") && this.config.scope && params.set("scope", this.config.scope);
|
|
1626
|
+
let clientInfo = await this.clientInformation();
|
|
1627
|
+
if (!clientInfo)
|
|
1628
|
+
return;
|
|
1629
|
+
let supportedMethods = metadata?.token_endpoint_auth_methods_supported ?? [], hasClientSecret = clientInfo.client_secret !== void 0, authMethod;
|
|
1630
|
+
if (supportedMethods.length === 0 ? authMethod = hasClientSecret ? "client_secret_post" : "none" : hasClientSecret && supportedMethods.includes("client_secret_basic") ? authMethod = "client_secret_basic" : hasClientSecret && supportedMethods.includes("client_secret_post") ? authMethod = "client_secret_post" : supportedMethods.includes("none") ? authMethod = "none" : authMethod = hasClientSecret ? "client_secret_post" : "none", authMethod === "client_secret_basic") {
|
|
1631
|
+
if (!clientInfo.client_secret)
|
|
1632
|
+
throw new Error("client_secret_basic authentication requires a client_secret");
|
|
1633
|
+
headers.set("Authorization", `Basic ${Buffer.from(`${clientInfo.client_id}:${clientInfo.client_secret}`).toString("base64")}`);
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
params.has("client_id") || params.set("client_id", clientInfo.client_id), authMethod === "client_secret_post" && clientInfo.client_secret && !params.has("client_secret") && params.set("client_secret", clientInfo.client_secret);
|
|
1637
|
+
};
|
|
1638
|
+
prepareTokenRequest(scope) {
|
|
1639
|
+
if (!this.usesClientCredentials)
|
|
1640
|
+
return;
|
|
1641
|
+
let params = new URLSearchParams({ grant_type: "client_credentials" }), requestedScope = scope ?? this.config.scope;
|
|
1642
|
+
return requestedScope && params.set("scope", requestedScope), params;
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
|
|
1646
|
+
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js
|
|
1647
|
+
import { createServer } from "http";
|
|
1648
|
+
var HTML_SUCCESS = `<!DOCTYPE html>
|
|
1649
|
+
<html>
|
|
1650
|
+
<head>
|
|
1651
|
+
<title>lunR - Authorization Successful</title>
|
|
1652
|
+
<style>
|
|
1653
|
+
body { font-family: system-ui, -apple-system, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: #1a1a2e; color: #eee; }
|
|
1654
|
+
.container { text-align: center; padding: 2rem; }
|
|
1655
|
+
h1 { color: #4ade80; margin-bottom: 1rem; }
|
|
1656
|
+
p { color: #aaa; }
|
|
1657
|
+
</style>
|
|
1658
|
+
</head>
|
|
1659
|
+
<body>
|
|
1660
|
+
<div class="container">
|
|
1661
|
+
<h1>Authorization Successful</h1>
|
|
1662
|
+
<p>You can close this window and return to lunR.</p>
|
|
1663
|
+
</div>
|
|
1664
|
+
<script>setTimeout(() => window.close(), 2000);</script>
|
|
1665
|
+
</body>
|
|
1666
|
+
</html>`;
|
|
1667
|
+
function escapeHtml(value) {
|
|
1668
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1669
|
+
}
|
|
1670
|
+
var HTML_ERROR = (error) => `<!DOCTYPE html>
|
|
1671
|
+
<html>
|
|
1672
|
+
<head>
|
|
1673
|
+
<title>lunR - Authorization Failed</title>
|
|
1674
|
+
<style>
|
|
1675
|
+
body { font-family: system-ui, -apple-system, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: #1a1a2e; color: #eee; }
|
|
1676
|
+
.container { text-align: center; padding: 2rem; }
|
|
1677
|
+
h1 { color: #f87171; margin-bottom: 1rem; }
|
|
1678
|
+
p { color: #aaa; }
|
|
1679
|
+
.error { color: #fca5a5; font-family: monospace; margin-top: 1rem; padding: 1rem; background: rgba(248,113,113,0.1); border-radius: 0.5rem; }
|
|
1680
|
+
</style>
|
|
1681
|
+
</head>
|
|
1682
|
+
<body>
|
|
1683
|
+
<div class="container">
|
|
1684
|
+
<h1>Authorization Failed</h1>
|
|
1685
|
+
<p>An error occurred during authorization.</p>
|
|
1686
|
+
<div class="error">${escapeHtml(error)}</div>
|
|
1687
|
+
</div>
|
|
1688
|
+
</body>
|
|
1689
|
+
</html>`, server, bindingPromise, pendingAuths = /* @__PURE__ */ new Map(), reservedAuthStates = /* @__PURE__ */ new Set(), callbackOwners = /* @__PURE__ */ new Set(), CALLBACK_TIMEOUT_MS = 300 * 1e3, DEFAULT_OAUTH_CALLBACK_HOST = "localhost", callbackServerHost = DEFAULT_OAUTH_CALLBACK_HOST;
|
|
1690
|
+
function handleRequest(req, res) {
|
|
1691
|
+
let url2 = new URL(req.url || "/", `http://${req.headers.host}`);
|
|
1692
|
+
if (url2.pathname !== getOAuthCallbackPath()) {
|
|
1693
|
+
res.writeHead(404, { "Content-Type": "text/plain" }), res.end("Not found");
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
let code = url2.searchParams.get("code"), state = url2.searchParams.get("state"), error = url2.searchParams.get("error"), errorDescription = url2.searchParams.get("error_description");
|
|
1697
|
+
if (!state) {
|
|
1698
|
+
let errorMsg = "Missing required state parameter - potential CSRF attack";
|
|
1699
|
+
res.writeHead(400, { "Content-Type": "text/html" }), res.end(HTML_ERROR(errorMsg));
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
let pending = pendingAuths.get(state), isReserved = reservedAuthStates.has(state);
|
|
1703
|
+
if (error) {
|
|
1704
|
+
if (!pending && !isReserved) {
|
|
1705
|
+
let errorMsg2 = "Invalid or expired state parameter - potential CSRF attack";
|
|
1706
|
+
res.writeHead(400, { "Content-Type": "text/html" }), res.end(HTML_ERROR(errorMsg2));
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
let errorMsg = errorDescription || error;
|
|
1710
|
+
res.writeHead(200, { "Content-Type": "text/html" }), res.end(HTML_ERROR(errorMsg)), reservedAuthStates.delete(state), pending && (clearTimeout(pending.timeout), pendingAuths.delete(state), setTimeout(() => pending.reject(new Error(errorMsg)), 0));
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
if (!pending) {
|
|
1714
|
+
let errorMsg = "Invalid or expired state parameter - potential CSRF attack";
|
|
1715
|
+
res.writeHead(400, { "Content-Type": "text/html" }), res.end(HTML_ERROR(errorMsg));
|
|
1716
|
+
return;
|
|
1717
|
+
}
|
|
1718
|
+
if (!code) {
|
|
1719
|
+
res.writeHead(400, { "Content-Type": "text/html" }), res.end(HTML_ERROR("No authorization code provided"));
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
clearTimeout(pending.timeout), pendingAuths.delete(state), pending.resolve(code), res.writeHead(200, { "Content-Type": "text/html" }), res.end(HTML_SUCCESS);
|
|
1723
|
+
}
|
|
1724
|
+
async function withCallbackLock(action) {
|
|
1725
|
+
for (; bindingPromise; )
|
|
1726
|
+
await bindingPromise.catch(() => {
|
|
1727
|
+
});
|
|
1728
|
+
let operation = action();
|
|
1729
|
+
bindingPromise = operation;
|
|
1730
|
+
try {
|
|
1731
|
+
await operation;
|
|
1732
|
+
} finally {
|
|
1733
|
+
bindingPromise === operation && (bindingPromise = void 0);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
function acquireCallbackServerOwner() {
|
|
1737
|
+
let owner = /* @__PURE__ */ Symbol("MCP OAuth owner");
|
|
1738
|
+
return callbackOwners.add(owner), owner;
|
|
1739
|
+
}
|
|
1740
|
+
async function releaseCallbackServerOwner(owner) {
|
|
1741
|
+
await withCallbackLock(async () => {
|
|
1742
|
+
callbackOwners.delete(owner), callbackOwners.size === 0 && await stopCallbackServerLocked();
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
async function ensureCallbackServer(options = {}) {
|
|
1746
|
+
await withCallbackLock(async () => {
|
|
1747
|
+
if (throwIfAborted(options.signal), options.owner && !callbackOwners.has(options.owner))
|
|
1748
|
+
throw new Error("MCP OAuth session closed");
|
|
1749
|
+
await ensureCallbackServerLocked(options), throwIfAborted(options.signal);
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
async function ensureCallbackServerLocked(options = {}) {
|
|
1753
|
+
let requiredPort = options.port ?? getConfiguredOAuthCallbackPort(), strictPort = options.strictPort === !0, requestedHost = options.callbackHost ?? DEFAULT_OAUTH_CALLBACK_HOST, rawRequestedPath = options.callbackPath ?? DEFAULT_OAUTH_CALLBACK_PATH, requestedPath = rawRequestedPath.startsWith("/") ? rawRequestedPath : `/${rawRequestedPath}`;
|
|
1754
|
+
if (options.reserveState && !options.oauthState)
|
|
1755
|
+
throw new Error("OAuth callback reservation requires an oauthState");
|
|
1756
|
+
let reservedState, previousServer = server, needsStrictRebind = !!(previousServer && strictPort && getOAuthCallbackPort() !== requiredPort), needsHostSwitch = !!(previousServer && callbackServerHost !== requestedHost), needsPathSwitch = !!(previousServer && getOAuthCallbackPath() !== requestedPath);
|
|
1757
|
+
if (previousServer) {
|
|
1758
|
+
if (!needsStrictRebind && !needsHostSwitch) {
|
|
1759
|
+
if (needsPathSwitch) {
|
|
1760
|
+
if (pendingAuths.size > 0 || reservedAuthStates.size > 0)
|
|
1761
|
+
throw new Error(`OAuth callback server is using path ${getOAuthCallbackPath()}, but callback path ${requestedPath} is required and cannot be switched while authorizations are pending`);
|
|
1762
|
+
setOAuthCallbackPath(requestedPath);
|
|
1763
|
+
}
|
|
1764
|
+
options.reserveState && options.oauthState && !options.signal?.aborted && (reservedAuthStates.add(options.oauthState), reservedState = options.oauthState);
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1767
|
+
if (pendingAuths.size > 0 || reservedAuthStates.size > 0)
|
|
1768
|
+
throw new Error(`OAuth callback server is running on ${callbackServerHost}:${getOAuthCallbackPort()}, but strict callback endpoint ${requestedHost}:${requiredPort} is required and cannot be switched while authorizations are pending`);
|
|
1769
|
+
}
|
|
1770
|
+
let candidateServer = createServer(handleRequest), listenPort = strictPort ? requiredPort : 0;
|
|
1771
|
+
try {
|
|
1772
|
+
if (await new Promise((resolve2, reject) => {
|
|
1773
|
+
candidateServer.once("error", (err) => {
|
|
1774
|
+
reject(err);
|
|
1775
|
+
}), candidateServer.listen(listenPort, requestedHost, () => {
|
|
1776
|
+
resolve2();
|
|
1777
|
+
});
|
|
1778
|
+
}), strictPort)
|
|
1779
|
+
setOAuthCallbackPort(requiredPort);
|
|
1780
|
+
else {
|
|
1781
|
+
let address = candidateServer.address();
|
|
1782
|
+
if (!address || typeof address == "string" || typeof address.port != "number")
|
|
1783
|
+
throw new Error("OAuth callback server did not report an assigned port");
|
|
1784
|
+
setOAuthCallbackPort(address.port);
|
|
1785
|
+
}
|
|
1786
|
+
previousServer && (needsStrictRebind || needsHostSwitch) && await new Promise((resolve2) => {
|
|
1787
|
+
previousServer.close(() => resolve2());
|
|
1788
|
+
}), callbackServerHost = requestedHost, setOAuthCallbackPath(requestedPath), server = candidateServer, options.reserveState && options.oauthState && !options.signal?.aborted && (reservedAuthStates.add(options.oauthState), reservedState = options.oauthState), server.unref();
|
|
1789
|
+
} catch (error) {
|
|
1790
|
+
reservedState && reservedAuthStates.delete(reservedState);
|
|
1791
|
+
let nodeError = error;
|
|
1792
|
+
throw await new Promise((resolve2) => {
|
|
1793
|
+
candidateServer.close(() => resolve2());
|
|
1794
|
+
}), strictPort && nodeError.code === "EADDRINUSE" ? new Error(`OAuth callback port ${requiredPort} is already in use. Pre-registered OAuth clients require an exact redirect URI; set MCP_OAUTH_CALLBACK_PORT to your registered port or free port ${requiredPort}`, { cause: error }) : error;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
function releaseCallbackServer(oauthState) {
|
|
1798
|
+
reservedAuthStates.delete(oauthState);
|
|
1799
|
+
}
|
|
1800
|
+
function waitForCallback(oauthState) {
|
|
1801
|
+
return reservedAuthStates.delete(oauthState), new Promise((resolve2, reject) => {
|
|
1802
|
+
let timeout = setTimeout(() => {
|
|
1803
|
+
pendingAuths.has(oauthState) && (pendingAuths.delete(oauthState), reject(new Error("OAuth callback timeout - authorization took too long")));
|
|
1804
|
+
}, CALLBACK_TIMEOUT_MS);
|
|
1805
|
+
pendingAuths.set(oauthState, { resolve: resolve2, reject, timeout });
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
function cancelPendingCallback(oauthState) {
|
|
1809
|
+
reservedAuthStates.delete(oauthState);
|
|
1810
|
+
let pending = pendingAuths.get(oauthState);
|
|
1811
|
+
pending && (clearTimeout(pending.timeout), pendingAuths.delete(oauthState), pending.reject(new Error("Authorization cancelled")));
|
|
1812
|
+
}
|
|
1813
|
+
async function stopCallbackServerLocked() {
|
|
1814
|
+
server && (await new Promise((resolve2) => {
|
|
1815
|
+
server.close(() => {
|
|
1816
|
+
resolve2();
|
|
1817
|
+
});
|
|
1818
|
+
}), server = void 0), setOAuthCallbackPort(getConfiguredOAuthCallbackPort()), callbackServerHost = DEFAULT_OAUTH_CALLBACK_HOST, setOAuthCallbackPath(DEFAULT_OAUTH_CALLBACK_PATH);
|
|
1819
|
+
let pendingList = Array.from(pendingAuths.entries());
|
|
1820
|
+
pendingAuths.clear(), reservedAuthStates.clear(), setTimeout(() => {
|
|
1821
|
+
for (let [, pending] of pendingList)
|
|
1822
|
+
clearTimeout(pending.timeout), pending.reject(new Error("OAuth callback server stopped"));
|
|
1823
|
+
}, 0);
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js
|
|
1827
|
+
var MANUAL_AUTH_TIMEOUT_MS = 300 * 1e3;
|
|
1828
|
+
function generateState() {
|
|
1829
|
+
return Array.from(crypto.getRandomValues(new Uint8Array(32))).map((b2) => b2.toString(16).padStart(2, "0")).join("");
|
|
1830
|
+
}
|
|
1831
|
+
function extractOAuthConfig(definition) {
|
|
1832
|
+
if (definition.oauth === !1)
|
|
1833
|
+
return {};
|
|
1834
|
+
let config = {};
|
|
1835
|
+
if (definition.oauth?.grantType !== void 0 && (config.grantType = definition.oauth.grantType), definition.oauth?.clientId !== void 0 && (config.clientId = definition.oauth.clientId), definition.oauth?.clientSecret !== void 0 && (config.clientSecret = definition.oauth.clientSecret), definition.oauth?.scope !== void 0 && (config.scope = definition.oauth.scope), definition.oauth?.redirectUri !== void 0) {
|
|
1836
|
+
if (typeof definition.oauth.redirectUri != "string")
|
|
1837
|
+
throw new Error("OAuth redirectUri must be a string");
|
|
1838
|
+
let redirectUri = definition.oauth.redirectUri.trim();
|
|
1839
|
+
if (!redirectUri)
|
|
1840
|
+
throw new Error("OAuth redirectUri must not be empty");
|
|
1841
|
+
config.redirectUri = redirectUri;
|
|
1842
|
+
}
|
|
1843
|
+
if (definition.oauth?.clientName !== void 0) {
|
|
1844
|
+
if (typeof definition.oauth.clientName != "string")
|
|
1845
|
+
throw new Error("OAuth clientName must be a string");
|
|
1846
|
+
let clientName = definition.oauth.clientName.trim();
|
|
1847
|
+
if (!clientName)
|
|
1848
|
+
throw new Error("OAuth clientName must not be empty");
|
|
1849
|
+
config.clientName = clientName;
|
|
1850
|
+
}
|
|
1851
|
+
if (definition.oauth?.clientUri !== void 0) {
|
|
1852
|
+
if (typeof definition.oauth.clientUri != "string")
|
|
1853
|
+
throw new Error("OAuth clientUri must be a string");
|
|
1854
|
+
let clientUri = definition.oauth.clientUri.trim();
|
|
1855
|
+
if (!clientUri)
|
|
1856
|
+
throw new Error("OAuth clientUri must not be empty");
|
|
1857
|
+
config.clientUri = clientUri;
|
|
1858
|
+
}
|
|
1859
|
+
return config;
|
|
1860
|
+
}
|
|
1861
|
+
function parseOAuthRedirectUri(redirectUri) {
|
|
1862
|
+
let url2;
|
|
1863
|
+
try {
|
|
1864
|
+
url2 = new URL(redirectUri);
|
|
1865
|
+
} catch (error) {
|
|
1866
|
+
throw new Error(`Invalid OAuth redirectUri: ${redirectUri}`, { cause: error });
|
|
1867
|
+
}
|
|
1868
|
+
let hostname = url2.hostname.toLowerCase(), isLocalhost = hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
|
|
1869
|
+
if (url2.protocol !== "http:" || !isLocalhost)
|
|
1870
|
+
throw new Error("OAuth redirectUri must be an http:// localhost or loopback URI");
|
|
1871
|
+
if (url2.username || url2.password)
|
|
1872
|
+
throw new Error("OAuth redirectUri must not include username or password");
|
|
1873
|
+
if (url2.hash)
|
|
1874
|
+
throw new Error("OAuth redirectUri must not include a fragment");
|
|
1875
|
+
if (!url2.port)
|
|
1876
|
+
throw new Error("OAuth redirectUri must include an explicit numeric port");
|
|
1877
|
+
let port = Number.parseInt(url2.port, 10);
|
|
1878
|
+
if (!Number.isInteger(port) || port <= 0 || port > 65535)
|
|
1879
|
+
throw new Error("OAuth redirectUri must include an explicit numeric port");
|
|
1880
|
+
return { port, callbackHost: hostname === "[::1]" ? "::1" : hostname, callbackPath: url2.pathname };
|
|
1881
|
+
}
|
|
1882
|
+
function getSearchParamsFromInput(input) {
|
|
1883
|
+
try {
|
|
1884
|
+
let url2 = new URL(input), params = new URLSearchParams(url2.search);
|
|
1885
|
+
if (url2.hash) {
|
|
1886
|
+
let hash = url2.hash.startsWith("#") ? url2.hash.slice(1) : url2.hash, hashParams = new URLSearchParams(hash);
|
|
1887
|
+
for (let [key, value] of hashParams)
|
|
1888
|
+
params.has(key) || params.set(key, value);
|
|
1889
|
+
}
|
|
1890
|
+
return params;
|
|
1891
|
+
} catch {
|
|
1892
|
+
let query = input.includes("?") ? input.slice(input.indexOf("?") + 1) : input, params = new URLSearchParams(query.startsWith("#") ? query.slice(1) : query);
|
|
1893
|
+
return params.has("code") || params.has("state") || params.has("error") ? params : void 0;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
function parseAuthorizationCodeInput(input, expectedState) {
|
|
1897
|
+
let trimmed = input.trim();
|
|
1898
|
+
if (!trimmed)
|
|
1899
|
+
throw new Error("Authorization code or redirect URL is required");
|
|
1900
|
+
let params = getSearchParamsFromInput(trimmed);
|
|
1901
|
+
if (params) {
|
|
1902
|
+
let error = params.get("error");
|
|
1903
|
+
if (error) {
|
|
1904
|
+
let description = params.get("error_description");
|
|
1905
|
+
throw new Error(description ? `${error}: ${description}` : error);
|
|
1906
|
+
}
|
|
1907
|
+
let state = params.get("state");
|
|
1908
|
+
if (expectedState && !state)
|
|
1909
|
+
throw new Error("OAuth state missing from redirect URL");
|
|
1910
|
+
if (expectedState && state !== expectedState)
|
|
1911
|
+
throw new Error("OAuth state mismatch - potential CSRF attack");
|
|
1912
|
+
let code = params.get("code");
|
|
1913
|
+
if (code)
|
|
1914
|
+
return code;
|
|
1915
|
+
}
|
|
1916
|
+
if (/^[A-Za-z0-9._~+/=-]+$/.test(trimmed))
|
|
1917
|
+
return trimmed;
|
|
1918
|
+
throw new Error("Could not find an OAuth authorization code in the provided input");
|
|
1919
|
+
}
|
|
1920
|
+
function createMcpAuthFlow() {
|
|
1921
|
+
let owner = acquireCallbackServerOwner(), flows = /* @__PURE__ */ new Map(), authenticating = /* @__PURE__ */ new Map(), shutdownPromise, closed = !1;
|
|
1922
|
+
function assertOpen() {
|
|
1923
|
+
if (closed)
|
|
1924
|
+
throw new Error("MCP OAuth session closed");
|
|
1925
|
+
}
|
|
1926
|
+
async function clearPendingAuth(serverName, flow = flows.get(serverName)) {
|
|
1927
|
+
flow && (flow.cleanup || (flow.cleanup = (async () => {
|
|
1928
|
+
flows.get(serverName) === flow && flows.delete(serverName), flow.timer && clearTimeout(flow.timer), flow.controller.abort(new Error("Authorization cancelled")), cancelPendingCallback(flow.state.oauthState), releaseCallbackServer(flow.state.oauthState), await flow.transport?.close().catch(() => {
|
|
1929
|
+
});
|
|
1930
|
+
})()), await flow.cleanup);
|
|
1931
|
+
}
|
|
1932
|
+
async function startAuth(serverName, serverUrl, definition) {
|
|
1933
|
+
assertOpen();
|
|
1934
|
+
let previous = flows.get(serverName);
|
|
1935
|
+
if (previous && await clearPendingAuth(serverName, previous), assertOpen(), flows.has(serverName))
|
|
1936
|
+
throw new Error(`OAuth flow already pending for server: ${serverName}`);
|
|
1937
|
+
let controller = new AbortController(), flow = { controller, state: { oauthState: generateState(), signal: controller.signal } };
|
|
1938
|
+
flows.set(serverName, flow);
|
|
1939
|
+
let signal = controller.signal, fetchFn = (input, init) => fetch(input, {
|
|
1940
|
+
...init,
|
|
1941
|
+
signal: init?.signal ? AbortSignal.any([init.signal, signal]) : signal
|
|
1942
|
+
});
|
|
1943
|
+
try {
|
|
1944
|
+
let config = definition ? extractOAuthConfig(definition) : {}, storedAuth = await getAuthForUrl(serverName, serverUrl);
|
|
1945
|
+
if (throwIfAborted(signal), flow.state.clientInfo = storedAuth?.clientInfo, config.grantType !== "client_credentials") {
|
|
1946
|
+
if (!config.redirectUri && !config.clientId) {
|
|
1947
|
+
let registeredRedirect = storedAuth?.clientInfo?.redirectUris?.[0];
|
|
1948
|
+
registeredRedirect && (config.redirectUri = registeredRedirect);
|
|
1949
|
+
}
|
|
1950
|
+
let redirect = config.redirectUri ? parseOAuthRedirectUri(config.redirectUri) : void 0;
|
|
1951
|
+
await ensureCallbackServer({
|
|
1952
|
+
owner,
|
|
1953
|
+
signal,
|
|
1954
|
+
strictPort: !!(config.clientId || storedAuth?.clientInfo) || config.redirectUri !== void 0,
|
|
1955
|
+
oauthState: flow.state.oauthState,
|
|
1956
|
+
reserveState: !0,
|
|
1957
|
+
...redirect ? { port: redirect.port, callbackHost: redirect.callbackHost, callbackPath: redirect.callbackPath } : {}
|
|
1958
|
+
}), throwIfAborted(signal);
|
|
1959
|
+
}
|
|
1960
|
+
let capturedUrl, authProvider = new McpOAuthProvider(serverName, serverUrl, config, {
|
|
1961
|
+
onRedirect: (url2) => {
|
|
1962
|
+
throwIfAborted(signal), capturedUrl = url2;
|
|
1963
|
+
}
|
|
1964
|
+
}, flow.state), result = await abortable(auth(authProvider, { serverUrl, fetchFn }), signal);
|
|
1965
|
+
if (throwIfAborted(signal), result === "AUTHORIZED")
|
|
1966
|
+
return await clearPendingAuth(serverName, flow), { authorizationUrl: "" };
|
|
1967
|
+
if (config.grantType === "client_credentials" || !capturedUrl)
|
|
1968
|
+
throw new UnauthorizedError("OAuth authorization URL was not provided");
|
|
1969
|
+
return flow.transport = new StreamableHTTPClientTransport(new URL(serverUrl), { authProvider, fetch: fetchFn }), flow.timer = setTimeout(() => {
|
|
1970
|
+
clearPendingAuth(serverName, flow);
|
|
1971
|
+
}, MANUAL_AUTH_TIMEOUT_MS), flow.timer.unref?.(), { authorizationUrl: capturedUrl.toString() };
|
|
1972
|
+
} catch (error) {
|
|
1973
|
+
throw await clearPendingAuth(serverName, flow), error;
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
async function completeAuthFromInput(serverName, input) {
|
|
1977
|
+
assertOpen();
|
|
1978
|
+
let flow = flows.get(serverName);
|
|
1979
|
+
if (!flow)
|
|
1980
|
+
throw new Error(`No pending OAuth flow for server: ${serverName}`);
|
|
1981
|
+
return completeAuth(serverName, parseAuthorizationCodeInput(input, flow.state.oauthState));
|
|
1982
|
+
}
|
|
1983
|
+
async function completeAuth(serverName, code) {
|
|
1984
|
+
assertOpen();
|
|
1985
|
+
let flow = flows.get(serverName);
|
|
1986
|
+
if (!flow?.transport)
|
|
1987
|
+
throw new Error(`No pending OAuth flow for server: ${serverName}`);
|
|
1988
|
+
try {
|
|
1989
|
+
return await abortable(flow.transport.finishAuth(code), flow.state.signal), throwIfAborted(flow.state.signal), "authenticated";
|
|
1990
|
+
} finally {
|
|
1991
|
+
await clearPendingAuth(serverName, flow);
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
async function authenticate(serverName, serverUrl, definition, options = {}) {
|
|
1995
|
+
assertOpen();
|
|
1996
|
+
let pending = authenticating.get(serverName);
|
|
1997
|
+
if (pending)
|
|
1998
|
+
return pending;
|
|
1999
|
+
let operation = (async () => {
|
|
2000
|
+
let { authorizationUrl } = await startAuth(serverName, serverUrl, definition);
|
|
2001
|
+
if (!authorizationUrl)
|
|
2002
|
+
return "authenticated";
|
|
2003
|
+
assertOpen();
|
|
2004
|
+
let flow = flows.get(serverName);
|
|
2005
|
+
if (!flow)
|
|
2006
|
+
throw new Error(`No pending OAuth flow for server: ${serverName}`);
|
|
2007
|
+
let callback = waitForCallback(flow.state.oauthState);
|
|
2008
|
+
callback.catch(() => {
|
|
2009
|
+
});
|
|
2010
|
+
try {
|
|
2011
|
+
options.onAuthorizationUrl ? await abortable(Promise.resolve(options.onAuthorizationUrl(authorizationUrl)), flow.state.signal) : console.log(`MCP Auth: Open this URL to authenticate ${serverName}:
|
|
2012
|
+
${authorizationUrl}`), throwIfAborted(flow.state.signal);
|
|
2013
|
+
try {
|
|
2014
|
+
await abortable(open(authorizationUrl), flow.state.signal);
|
|
2015
|
+
} catch (error) {
|
|
2016
|
+
throwIfAborted(flow.state.signal), console.warn(`MCP Auth: Failed to open browser for ${serverName}; waiting for manual callback`, { error });
|
|
2017
|
+
}
|
|
2018
|
+
let code = await callback;
|
|
2019
|
+
return await completeAuth(serverName, code);
|
|
2020
|
+
} catch (error) {
|
|
2021
|
+
throw await clearPendingAuth(serverName, flow), error;
|
|
2022
|
+
}
|
|
2023
|
+
})();
|
|
2024
|
+
authenticating.set(serverName, operation);
|
|
2025
|
+
try {
|
|
2026
|
+
return await operation;
|
|
2027
|
+
} finally {
|
|
2028
|
+
authenticating.get(serverName) === operation && authenticating.delete(serverName);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
async function removeAuth(serverName) {
|
|
2032
|
+
assertOpen(), await clearPendingAuth(serverName), clearAllCredentials(serverName);
|
|
2033
|
+
}
|
|
2034
|
+
function shutdown() {
|
|
2035
|
+
return shutdownPromise || (closed = !0, shutdownPromise = (async () => {
|
|
2036
|
+
await Promise.all([...flows].map(([name, flow]) => clearPendingAuth(name, flow))), await releaseCallbackServerOwner(owner);
|
|
2037
|
+
})()), shutdownPromise;
|
|
2038
|
+
}
|
|
2039
|
+
return { startAuth, completeAuth, completeAuthFromInput, authenticate, removeAuth, shutdown };
|
|
2040
|
+
}
|
|
2041
|
+
function supportsOAuth(definition) {
|
|
2042
|
+
return !definition.url || definition.auth === !1 || definition.oauth === !1 ? !1 : definition.auth === "oauth" ? !0 : definition.headers && Object.keys(definition.headers).length > 0 ? !1 : definition.auth === void 0;
|
|
2043
|
+
}
|
|
2044
|
+
|
|
72
2045
|
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/init.js
|
|
73
|
-
import { existsSync as
|
|
2046
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
74
2047
|
|
|
75
2048
|
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/errors.js
|
|
76
2049
|
var McpUiError = class extends Error {
|
|
@@ -111,16 +2084,16 @@ var McpUiError = class extends Error {
|
|
|
111
2084
|
};
|
|
112
2085
|
var ConsentError = class extends McpUiError {
|
|
113
2086
|
denied;
|
|
114
|
-
constructor(
|
|
115
|
-
let message = options.denied ? `Tool calls for "${
|
|
2087
|
+
constructor(server2, options) {
|
|
2088
|
+
let message = options.denied ? `Tool calls for "${server2}" were denied for this session` : `Tool call approval required for "${server2}"`;
|
|
116
2089
|
super(message, {
|
|
117
2090
|
code: options.denied ? "CONSENT_DENIED" : "CONSENT_REQUIRED",
|
|
118
|
-
context: { server },
|
|
2091
|
+
context: { server: server2 },
|
|
119
2092
|
recoveryHint: options.denied ? "The user denied tool access. Start a new session to try again." : "Prompt the user for consent before calling tools."
|
|
120
2093
|
}), this.name = "ConsentError", this.denied = options.denied ?? !1;
|
|
121
2094
|
}
|
|
122
2095
|
};
|
|
123
|
-
var
|
|
2096
|
+
var ServerError2 = class extends McpUiError {
|
|
124
2097
|
constructor(reason, options) {
|
|
125
2098
|
super(`UI server error: ${reason}`, {
|
|
126
2099
|
code: "SERVER_ERROR",
|
|
@@ -410,7 +2383,7 @@ function inspectableError(err) {
|
|
|
410
2383
|
var __typeError = (msg) => {
|
|
411
2384
|
throw TypeError(msg);
|
|
412
2385
|
}, __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method), _readyState, _url, _redirectUrl, _withCredentials, _fetch, _reconnectInterval, _reconnectTimer, _lastEventId, _controller, _parser, _onError, _onMessage, _onOpen, _EventSource_instances, connect_fn, _onFetchResponse, _onFetchError, getRequestOptions_fn, _onEvent, _onRetryChange, failConnection_fn, scheduleReconnect_fn, _reconnect, EventSource = class extends EventTarget {
|
|
413
|
-
constructor(
|
|
2386
|
+
constructor(url2, eventSourceInitDict) {
|
|
414
2387
|
var _a, _b;
|
|
415
2388
|
super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {
|
|
416
2389
|
var _a2;
|
|
@@ -436,11 +2409,11 @@ var __typeError = (msg) => {
|
|
|
436
2409
|
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
|
|
437
2410
|
return;
|
|
438
2411
|
}
|
|
439
|
-
let decoder = new TextDecoder(), reader = body.getReader(),
|
|
2412
|
+
let decoder = new TextDecoder(), reader = body.getReader(), open3 = !0;
|
|
440
2413
|
do {
|
|
441
2414
|
let { done, value } = await reader.read();
|
|
442
|
-
value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (
|
|
443
|
-
} while (
|
|
2415
|
+
value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open3 = !1, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
|
|
2416
|
+
} while (open3);
|
|
444
2417
|
}), __privateAdd(this, _onFetchError, (err) => {
|
|
445
2418
|
__privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));
|
|
446
2419
|
}), __privateAdd(this, _onEvent, (event) => {
|
|
@@ -457,10 +2430,10 @@ var __typeError = (msg) => {
|
|
|
457
2430
|
__privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
458
2431
|
});
|
|
459
2432
|
try {
|
|
460
|
-
if (
|
|
461
|
-
__privateSet(this, _url,
|
|
462
|
-
else if (typeof
|
|
463
|
-
__privateSet(this, _url, new URL(
|
|
2433
|
+
if (url2 instanceof URL)
|
|
2434
|
+
__privateSet(this, _url, url2);
|
|
2435
|
+
else if (typeof url2 == "string")
|
|
2436
|
+
__privateSet(this, _url, new URL(url2, getBaseURL()));
|
|
464
2437
|
else
|
|
465
2438
|
throw new Error("Invalid URL");
|
|
466
2439
|
} catch {
|
|
@@ -620,8 +2593,8 @@ var SseError = class extends Error {
|
|
|
620
2593
|
super(`SSE error: ${message}`), this.code = code, this.event = event;
|
|
621
2594
|
}
|
|
622
2595
|
}, SSEClientTransport = class {
|
|
623
|
-
constructor(
|
|
624
|
-
this._url =
|
|
2596
|
+
constructor(url2, opts) {
|
|
2597
|
+
this._url = url2, this._resourceMetadataUrl = void 0, this._scope = void 0, this._eventSourceInit = opts?.eventSourceInit, this._requestInit = opts?.requestInit, this._authProvider = opts?.authProvider, this._fetch = opts?.fetch, this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
625
2598
|
}
|
|
626
2599
|
async _authThenStart() {
|
|
627
2600
|
if (!this._authProvider)
|
|
@@ -659,10 +2632,10 @@ var SseError = class extends Error {
|
|
|
659
2632
|
return new Promise((resolve2, reject) => {
|
|
660
2633
|
this._eventSource = new EventSource(this._url.href, {
|
|
661
2634
|
...this._eventSourceInit,
|
|
662
|
-
fetch: async (
|
|
2635
|
+
fetch: async (url2, init) => {
|
|
663
2636
|
let headers = await this._commonHeaders();
|
|
664
2637
|
headers.set("Accept", "text/event-stream");
|
|
665
|
-
let response = await fetchImpl(
|
|
2638
|
+
let response = await fetchImpl(url2, {
|
|
666
2639
|
...init,
|
|
667
2640
|
headers
|
|
668
2641
|
});
|
|
@@ -764,8 +2737,8 @@ var SseError = class extends Error {
|
|
|
764
2737
|
};
|
|
765
2738
|
|
|
766
2739
|
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.js
|
|
767
|
-
import { existsSync, readFileSync, realpathSync, readdirSync, statSync, writeFileSync, renameSync, mkdirSync, openSync, readSync, closeSync } from "node:fs";
|
|
768
|
-
import { join, dirname, extname, resolve, sep } from "node:path";
|
|
2740
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync, readdirSync, statSync, writeFileSync as writeFileSync2, renameSync, mkdirSync as mkdirSync2, openSync, readSync, closeSync } from "node:fs";
|
|
2741
|
+
import { join as join2, dirname, extname, resolve, sep } from "node:path";
|
|
769
2742
|
import { spawn, spawnSync } from "node:child_process";
|
|
770
2743
|
var CACHE_VERSION = 1, CACHE_TTL_MS = 1440 * 60 * 1e3;
|
|
771
2744
|
async function resolveNpxBinary(command, args) {
|
|
@@ -773,7 +2746,7 @@ async function resolveNpxBinary(command, args) {
|
|
|
773
2746
|
if (!parsed)
|
|
774
2747
|
return null;
|
|
775
2748
|
let cacheKey = JSON.stringify([command, ...args]), cached = loadCache()?.entries?.[cacheKey];
|
|
776
|
-
if (cached && Date.now() - cached.resolvedAt < CACHE_TTL_MS &&
|
|
2749
|
+
if (cached && Date.now() - cached.resolvedAt < CACHE_TTL_MS && existsSync2(cached.resolvedBin))
|
|
777
2750
|
return { binPath: cached.resolvedBin, extraArgs: parsed.extraArgs, isJs: cached.isJs };
|
|
778
2751
|
let resolved = resolveFromNpmCache(parsed.packageSpec, parsed.binName);
|
|
779
2752
|
if (resolved)
|
|
@@ -868,12 +2841,12 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
868
2841
|
let packageDir = findCachedPackageDir(cacheDir, packageName);
|
|
869
2842
|
if (!packageDir)
|
|
870
2843
|
return null;
|
|
871
|
-
let packageJsonPath =
|
|
872
|
-
if (!
|
|
2844
|
+
let packageJsonPath = join2(packageDir, "package.json");
|
|
2845
|
+
if (!existsSync2(packageJsonPath))
|
|
873
2846
|
return null;
|
|
874
2847
|
let pkg = null;
|
|
875
2848
|
try {
|
|
876
|
-
pkg = JSON.parse(
|
|
2849
|
+
pkg = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
877
2850
|
} catch {
|
|
878
2851
|
return null;
|
|
879
2852
|
}
|
|
@@ -896,8 +2869,8 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
896
2869
|
}
|
|
897
2870
|
if (!binRel)
|
|
898
2871
|
return null;
|
|
899
|
-
let nodeModulesDir = findNodeModulesDir(packageDir), binLink = chosenBinName ?
|
|
900
|
-
if (!resolvedBin && (resolvedBin = resolve(packageDir, binRel), !
|
|
2872
|
+
let nodeModulesDir = findNodeModulesDir(packageDir), binLink = chosenBinName ? join2(nodeModulesDir, ".bin", chosenBinName) : null, resolvedBin = binLink && existsSync2(binLink) ? safeRealpath(binLink) : "";
|
|
2873
|
+
if (!resolvedBin && (resolvedBin = resolve(packageDir, binRel), !existsSync2(resolvedBin)))
|
|
901
2874
|
return null;
|
|
902
2875
|
let isJs = detectJsBinary(resolvedBin);
|
|
903
2876
|
return {
|
|
@@ -950,23 +2923,23 @@ function defaultBinName(packageName) {
|
|
|
950
2923
|
return packageName.startsWith("@") ? packageName.split("/")[1] ?? packageName.replace("@", "").replace("/", "-") : packageName;
|
|
951
2924
|
}
|
|
952
2925
|
function findCachedPackageDir(cacheDir, packageName) {
|
|
953
|
-
let npxDir =
|
|
954
|
-
if (!
|
|
2926
|
+
let npxDir = join2(cacheDir, "_npx");
|
|
2927
|
+
if (!existsSync2(npxDir))
|
|
955
2928
|
return null;
|
|
956
2929
|
let packagePathParts = packageName.startsWith("@") ? packageName.split("/") : [packageName], candidates = readdirSync(npxDir, { withFileTypes: !0 }).filter((entry) => entry.isDirectory()).map((entry) => {
|
|
957
|
-
let full =
|
|
2930
|
+
let full = join2(npxDir, entry.name), mtime = safeStatMtime(full);
|
|
958
2931
|
return { name: entry.name, mtime };
|
|
959
2932
|
}).sort((a2, b2) => b2.mtime - a2.mtime);
|
|
960
2933
|
for (let entry of candidates) {
|
|
961
|
-
let pkgDir =
|
|
962
|
-
if (
|
|
2934
|
+
let pkgDir = join2(npxDir, entry.name, "node_modules", ...packagePathParts);
|
|
2935
|
+
if (existsSync2(join2(pkgDir, "package.json")))
|
|
963
2936
|
return pkgDir;
|
|
964
2937
|
}
|
|
965
2938
|
return null;
|
|
966
2939
|
}
|
|
967
2940
|
function findNodeModulesDir(packageDir) {
|
|
968
2941
|
let parts = packageDir.split(sep), idx = parts.lastIndexOf("node_modules");
|
|
969
|
-
return idx >= 0 ? parts.slice(0, idx + 1).join(sep) :
|
|
2942
|
+
return idx >= 0 ? parts.slice(0, idx + 1).join(sep) : join2(packageDir, "..");
|
|
970
2943
|
}
|
|
971
2944
|
function detectJsBinary(binPath) {
|
|
972
2945
|
let ext = extname(binPath).toLowerCase();
|
|
@@ -1007,10 +2980,10 @@ function getNpxCachePath() {
|
|
|
1007
2980
|
}
|
|
1008
2981
|
function loadCache() {
|
|
1009
2982
|
let cachePath = getNpxCachePath();
|
|
1010
|
-
if (!
|
|
2983
|
+
if (!existsSync2(cachePath))
|
|
1011
2984
|
return null;
|
|
1012
2985
|
try {
|
|
1013
|
-
let raw = JSON.parse(
|
|
2986
|
+
let raw = JSON.parse(readFileSync2(cachePath, "utf-8"));
|
|
1014
2987
|
return !raw || typeof raw != "object" || raw.version !== CACHE_VERSION || !raw.entries || typeof raw.entries != "object" ? null : raw;
|
|
1015
2988
|
} catch {
|
|
1016
2989
|
return null;
|
|
@@ -1018,18 +2991,18 @@ function loadCache() {
|
|
|
1018
2991
|
}
|
|
1019
2992
|
function saveCacheEntry(key, entry) {
|
|
1020
2993
|
let cachePath = getNpxCachePath(), dir = dirname(cachePath);
|
|
1021
|
-
|
|
2994
|
+
mkdirSync2(dir, { recursive: !0 });
|
|
1022
2995
|
let merged = { version: CACHE_VERSION, entries: {} };
|
|
1023
2996
|
try {
|
|
1024
|
-
if (
|
|
1025
|
-
let existing = JSON.parse(
|
|
2997
|
+
if (existsSync2(cachePath)) {
|
|
2998
|
+
let existing = JSON.parse(readFileSync2(cachePath, "utf-8"));
|
|
1026
2999
|
existing && existing.version === CACHE_VERSION && existing.entries && (merged.entries = { ...existing.entries });
|
|
1027
3000
|
}
|
|
1028
3001
|
} catch {
|
|
1029
3002
|
}
|
|
1030
3003
|
merged.entries[key] = entry;
|
|
1031
3004
|
let tmpPath = `${cachePath}.${process.pid}.tmp`;
|
|
1032
|
-
|
|
3005
|
+
writeFileSync2(tmpPath, JSON.stringify(merged, null, 2), "utf-8"), renameSync(tmpPath, cachePath);
|
|
1033
3006
|
}
|
|
1034
3007
|
function safeRealpath(path) {
|
|
1035
3008
|
try {
|
|
@@ -1201,7 +3174,7 @@ function zeroUsage() {
|
|
|
1201
3174
|
}
|
|
1202
3175
|
|
|
1203
3176
|
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.js
|
|
1204
|
-
import
|
|
3177
|
+
import open2 from "open";
|
|
1205
3178
|
function registerElicitationHandler(client, options) {
|
|
1206
3179
|
client.setRequestHandler(ElicitRequestSchema, (request) => handleElicitationRequest(options, request));
|
|
1207
3180
|
}
|
|
@@ -1430,7 +3403,7 @@ async function handleUrlElicitation(options, params) {
|
|
|
1430
3403
|
if (decision === "Decline")
|
|
1431
3404
|
return { action: "decline" };
|
|
1432
3405
|
try {
|
|
1433
|
-
await
|
|
3406
|
+
await open2(params.url);
|
|
1434
3407
|
} catch (error) {
|
|
1435
3408
|
return options.ui.notify(`Could not open MCP elicitation URL: ${error instanceof Error ? error.message : String(error)}`, "error"), { action: "cancel" };
|
|
1436
3409
|
}
|
|
@@ -1571,7 +3544,7 @@ var McpServerManager = class {
|
|
|
1571
3544
|
};
|
|
1572
3545
|
}
|
|
1573
3546
|
createClient(serverName) {
|
|
1574
|
-
let capabilities = this.buildClientCapabilities(), client = new Client({ name: `
|
|
3547
|
+
let capabilities = this.buildClientCapabilities(), client = new Client({ name: `lunR-mcp-${serverName}`, version: "1.0.0" }, Object.keys(capabilities).length > 0 ? { capabilities } : void 0);
|
|
1575
3548
|
return this.samplingConfig && registerSamplingHandler(client, { ...this.samplingConfig, serverName }), this.elicitationConfig && (registerElicitationHandler(client, {
|
|
1576
3549
|
...this.elicitationConfig,
|
|
1577
3550
|
serverName,
|
|
@@ -1600,7 +3573,7 @@ var McpServerManager = class {
|
|
|
1600
3573
|
}
|
|
1601
3574
|
async createHttpTransport(definition, serverName, signal) {
|
|
1602
3575
|
throwIfAborted(signal);
|
|
1603
|
-
let
|
|
3576
|
+
let url2 = new URL(definition.url), headers = resolveHeaders(definition.headers) ?? {};
|
|
1604
3577
|
if (definition.auth === "bearer") {
|
|
1605
3578
|
let token = resolveBearerToken(definition);
|
|
1606
3579
|
token && (headers.Authorization = `Bearer ${token}`);
|
|
@@ -1613,20 +3586,20 @@ var McpServerManager = class {
|
|
|
1613
3586
|
}
|
|
1614
3587
|
});
|
|
1615
3588
|
}
|
|
1616
|
-
let streamableTransport = new StreamableHTTPClientTransport(
|
|
3589
|
+
let streamableTransport = new StreamableHTTPClientTransport(url2, {
|
|
1617
3590
|
requestInit,
|
|
1618
3591
|
authProvider
|
|
1619
3592
|
});
|
|
1620
3593
|
try {
|
|
1621
|
-
let testClient = new Client({ name: "
|
|
3594
|
+
let testClient = new Client({ name: "lunR-mcp-probe", version: "2.1.2" });
|
|
1622
3595
|
return await testClient.connect(streamableTransport, this.buildRequestOptions(definition, signal)), await testClient.close().catch(() => {
|
|
1623
3596
|
}), await streamableTransport.close().catch(() => {
|
|
1624
|
-
}), new StreamableHTTPClientTransport(
|
|
3597
|
+
}), new StreamableHTTPClientTransport(url2, { requestInit, authProvider });
|
|
1625
3598
|
} catch (error) {
|
|
1626
3599
|
if (await streamableTransport.close().catch(() => {
|
|
1627
3600
|
}), signal?.aborted && throwIfAborted(signal), error instanceof UnauthorizedError)
|
|
1628
3601
|
throw error;
|
|
1629
|
-
return new SSEClientTransport(
|
|
3602
|
+
return new SSEClientTransport(url2, { requestInit, authProvider });
|
|
1630
3603
|
}
|
|
1631
3604
|
}
|
|
1632
3605
|
async fetchAllTools(client, requestOptions) {
|
|
@@ -1990,7 +3963,7 @@ function isTuiMode(ctx) {
|
|
|
1990
3963
|
async function initializeMcp(pi, ctx, options = {}) {
|
|
1991
3964
|
let signal = options.signal ?? ctx.signal;
|
|
1992
3965
|
throwIfAborted(signal);
|
|
1993
|
-
let configPath = pi.getFlag("mcp-config"), config = loadMcpConfig(configPath, ctx.cwd), manager = new McpServerManager(ctx.cwd);
|
|
3966
|
+
let configPath = pi.getFlag("mcp-config"), config = loadMcpConfig(configPath, ctx.cwd, ctx.isProjectTrusted()), manager = new McpServerManager(ctx.cwd);
|
|
1994
3967
|
manager.setDefaultRequestTimeoutMs(config.settings?.requestTimeoutMs);
|
|
1995
3968
|
let samplingAutoApprove = config.settings?.samplingAutoApprove === !0;
|
|
1996
3969
|
config.settings?.sampling !== !1 && (ctx.hasUI || samplingAutoApprove) && manager.setSamplingConfig({
|
|
@@ -2004,6 +3977,7 @@ async function initializeMcp(pi, ctx, options = {}) {
|
|
|
2004
3977
|
allowUrl: isTuiMode(ctx)
|
|
2005
3978
|
});
|
|
2006
3979
|
let lifecycle = new McpLifecycleManager(manager), toolMetadata = /* @__PURE__ */ new Map(), failureTracker = /* @__PURE__ */ new Map(), uiResourceHandler = new UiResourceHandler(manager), consentManager = new ConsentManager("once-per-server"), ui = ctx.hasUI ? ctx.ui : void 0, state = {
|
|
3980
|
+
authFlow: createMcpAuthFlow(),
|
|
2007
3981
|
manager,
|
|
2008
3982
|
lifecycle,
|
|
2009
3983
|
toolMetadata,
|
|
@@ -2013,7 +3987,7 @@ async function initializeMcp(pi, ctx, options = {}) {
|
|
|
2013
3987
|
consentManager,
|
|
2014
3988
|
uiServer: null,
|
|
2015
3989
|
completedUiSessions: [],
|
|
2016
|
-
openBrowser: (
|
|
3990
|
+
openBrowser: (url2) => openUrl(pi, url2, process.env.BROWSER),
|
|
2017
3991
|
ui,
|
|
2018
3992
|
sendMessage: (message, options2) => pi.sendMessage(message, options2)
|
|
2019
3993
|
};
|
|
@@ -2023,7 +3997,7 @@ async function initializeMcp(pi, ctx, options = {}) {
|
|
|
2023
3997
|
return state;
|
|
2024
3998
|
let idleSetting = typeof config.settings?.idleTimeout == "number" ? config.settings.idleTimeout : 10;
|
|
2025
3999
|
lifecycle.setGlobalIdleTimeout(idleSetting);
|
|
2026
|
-
let cachePath = getMetadataCachePath(), cacheFileExists =
|
|
4000
|
+
let cachePath = getMetadataCachePath(), cacheFileExists = existsSync3(cachePath), cache = loadMetadataCache(), bootstrapAll = !1;
|
|
2027
4001
|
cacheFileExists ? cache || (cache = { version: 1, servers: {} }, saveMetadataCache(cache)) : (bootstrapAll = !0, saveMetadataCache({ version: 1, servers: {} }));
|
|
2028
4002
|
let prefix = config.settings?.toolPrefix ?? "server";
|
|
2029
4003
|
for (let [name, definition] of serverEntries) {
|
|
@@ -2166,7 +4140,9 @@ function getEffectiveIdleTimeoutMinutes(state, serverName) {
|
|
|
2166
4140
|
}
|
|
2167
4141
|
|
|
2168
4142
|
export {
|
|
2169
|
-
|
|
4143
|
+
getAuthForUrl,
|
|
4144
|
+
supportsOAuth,
|
|
4145
|
+
ServerError2 as ServerError,
|
|
2170
4146
|
wrapError,
|
|
2171
4147
|
logger,
|
|
2172
4148
|
AZ,
|
|
@@ -2183,3 +4159,12 @@ export {
|
|
|
2183
4159
|
getFailureAgeSeconds,
|
|
2184
4160
|
lazyConnect
|
|
2185
4161
|
};
|
|
4162
|
+
/*! Bundled license information:
|
|
4163
|
+
|
|
4164
|
+
content-type/index.js:
|
|
4165
|
+
(*!
|
|
4166
|
+
* content-type
|
|
4167
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
4168
|
+
* MIT Licensed
|
|
4169
|
+
*)
|
|
4170
|
+
*/
|