@f5-sales-demo/xcsh 19.51.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7073 -0
- package/README.md +14 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +109 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/custom-tools/todo/index.ts +206 -0
- package/examples/extensions/README.md +143 -0
- package/examples/extensions/api-demo.ts +89 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +32 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +551 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/todo.ts +296 -0
- package/examples/extensions/tools.ts +145 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +16 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +21 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +43 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +80 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +41 -0
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +539 -0
- package/scripts/build-info/resolvers.ts +51 -0
- package/scripts/capture-ax-fixture.ts +84 -0
- package/scripts/capture-login-fixture.ts +30 -0
- package/scripts/check-workflow-field-coverage.ts +101 -0
- package/scripts/extension-uat-harness.ts +340 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-api-spec-index.ts +580 -0
- package/scripts/generate-branding-index.ts +81 -0
- package/scripts/generate-build-info.ts +106 -0
- package/scripts/generate-console-catalog.ts +88 -0
- package/scripts/generate-console-field-metadata.ts +74 -0
- package/scripts/generate-docs-index.ts +40 -0
- package/scripts/generate-template.ts +32 -0
- package/scripts/generate-terraform-index.ts +81 -0
- package/scripts/mermaid-gallery.ts +132 -0
- package/scripts/uat-matrix-modalities.ts +451 -0
- package/scripts/uat-matrix-report.ts +175 -0
- package/scripts/uat-matrix.ts +353 -0
- package/src/async/index.ts +2 -0
- package/src/async/job-manager.ts +416 -0
- package/src/async/support.ts +5 -0
- package/src/autoresearch/apply-contract-to-state.ts +1 -0
- package/src/autoresearch/command-resume.md +17 -0
- package/src/autoresearch/contract.ts +205 -0
- package/src/autoresearch/dashboard.ts +374 -0
- package/src/autoresearch/git.ts +191 -0
- package/src/autoresearch/helpers.ts +328 -0
- package/src/autoresearch/index.ts +402 -0
- package/src/autoresearch/prompt.md +236 -0
- package/src/autoresearch/resume-message.md +16 -0
- package/src/autoresearch/state.ts +303 -0
- package/src/autoresearch/tools/init-experiment.ts +400 -0
- package/src/autoresearch/tools/log-experiment.ts +793 -0
- package/src/autoresearch/tools/run-experiment.ts +679 -0
- package/src/autoresearch/types.ts +114 -0
- package/src/browser/acquire.ts +249 -0
- package/src/browser/actions.ts +126 -0
- package/src/browser/auth.ts +176 -0
- package/src/browser/ax.ts +134 -0
- package/src/browser/cdp-core.ts +45 -0
- package/src/browser/cdp-page-actions.ts +51 -0
- package/src/browser/chrome-locate.ts +66 -0
- package/src/browser/dom-context.ts +89 -0
- package/src/browser/dt-context.ts +100 -0
- package/src/browser/extension-bridge.ts +182 -0
- package/src/browser/extension-page-actions.ts +397 -0
- package/src/browser/extension-provider.ts +373 -0
- package/src/browser/index.ts +17 -0
- package/src/browser/input-commit.ts +74 -0
- package/src/browser/native-messaging.ts +20 -0
- package/src/browser/page-actions.ts +18 -0
- package/src/browser/provider.ts +155 -0
- package/src/browser/resolver.ts +126 -0
- package/src/browser/selector.ts +40 -0
- package/src/bun-imports.d.ts +22 -0
- package/src/capability/context-file.ts +43 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +438 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +224 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +50 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +138 -0
- package/src/cli/args.ts +286 -0
- package/src/cli/chrome-cli.ts +88 -0
- package/src/cli/classify-install-target.ts +50 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +418 -0
- package/src/cli/file-processor.ts +121 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/grievances-cli.ts +78 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/jupyter-cli.ts +106 -0
- package/src/cli/list-models.ts +128 -0
- package/src/cli/plugin-cli.ts +964 -0
- package/src/cli/read-cli.ts +68 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +479 -0
- package/src/cli/shell-cli.ts +174 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +182 -0
- package/src/cli/update-cli.ts +446 -0
- package/src/cli/web-search-cli.ts +203 -0
- package/src/cli.ts +123 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/chrome-host.ts +71 -0
- package/src/commands/chrome.ts +28 -0
- package/src/commands/commit.ts +36 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/grievances.ts +20 -0
- package/src/commands/jupyter.ts +32 -0
- package/src/commands/launch.ts +144 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/read.ts +33 -0
- package/src/commands/setup.ts +42 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +46 -0
- package/src/commit/agentic/agent.ts +314 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +354 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +127 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +139 -0
- package/src/commit/agentic/tools/propose-commit.ts +122 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +31 -0
- package/src/commit/agentic/tools/split-commit.ts +251 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +122 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +101 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +108 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +66 -0
- package/src/commit/pipeline.ts +242 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +44 -0
- package/src/config/auto-config.ts +698 -0
- package/src/config/context-schema.json +115 -0
- package/src/config/file-lock.ts +121 -0
- package/src/config/keybindings.ts +493 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-equivalence.ts +675 -0
- package/src/config/model-registry.ts +2265 -0
- package/src/config/model-resolver.ts +1289 -0
- package/src/config/prompt-templates.ts +271 -0
- package/src/config/resolve-config-value.ts +110 -0
- package/src/config/settings-schema.ts +2155 -0
- package/src/config/settings.ts +730 -0
- package/src/config.ts +418 -0
- package/src/cursor.ts +323 -0
- package/src/dap/client.ts +674 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1255 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/index.ts +440 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +158 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/system-info.ts +107 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +219 -0
- package/src/discovery/builtin.ts +851 -0
- package/src/discovery/claude-plugins.ts +297 -0
- package/src/discovery/claude.ts +543 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +535 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +396 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +934 -0
- package/src/discovery/index.ts +79 -0
- package/src/discovery/language.ts +46 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +393 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/diff.ts +818 -0
- package/src/edit/index.ts +481 -0
- package/src/edit/line-hash.ts +67 -0
- package/src/edit/modes/chunk.ts +762 -0
- package/src/edit/modes/hashline.ts +1366 -0
- package/src/edit/modes/patch.ts +1791 -0
- package/src/edit/modes/replace.ts +1115 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/renderer.ts +627 -0
- package/src/exa/factory.ts +61 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +293 -0
- package/src/exa/render.ts +232 -0
- package/src/exa/researcher.ts +47 -0
- package/src/exa/search.ts +86 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +247 -0
- package/src/exec/bash-executor.ts +332 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +48 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +161 -0
- package/src/export/html/template.css +1001 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +46 -0
- package/src/export/html/template.js +1950 -0
- package/src/export/html/template.macro.ts +24 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/ttsr.ts +434 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +456 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +236 -0
- package/src/extensibility/custom-commands/types.ts +111 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +238 -0
- package/src/extensibility/custom-tools/types.ts +251 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +572 -0
- package/src/extensibility/extensions/runner.ts +848 -0
- package/src/extensibility/extensions/types.ts +1394 -0
- package/src/extensibility/extensions/wrapper.ts +191 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +255 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +108 -0
- package/src/extensibility/hooks/types.ts +826 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +281 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/loader.ts +267 -0
- package/src/extensibility/plugins/manager.ts +731 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +318 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +781 -0
- package/src/extensibility/plugins/marketplace/prerequisites.ts +255 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +201 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/skills.ts +269 -0
- package/src/extensibility/slash-commands.ts +246 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/utils.ts +38 -0
- package/src/index.ts +61 -0
- package/src/internal-urls/agent-protocol.ts +136 -0
- package/src/internal-urls/api-catalog-resolve.ts +495 -0
- package/src/internal-urls/api-catalog-types.ts +94 -0
- package/src/internal-urls/api-spec-resolve.ts +1036 -0
- package/src/internal-urls/api-spec-types.ts +239 -0
- package/src/internal-urls/artifact-protocol.ts +97 -0
- package/src/internal-urls/branding-index.generated.ts +88 -0
- package/src/internal-urls/build-info-runtime.ts +302 -0
- package/src/internal-urls/build-info.generated.ts +33 -0
- package/src/internal-urls/computer-profile.ts +692 -0
- package/src/internal-urls/console-catalog-types.ts +21 -0
- package/src/internal-urls/console-catalog.generated.ts +532 -0
- package/src/internal-urls/console-field-metadata-types.ts +59 -0
- package/src/internal-urls/console-field-metadata.generated.ts +4841 -0
- package/src/internal-urls/console-resolve.ts +178 -0
- package/src/internal-urls/docs-index.generated.ts +698 -0
- package/src/internal-urls/extension-api.md +147 -0
- package/src/internal-urls/index.ts +46 -0
- package/src/internal-urls/jobs-protocol.ts +119 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +206 -0
- package/src/internal-urls/mcp-protocol.ts +156 -0
- package/src/internal-urls/memory-protocol.ts +133 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/profile-collectors.ts +106 -0
- package/src/internal-urls/router.ts +55 -0
- package/src/internal-urls/rule-protocol.ts +55 -0
- package/src/internal-urls/skill-protocol.ts +111 -0
- package/src/internal-urls/terraform-index.generated.ts +1852 -0
- package/src/internal-urls/terraform-resolve.ts +184 -0
- package/src/internal-urls/terraform-types.ts +45 -0
- package/src/internal-urls/types.ts +52 -0
- package/src/internal-urls/user-profile.ts +363 -0
- package/src/internal-urls/xcsh-protocol.ts +644 -0
- package/src/ipy/cancellation.ts +28 -0
- package/src/ipy/executor.ts +1155 -0
- package/src/ipy/gateway-coordinator.ts +424 -0
- package/src/ipy/kernel.ts +1091 -0
- package/src/ipy/modules.ts +144 -0
- package/src/ipy/prelude.py +849 -0
- package/src/ipy/prelude.ts +3 -0
- package/src/ipy/runtime.ts +221 -0
- package/src/locales/ar.json +512 -0
- package/src/locales/de.json +512 -0
- package/src/locales/en.json +549 -0
- package/src/locales/es.json +512 -0
- package/src/locales/fr.json +512 -0
- package/src/locales/hi.json +512 -0
- package/src/locales/index.ts +29 -0
- package/src/locales/it.json +512 -0
- package/src/locales/ja.json +512 -0
- package/src/locales/ko.json +512 -0
- package/src/locales/pt-br.json +512 -0
- package/src/locales/th.json +512 -0
- package/src/locales/zh-cn.json +512 -0
- package/src/locales/zh-tw.json +512 -0
- package/src/lsp/client.ts +941 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +418 -0
- package/src/lsp/defaults.json +999 -0
- package/src/lsp/edits.ts +109 -0
- package/src/lsp/index.ts +1746 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +692 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +444 -0
- package/src/lsp/utils.ts +691 -0
- package/src/main.ts +944 -0
- package/src/mcp/client.ts +482 -0
- package/src/mcp/config-writer.ts +225 -0
- package/src/mcp/config.ts +365 -0
- package/src/mcp/discoverable-tool-metadata.ts +202 -0
- package/src/mcp/index.ts +29 -0
- package/src/mcp/json-rpc.ts +84 -0
- package/src/mcp/loader.ts +124 -0
- package/src/mcp/manager.ts +1152 -0
- package/src/mcp/oauth-discovery.ts +349 -0
- package/src/mcp/oauth-flow.ts +387 -0
- package/src/mcp/render.ts +157 -0
- package/src/mcp/smithery-auth.ts +104 -0
- package/src/mcp/smithery-connect.ts +145 -0
- package/src/mcp/smithery-registry.ts +477 -0
- package/src/mcp/tool-bridge.ts +417 -0
- package/src/mcp/tool-cache.ts +117 -0
- package/src/mcp/transports/http.ts +475 -0
- package/src/mcp/transports/index.ts +6 -0
- package/src/mcp/transports/stdio.ts +325 -0
- package/src/mcp/types.ts +423 -0
- package/src/memories/index.ts +1115 -0
- package/src/memories/storage.ts +577 -0
- package/src/modes/acp/acp-agent.ts +1361 -0
- package/src/modes/acp/acp-event-mapper.ts +538 -0
- package/src/modes/acp/acp-mode.ts +15 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/components/agent-dashboard.ts +1124 -0
- package/src/modes/components/assistant-message.ts +213 -0
- package/src/modes/components/bash-execution.ts +345 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +45 -0
- package/src/modes/components/btw-panel.ts +103 -0
- package/src/modes/components/compaction-summary-message.ts +51 -0
- package/src/modes/components/context-add-wizard.ts +534 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +238 -0
- package/src/modes/components/custom-message.ts +91 -0
- package/src/modes/components/diff.ts +210 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/extensions/extension-dashboard.ts +326 -0
- package/src/modes/components/extensions/extension-list.ts +492 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +587 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +262 -0
- package/src/modes/components/gutter-block.ts +315 -0
- package/src/modes/components/history-search.ts +158 -0
- package/src/modes/components/hook-editor.ts +151 -0
- package/src/modes/components/hook-input.ts +81 -0
- package/src/modes/components/hook-message.ts +100 -0
- package/src/modes/components/hook-selector.ts +192 -0
- package/src/modes/components/index.ts +36 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/mcp-add-wizard.ts +1314 -0
- package/src/modes/components/model-selector.ts +946 -0
- package/src/modes/components/oauth-selector.ts +211 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +477 -0
- package/src/modes/components/plugins/index.ts +5 -0
- package/src/modes/components/plugins/plugin-dashboard.ts +523 -0
- package/src/modes/components/plugins/plugin-inspector-pane.ts +84 -0
- package/src/modes/components/plugins/plugin-list-pane.ts +109 -0
- package/src/modes/components/plugins/state-manager.ts +229 -0
- package/src/modes/components/plugins/types.ts +51 -0
- package/src/modes/components/plugins/utils.ts +6 -0
- package/src/modes/components/python-execution.ts +244 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +137 -0
- package/src/modes/components/session-observer-overlay.ts +483 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +568 -0
- package/src/modes/components/settings-selector.ts +641 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-message.ts +90 -0
- package/src/modes/components/status-line/context-gradient.ts +64 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/hex-ansi.ts +29 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +174 -0
- package/src/modes/components/status-line/segments.ts +494 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +96 -0
- package/src/modes/components/status-line-segment-editor.ts +361 -0
- package/src/modes/components/status-line.ts +729 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/todo-reminder.ts +54 -0
- package/src/modes/components/tool-execution.ts +781 -0
- package/src/modes/components/tree-selector.ts +908 -0
- package/src/modes/components/ttsr-notification.ts +80 -0
- package/src/modes/components/user-message-selector.ts +141 -0
- package/src/modes/components/user-message.ts +100 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome-checks.ts +313 -0
- package/src/modes/components/welcome.ts +270 -0
- package/src/modes/controllers/btw-controller.ts +193 -0
- package/src/modes/controllers/chord-routing.ts +37 -0
- package/src/modes/controllers/command-controller.ts +1293 -0
- package/src/modes/controllers/context-command-controller.ts +61 -0
- package/src/modes/controllers/event-controller.ts +743 -0
- package/src/modes/controllers/extension-ui-controller.ts +983 -0
- package/src/modes/controllers/input-controller.ts +877 -0
- package/src/modes/controllers/mcp-command-controller.ts +1940 -0
- package/src/modes/controllers/selector-controller.ts +1292 -0
- package/src/modes/controllers/ssh-command-controller.ts +421 -0
- package/src/modes/index.ts +34 -0
- package/src/modes/interactive-mode.ts +1781 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +196 -0
- package/src/modes/prompt-action-autocomplete.ts +231 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/rpc-client.ts +762 -0
- package/src/modes/rpc/rpc-mode.ts +877 -0
- package/src/modes/rpc/rpc-types.ts +322 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared.ts +30 -0
- package/src/modes/theme/defaults/index.ts +7 -0
- package/src/modes/theme/defaults/xcsh-dark.json +113 -0
- package/src/modes/theme/defaults/xcsh-light.json +115 -0
- package/src/modes/theme/mermaid-cache.ts +151 -0
- package/src/modes/theme/mermaid-palette.ts +39 -0
- package/src/modes/theme/theme-schema.json +553 -0
- package/src/modes/theme/theme.ts +2563 -0
- package/src/modes/types.ts +273 -0
- package/src/modes/utils/hotkeys-markdown.ts +60 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/read-group-outcome-aggregator.ts +55 -0
- package/src/modes/utils/sanitize-error-message.ts +60 -0
- package/src/modes/utils/tools-markdown.ts +28 -0
- package/src/modes/utils/ui-helpers.ts +734 -0
- package/src/plan-mode/approved-plan.ts +55 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +37 -0
- package/src/prompts/agents/designer.md +67 -0
- package/src/prompts/agents/explore.md +61 -0
- package/src/prompts/agents/frontmatter.md +10 -0
- package/src/prompts/agents/init.md +36 -0
- package/src/prompts/agents/librarian.md +121 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/reviewer.md +127 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +35 -0
- package/src/prompts/compaction/branch-summary-context.md +5 -0
- package/src/prompts/compaction/branch-summary-preamble.md +2 -0
- package/src/prompts/compaction/branch-summary.md +30 -0
- package/src/prompts/compaction/compaction-short-summary.md +9 -0
- package/src/prompts/compaction/compaction-summary-context.md +5 -0
- package/src/prompts/compaction/compaction-summary.md +38 -0
- package/src/prompts/compaction/compaction-turn-prefix.md +17 -0
- package/src/prompts/compaction/compaction-update-summary.md +45 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +11 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/review-request.md +70 -0
- package/src/prompts/system/agent-creation-architect.md +65 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-handoff-threshold-focus.md +1 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +82 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/file-operations.md +10 -0
- package/src/prompts/system/handoff-document.md +48 -0
- package/src/prompts/system/plan-mode-active.md +114 -0
- package/src/prompts/system/plan-mode-approved.md +23 -0
- package/src/prompts/system/plan-mode-reference.md +14 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/subagent-submit-reminder.md +7 -0
- package/src/prompts/system/subagent-system-prompt.md +36 -0
- package/src/prompts/system/subagent-user-prompt.md +12 -0
- package/src/prompts/system/summarization-system.md +3 -0
- package/src/prompts/system/system-prompt.md +698 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/web-search.md +28 -0
- package/src/prompts/tools/ask.md +28 -0
- package/src/prompts/tools/ast-edit.md +48 -0
- package/src/prompts/tools/ast-grep.md +54 -0
- package/src/prompts/tools/async-result.md +5 -0
- package/src/prompts/tools/bash.md +67 -0
- package/src/prompts/tools/browser.md +26 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/cancel-job.md +5 -0
- package/src/prompts/tools/catalog-workflow-runner.md +13 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/chunk-edit.md +279 -0
- package/src/prompts/tools/debug.md +43 -0
- package/src/prompts/tools/display-image.md +23 -0
- package/src/prompts/tools/exit-plan-mode.md +41 -0
- package/src/prompts/tools/find.md +26 -0
- package/src/prompts/tools/gemini-image.md +7 -0
- package/src/prompts/tools/grep.md +29 -0
- package/src/prompts/tools/hashline.md +131 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/lsp.md +33 -0
- package/src/prompts/tools/patch.md +77 -0
- package/src/prompts/tools/poll.md +5 -0
- package/src/prompts/tools/python.md +60 -0
- package/src/prompts/tools/read-chunk.md +35 -0
- package/src/prompts/tools/read.md +63 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +8 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +34 -0
- package/src/prompts/tools/ssh.md +44 -0
- package/src/prompts/tools/task-summary.md +28 -0
- package/src/prompts/tools/task.md +131 -0
- package/src/prompts/tools/todo-write.md +89 -0
- package/src/prompts/tools/vim.md +98 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/prompts/tools/xcsh-api.md +283 -0
- package/src/resource-management/index.ts +42 -0
- package/src/sdk.ts +2123 -0
- package/src/secrets/index.ts +146 -0
- package/src/secrets/obfuscator.ts +290 -0
- package/src/secrets/regex.ts +21 -0
- package/src/services/context-env.ts +102 -0
- package/src/services/xcsh-api-client.ts +230 -0
- package/src/services/xcsh-context-command.ts +803 -0
- package/src/services/xcsh-context-display.ts +49 -0
- package/src/services/xcsh-context-indicators.ts +17 -0
- package/src/services/xcsh-context-segment.ts +39 -0
- package/src/services/xcsh-context.ts +1410 -0
- package/src/services/xcsh-env.ts +107 -0
- package/src/services/xcsh-knowledge.ts +177 -0
- package/src/services/xcsh-table.ts +164 -0
- package/src/session/agent-session.ts +6690 -0
- package/src/session/agent-storage.ts +451 -0
- package/src/session/artifacts.ts +132 -0
- package/src/session/auth-storage.ts +17 -0
- package/src/session/blob-store.ts +135 -0
- package/src/session/compaction/branch-summarization.ts +322 -0
- package/src/session/compaction/compaction.ts +1388 -0
- package/src/session/compaction/index.ts +7 -0
- package/src/session/compaction/pruning.ts +91 -0
- package/src/session/compaction/utils.ts +184 -0
- package/src/session/history-storage.ts +253 -0
- package/src/session/messages.ts +597 -0
- package/src/session/session-dump-format.ts +203 -0
- package/src/session/session-manager.ts +2816 -0
- package/src/session/session-storage.ts +370 -0
- package/src/session/streaming-output.ts +770 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/slash-commands/builtin-registry.ts +1614 -0
- package/src/slash-commands/export-command.ts +178 -0
- package/src/slash-commands/marketplace-install-parser.ts +99 -0
- package/src/slash-commands/resource-commands.ts +250 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +445 -0
- package/src/ssh/ssh-executor.ts +131 -0
- package/src/ssh/sshfs-mount.ts +137 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +688 -0
- package/src/task/agents.ts +166 -0
- package/src/task/commands.ts +131 -0
- package/src/task/discovery.ts +126 -0
- package/src/task/executor.ts +1324 -0
- package/src/task/index.ts +1197 -0
- package/src/task/isolation-backend.ts +72 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +107 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/render.ts +1035 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/template.ts +33 -0
- package/src/task/types.ts +230 -0
- package/src/task/worktree.ts +580 -0
- package/src/task/xcsh-command.ts +26 -0
- package/src/thinking.ts +87 -0
- package/src/tools/action-renderer.ts +198 -0
- package/src/tools/archive-reader.ts +315 -0
- package/src/tools/ask.ts +791 -0
- package/src/tools/ast-edit.ts +492 -0
- package/src/tools/ast-grep.ts +453 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/bash-interactive.ts +383 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-normalize.ts +107 -0
- package/src/tools/bash-skill-urls.ts +246 -0
- package/src/tools/bash.ts +878 -0
- package/src/tools/browser-renderer.ts +129 -0
- package/src/tools/browser.ts +1366 -0
- package/src/tools/calculator.ts +543 -0
- package/src/tools/cancel-job.ts +100 -0
- package/src/tools/catalog-workflow-runner.ts +718 -0
- package/src/tools/checkpoint.ts +133 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1004 -0
- package/src/tools/display-image-renderer.ts +96 -0
- package/src/tools/display-image.ts +109 -0
- package/src/tools/exit-plan-mode.ts +101 -0
- package/src/tools/fetch.ts +1462 -0
- package/src/tools/find.ts +437 -0
- package/src/tools/fs-cache-invalidation.ts +33 -0
- package/src/tools/gemini-image.ts +1004 -0
- package/src/tools/grep.ts +705 -0
- package/src/tools/index.ts +442 -0
- package/src/tools/inspect-image-renderer.ts +101 -0
- package/src/tools/inspect-image.ts +176 -0
- package/src/tools/json-tree.ts +266 -0
- package/src/tools/jtd-to-json-schema.ts +199 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/mermaid-renderer.ts +127 -0
- package/src/tools/notebook.ts +288 -0
- package/src/tools/output-meta.ts +588 -0
- package/src/tools/path-utils.ts +560 -0
- package/src/tools/plan-mode-guard.ts +41 -0
- package/src/tools/poll-tool.ts +177 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/python.ts +1184 -0
- package/src/tools/read.ts +1591 -0
- package/src/tools/render-mermaid.ts +93 -0
- package/src/tools/render-utils.ts +677 -0
- package/src/tools/renderers.ts +82 -0
- package/src/tools/report-tool-issue.ts +80 -0
- package/src/tools/resolve.ts +196 -0
- package/src/tools/review.ts +238 -0
- package/src/tools/search-tool-bm25.ts +288 -0
- package/src/tools/sqlite-reader.ts +623 -0
- package/src/tools/ssh.ts +322 -0
- package/src/tools/submit-result.ts +229 -0
- package/src/tools/todo-render.ts +33 -0
- package/src/tools/todo-write.ts +440 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +93 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/vim.ts +981 -0
- package/src/tools/write.ts +671 -0
- package/src/tools/xcsh-api-renderer.ts +402 -0
- package/src/tools/xcsh-api.ts +887 -0
- package/src/tui/code-cell.ts +101 -0
- package/src/tui/file-list.ts +47 -0
- package/src/tui/index.ts +11 -0
- package/src/tui/output-block.ts +175 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +98 -0
- package/src/utils/clipboard.ts +80 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +137 -0
- package/src/utils/edit-mode.ts +50 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +37 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/fuzzy.ts +108 -0
- package/src/utils/git.ts +1495 -0
- package/src/utils/gitstatus.ts +140 -0
- package/src/utils/image-convert.ts +27 -0
- package/src/utils/image-loading.ts +98 -0
- package/src/utils/image-passthrough.ts +118 -0
- package/src/utils/image-resize.ts +272 -0
- package/src/utils/image-viewer.ts +17 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +81 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/session-color.ts +55 -0
- package/src/utils/shell-snapshot.ts +188 -0
- package/src/utils/title-generator.ts +193 -0
- package/src/utils/tool-choice.ts +28 -0
- package/src/utils/tools-manager.ts +356 -0
- package/src/vim/buffer.ts +309 -0
- package/src/vim/commands.ts +382 -0
- package/src/vim/engine.ts +2426 -0
- package/src/vim/parser.ts +151 -0
- package/src/vim/render.ts +252 -0
- package/src/vim/types.ts +197 -0
- package/src/web/kagi.ts +174 -0
- package/src/web/parallel.ts +346 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +110 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +169 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +190 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +267 -0
- package/src/web/scrapers/utils.ts +109 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +313 -0
- package/src/web/search/errors.ts +120 -0
- package/src/web/search/index.ts +346 -0
- package/src/web/search/params.ts +129 -0
- package/src/web/search/provider.ts +97 -0
- package/src/web/search/providers/anthropic.ts +339 -0
- package/src/web/search/providers/base.ts +35 -0
- package/src/web/search/providers/brave.ts +150 -0
- package/src/web/search/providers/codex.ts +402 -0
- package/src/web/search/providers/exa.ts +264 -0
- package/src/web/search/providers/firecrawl.ts +115 -0
- package/src/web/search/providers/gemini.ts +566 -0
- package/src/web/search/providers/jina.ts +99 -0
- package/src/web/search/providers/kagi.ts +70 -0
- package/src/web/search/providers/kimi.ts +157 -0
- package/src/web/search/providers/parallel.ts +63 -0
- package/src/web/search/providers/perplexity.ts +546 -0
- package/src/web/search/providers/synthetic.ts +113 -0
- package/src/web/search/providers/tavily.ts +162 -0
- package/src/web/search/providers/utils.ts +36 -0
- package/src/web/search/providers/zai.ts +311 -0
- package/src/web/search/render.ts +348 -0
- package/src/web/search/types.ts +438 -0
- package/src/web/search/utils.ts +17 -0
|
@@ -0,0 +1,1314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Add Wizard Component
|
|
3
|
+
*
|
|
4
|
+
* Interactive multi-step wizard for adding MCP servers.
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
Container,
|
|
8
|
+
Input,
|
|
9
|
+
matchesKey,
|
|
10
|
+
replaceTabs,
|
|
11
|
+
Spacer,
|
|
12
|
+
Text,
|
|
13
|
+
TruncatedText,
|
|
14
|
+
truncateToWidth,
|
|
15
|
+
} from "@f5xc-salesdemos/pi-tui";
|
|
16
|
+
import { getMCPConfigPath, getProjectDir } from "@f5xc-salesdemos/pi-utils";
|
|
17
|
+
import { validateServerName } from "../../mcp/config-writer";
|
|
18
|
+
import { analyzeAuthError, discoverOAuthEndpoints } from "../../mcp/oauth-discovery";
|
|
19
|
+
import type { MCPHttpServerConfig, MCPServerConfig, MCPSseServerConfig, MCPStdioServerConfig } from "../../mcp/types";
|
|
20
|
+
import { shortenPath } from "../../tools/render-utils";
|
|
21
|
+
import { theme } from "../theme/theme";
|
|
22
|
+
import { matchesAppInterrupt } from "../utils/keybinding-matchers";
|
|
23
|
+
import { DynamicBorder } from "./dynamic-border";
|
|
24
|
+
|
|
25
|
+
type TransportType = "stdio" | "http" | "sse";
|
|
26
|
+
type AuthMethod = "none" | "oauth" | "manual";
|
|
27
|
+
type AuthLocation = "env" | "header";
|
|
28
|
+
type Scope = "user" | "project";
|
|
29
|
+
|
|
30
|
+
type WizardStep =
|
|
31
|
+
| "name"
|
|
32
|
+
| "transport"
|
|
33
|
+
| "command"
|
|
34
|
+
| "args"
|
|
35
|
+
| "url"
|
|
36
|
+
| "auth-method"
|
|
37
|
+
| "oauth-error"
|
|
38
|
+
| "oauth-auth-url"
|
|
39
|
+
| "oauth-token-url"
|
|
40
|
+
| "oauth-client-id"
|
|
41
|
+
| "oauth-client-secret"
|
|
42
|
+
| "oauth-scopes"
|
|
43
|
+
| "apikey"
|
|
44
|
+
| "auth-location"
|
|
45
|
+
| "env-var-name"
|
|
46
|
+
| "header-name"
|
|
47
|
+
| "scope"
|
|
48
|
+
| "confirm";
|
|
49
|
+
|
|
50
|
+
interface WizardState {
|
|
51
|
+
name: string;
|
|
52
|
+
transport: TransportType | null;
|
|
53
|
+
command: string;
|
|
54
|
+
args: string;
|
|
55
|
+
url: string;
|
|
56
|
+
authMethod: AuthMethod;
|
|
57
|
+
oauthAuthUrl: string;
|
|
58
|
+
oauthTokenUrl: string;
|
|
59
|
+
oauthClientId: string;
|
|
60
|
+
oauthClientSecret: string;
|
|
61
|
+
oauthScopes: string;
|
|
62
|
+
oauthCredentialId: string | null;
|
|
63
|
+
apiKey: string;
|
|
64
|
+
authLocation: AuthLocation | null;
|
|
65
|
+
envVarName: string;
|
|
66
|
+
headerName: string;
|
|
67
|
+
scope: Scope | null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Max display width for sanitized error/URL text in wizard TUI */
|
|
71
|
+
const MAX_DISPLAY_WIDTH = 120;
|
|
72
|
+
|
|
73
|
+
/** Sanitize a string for TUI display: replace tabs and truncate */
|
|
74
|
+
function sanitize(text: string): string {
|
|
75
|
+
return truncateToWidth(replaceTabs(text), MAX_DISPLAY_WIDTH);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class MCPAddWizard extends Container {
|
|
79
|
+
#currentStep: WizardStep = "name";
|
|
80
|
+
#state: WizardState = {
|
|
81
|
+
name: "",
|
|
82
|
+
transport: null,
|
|
83
|
+
command: "",
|
|
84
|
+
args: "",
|
|
85
|
+
url: "",
|
|
86
|
+
authMethod: "none",
|
|
87
|
+
oauthAuthUrl: "",
|
|
88
|
+
oauthTokenUrl: "",
|
|
89
|
+
oauthClientId: "",
|
|
90
|
+
oauthClientSecret: "",
|
|
91
|
+
oauthScopes: "",
|
|
92
|
+
oauthCredentialId: null,
|
|
93
|
+
apiKey: "",
|
|
94
|
+
authLocation: null,
|
|
95
|
+
envVarName: "API_KEY",
|
|
96
|
+
headerName: "Authorization",
|
|
97
|
+
scope: null,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
#contentContainer: Container;
|
|
101
|
+
#inputField: Input | null = null;
|
|
102
|
+
#selectedIndex = 0;
|
|
103
|
+
#validationError: string | null = null;
|
|
104
|
+
#onCompleteCallback: (name: string, config: MCPServerConfig, scope: Scope) => void;
|
|
105
|
+
#onCancelCallback: () => void;
|
|
106
|
+
#onOAuthCallback:
|
|
107
|
+
| ((authUrl: string, tokenUrl: string, clientId: string, clientSecret: string, scopes: string) => Promise<string>)
|
|
108
|
+
| null = null;
|
|
109
|
+
#onTestConnectionCallback: ((config: MCPServerConfig) => Promise<void>) | null = null;
|
|
110
|
+
#onRenderCallback: (() => void) | null = null;
|
|
111
|
+
|
|
112
|
+
constructor(
|
|
113
|
+
onComplete: (name: string, config: MCPServerConfig, scope: Scope) => void,
|
|
114
|
+
onCancel: () => void,
|
|
115
|
+
onOAuth?: (
|
|
116
|
+
authUrl: string,
|
|
117
|
+
tokenUrl: string,
|
|
118
|
+
clientId: string,
|
|
119
|
+
clientSecret: string,
|
|
120
|
+
scopes: string,
|
|
121
|
+
) => Promise<string>,
|
|
122
|
+
onTestConnection?: (config: MCPServerConfig) => Promise<void>,
|
|
123
|
+
onRender?: () => void,
|
|
124
|
+
initialName?: string,
|
|
125
|
+
) {
|
|
126
|
+
super();
|
|
127
|
+
this.#onCompleteCallback = onComplete;
|
|
128
|
+
this.#onCancelCallback = onCancel;
|
|
129
|
+
this.#onOAuthCallback = onOAuth ?? null;
|
|
130
|
+
this.#onTestConnectionCallback = onTestConnection ?? null;
|
|
131
|
+
this.#onRenderCallback = onRender ?? null;
|
|
132
|
+
if (initialName && initialName.trim().length > 0) {
|
|
133
|
+
this.#state.name = initialName.trim();
|
|
134
|
+
this.#currentStep = "transport";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Add border
|
|
138
|
+
this.addChild(new DynamicBorder());
|
|
139
|
+
this.addChild(new Spacer(1));
|
|
140
|
+
|
|
141
|
+
// Add title
|
|
142
|
+
this.addChild(new TruncatedText(theme.bold("Add MCP Server")));
|
|
143
|
+
this.addChild(new Spacer(1));
|
|
144
|
+
|
|
145
|
+
// Content container for step-specific content
|
|
146
|
+
this.#contentContainer = new Container();
|
|
147
|
+
this.addChild(this.#contentContainer);
|
|
148
|
+
|
|
149
|
+
this.addChild(new Spacer(1));
|
|
150
|
+
|
|
151
|
+
// Add bottom border
|
|
152
|
+
this.addChild(new DynamicBorder());
|
|
153
|
+
|
|
154
|
+
// Render first step
|
|
155
|
+
this.#renderStep();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
#requestRender(): void {
|
|
159
|
+
this.#onRenderCallback?.();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#renderStep(): void {
|
|
163
|
+
this.#contentContainer.clear();
|
|
164
|
+
this.#inputField = null; // Reset input field
|
|
165
|
+
|
|
166
|
+
switch (this.#currentStep) {
|
|
167
|
+
case "name":
|
|
168
|
+
this.#renderNameStep();
|
|
169
|
+
break;
|
|
170
|
+
case "transport":
|
|
171
|
+
this.#renderTransportStep();
|
|
172
|
+
break;
|
|
173
|
+
case "command":
|
|
174
|
+
this.#renderCommandStep();
|
|
175
|
+
break;
|
|
176
|
+
case "args":
|
|
177
|
+
this.#renderArgsStep();
|
|
178
|
+
break;
|
|
179
|
+
case "url":
|
|
180
|
+
this.#renderUrlStep();
|
|
181
|
+
break;
|
|
182
|
+
case "auth-method":
|
|
183
|
+
this.#renderAuthMethodStep();
|
|
184
|
+
break;
|
|
185
|
+
case "oauth-error":
|
|
186
|
+
this.#renderOAuthErrorStep();
|
|
187
|
+
break;
|
|
188
|
+
case "oauth-auth-url":
|
|
189
|
+
this.#renderOAuthAuthUrlStep();
|
|
190
|
+
break;
|
|
191
|
+
case "oauth-token-url":
|
|
192
|
+
this.#renderOAuthTokenUrlStep();
|
|
193
|
+
break;
|
|
194
|
+
case "oauth-client-id":
|
|
195
|
+
this.#renderOAuthClientIdStep();
|
|
196
|
+
break;
|
|
197
|
+
case "oauth-client-secret":
|
|
198
|
+
this.#renderOAuthClientSecretStep();
|
|
199
|
+
break;
|
|
200
|
+
case "oauth-scopes":
|
|
201
|
+
this.#renderOAuthScopesStep();
|
|
202
|
+
break;
|
|
203
|
+
case "apikey":
|
|
204
|
+
this.#renderApiKeyStep();
|
|
205
|
+
break;
|
|
206
|
+
case "auth-location":
|
|
207
|
+
this.#renderAuthLocationStep();
|
|
208
|
+
break;
|
|
209
|
+
case "env-var-name":
|
|
210
|
+
this.#renderEnvVarNameStep();
|
|
211
|
+
break;
|
|
212
|
+
case "header-name":
|
|
213
|
+
this.#renderHeaderNameStep();
|
|
214
|
+
break;
|
|
215
|
+
case "scope":
|
|
216
|
+
this.#renderScopeStep();
|
|
217
|
+
break;
|
|
218
|
+
case "confirm":
|
|
219
|
+
this.#renderConfirmStep();
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
#renderNameStep(): void {
|
|
225
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step 1: Server Name")));
|
|
226
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
227
|
+
this.#contentContainer.addChild(new Text("Enter a unique name for this server:", 0, 0));
|
|
228
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
229
|
+
|
|
230
|
+
this.#inputField = new Input();
|
|
231
|
+
this.#inputField.setValue(this.#state.name);
|
|
232
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
233
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
234
|
+
|
|
235
|
+
// Show validation error if any
|
|
236
|
+
if (this.#validationError) {
|
|
237
|
+
this.#contentContainer.addChild(new Text(theme.fg("error", `✗ ${sanitize(this.#validationError)}`), 0, 0));
|
|
238
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
this.#contentContainer.addChild(
|
|
242
|
+
new Text(theme.fg("muted", "[Only letters, numbers, dash, underscore, dot]"), 0, 0),
|
|
243
|
+
);
|
|
244
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to cancel]"), 0, 0));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
#renderTransportStep(): void {
|
|
248
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step 2: Transport Type")));
|
|
249
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
250
|
+
this.#contentContainer.addChild(new Text("Select the transport type:", 0, 0));
|
|
251
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
252
|
+
|
|
253
|
+
const options = [
|
|
254
|
+
{ value: "stdio" as const, label: "stdio (Local process)" },
|
|
255
|
+
{ value: "http" as const, label: "http (HTTP server)" },
|
|
256
|
+
{ value: "sse" as const, label: "sse (Server-Sent Events)" },
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
for (let i = 0; i < options.length; i++) {
|
|
260
|
+
const option = options[i];
|
|
261
|
+
const isSelected = i === this.#selectedIndex;
|
|
262
|
+
const prefix = isSelected ? theme.fg("chromeAccent", `${theme.nav.cursor} `) : " ";
|
|
263
|
+
const text = isSelected ? theme.fg("contentAccent", option.label) : option.label;
|
|
264
|
+
this.#contentContainer.addChild(new Text(prefix + text, 0, 0));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
268
|
+
this.#contentContainer.addChild(
|
|
269
|
+
new Text(theme.fg("muted", "[↑↓ to navigate, Enter to select, Esc to cancel]"), 0, 0),
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
#renderCommandStep(): void {
|
|
274
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step 3: Command")));
|
|
275
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
276
|
+
this.#contentContainer.addChild(new Text("Enter the command to run:", 0, 0));
|
|
277
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
278
|
+
|
|
279
|
+
this.#inputField = new Input();
|
|
280
|
+
this.#inputField.setValue(this.#state.command);
|
|
281
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
282
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
283
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
#renderArgsStep(): void {
|
|
287
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step 4: Arguments (Optional)")));
|
|
288
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
289
|
+
this.#contentContainer.addChild(new Text("Enter command arguments (space-separated):", 0, 0));
|
|
290
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
291
|
+
|
|
292
|
+
this.#inputField = new Input();
|
|
293
|
+
this.#inputField.setValue(this.#state.args);
|
|
294
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
295
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
296
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Press Enter to skip or continue]"), 0, 0));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
#renderUrlStep(): void {
|
|
300
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step 3: Server URL")));
|
|
301
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
302
|
+
this.#contentContainer.addChild(new Text("Enter the server URL:", 0, 0));
|
|
303
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
304
|
+
|
|
305
|
+
this.#inputField = new Input();
|
|
306
|
+
this.#inputField.setValue(this.#state.url);
|
|
307
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
308
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
309
|
+
|
|
310
|
+
// Show validation error if any
|
|
311
|
+
if (this.#validationError) {
|
|
312
|
+
this.#contentContainer.addChild(new Text(theme.fg("error", `✗ ${sanitize(this.#validationError)}`), 0, 0));
|
|
313
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Must start with http:// or https://]"), 0, 0));
|
|
317
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
#renderAuthLocationStep(): void {
|
|
321
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step: How to provide the key?")));
|
|
322
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
323
|
+
|
|
324
|
+
const options = [
|
|
325
|
+
{ value: "env" as const, label: "Environment variable" },
|
|
326
|
+
{ value: "header" as const, label: "HTTP header" },
|
|
327
|
+
];
|
|
328
|
+
|
|
329
|
+
for (let i = 0; i < options.length; i++) {
|
|
330
|
+
const option = options[i];
|
|
331
|
+
const isSelected = i === this.#selectedIndex;
|
|
332
|
+
const prefix = isSelected ? theme.fg("chromeAccent", `${theme.nav.cursor} `) : " ";
|
|
333
|
+
const text = isSelected ? theme.fg("contentAccent", option.label) : option.label;
|
|
334
|
+
this.#contentContainer.addChild(new Text(prefix + text, 0, 0));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
338
|
+
this.#contentContainer.addChild(
|
|
339
|
+
new Text(theme.fg("muted", "[↑↓ to navigate, Enter to select, Esc to go back]"), 0, 0),
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
#renderEnvVarNameStep(): void {
|
|
344
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step: Environment Variable Name")));
|
|
345
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
346
|
+
this.#contentContainer.addChild(new Text("Enter the environment variable name:", 0, 0));
|
|
347
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
348
|
+
|
|
349
|
+
this.#inputField = new Input();
|
|
350
|
+
this.#inputField.setValue(this.#state.envVarName);
|
|
351
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
352
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
353
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
#renderHeaderNameStep(): void {
|
|
357
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step: HTTP Header Name")));
|
|
358
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
359
|
+
this.#contentContainer.addChild(new Text("Enter the HTTP header name:", 0, 0));
|
|
360
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
361
|
+
|
|
362
|
+
this.#inputField = new Input();
|
|
363
|
+
this.#inputField.setValue(this.#state.headerName);
|
|
364
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
365
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
366
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
#renderScopeStep(): void {
|
|
370
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step: Configuration Scope")));
|
|
371
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
372
|
+
|
|
373
|
+
const cwd = getProjectDir();
|
|
374
|
+
|
|
375
|
+
const userPathLabel = shortenPath(getMCPConfigPath("user", cwd));
|
|
376
|
+
const projectPathLabel = shortenPath(getMCPConfigPath("project", cwd));
|
|
377
|
+
const options = [
|
|
378
|
+
{ value: "user" as const, label: `User level (${userPathLabel})` },
|
|
379
|
+
{ value: "project" as const, label: `Project level (${projectPathLabel})` },
|
|
380
|
+
];
|
|
381
|
+
|
|
382
|
+
for (let i = 0; i < options.length; i++) {
|
|
383
|
+
const option = options[i];
|
|
384
|
+
const isSelected = i === this.#selectedIndex;
|
|
385
|
+
const prefix = isSelected ? theme.fg("chromeAccent", `${theme.nav.cursor} `) : " ";
|
|
386
|
+
const text = isSelected ? theme.fg("contentAccent", option.label) : option.label;
|
|
387
|
+
this.#contentContainer.addChild(new Text(prefix + text, 0, 0));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
391
|
+
this.#contentContainer.addChild(
|
|
392
|
+
new Text(theme.fg("muted", "[↑↓ to navigate, Enter to select, Esc to go back]"), 0, 0),
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
#renderConfirmStep(): void {
|
|
397
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Review Configuration")));
|
|
398
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
399
|
+
|
|
400
|
+
// Show summary
|
|
401
|
+
this.#contentContainer.addChild(new Text(`Name: ${theme.fg("contentAccent", this.#state.name)}`, 0, 0));
|
|
402
|
+
this.#contentContainer.addChild(new Text(`Type: ${this.#state.transport}`, 0, 0));
|
|
403
|
+
|
|
404
|
+
if (this.#state.transport === "stdio") {
|
|
405
|
+
this.#contentContainer.addChild(new Text(`Command: ${this.#state.command}`, 0, 0));
|
|
406
|
+
if (this.#state.args) {
|
|
407
|
+
this.#contentContainer.addChild(new Text(`Args: ${this.#state.args}`, 0, 0));
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
this.#contentContainer.addChild(new Text(`URL: ${sanitize(this.#state.url)}`, 0, 0));
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Auth info
|
|
414
|
+
if (this.#state.authMethod === "none") {
|
|
415
|
+
this.#contentContainer.addChild(new Text("Auth: None", 0, 0));
|
|
416
|
+
} else if (this.#state.authMethod === "oauth") {
|
|
417
|
+
this.#contentContainer.addChild(new Text("Auth: OAuth (authenticated)", 0, 0));
|
|
418
|
+
} else if (this.#state.authMethod === "manual") {
|
|
419
|
+
if (this.#state.authLocation === "env") {
|
|
420
|
+
this.#contentContainer.addChild(new Text(`Auth: API key via env (${this.#state.envVarName})`, 0, 0));
|
|
421
|
+
} else {
|
|
422
|
+
this.#contentContainer.addChild(new Text(`Auth: API key via header (${this.#state.headerName})`, 0, 0));
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const scopeLabel = this.#state.scope === "user" ? "User level" : "Project level";
|
|
427
|
+
this.#contentContainer.addChild(new Text(`Scope: ${scopeLabel}`, 0, 0));
|
|
428
|
+
|
|
429
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
430
|
+
this.#contentContainer.addChild(new Text("Save this configuration?", 0, 0));
|
|
431
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
432
|
+
|
|
433
|
+
const options = ["Yes", "No"];
|
|
434
|
+
for (let i = 0; i < options.length; i++) {
|
|
435
|
+
const isSelected = i === this.#selectedIndex;
|
|
436
|
+
const prefix = isSelected ? theme.fg("chromeAccent", `${theme.nav.cursor} `) : " ";
|
|
437
|
+
const text = isSelected ? theme.fg("contentAccent", options[i]) : options[i];
|
|
438
|
+
this.#contentContainer.addChild(new Text(prefix + text, 0, 0));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
442
|
+
this.#contentContainer.addChild(
|
|
443
|
+
new Text(theme.fg("muted", "[↑↓ to navigate, Enter to select, Esc to go back]"), 0, 0),
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
handleInput(keyData: string): void {
|
|
448
|
+
// Handle Ctrl+C to cancel wizard immediately
|
|
449
|
+
if (keyData === "\x03") {
|
|
450
|
+
// Ctrl+C pressed - cancel wizard
|
|
451
|
+
this.#onCancelCallback();
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// Handle Escape (always handled by wizard)
|
|
456
|
+
if (matchesAppInterrupt(keyData)) {
|
|
457
|
+
if (this.#currentStep === "name") {
|
|
458
|
+
// Cancel wizard
|
|
459
|
+
this.#onCancelCallback();
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
// Go back to previous step
|
|
463
|
+
this.#goBack();
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// If we have an input field, let it handle the input
|
|
468
|
+
if (this.#inputField) {
|
|
469
|
+
// Handle Enter to proceed
|
|
470
|
+
if (matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n") {
|
|
471
|
+
this.#saveInputAndProceed();
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
// Pass all other keys to the input field
|
|
475
|
+
this.#inputField.handleInput(keyData);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Selector steps - handle Enter
|
|
480
|
+
if (matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n") {
|
|
481
|
+
this.#selectCurrentOption();
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Handle up/down arrows for selectors
|
|
486
|
+
if (matchesKey(keyData, "up")) {
|
|
487
|
+
this.#moveSelection(-1);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
if (matchesKey(keyData, "down")) {
|
|
491
|
+
this.#moveSelection(1);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
#saveInputAndProceed(): void {
|
|
497
|
+
if (!this.#inputField) return;
|
|
498
|
+
|
|
499
|
+
const value = this.#inputField.getValue().trim();
|
|
500
|
+
|
|
501
|
+
switch (this.#currentStep) {
|
|
502
|
+
case "name": {
|
|
503
|
+
// Validate server name
|
|
504
|
+
const nameError = validateServerName(value);
|
|
505
|
+
if (nameError) {
|
|
506
|
+
this.#validationError = nameError;
|
|
507
|
+
this.#renderStep();
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
this.#validationError = null;
|
|
511
|
+
this.#state.name = value;
|
|
512
|
+
this.#currentStep = "transport";
|
|
513
|
+
this.#selectedIndex = 0;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
case "command":
|
|
517
|
+
if (!value) {
|
|
518
|
+
// Command is required
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
this.#state.command = value;
|
|
522
|
+
this.#currentStep = "args";
|
|
523
|
+
break;
|
|
524
|
+
case "args":
|
|
525
|
+
this.#state.args = value; // Optional
|
|
526
|
+
void this.#testConnectionAndDetectAuth();
|
|
527
|
+
return;
|
|
528
|
+
case "url": {
|
|
529
|
+
// Validate URL
|
|
530
|
+
if (!value) {
|
|
531
|
+
this.#validationError = "URL is required";
|
|
532
|
+
this.#renderStep();
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
let parsedUrl: URL;
|
|
536
|
+
try {
|
|
537
|
+
parsedUrl = new URL(value);
|
|
538
|
+
} catch {
|
|
539
|
+
this.#validationError = "Invalid URL format (must start with http:// or https://)";
|
|
540
|
+
this.#renderStep();
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
544
|
+
this.#validationError = "URL must use http:// or https:// scheme";
|
|
545
|
+
this.#renderStep();
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
this.#validationError = null;
|
|
549
|
+
this.#state.url = value;
|
|
550
|
+
void this.#testConnectionAndDetectAuth();
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
case "oauth-auth-url":
|
|
554
|
+
if (!value) return;
|
|
555
|
+
this.#state.oauthAuthUrl = value;
|
|
556
|
+
this.#currentStep = "oauth-token-url";
|
|
557
|
+
break;
|
|
558
|
+
case "oauth-token-url":
|
|
559
|
+
if (!value) return;
|
|
560
|
+
this.#state.oauthTokenUrl = value;
|
|
561
|
+
this.#currentStep = "oauth-client-id";
|
|
562
|
+
break;
|
|
563
|
+
case "oauth-client-id":
|
|
564
|
+
if (!value) return;
|
|
565
|
+
this.#state.oauthClientId = value;
|
|
566
|
+
this.#currentStep = "oauth-client-secret";
|
|
567
|
+
break;
|
|
568
|
+
case "oauth-client-secret":
|
|
569
|
+
this.#state.oauthClientSecret = value; // Optional
|
|
570
|
+
this.#currentStep = "oauth-scopes";
|
|
571
|
+
break;
|
|
572
|
+
case "oauth-scopes":
|
|
573
|
+
this.#state.oauthScopes = value; // Optional
|
|
574
|
+
// Launch OAuth flow
|
|
575
|
+
void this.#launchOAuthFlow();
|
|
576
|
+
return;
|
|
577
|
+
case "apikey":
|
|
578
|
+
if (!value) {
|
|
579
|
+
// API key is required
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
this.#state.apiKey = value;
|
|
583
|
+
// Determine auth location based on transport
|
|
584
|
+
if (this.#state.transport === "stdio") {
|
|
585
|
+
this.#currentStep = "env-var-name";
|
|
586
|
+
} else {
|
|
587
|
+
this.#currentStep = "auth-location";
|
|
588
|
+
this.#selectedIndex = 0;
|
|
589
|
+
}
|
|
590
|
+
break;
|
|
591
|
+
case "env-var-name":
|
|
592
|
+
if (!value) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
this.#state.envVarName = value;
|
|
596
|
+
this.#state.authLocation = "env";
|
|
597
|
+
this.#currentStep = "scope";
|
|
598
|
+
this.#selectedIndex = 0;
|
|
599
|
+
break;
|
|
600
|
+
case "header-name":
|
|
601
|
+
if (!value) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
this.#state.headerName = value;
|
|
605
|
+
this.#state.authLocation = "header";
|
|
606
|
+
this.#currentStep = "scope";
|
|
607
|
+
this.#selectedIndex = 0;
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
this.#inputField = null;
|
|
612
|
+
this.#renderStep();
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
#selectCurrentOption(): void {
|
|
616
|
+
switch (this.#currentStep) {
|
|
617
|
+
case "transport": {
|
|
618
|
+
const transports: TransportType[] = ["stdio", "http", "sse"];
|
|
619
|
+
this.#state.transport = transports[this.#selectedIndex];
|
|
620
|
+
this.#currentStep = this.#state.transport === "stdio" ? "command" : "url";
|
|
621
|
+
break;
|
|
622
|
+
}
|
|
623
|
+
case "auth-method": {
|
|
624
|
+
const authMethods: Array<"oauth" | "manual"> = ["oauth", "manual"];
|
|
625
|
+
this.#state.authMethod = authMethods[this.#selectedIndex];
|
|
626
|
+
if (this.#state.authMethod === "oauth") {
|
|
627
|
+
this.#currentStep = "oauth-auth-url";
|
|
628
|
+
} else {
|
|
629
|
+
// manual
|
|
630
|
+
this.#currentStep = "apikey";
|
|
631
|
+
}
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
case "oauth-error":
|
|
635
|
+
if (this.#selectedIndex === 0) {
|
|
636
|
+
void this.#launchOAuthFlow();
|
|
637
|
+
} else {
|
|
638
|
+
this.#currentStep = "oauth-auth-url";
|
|
639
|
+
}
|
|
640
|
+
return;
|
|
641
|
+
case "auth-location": {
|
|
642
|
+
const authLocations: Array<"env" | "header"> = ["env", "header"];
|
|
643
|
+
this.#state.authLocation = authLocations[this.#selectedIndex];
|
|
644
|
+
if (this.#state.authLocation === "env") {
|
|
645
|
+
this.#currentStep = "env-var-name";
|
|
646
|
+
} else {
|
|
647
|
+
this.#currentStep = "header-name";
|
|
648
|
+
}
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
case "scope": {
|
|
652
|
+
const scopes: Scope[] = ["user", "project"];
|
|
653
|
+
this.#state.scope = scopes[this.#selectedIndex];
|
|
654
|
+
this.#currentStep = "confirm";
|
|
655
|
+
this.#selectedIndex = 0;
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
case "confirm": {
|
|
659
|
+
if (this.#selectedIndex === 0) {
|
|
660
|
+
this.#complete();
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
this.#currentStep = "scope";
|
|
664
|
+
this.#selectedIndex = this.#state.scope === "user" ? 0 : 1;
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
this.#renderStep();
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
#moveSelection(delta: number): void {
|
|
673
|
+
const maxIndex = this.#getMaxIndexForCurrentStep();
|
|
674
|
+
this.#selectedIndex = (this.#selectedIndex + delta + maxIndex + 1) % (maxIndex + 1);
|
|
675
|
+
this.#renderStep();
|
|
676
|
+
this.#requestRender();
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
#getMaxIndexForCurrentStep(): number {
|
|
680
|
+
switch (this.#currentStep) {
|
|
681
|
+
case "transport":
|
|
682
|
+
return 2; // 3 options
|
|
683
|
+
case "auth-method":
|
|
684
|
+
return 1; // 2 options
|
|
685
|
+
case "oauth-error":
|
|
686
|
+
return 1; // 2 options
|
|
687
|
+
case "auth-location":
|
|
688
|
+
return 1; // 2 options
|
|
689
|
+
case "scope":
|
|
690
|
+
return 1; // 2 options
|
|
691
|
+
case "confirm":
|
|
692
|
+
return 1; // 2 options
|
|
693
|
+
default:
|
|
694
|
+
return 0;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
#goBack(): void {
|
|
699
|
+
// Navigate to previous step
|
|
700
|
+
switch (this.#currentStep) {
|
|
701
|
+
case "transport":
|
|
702
|
+
this.#currentStep = "name";
|
|
703
|
+
break;
|
|
704
|
+
case "command":
|
|
705
|
+
case "url":
|
|
706
|
+
this.#currentStep = "transport";
|
|
707
|
+
this.#selectedIndex = this.#state.transport === "stdio" ? 0 : this.#state.transport === "http" ? 1 : 2;
|
|
708
|
+
break;
|
|
709
|
+
case "args":
|
|
710
|
+
this.#currentStep = "command";
|
|
711
|
+
break;
|
|
712
|
+
case "auth-method":
|
|
713
|
+
// Go back to url or args depending on transport
|
|
714
|
+
if (this.#state.transport === "stdio") {
|
|
715
|
+
this.#currentStep = "args";
|
|
716
|
+
} else {
|
|
717
|
+
this.#currentStep = "url";
|
|
718
|
+
}
|
|
719
|
+
break;
|
|
720
|
+
case "oauth-auth-url":
|
|
721
|
+
case "apikey":
|
|
722
|
+
// Go back to transport-specific connection step
|
|
723
|
+
if (this.#state.transport === "stdio") {
|
|
724
|
+
this.#currentStep = "args";
|
|
725
|
+
} else {
|
|
726
|
+
this.#currentStep = "url";
|
|
727
|
+
}
|
|
728
|
+
break;
|
|
729
|
+
case "auth-location":
|
|
730
|
+
// Go back to API key input
|
|
731
|
+
this.#currentStep = "apikey";
|
|
732
|
+
break;
|
|
733
|
+
case "env-var-name":
|
|
734
|
+
case "header-name":
|
|
735
|
+
// Go back to auth location selection (for HTTP) or directly to apikey (for stdio)
|
|
736
|
+
if (this.#state.transport === "stdio") {
|
|
737
|
+
this.#currentStep = "apikey";
|
|
738
|
+
} else {
|
|
739
|
+
this.#currentStep = "auth-location";
|
|
740
|
+
this.#selectedIndex = this.#state.authLocation === "env" ? 0 : 1;
|
|
741
|
+
}
|
|
742
|
+
break;
|
|
743
|
+
case "oauth-token-url":
|
|
744
|
+
case "oauth-client-id":
|
|
745
|
+
case "oauth-client-secret":
|
|
746
|
+
case "oauth-scopes":
|
|
747
|
+
// Go back through OAuth flow
|
|
748
|
+
if (this.#currentStep === "oauth-token-url") {
|
|
749
|
+
this.#currentStep = "oauth-auth-url";
|
|
750
|
+
} else if (this.#currentStep === "oauth-client-id") {
|
|
751
|
+
this.#currentStep = "oauth-token-url";
|
|
752
|
+
} else if (this.#currentStep === "oauth-client-secret") {
|
|
753
|
+
this.#currentStep = "oauth-client-id";
|
|
754
|
+
} else if (this.#currentStep === "oauth-scopes") {
|
|
755
|
+
this.#currentStep = "oauth-client-secret";
|
|
756
|
+
}
|
|
757
|
+
break;
|
|
758
|
+
case "scope":
|
|
759
|
+
// Go back to last authentication step
|
|
760
|
+
if (this.#state.authMethod === "oauth") {
|
|
761
|
+
this.#currentStep = "oauth-scopes";
|
|
762
|
+
} else {
|
|
763
|
+
// manual - go back to env var name or header name
|
|
764
|
+
if (this.#state.authLocation === "env") {
|
|
765
|
+
this.#currentStep = "env-var-name";
|
|
766
|
+
} else {
|
|
767
|
+
this.#currentStep = "header-name";
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
break;
|
|
771
|
+
case "oauth-error":
|
|
772
|
+
this.#currentStep = "oauth-auth-url";
|
|
773
|
+
break;
|
|
774
|
+
case "confirm":
|
|
775
|
+
this.#currentStep = "scope";
|
|
776
|
+
this.#selectedIndex = this.#state.scope === "user" ? 0 : 1;
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
this.#renderStep();
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
#renderAuthMethodStep(): void {
|
|
784
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "Step: Authentication Method")));
|
|
785
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
786
|
+
|
|
787
|
+
const options = [
|
|
788
|
+
{ value: "oauth" as const, label: "OAuth flow (web-based)", desc: "(opens browser)" },
|
|
789
|
+
{ value: "manual" as const, label: "Manual API key/token", desc: "(paste or use shell command)" },
|
|
790
|
+
];
|
|
791
|
+
|
|
792
|
+
for (let i = 0; i < options.length; i++) {
|
|
793
|
+
const option = options[i];
|
|
794
|
+
const isSelected = i === this.#selectedIndex;
|
|
795
|
+
const prefix = isSelected ? theme.fg("chromeAccent", `${theme.nav.cursor} `) : " ";
|
|
796
|
+
const text = isSelected ? theme.fg("contentAccent", option.label) : option.label;
|
|
797
|
+
this.#contentContainer.addChild(new Text(prefix + text, 0, 0));
|
|
798
|
+
if (!isSelected) {
|
|
799
|
+
this.#contentContainer.addChild(new Text(` ${theme.fg("dim", option.desc)}`, 0, 0));
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
804
|
+
this.#contentContainer.addChild(
|
|
805
|
+
new Text(theme.fg("muted", "[↑↓ to navigate, Enter to select, Esc to go back]"), 0, 0),
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
#renderOAuthAuthUrlStep(): void {
|
|
810
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "OAuth: Authorization URL")));
|
|
811
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
812
|
+
this.#contentContainer.addChild(new Text("Enter the OAuth authorization endpoint:", 0, 0));
|
|
813
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
814
|
+
|
|
815
|
+
this.#inputField = new Input();
|
|
816
|
+
this.#inputField.setValue(this.#state.oauthAuthUrl);
|
|
817
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
818
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
819
|
+
this.#contentContainer.addChild(
|
|
820
|
+
new Text(theme.fg("muted", "e.g., https://auth.example.com/oauth/authorize"), 0, 0),
|
|
821
|
+
);
|
|
822
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
823
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
#renderOAuthTokenUrlStep(): void {
|
|
827
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "OAuth: Token URL")));
|
|
828
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
829
|
+
this.#contentContainer.addChild(new Text("Enter the OAuth token endpoint:", 0, 0));
|
|
830
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
831
|
+
|
|
832
|
+
this.#inputField = new Input();
|
|
833
|
+
this.#inputField.setValue(this.#state.oauthTokenUrl);
|
|
834
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
835
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
836
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "e.g., https://auth.example.com/oauth/token"), 0, 0));
|
|
837
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
838
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
#renderOAuthClientIdStep(): void {
|
|
842
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "OAuth: Client ID")));
|
|
843
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
844
|
+
this.#contentContainer.addChild(new Text("Enter your OAuth client ID:", 0, 0));
|
|
845
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
846
|
+
|
|
847
|
+
this.#inputField = new Input();
|
|
848
|
+
this.#inputField.setValue(this.#state.oauthClientId);
|
|
849
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
850
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
851
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
#renderOAuthClientSecretStep(): void {
|
|
855
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "OAuth: Client Secret (Optional)")));
|
|
856
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
857
|
+
this.#contentContainer.addChild(new Text("Enter your OAuth client secret:", 0, 0));
|
|
858
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "(Leave empty for PKCE-only flows)"), 0, 0));
|
|
859
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
860
|
+
|
|
861
|
+
this.#inputField = new Input();
|
|
862
|
+
this.#inputField.setValue(this.#state.oauthClientSecret);
|
|
863
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
864
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
865
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
#renderOAuthScopesStep(): void {
|
|
869
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "OAuth: Scopes (Optional)")));
|
|
870
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
871
|
+
this.#contentContainer.addChild(new Text("Enter OAuth scopes (space-separated):", 0, 0));
|
|
872
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
873
|
+
|
|
874
|
+
this.#inputField = new Input();
|
|
875
|
+
this.#inputField.setValue(this.#state.oauthScopes);
|
|
876
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
877
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
878
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "e.g., read write"), 0, 0));
|
|
879
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
880
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
#renderOAuthErrorStep(): void {
|
|
884
|
+
this.#contentContainer.addChild(new Text(theme.fg("error", "OAuth authentication failed"), 0, 0));
|
|
885
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
886
|
+
this.#contentContainer.addChild(new Text("Choose next action:", 0, 0));
|
|
887
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
888
|
+
|
|
889
|
+
const options = ["Retry OAuth authentication", "Edit OAuth settings"];
|
|
890
|
+
for (let i = 0; i < options.length; i++) {
|
|
891
|
+
const isSelected = i === this.#selectedIndex;
|
|
892
|
+
const prefix = isSelected ? theme.fg("chromeAccent", `${theme.nav.cursor} `) : " ";
|
|
893
|
+
const text = isSelected ? theme.fg("contentAccent", options[i]) : options[i];
|
|
894
|
+
this.#contentContainer.addChild(new Text(prefix + text, 0, 0));
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
898
|
+
this.#contentContainer.addChild(
|
|
899
|
+
new Text(theme.fg("muted", "[↑↓ to navigate, Enter to select, Esc to go back]"), 0, 0),
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
#renderApiKeyStep(): void {
|
|
904
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "API Key Required")));
|
|
905
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
906
|
+
this.#contentContainer.addChild(new Text("Enter your API key or token:", 0, 0));
|
|
907
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "(Supports !command for password manager)"), 0, 0));
|
|
908
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
909
|
+
|
|
910
|
+
this.#inputField = new Input();
|
|
911
|
+
this.#inputField.setValue(this.#state.apiKey);
|
|
912
|
+
this.#contentContainer.addChild(this.#inputField);
|
|
913
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
914
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Enter to continue, Esc to go back]"), 0, 0));
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Test connection and automatically detect if auth is needed.
|
|
919
|
+
*/
|
|
920
|
+
async #testConnectionAndDetectAuth(): Promise<void> {
|
|
921
|
+
const testConfig = this.#buildServerConfig();
|
|
922
|
+
|
|
923
|
+
if (!this.#onTestConnectionCallback) {
|
|
924
|
+
// Skip test, go to scope
|
|
925
|
+
this.#currentStep = "scope";
|
|
926
|
+
this.#selectedIndex = 0;
|
|
927
|
+
this.#renderStep();
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
try {
|
|
932
|
+
// Try to connect - timeout is handled by the transport layer (5 seconds)
|
|
933
|
+
await this.#onTestConnectionCallback(testConfig);
|
|
934
|
+
|
|
935
|
+
// Success! No auth required
|
|
936
|
+
this.#contentContainer.clear();
|
|
937
|
+
this.#contentContainer.addChild(new Text(theme.fg("success", "✓ Connection successful!"), 0, 0));
|
|
938
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
939
|
+
this.#contentContainer.addChild(new Text("No authentication required", 0, 0));
|
|
940
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
941
|
+
|
|
942
|
+
setTimeout(() => {
|
|
943
|
+
this.#state.authMethod = "none";
|
|
944
|
+
this.#currentStep = "scope";
|
|
945
|
+
this.#selectedIndex = 0;
|
|
946
|
+
this.#renderStep();
|
|
947
|
+
}, 1000);
|
|
948
|
+
} catch (error) {
|
|
949
|
+
// Connection failed - check if it's an auth error
|
|
950
|
+
const authResult = analyzeAuthError(error as Error);
|
|
951
|
+
|
|
952
|
+
if (authResult.requiresAuth) {
|
|
953
|
+
// Prefer OAuth first: use error metadata, then well-known discovery fallback.
|
|
954
|
+
let oauth = authResult.authType === "oauth" ? (authResult.oauth ?? null) : null;
|
|
955
|
+
if (!oauth && this.#state.transport !== "stdio" && this.#state.url) {
|
|
956
|
+
try {
|
|
957
|
+
oauth = await discoverOAuthEndpoints(this.#state.url, authResult.authServerUrl);
|
|
958
|
+
} catch {
|
|
959
|
+
// Ignore discovery failures and fallback to manual auth.
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
if (oauth) {
|
|
964
|
+
this.#state.oauthAuthUrl = oauth.authorizationUrl;
|
|
965
|
+
this.#state.oauthTokenUrl = oauth.tokenUrl;
|
|
966
|
+
this.#state.oauthClientId = oauth.clientId || "";
|
|
967
|
+
this.#state.oauthScopes = oauth.scopes || "";
|
|
968
|
+
this.#state.authMethod = "oauth";
|
|
969
|
+
|
|
970
|
+
this.#contentContainer.clear();
|
|
971
|
+
this.#contentContainer.addChild(new Text(theme.fg("success", "✓ OAuth detected"), 0, 0));
|
|
972
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
973
|
+
this.#contentContainer.addChild(new Text("Launching browser for authorization...", 0, 0));
|
|
974
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
975
|
+
|
|
976
|
+
void this.#launchOAuthFlow();
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// OAuth metadata unavailable: fallback to manual API key.
|
|
981
|
+
this.#contentContainer.clear();
|
|
982
|
+
this.#contentContainer.addChild(new Text(theme.fg("warning", "⚠ Authentication required"), 0, 0));
|
|
983
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
984
|
+
this.#contentContainer.addChild(new Text("OAuth parameters could not be discovered.", 0, 0));
|
|
985
|
+
this.#contentContainer.addChild(new Text("Provide API key/token manually.", 0, 0));
|
|
986
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
987
|
+
this.#currentStep = "apikey";
|
|
988
|
+
this.#renderStep();
|
|
989
|
+
} else {
|
|
990
|
+
// Not an auth error - just a connection failure
|
|
991
|
+
const errorMsg = sanitize(error instanceof Error ? error.message : String(error));
|
|
992
|
+
this.#contentContainer.clear();
|
|
993
|
+
this.#contentContainer.addChild(new Text(theme.fg("error", "✗ Connection failed"), 0, 0));
|
|
994
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
995
|
+
this.#contentContainer.addChild(new Text(errorMsg, 0, 0));
|
|
996
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
997
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "Adding server anyway..."), 0, 0));
|
|
998
|
+
|
|
999
|
+
setTimeout(() => {
|
|
1000
|
+
this.#state.authMethod = "none";
|
|
1001
|
+
this.#currentStep = "scope";
|
|
1002
|
+
this.#selectedIndex = 0;
|
|
1003
|
+
this.#renderStep();
|
|
1004
|
+
}, 2000);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Build a server config from current wizard state for connection testing (no auth).
|
|
1011
|
+
*/
|
|
1012
|
+
#buildServerConfig(): MCPServerConfig {
|
|
1013
|
+
return this.#buildServerConfigWithAuth(false);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
#buildServerConfigWithAuth(includeAuth: boolean): MCPServerConfig {
|
|
1017
|
+
const transport = this.#state.transport ?? "stdio";
|
|
1018
|
+
|
|
1019
|
+
if (transport === "stdio") {
|
|
1020
|
+
const config: MCPStdioServerConfig = {
|
|
1021
|
+
type: "stdio",
|
|
1022
|
+
command: this.#state.command,
|
|
1023
|
+
timeout: 5000,
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
if (this.#state.args) {
|
|
1027
|
+
config.args = this.#state.args.split(/\s+/).filter(Boolean);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
if (includeAuth && this.#state.authMethod === "oauth" && this.#state.oauthCredentialId) {
|
|
1031
|
+
config.auth = {
|
|
1032
|
+
type: "oauth",
|
|
1033
|
+
credentialId: this.#state.oauthCredentialId,
|
|
1034
|
+
tokenUrl: this.#state.oauthTokenUrl || undefined,
|
|
1035
|
+
clientId: this.#state.oauthClientId || undefined,
|
|
1036
|
+
clientSecret: this.#state.oauthClientSecret || undefined,
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
if (includeAuth && this.#state.authMethod === "manual" && this.#state.apiKey) {
|
|
1041
|
+
config.env = {
|
|
1042
|
+
...(config.env ?? {}),
|
|
1043
|
+
[this.#state.envVarName || "API_KEY"]: this.#state.apiKey,
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
return config;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// http or sse
|
|
1051
|
+
const config: MCPHttpServerConfig | MCPSseServerConfig = {
|
|
1052
|
+
type: transport,
|
|
1053
|
+
url: this.#state.url,
|
|
1054
|
+
timeout: 5000,
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
if (includeAuth && this.#state.authMethod === "oauth" && this.#state.oauthCredentialId) {
|
|
1058
|
+
config.auth = {
|
|
1059
|
+
type: "oauth",
|
|
1060
|
+
credentialId: this.#state.oauthCredentialId,
|
|
1061
|
+
tokenUrl: this.#state.oauthTokenUrl || undefined,
|
|
1062
|
+
clientId: this.#state.oauthClientId || undefined,
|
|
1063
|
+
clientSecret: this.#state.oauthClientSecret || undefined,
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
if (includeAuth && this.#state.authMethod === "manual" && this.#state.apiKey) {
|
|
1068
|
+
if (this.#state.authLocation === "env") {
|
|
1069
|
+
// For HTTP with env location, store in headers using the env var name as-is
|
|
1070
|
+
config.headers = {
|
|
1071
|
+
...(config.headers ?? {}),
|
|
1072
|
+
[this.#state.headerName || "Authorization"]: this.#state.apiKey,
|
|
1073
|
+
};
|
|
1074
|
+
} else {
|
|
1075
|
+
const headerName = this.#state.headerName || "Authorization";
|
|
1076
|
+
config.headers = {
|
|
1077
|
+
...(config.headers ?? {}),
|
|
1078
|
+
[headerName]: this.#state.apiKey,
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
return config;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
async #launchOAuthFlow(): Promise<void> {
|
|
1087
|
+
if (!this.#onOAuthCallback) {
|
|
1088
|
+
this.#contentContainer.clear();
|
|
1089
|
+
this.#contentContainer.addChild(new Text(theme.fg("error", "OAuth flow not available"), 0, 0));
|
|
1090
|
+
this.#renderStep();
|
|
1091
|
+
this.#requestRender();
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// Validate OAuth configuration
|
|
1096
|
+
if (!this.#state.oauthAuthUrl || !this.#state.oauthTokenUrl) {
|
|
1097
|
+
this.#contentContainer.clear();
|
|
1098
|
+
this.#contentContainer.addChild(new Text(theme.fg("error", "OAuth configuration incomplete"), 0, 0));
|
|
1099
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1100
|
+
this.#contentContainer.addChild(new Text("Authorization and Token URLs are required.", 0, 0));
|
|
1101
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1102
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "[Press Esc to go back]"), 0, 0));
|
|
1103
|
+
this.#requestRender();
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// Show "Authenticating..." message
|
|
1108
|
+
this.#contentContainer.clear();
|
|
1109
|
+
this.#contentContainer.addChild(new Text(theme.fg("contentAccent", "OAuth Authentication"), 0, 0));
|
|
1110
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1111
|
+
this.#contentContainer.addChild(new Text("Launching OAuth flow...", 0, 0));
|
|
1112
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "Browser will open automatically."), 0, 0));
|
|
1113
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1114
|
+
this.#contentContainer.addChild(
|
|
1115
|
+
new Text(theme.fg("warning", "If browser doesn't open, copy the URL from chat."), 0, 0),
|
|
1116
|
+
);
|
|
1117
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1118
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "(Press Esc to cancel)"), 0, 0));
|
|
1119
|
+
this.#requestRender();
|
|
1120
|
+
|
|
1121
|
+
try {
|
|
1122
|
+
// Call OAuth handler
|
|
1123
|
+
const credentialId = await this.#onOAuthCallback(
|
|
1124
|
+
this.#state.oauthAuthUrl,
|
|
1125
|
+
this.#state.oauthTokenUrl,
|
|
1126
|
+
this.#state.oauthClientId,
|
|
1127
|
+
this.#state.oauthClientSecret,
|
|
1128
|
+
this.#state.oauthScopes,
|
|
1129
|
+
);
|
|
1130
|
+
|
|
1131
|
+
// Store credential ID
|
|
1132
|
+
this.#state.oauthCredentialId = credentialId;
|
|
1133
|
+
|
|
1134
|
+
// Show success message
|
|
1135
|
+
this.#contentContainer.clear();
|
|
1136
|
+
this.#contentContainer.addChild(new Text(theme.fg("success", "✓ Authentication successful!"), 0, 0));
|
|
1137
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1138
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", "Running connection health check..."), 0, 0));
|
|
1139
|
+
const healthText = new Text(theme.fg("muted", "| Checking server connection..."), 0, 0);
|
|
1140
|
+
this.#contentContainer.addChild(healthText);
|
|
1141
|
+
|
|
1142
|
+
const spinnerFrames = ["|", "/", "-", "\\"];
|
|
1143
|
+
let spinnerIndex = 0;
|
|
1144
|
+
const spinner = setInterval(() => {
|
|
1145
|
+
healthText.setText(
|
|
1146
|
+
theme.fg("muted", `${spinnerFrames[spinnerIndex % spinnerFrames.length]} Checking server connection...`),
|
|
1147
|
+
);
|
|
1148
|
+
spinnerIndex++;
|
|
1149
|
+
this.#requestRender();
|
|
1150
|
+
}, 120);
|
|
1151
|
+
|
|
1152
|
+
let healthPassed = true;
|
|
1153
|
+
let healthError = "";
|
|
1154
|
+
if (this.#onTestConnectionCallback) {
|
|
1155
|
+
try {
|
|
1156
|
+
const { promise: timeoutPromise, reject: timeoutReject } = Promise.withResolvers<never>();
|
|
1157
|
+
const timer = setTimeout(
|
|
1158
|
+
() => timeoutReject(new Error("Health check timed out after 10 seconds")),
|
|
1159
|
+
10_000,
|
|
1160
|
+
);
|
|
1161
|
+
try {
|
|
1162
|
+
await Promise.race([
|
|
1163
|
+
this.#onTestConnectionCallback(this.#buildServerConfigWithAuth(true)),
|
|
1164
|
+
timeoutPromise,
|
|
1165
|
+
]);
|
|
1166
|
+
} finally {
|
|
1167
|
+
clearTimeout(timer);
|
|
1168
|
+
}
|
|
1169
|
+
} catch (error) {
|
|
1170
|
+
healthPassed = false;
|
|
1171
|
+
healthError = sanitize(error instanceof Error ? error.message : String(error));
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
clearInterval(spinner);
|
|
1176
|
+
if (healthPassed) {
|
|
1177
|
+
healthText.setText(theme.fg("success", "✓ Health check passed"));
|
|
1178
|
+
} else {
|
|
1179
|
+
healthText.setText(theme.fg("warning", "⚠ Health check failed (will still save config)"));
|
|
1180
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1181
|
+
this.#contentContainer.addChild(new Text(theme.fg("muted", healthError), 0, 0));
|
|
1182
|
+
}
|
|
1183
|
+
this.#requestRender();
|
|
1184
|
+
|
|
1185
|
+
// Move to scope selection after short delay
|
|
1186
|
+
setTimeout(
|
|
1187
|
+
() => {
|
|
1188
|
+
this.#currentStep = "scope";
|
|
1189
|
+
this.#selectedIndex = 0;
|
|
1190
|
+
this.#renderStep();
|
|
1191
|
+
this.#requestRender();
|
|
1192
|
+
},
|
|
1193
|
+
healthPassed ? 1000 : 2000,
|
|
1194
|
+
);
|
|
1195
|
+
} catch (error) {
|
|
1196
|
+
// Show error with options to retry or go back
|
|
1197
|
+
const errorMsg = sanitize(error instanceof Error ? error.message : String(error));
|
|
1198
|
+
this.#contentContainer.clear();
|
|
1199
|
+
this.#contentContainer.addChild(new Text(theme.fg("error", "✗ OAuth authentication failed"), 0, 0));
|
|
1200
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1201
|
+
this.#contentContainer.addChild(new Text(errorMsg, 0, 0));
|
|
1202
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1203
|
+
|
|
1204
|
+
// Provide helpful tips based on error type
|
|
1205
|
+
if (errorMsg.includes("timeout") || errorMsg.includes("timed out")) {
|
|
1206
|
+
this.#contentContainer.addChild(
|
|
1207
|
+
new Text(theme.fg("muted", "Tip: Complete authorization faster next time"), 0, 0),
|
|
1208
|
+
);
|
|
1209
|
+
} else if (errorMsg.includes("Invalid OAuth URLs")) {
|
|
1210
|
+
this.#contentContainer.addChild(
|
|
1211
|
+
new Text(theme.fg("muted", "Tip: Check that the OAuth URLs are correct"), 0, 0),
|
|
1212
|
+
);
|
|
1213
|
+
} else if (errorMsg.includes("ECONNREFUSED")) {
|
|
1214
|
+
this.#contentContainer.addChild(
|
|
1215
|
+
new Text(theme.fg("muted", "Tip: Verify the OAuth server is accessible"), 0, 0),
|
|
1216
|
+
);
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1220
|
+
this.#contentContainer.addChild(new Text(`${theme.fg("chromeAccent", "→ ")}Retry`, 0, 0));
|
|
1221
|
+
this.#contentContainer.addChild(new Text(" Edit OAuth settings", 0, 0));
|
|
1222
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
1223
|
+
this.#contentContainer.addChild(
|
|
1224
|
+
new Text(theme.fg("muted", "[↑↓ to navigate, Enter to select, Esc to go back]"), 0, 0),
|
|
1225
|
+
);
|
|
1226
|
+
this.#requestRender();
|
|
1227
|
+
|
|
1228
|
+
// Set up as a selector step
|
|
1229
|
+
this.#selectedIndex = 0;
|
|
1230
|
+
this.#currentStep = "oauth-error";
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
#complete(): void {
|
|
1235
|
+
if (!this.#state.scope) return;
|
|
1236
|
+
|
|
1237
|
+
// Build the config
|
|
1238
|
+
const config: MCPServerConfig = this.#buildConfig();
|
|
1239
|
+
|
|
1240
|
+
// Call completion callback
|
|
1241
|
+
this.#onCompleteCallback(this.#state.name, config, this.#state.scope);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
#buildConfig(): MCPServerConfig {
|
|
1245
|
+
if (this.#state.transport === "stdio") {
|
|
1246
|
+
const config: MCPStdioServerConfig = {
|
|
1247
|
+
type: "stdio",
|
|
1248
|
+
command: this.#state.command,
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1251
|
+
if (this.#state.args) {
|
|
1252
|
+
config.args = this.#state.args.split(/\s+/).filter(Boolean);
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
// Add OAuth auth if configured
|
|
1256
|
+
if (this.#state.authMethod === "oauth" && this.#state.oauthCredentialId) {
|
|
1257
|
+
config.auth = {
|
|
1258
|
+
type: "oauth",
|
|
1259
|
+
credentialId: this.#state.oauthCredentialId,
|
|
1260
|
+
tokenUrl: this.#state.oauthTokenUrl || undefined,
|
|
1261
|
+
clientId: this.#state.oauthClientId || undefined,
|
|
1262
|
+
clientSecret: this.#state.oauthClientSecret || undefined,
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
// Add API key to env if manual auth — use user-chosen env var name
|
|
1267
|
+
if (this.#state.authMethod === "manual" && this.#state.apiKey) {
|
|
1268
|
+
const envKey = this.#state.envVarName || "API_KEY";
|
|
1269
|
+
config.env = {
|
|
1270
|
+
[envKey]: this.#state.apiKey,
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
return config;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
// HTTP or SSE — use concrete type
|
|
1278
|
+
const config: MCPHttpServerConfig | MCPSseServerConfig = {
|
|
1279
|
+
type: this.#state.transport!,
|
|
1280
|
+
url: this.#state.url,
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
// Add OAuth auth if configured
|
|
1284
|
+
if (this.#state.authMethod === "oauth" && this.#state.oauthCredentialId) {
|
|
1285
|
+
config.auth = {
|
|
1286
|
+
type: "oauth",
|
|
1287
|
+
credentialId: this.#state.oauthCredentialId,
|
|
1288
|
+
tokenUrl: this.#state.oauthTokenUrl || undefined,
|
|
1289
|
+
clientId: this.#state.oauthClientId || undefined,
|
|
1290
|
+
clientSecret: this.#state.oauthClientSecret || undefined,
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// Add API key using user-chosen header name and auth location
|
|
1295
|
+
if (this.#state.authMethod === "manual" && this.#state.apiKey) {
|
|
1296
|
+
if (this.#state.authLocation === "env") {
|
|
1297
|
+
// Env-based auth for HTTP: store the key in env on the config
|
|
1298
|
+
// HTTP/SSE configs don't have an env field, so use headers as carrier
|
|
1299
|
+
const headerName = this.#state.headerName || "Authorization";
|
|
1300
|
+
config.headers = {
|
|
1301
|
+
[headerName]: this.#state.apiKey,
|
|
1302
|
+
};
|
|
1303
|
+
} else {
|
|
1304
|
+
// Header-based auth: use the user's chosen header name
|
|
1305
|
+
const headerName = this.#state.headerName || "Authorization";
|
|
1306
|
+
config.headers = {
|
|
1307
|
+
[headerName]: this.#state.apiKey,
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
return config;
|
|
1313
|
+
}
|
|
1314
|
+
}
|