@humain/terminal 0.0.2 → 0.0.3-beta.0
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 +241 -24
- package/README.md +143 -119
- package/dist/cli/args.d.ts +4 -2
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +37 -39
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +19 -0
- package/dist/cli/auth-check.d.ts.map +1 -0
- package/dist/cli/auth-check.js +50 -0
- package/dist/cli/auth-check.js.map +1 -0
- package/dist/cli/auth-command.d.ts +24 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +103 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +2 -2
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +5 -15
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +42 -83
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/experimental/auth.d.ts +16 -0
- package/dist/cli/experimental/auth.d.ts.map +1 -0
- package/dist/cli/experimental/auth.js +13 -0
- package/dist/cli/experimental/auth.js.map +1 -0
- package/dist/cli/experimental/cli.d.ts +6 -0
- package/dist/cli/experimental/cli.d.ts.map +1 -0
- package/dist/cli/experimental/cli.js +5 -0
- package/dist/cli/experimental/cli.js.map +1 -0
- package/dist/cli/experimental/command-options.d.ts +17 -0
- package/dist/cli/experimental/command-options.d.ts.map +1 -0
- package/dist/cli/experimental/command-options.js +35 -0
- package/dist/cli/experimental/command-options.js.map +1 -0
- package/dist/cli/experimental/command.d.ts +63 -0
- package/dist/cli/experimental/command.d.ts.map +1 -0
- package/dist/cli/experimental/command.js +130 -0
- package/dist/cli/experimental/command.js.map +1 -0
- package/dist/cli/experimental/commands/client.d.ts +13 -0
- package/dist/cli/experimental/commands/client.d.ts.map +1 -0
- package/dist/cli/experimental/commands/client.js +25 -0
- package/dist/cli/experimental/commands/client.js.map +1 -0
- package/dist/cli/experimental/commands/pi.d.ts +15 -0
- package/dist/cli/experimental/commands/pi.d.ts.map +1 -0
- package/dist/cli/experimental/commands/pi.js +28 -0
- package/dist/cli/experimental/commands/pi.js.map +1 -0
- package/dist/cli/experimental/commands/server.d.ts +13 -0
- package/dist/cli/experimental/commands/server.d.ts.map +1 -0
- package/dist/cli/experimental/commands/server.js +25 -0
- package/dist/cli/experimental/commands/server.js.map +1 -0
- package/dist/cli/experimental/transport-address.d.ts +10 -0
- package/dist/cli/experimental/transport-address.d.ts.map +1 -0
- package/dist/cli/experimental/transport-address.js +38 -0
- package/dist/cli/experimental/transport-address.js.map +1 -0
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +2 -2
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +2 -2
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/remote-session.d.ts +53 -0
- package/dist/client/remote-session.d.ts.map +1 -0
- package/dist/client/remote-session.js +340 -0
- package/dist/client/remote-session.js.map +1 -0
- package/dist/client/transcript.d.ts +12 -0
- package/dist/client/transcript.d.ts.map +1 -0
- package/dist/client/transcript.js +98 -0
- package/dist/client/transcript.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -10
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +72 -70
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +25 -9
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +237 -39
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +60 -41
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +27 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +5 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +45 -5
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +29 -5
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +4 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -3
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -10
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +4 -3
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +42 -10
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +30 -13
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +233 -73
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts +12 -7
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +83 -14
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts +6 -3
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +80 -61
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts +8 -0
- package/dist/core/pi-manifest.d.ts.map +1 -0
- package/dist/core/pi-manifest.js +28 -0
- package/dist/core/pi-manifest.js.map +1 -0
- package/dist/core/provider-composer.d.ts +4 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +36 -15
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +73 -67
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +2 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +5 -5
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +11 -8
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +3 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +12 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +40 -16
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +8 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +5 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +16 -15
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +4 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +11 -7
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +7 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +16 -19
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +4 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +5 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts +4 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +5 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +7 -3
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts +4 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +6 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +11 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +21 -7
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/humain/agent-execution-protocol.d.ts +218 -0
- package/dist/humain/agent-execution-protocol.d.ts.map +1 -0
- package/dist/humain/agent-execution-protocol.js +204 -0
- package/dist/humain/agent-execution-protocol.js.map +1 -0
- package/dist/humain/agent-execution-runtime.d.ts +35 -0
- package/dist/humain/agent-execution-runtime.d.ts.map +1 -0
- package/dist/humain/agent-execution-runtime.js +170 -0
- package/dist/humain/agent-execution-runtime.js.map +1 -0
- package/dist/humain/index.d.ts.map +1 -1
- package/dist/humain/index.js +8 -7
- package/dist/humain/index.js.map +1 -1
- package/dist/humain/mcp-adapter/vendor/CHANGELOG.md +660 -0
- package/dist/humain/mcp-adapter/vendor/LICENSE +21 -0
- package/dist/humain/mcp-adapter/vendor/README.md +733 -0
- package/dist/humain/mcp-adapter/vendor/abort.ts +34 -0
- package/dist/humain/mcp-adapter/vendor/agent-dir.ts +60 -0
- package/dist/humain/mcp-adapter/vendor/agent-plugin-loader.ts +377 -0
- package/dist/humain/mcp-adapter/vendor/app-bridge.bundle.js +67 -0
- package/dist/humain/mcp-adapter/vendor/banner.png +0 -0
- package/dist/humain/mcp-adapter/vendor/cli.js +209 -0
- package/dist/humain/mcp-adapter/vendor/commands.ts +627 -0
- package/dist/humain/mcp-adapter/vendor/config.ts +1226 -0
- package/dist/humain/mcp-adapter/vendor/consent-manager.ts +64 -0
- package/dist/humain/mcp-adapter/vendor/direct-tools.ts +604 -0
- package/dist/humain/mcp-adapter/vendor/elicitation-handler.ts +348 -0
- package/dist/humain/mcp-adapter/vendor/error-signal.ts +21 -0
- package/dist/humain/mcp-adapter/vendor/errors.ts +223 -0
- package/dist/humain/mcp-adapter/vendor/glimpse-ui.ts +80 -0
- package/dist/humain/mcp-adapter/vendor/host-html-template.ts +461 -0
- package/dist/humain/mcp-adapter/vendor/index.bundle.d.mts +4 -0
- package/dist/humain/mcp-adapter/vendor/index.bundle.mjs +15923 -0
- package/dist/humain/mcp-adapter/vendor/index.ts +898 -0
- package/dist/humain/mcp-adapter/vendor/init.ts +649 -0
- package/dist/humain/mcp-adapter/vendor/json-schema-validator.ts +69 -0
- package/dist/humain/mcp-adapter/vendor/lifecycle.ts +147 -0
- package/dist/humain/mcp-adapter/vendor/logger.ts +169 -0
- package/dist/humain/mcp-adapter/vendor/mcp-auth-flow.ts +993 -0
- package/dist/humain/mcp-adapter/vendor/mcp-auth.ts +1000 -0
- package/dist/humain/mcp-adapter/vendor/mcp-callback-server.ts +510 -0
- package/dist/humain/mcp-adapter/vendor/mcp-code.ts +354 -0
- package/dist/humain/mcp-adapter/vendor/mcp-keyring-helper.cjs +89 -0
- package/dist/humain/mcp-adapter/vendor/mcp-oauth-provider.ts +616 -0
- package/dist/humain/mcp-adapter/vendor/mcp-output-guard.ts +408 -0
- package/dist/humain/mcp-adapter/vendor/mcp-panel.ts +1015 -0
- package/dist/humain/mcp-adapter/vendor/mcp-probe.ts +187 -0
- package/dist/humain/mcp-adapter/vendor/mcp-script-worker.mjs +130 -0
- package/dist/humain/mcp-adapter/vendor/mcp-setup-panel.ts +666 -0
- package/dist/humain/mcp-adapter/vendor/mcp-status.ts +109 -0
- package/dist/humain/mcp-adapter/vendor/mcp-trace.ts +306 -0
- package/dist/humain/mcp-adapter/vendor/metadata-cache.ts +353 -0
- package/dist/humain/mcp-adapter/vendor/npx-resolver.ts +543 -0
- package/dist/humain/mcp-adapter/vendor/oauth-handler.ts +30 -0
- package/dist/humain/mcp-adapter/vendor/oauth.ts +48 -0
- package/dist/humain/mcp-adapter/vendor/onboarding-state.ts +76 -0
- package/dist/humain/mcp-adapter/vendor/package.json +178 -0
- package/dist/humain/mcp-adapter/vendor/panel-keys.ts +53 -0
- package/dist/humain/mcp-adapter/vendor/prompts.ts +353 -0
- package/dist/humain/mcp-adapter/vendor/proxy-modes.ts +1331 -0
- package/dist/humain/mcp-adapter/vendor/resource-tools.ts +17 -0
- package/dist/humain/mcp-adapter/vendor/runtime-owner.ts +91 -0
- package/dist/humain/mcp-adapter/vendor/sampling-handler.ts +284 -0
- package/dist/humain/mcp-adapter/vendor/search-ranking.ts +206 -0
- package/dist/humain/mcp-adapter/vendor/server-manager.ts +1124 -0
- package/dist/humain/mcp-adapter/vendor/session-recovery.ts +151 -0
- package/dist/humain/mcp-adapter/vendor/skills/mcp-scripting/SKILL.md +38 -0
- package/dist/humain/mcp-adapter/vendor/state.ts +62 -0
- package/dist/humain/mcp-adapter/vendor/tool-approval.ts +182 -0
- package/dist/humain/mcp-adapter/vendor/tool-metadata.ts +276 -0
- package/dist/humain/mcp-adapter/vendor/tool-registrar.ts +253 -0
- package/dist/humain/mcp-adapter/vendor/tool-result-renderer.ts +423 -0
- package/dist/humain/mcp-adapter/vendor/ts-shape.ts +149 -0
- package/dist/humain/mcp-adapter/vendor/types.ts +859 -0
- package/dist/humain/mcp-adapter/vendor/ui-app-bridge-helpers.ts +40 -0
- package/dist/humain/mcp-adapter/vendor/ui-resource-handler.ts +250 -0
- package/dist/humain/mcp-adapter/vendor/ui-server.ts +866 -0
- package/dist/humain/mcp-adapter/vendor/ui-session.ts +570 -0
- package/dist/humain/mcp-adapter/vendor/ui-stream-types.ts +89 -0
- package/dist/humain/mcp-adapter/vendor/ui-tool-visibility.ts +25 -0
- package/dist/humain/mcp-adapter/vendor/unix-socket-transport.ts +85 -0
- package/dist/humain/mcp-adapter/vendor/utils.ts +310 -0
- package/dist/humain/mcp-adapter.d.ts +3 -0
- package/dist/humain/mcp-adapter.d.ts.map +1 -0
- package/dist/humain/mcp-adapter.js +5 -0
- package/dist/humain/mcp-adapter.js.map +1 -0
- package/dist/humain/pi-agent-execution-host.d.ts +34 -0
- package/dist/humain/pi-agent-execution-host.d.ts.map +1 -0
- package/dist/humain/pi-agent-execution-host.js +77 -0
- package/dist/humain/pi-agent-execution-host.js.map +1 -0
- package/dist/humain/web-access/host.d.ts +4 -0
- package/dist/humain/web-access/host.d.ts.map +1 -0
- package/dist/humain/web-access/host.js +3 -0
- package/dist/humain/web-access/host.js.map +1 -0
- package/dist/humain/web-access/index.d.ts +3 -0
- package/dist/humain/web-access/index.d.ts.map +1 -0
- package/dist/humain/web-access/index.js +5 -0
- package/dist/humain/web-access/index.js.map +1 -0
- package/dist/humain/web-access/vendor/activity.d.ts +34 -0
- package/dist/humain/web-access/vendor/activity.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/activity.js +68 -0
- package/dist/humain/web-access/vendor/activity.js.map +1 -0
- package/dist/humain/web-access/vendor/anysearch.d.ts +8 -0
- package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/anysearch.js +167 -0
- package/dist/humain/web-access/vendor/anysearch.js.map +1 -0
- package/dist/humain/web-access/vendor/bocha.d.ts +4 -0
- package/dist/humain/web-access/vendor/bocha.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/bocha.js +219 -0
- package/dist/humain/web-access/vendor/bocha.js.map +1 -0
- package/dist/humain/web-access/vendor/brave.d.ts +4 -0
- package/dist/humain/web-access/vendor/brave.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/brave.js +194 -0
- package/dist/humain/web-access/vendor/brave.js.map +1 -0
- package/dist/humain/web-access/vendor/brightdata-unlocker.d.ts +12 -0
- package/dist/humain/web-access/vendor/brightdata-unlocker.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/brightdata-unlocker.js +230 -0
- package/dist/humain/web-access/vendor/brightdata-unlocker.js.map +1 -0
- package/dist/humain/web-access/vendor/brightdata.d.ts +8 -0
- package/dist/humain/web-access/vendor/brightdata.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/brightdata.js +519 -0
- package/dist/humain/web-access/vendor/brightdata.js.map +1 -0
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts +10 -0
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/chrome-cookies.js +438 -0
- package/dist/humain/web-access/vendor/chrome-cookies.js.map +1 -0
- package/dist/humain/web-access/vendor/content-find.d.ts +11 -0
- package/dist/humain/web-access/vendor/content-find.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/content-find.js +117 -0
- package/dist/humain/web-access/vendor/content-find.js.map +1 -0
- package/dist/humain/web-access/vendor/credential-source.d.ts +28 -0
- package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/credential-source.js +151 -0
- package/dist/humain/web-access/vendor/credential-source.js.map +1 -0
- package/dist/humain/web-access/vendor/curator-page.d.ts +29 -0
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/curator-page.js +3554 -0
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -0
- package/dist/humain/web-access/vendor/curator-server.d.ts +93 -0
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/curator-server.js +688 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -0
- package/dist/humain/web-access/vendor/datalab-pdf-extract.d.ts +60 -0
- package/dist/humain/web-access/vendor/datalab-pdf-extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/datalab-pdf-extract.js +416 -0
- package/dist/humain/web-access/vendor/datalab-pdf-extract.js.map +1 -0
- package/dist/humain/web-access/vendor/declared-web-links.d.ts +16 -0
- package/dist/humain/web-access/vendor/declared-web-links.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/declared-web-links.js +168 -0
- package/dist/humain/web-access/vendor/declared-web-links.js.map +1 -0
- package/dist/humain/web-access/vendor/duckduckgo.d.ts +4 -0
- package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/duckduckgo.js +123 -0
- package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -0
- package/dist/humain/web-access/vendor/exa.d.ts +10 -0
- package/dist/humain/web-access/vendor/exa.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/exa.js +426 -0
- package/dist/humain/web-access/vendor/exa.js.map +1 -0
- package/dist/humain/web-access/vendor/extract.d.ts +46 -0
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/extract.js +1064 -0
- package/dist/humain/web-access/vendor/extract.js.map +1 -0
- package/dist/humain/web-access/vendor/feature-config.d.ts +3 -0
- package/dist/humain/web-access/vendor/feature-config.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/feature-config.js +27 -0
- package/dist/humain/web-access/vendor/feature-config.js.map +1 -0
- package/dist/humain/web-access/vendor/fetch-params.d.ts +25 -0
- package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/fetch-params.js +57 -0
- package/dist/humain/web-access/vendor/fetch-params.js.map +1 -0
- package/dist/humain/web-access/vendor/firecrawl.d.ts +12 -0
- package/dist/humain/web-access/vendor/firecrawl.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/firecrawl.js +239 -0
- package/dist/humain/web-access/vendor/firecrawl.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-api.d.ts +27 -0
- package/dist/humain/web-access/vendor/gemini-api.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-api.js +230 -0
- package/dist/humain/web-access/vendor/gemini-api.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-pdf-extract.d.ts +9 -0
- package/dist/humain/web-access/vendor/gemini-pdf-extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-pdf-extract.js +85 -0
- package/dist/humain/web-access/vendor/gemini-pdf-extract.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-search.d.ts +40 -0
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-search.js +814 -0
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-url-context.d.ts +4 -0
- package/dist/humain/web-access/vendor/gemini-url-context.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-url-context.js +101 -0
- package/dist/humain/web-access/vendor/gemini-url-context.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts +4 -0
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-web-config.js +42 -0
- package/dist/humain/web-access/vendor/gemini-web-config.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-web.d.ts +18 -0
- package/dist/humain/web-access/vendor/gemini-web.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-web.js +385 -0
- package/dist/humain/web-access/vendor/gemini-web.js.map +1 -0
- package/dist/humain/web-access/vendor/github-api.d.ts +7 -0
- package/dist/humain/web-access/vendor/github-api.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/github-api.js +160 -0
- package/dist/humain/web-access/vendor/github-api.js.map +1 -0
- package/dist/humain/web-access/vendor/github-extract.d.ts +13 -0
- package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/github-extract.js +635 -0
- package/dist/humain/web-access/vendor/github-extract.js.map +1 -0
- package/dist/humain/web-access/vendor/index.d.ts +4 -0
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/index.js +3002 -0
- package/dist/humain/web-access/vendor/index.js.map +1 -0
- package/dist/humain/web-access/vendor/jina-search.d.ts +8 -0
- package/dist/humain/web-access/vendor/jina-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/jina-search.js +255 -0
- package/dist/humain/web-access/vendor/jina-search.js.map +1 -0
- package/dist/humain/web-access/vendor/kagi.d.ts +15 -0
- package/dist/humain/web-access/vendor/kagi.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/kagi.js +262 -0
- package/dist/humain/web-access/vendor/kagi.js.map +1 -0
- package/dist/humain/web-access/vendor/ollama.d.ts +15 -0
- package/dist/humain/web-access/vendor/ollama.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/ollama.js +216 -0
- package/dist/humain/web-access/vendor/ollama.js.map +1 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts +15 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/openai-search.js +459 -0
- package/dist/humain/web-access/vendor/openai-search.js.map +1 -0
- package/dist/humain/web-access/vendor/page-query.d.ts +16 -0
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/page-query.js +79 -0
- package/dist/humain/web-access/vendor/page-query.js.map +1 -0
- package/dist/humain/web-access/vendor/parallel.d.ts +12 -0
- package/dist/humain/web-access/vendor/parallel.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/parallel.js +343 -0
- package/dist/humain/web-access/vendor/parallel.js.map +1 -0
- package/dist/humain/web-access/vendor/pdf-extract.d.ts +44 -0
- package/dist/humain/web-access/vendor/pdf-extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/pdf-extract.js +298 -0
- package/dist/humain/web-access/vendor/pdf-extract.js.map +1 -0
- package/dist/humain/web-access/vendor/perplexity.d.ts +20 -0
- package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/perplexity.js +159 -0
- package/dist/humain/web-access/vendor/perplexity.js.map +1 -0
- package/dist/humain/web-access/vendor/querit.d.ts +10 -0
- package/dist/humain/web-access/vendor/querit.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/querit.js +335 -0
- package/dist/humain/web-access/vendor/querit.js.map +1 -0
- package/dist/humain/web-access/vendor/render-search-error.d.ts +57 -0
- package/dist/humain/web-access/vendor/render-search-error.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/render-search-error.js +130 -0
- package/dist/humain/web-access/vendor/render-search-error.js.map +1 -0
- package/dist/humain/web-access/vendor/rsc-extract.d.ts +12 -0
- package/dist/humain/web-access/vendor/rsc-extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/rsc-extract.js +329 -0
- package/dist/humain/web-access/vendor/rsc-extract.js.map +1 -0
- package/dist/humain/web-access/vendor/search1api.d.ts +10 -0
- package/dist/humain/web-access/vendor/search1api.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/search1api.js +251 -0
- package/dist/humain/web-access/vendor/search1api.js.map +1 -0
- package/dist/humain/web-access/vendor/searchinfinity.d.ts +8 -0
- package/dist/humain/web-access/vendor/searchinfinity.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/searchinfinity.js +229 -0
- package/dist/humain/web-access/vendor/searchinfinity.js.map +1 -0
- package/dist/humain/web-access/vendor/searxng.d.ts +4 -0
- package/dist/humain/web-access/vendor/searxng.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/searxng.js +238 -0
- package/dist/humain/web-access/vendor/searxng.js.map +1 -0
- package/dist/humain/web-access/vendor/serpbase.d.ts +4 -0
- package/dist/humain/web-access/vendor/serpbase.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/serpbase.js +211 -0
- package/dist/humain/web-access/vendor/serpbase.js.map +1 -0
- package/dist/humain/web-access/vendor/serpdive.d.ts +8 -0
- package/dist/humain/web-access/vendor/serpdive.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/serpdive.js +267 -0
- package/dist/humain/web-access/vendor/serpdive.js.map +1 -0
- package/dist/humain/web-access/vendor/source-check.d.ts +99 -0
- package/dist/humain/web-access/vendor/source-check.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/source-check.js +205 -0
- package/dist/humain/web-access/vendor/source-check.js.map +1 -0
- package/dist/humain/web-access/vendor/ssrf-protection.d.ts +50 -0
- package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/ssrf-protection.js +466 -0
- package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -0
- package/dist/humain/web-access/vendor/storage.d.ts +55 -0
- package/dist/humain/web-access/vendor/storage.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/storage.js +485 -0
- package/dist/humain/web-access/vendor/storage.js.map +1 -0
- package/dist/humain/web-access/vendor/summary-model-scope.d.ts +25 -0
- package/dist/humain/web-access/vendor/summary-model-scope.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/summary-model-scope.js +98 -0
- package/dist/humain/web-access/vendor/summary-model-scope.js.map +1 -0
- package/dist/humain/web-access/vendor/summary-review.d.ts +24 -0
- package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/summary-review.js +341 -0
- package/dist/humain/web-access/vendor/summary-review.js.map +1 -0
- package/dist/humain/web-access/vendor/tavily.d.ts +8 -0
- package/dist/humain/web-access/vendor/tavily.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/tavily.js +194 -0
- package/dist/humain/web-access/vendor/tavily.js.map +1 -0
- package/dist/humain/web-access/vendor/tinyfish.d.ts +11 -0
- package/dist/humain/web-access/vendor/tinyfish.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/tinyfish.js +331 -0
- package/dist/humain/web-access/vendor/tinyfish.js.map +1 -0
- package/dist/humain/web-access/vendor/utils.d.ts +20 -0
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/utils.js +91 -0
- package/dist/humain/web-access/vendor/utils.js.map +1 -0
- package/dist/humain/web-access/vendor/video-extract.d.ts +16 -0
- package/dist/humain/web-access/vendor/video-extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/video-extract.js +335 -0
- package/dist/humain/web-access/vendor/video-extract.js.map +1 -0
- package/dist/humain/web-access/vendor/xai-search.d.ts +13 -0
- package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/xai-search.js +331 -0
- package/dist/humain/web-access/vendor/xai-search.js.map +1 -0
- package/dist/humain/web-access/vendor/youtube-extract.d.ts +27 -0
- package/dist/humain/web-access/vendor/youtube-extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/youtube-extract.js +282 -0
- package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +169 -102
- package/dist/main.js.map +1 -1
- package/dist/modes/agent-exec-mode.d.ts +14 -0
- package/dist/modes/agent-exec-mode.d.ts.map +1 -0
- package/dist/modes/agent-exec-mode.js +92 -0
- package/dist/modes/agent-exec-mode.js.map +1 -0
- package/dist/modes/index.d.ts +4 -2
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js +2 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +5 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +13 -4
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +7 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.js +40 -0
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +11 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +75 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +16 -4
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +26 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +8 -2
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +30 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +3 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +9 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +45 -9
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +581 -211
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -0
- package/dist/modes/interactive/theme/light.json +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +3 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +10 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +5 -1
- package/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +24 -6
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +28 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +12 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +12 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +12 -5
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +55 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +13 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +11 -9
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/rpc-entry.d.ts.map +1 -1
- package/dist/rpc-entry.js +3 -2
- package/dist/rpc-entry.js.map +1 -1
- package/dist/server/create-harness.d.ts +26 -0
- package/dist/server/create-harness.d.ts.map +1 -0
- package/dist/server/create-harness.js +104 -0
- package/dist/server/create-harness.js.map +1 -0
- package/dist/utils/abort.d.ts +5 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +48 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +22 -2
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/management-http.d.ts +23 -0
- package/dist/utils/management-http.d.ts.map +1 -0
- package/dist/utils/management-http.js +50 -0
- package/dist/utils/management-http.js.map +1 -0
- package/dist/utils/paths.d.ts +3 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +23 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +19 -0
- package/dist/utils/tool-result-images.d.ts.map +1 -0
- package/dist/utils/tool-result-images.js +45 -0
- package/dist/utils/tool-result-images.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +13 -25
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +4 -0
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +23 -5
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +2 -2
- package/docs/custom-provider.md +7 -5
- package/docs/extensions.md +30 -5
- package/docs/humain-terminal.md +21 -1
- package/docs/json.md +24 -19
- package/docs/keybindings.md +46 -14
- package/docs/models.md +32 -11
- package/docs/providers.md +9 -1
- package/docs/quickstart.md +39 -37
- package/docs/rpc.md +31 -11
- package/docs/sdk.md +21 -2
- package/docs/security.md +21 -21
- package/docs/session-format.md +14 -14
- package/docs/settings.md +4 -1
- package/docs/themes.md +5 -3
- package/docs/usage.md +7 -0
- package/examples/extensions/custom-compaction.ts +3 -18
- package/examples/extensions/custom-provider-anthropic/index.ts +5 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +5 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +4 -13
- package/examples/extensions/qna.ts +5 -9
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/summarize.ts +9 -20
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/rpc-extension-ui.ts +11 -2
- package/examples/sdk/02-custom-model.ts +2 -3
- package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +2771 -535
- package/package.json +40 -11
- package/src/humain/mcp-adapter/UPSTREAM.md +15 -0
- package/src/humain/mcp-adapter/upstream.json +7 -0
- package/src/humain/mcp-adapter/vendor/CHANGELOG.md +660 -0
- package/src/humain/mcp-adapter/vendor/LICENSE +21 -0
- package/src/humain/web-access/UPSTREAM.md +17 -0
- package/src/humain/web-access/upstream.json +23 -0
- package/src/humain/web-access/vendor/LICENSE +21 -0
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
import { matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { createPanelKeys, type PanelKeybindings, type PanelKeys } from "./panel-keys.ts";
|
|
3
|
+
import type { ImportKind } from "./types.ts";
|
|
4
|
+
import { KNOWN_SERVER_PRESETS, type ConfigWritePreview, type KnownServerPreset, type McpDiscoverySummary } from "./config.ts";
|
|
5
|
+
import type { McpOnboardingState } from "./onboarding-state.ts";
|
|
6
|
+
|
|
7
|
+
interface SetupTheme {
|
|
8
|
+
border: string;
|
|
9
|
+
title: string;
|
|
10
|
+
selected: string;
|
|
11
|
+
hint: string;
|
|
12
|
+
success: string;
|
|
13
|
+
warning: string;
|
|
14
|
+
muted: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const DEFAULT_THEME: SetupTheme = {
|
|
18
|
+
border: "2",
|
|
19
|
+
title: "36",
|
|
20
|
+
selected: "32",
|
|
21
|
+
hint: "2",
|
|
22
|
+
success: "32",
|
|
23
|
+
warning: "33",
|
|
24
|
+
muted: "2;3",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const MIN_PANEL_WIDTH = 24;
|
|
28
|
+
const COMPACT_WIDTH = 60;
|
|
29
|
+
const COMPACT_ACTION_ROWS = 7;
|
|
30
|
+
const DESKTOP_PREVIEW_WIDTH = 74;
|
|
31
|
+
|
|
32
|
+
function fg(code: string, text: string): string {
|
|
33
|
+
return code ? `\x1b[${code}m${text}\x1b[0m` : text;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function wrapText(text: string, width: number): string[] {
|
|
37
|
+
if (width <= 8) return [text];
|
|
38
|
+
const words = text.split(/\s+/).filter(Boolean);
|
|
39
|
+
const lines: string[] = [];
|
|
40
|
+
let current = "";
|
|
41
|
+
for (const word of words) {
|
|
42
|
+
const candidate = current ? `${current} ${word}` : word;
|
|
43
|
+
if (visibleWidth(candidate) <= width) {
|
|
44
|
+
current = candidate;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (current) lines.push(current);
|
|
48
|
+
current = word;
|
|
49
|
+
}
|
|
50
|
+
if (current) lines.push(current);
|
|
51
|
+
return lines.length > 0 ? lines : [""];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface SetupPanelCallbacks {
|
|
55
|
+
previewImports: (imports: ImportKind[]) => ConfigWritePreview;
|
|
56
|
+
previewStarterProject: () => ConfigWritePreview;
|
|
57
|
+
previewRepoPrompt: () => ConfigWritePreview | null;
|
|
58
|
+
previewKnownServer: (preset: KnownServerPreset) => ConfigWritePreview;
|
|
59
|
+
adoptImports: (imports: ImportKind[]) => Promise<{ added: ImportKind[]; path: string }>;
|
|
60
|
+
scaffoldProjectConfig: () => Promise<{ path: string }>;
|
|
61
|
+
addRepoPrompt: () => Promise<{ path: string; serverName: string }>;
|
|
62
|
+
addKnownServer: (preset: KnownServerPreset) => Promise<{ path: string; serverName: string }>;
|
|
63
|
+
openPath: (path: string) => Promise<void>;
|
|
64
|
+
markSetupCompleted: () => void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface SetupPanelOptions {
|
|
68
|
+
mode: "empty" | "setup";
|
|
69
|
+
onboardingState: McpOnboardingState;
|
|
70
|
+
keybindings?: PanelKeybindings;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type Screen = "empty" | "setup" | "imports" | "paths";
|
|
74
|
+
|
|
75
|
+
type ActionId =
|
|
76
|
+
| "run-setup"
|
|
77
|
+
| "adopt-imports"
|
|
78
|
+
| "view-example"
|
|
79
|
+
| "show-precedence"
|
|
80
|
+
| "open-paths"
|
|
81
|
+
| "add-repoprompt"
|
|
82
|
+
| "add-known-server"
|
|
83
|
+
| "scaffold-project"
|
|
84
|
+
| "close";
|
|
85
|
+
|
|
86
|
+
interface Action {
|
|
87
|
+
id: ActionId;
|
|
88
|
+
label: string;
|
|
89
|
+
description: string;
|
|
90
|
+
preset?: KnownServerPreset;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class McpSetupPanel {
|
|
94
|
+
private screen: Screen;
|
|
95
|
+
private actionCursor = 0;
|
|
96
|
+
private importCursor = 0;
|
|
97
|
+
private pathCursor = 0;
|
|
98
|
+
private selectedImports = new Set<ImportKind>();
|
|
99
|
+
private busy = false;
|
|
100
|
+
private notice: { text: string; tone: "success" | "warning" | "muted" } | null = null;
|
|
101
|
+
private tui: { requestRender(): void };
|
|
102
|
+
private t = DEFAULT_THEME;
|
|
103
|
+
private keys: PanelKeys;
|
|
104
|
+
private inactivityTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
105
|
+
private static readonly INACTIVITY_MS = 60_000;
|
|
106
|
+
|
|
107
|
+
constructor(
|
|
108
|
+
private discovery: McpDiscoverySummary,
|
|
109
|
+
private callbacks: SetupPanelCallbacks,
|
|
110
|
+
private options: SetupPanelOptions,
|
|
111
|
+
tui: { requestRender(): void },
|
|
112
|
+
private done: () => void,
|
|
113
|
+
) {
|
|
114
|
+
this.tui = tui;
|
|
115
|
+
this.keys = createPanelKeys(options.keybindings);
|
|
116
|
+
this.screen = options.mode;
|
|
117
|
+
for (const entry of discovery.imports) {
|
|
118
|
+
this.selectedImports.add(entry.kind);
|
|
119
|
+
}
|
|
120
|
+
this.resetInactivityTimeout();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private resetInactivityTimeout(): void {
|
|
124
|
+
if (this.inactivityTimeout) clearTimeout(this.inactivityTimeout);
|
|
125
|
+
this.inactivityTimeout = setTimeout(() => {
|
|
126
|
+
this.cleanup();
|
|
127
|
+
this.done();
|
|
128
|
+
}, McpSetupPanel.INACTIVITY_MS);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private cleanup(): void {
|
|
132
|
+
if (this.inactivityTimeout) {
|
|
133
|
+
clearTimeout(this.inactivityTimeout);
|
|
134
|
+
this.inactivityTimeout = null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private getActions(): Action[] {
|
|
139
|
+
const actions: Action[] = [];
|
|
140
|
+
if (this.screen === "empty") {
|
|
141
|
+
actions.push({ id: "run-setup", label: "Run setup", description: "Inspect detected configs, adopt imports, and scaffold a minimal `.mcp.json`." });
|
|
142
|
+
}
|
|
143
|
+
if (this.discovery.imports.length > 0) {
|
|
144
|
+
actions.push({ id: "adopt-imports", label: "Adopt detected compatibility imports", description: `Choose which host-specific MCP configs Pi should import into its own override file. ${this.discovery.imports.length} source${this.discovery.imports.length === 1 ? "" : "s"} found.` });
|
|
145
|
+
}
|
|
146
|
+
actions.push({ id: "view-example", label: "View example `.mcp.json`", description: "Preview a working shared MCP config you can paste or adapt." });
|
|
147
|
+
if (!this.discovery.sources.some((source) => source.id === "shared-project" && source.exists)) {
|
|
148
|
+
actions.push({ id: "scaffold-project", label: "Scaffold project `.mcp.json`", description: "Write a minimal project config using the standard shared MCP file path, then reload Pi." });
|
|
149
|
+
}
|
|
150
|
+
actions.push({ id: "show-precedence", label: "Explain config precedence", description: "Show the read order and where Pi writes compatibility settings." });
|
|
151
|
+
if (this.getDetectedPaths().length > 0) {
|
|
152
|
+
actions.push({ id: "open-paths", label: "Open detected config paths", description: "Browse the actual config files that Pi discovered on this machine." });
|
|
153
|
+
}
|
|
154
|
+
for (const preset of KNOWN_SERVER_PRESETS) {
|
|
155
|
+
actions.push({ id: "add-known-server", label: preset.name, description: preset.summary, preset });
|
|
156
|
+
}
|
|
157
|
+
if (!this.discovery.repoPrompt.configured && this.discovery.repoPrompt.executablePath && this.discovery.repoPrompt.targetPath && this.discovery.repoPrompt.entry && this.discovery.repoPrompt.serverName) {
|
|
158
|
+
actions.push({ id: "add-repoprompt", label: "Add RepoPrompt to shared MCP config", description: "Write a standard MCP entry for RepoPrompt to the recommended shared target, then reload MCP in-session." });
|
|
159
|
+
}
|
|
160
|
+
actions.push({ id: "close", label: "Close", description: "Exit the onboarding flow." });
|
|
161
|
+
return actions;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private getDetectedPaths(): string[] {
|
|
165
|
+
const paths = [
|
|
166
|
+
...this.discovery.sources.filter((source) => source.exists).map((source) => source.path),
|
|
167
|
+
...this.discovery.imports.map((entry) => entry.path),
|
|
168
|
+
];
|
|
169
|
+
return [...new Set(paths)];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private getSelectedAction(): Action | undefined {
|
|
173
|
+
const actions = this.getActions();
|
|
174
|
+
return actions[this.actionCursor];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
handleInput(data: string): void {
|
|
178
|
+
this.resetInactivityTimeout();
|
|
179
|
+
if (!this.busy) this.notice = null;
|
|
180
|
+
|
|
181
|
+
if (matchesKey(data, "ctrl+c")) {
|
|
182
|
+
this.cleanup();
|
|
183
|
+
this.done();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (matchesKey(data, "escape")) {
|
|
188
|
+
if (this.screen === "imports" || this.screen === "paths") {
|
|
189
|
+
this.screen = this.discovery.hasAnyConfig ? "setup" : "empty";
|
|
190
|
+
this.tui.requestRender();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this.cleanup();
|
|
194
|
+
this.done();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (this.busy) return;
|
|
199
|
+
|
|
200
|
+
if (this.screen === "imports") {
|
|
201
|
+
this.handleImportsInput(data);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (this.screen === "paths") {
|
|
205
|
+
this.handlePathsInput(data);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const actions = this.getActions();
|
|
210
|
+
if (this.keys.selectUp(data)) {
|
|
211
|
+
this.actionCursor = Math.max(0, this.actionCursor - 1);
|
|
212
|
+
this.tui.requestRender();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (this.keys.selectDown(data)) {
|
|
216
|
+
this.actionCursor = Math.min(actions.length - 1, this.actionCursor + 1);
|
|
217
|
+
this.tui.requestRender();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (this.keys.selectConfirm(data)) {
|
|
221
|
+
const selected = this.getSelectedAction();
|
|
222
|
+
if (selected) void this.runAction(selected);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private handleImportsInput(data: string): void {
|
|
227
|
+
const imports = this.discovery.imports;
|
|
228
|
+
if (this.keys.selectUp(data)) {
|
|
229
|
+
this.importCursor = Math.max(0, this.importCursor - 1);
|
|
230
|
+
this.tui.requestRender();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (this.keys.selectDown(data)) {
|
|
234
|
+
this.importCursor = Math.min(imports.length - 1, this.importCursor + 1);
|
|
235
|
+
this.tui.requestRender();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (matchesKey(data, "space")) {
|
|
239
|
+
const current = imports[this.importCursor];
|
|
240
|
+
if (!current) return;
|
|
241
|
+
if (this.selectedImports.has(current.kind)) {
|
|
242
|
+
this.selectedImports.delete(current.kind);
|
|
243
|
+
} else {
|
|
244
|
+
this.selectedImports.add(current.kind);
|
|
245
|
+
}
|
|
246
|
+
this.tui.requestRender();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (this.keys.selectConfirm(data)) {
|
|
250
|
+
void this.applySelectedImports();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private handlePathsInput(data: string): void {
|
|
255
|
+
const paths = this.getDetectedPaths();
|
|
256
|
+
if (this.keys.selectUp(data)) {
|
|
257
|
+
this.pathCursor = Math.max(0, this.pathCursor - 1);
|
|
258
|
+
this.tui.requestRender();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (this.keys.selectDown(data)) {
|
|
262
|
+
this.pathCursor = Math.min(paths.length - 1, this.pathCursor + 1);
|
|
263
|
+
this.tui.requestRender();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (this.keys.selectConfirm(data)) {
|
|
267
|
+
const selected = paths[this.pathCursor];
|
|
268
|
+
if (!selected) return;
|
|
269
|
+
void this.runBusy(async () => {
|
|
270
|
+
await this.callbacks.openPath(selected);
|
|
271
|
+
this.notice = { text: `Opened ${selected}`, tone: "success" };
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private async runAction(action: Action): Promise<void> {
|
|
277
|
+
if (action.id === "run-setup") {
|
|
278
|
+
this.screen = "setup";
|
|
279
|
+
this.actionCursor = 0;
|
|
280
|
+
this.tui.requestRender();
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (action.id === "adopt-imports") {
|
|
284
|
+
this.screen = "imports";
|
|
285
|
+
this.importCursor = 0;
|
|
286
|
+
this.tui.requestRender();
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (action.id === "open-paths") {
|
|
290
|
+
this.screen = "paths";
|
|
291
|
+
this.pathCursor = 0;
|
|
292
|
+
this.tui.requestRender();
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (action.id === "scaffold-project") {
|
|
296
|
+
await this.runBusy(async () => {
|
|
297
|
+
const result = await this.callbacks.scaffoldProjectConfig();
|
|
298
|
+
this.callbacks.markSetupCompleted();
|
|
299
|
+
this.notice = { text: `Wrote starter config to ${result.path}. Pi will reload after this panel closes.`, tone: "success" };
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (action.id === "add-repoprompt") {
|
|
304
|
+
await this.runBusy(async () => {
|
|
305
|
+
const result = await this.callbacks.addRepoPrompt();
|
|
306
|
+
this.callbacks.markSetupCompleted();
|
|
307
|
+
this.notice = { text: `Added ${result.serverName} to ${result.path}. Pi will reload after this panel closes.`, tone: "success" };
|
|
308
|
+
});
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (action.id === "add-known-server" && action.preset) {
|
|
312
|
+
const preset = action.preset;
|
|
313
|
+
await this.runBusy(async () => {
|
|
314
|
+
const result = await this.callbacks.addKnownServer(preset);
|
|
315
|
+
this.callbacks.markSetupCompleted();
|
|
316
|
+
this.notice = { text: `Added ${result.serverName} to ${result.path}. Pi will reload after this panel closes.`, tone: "success" };
|
|
317
|
+
});
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (action.id === "close") {
|
|
321
|
+
this.cleanup();
|
|
322
|
+
this.done();
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
this.notice = { text: "Review the details below. Press Enter on an action with a side effect to apply it.", tone: "muted" };
|
|
327
|
+
this.tui.requestRender();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private async applySelectedImports(): Promise<void> {
|
|
331
|
+
const selected = this.discovery.imports.filter((entry) => this.selectedImports.has(entry.kind)).map((entry) => entry.kind);
|
|
332
|
+
if (selected.length === 0) {
|
|
333
|
+
this.notice = { text: "Select at least one compatibility import first.", tone: "warning" };
|
|
334
|
+
this.tui.requestRender();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
await this.runBusy(async () => {
|
|
339
|
+
const result = await this.callbacks.adoptImports(selected);
|
|
340
|
+
this.callbacks.markSetupCompleted();
|
|
341
|
+
this.notice = result.added.length > 0
|
|
342
|
+
? { text: `Added ${result.added.join(", ")} to ${result.path}. Pi will reload after this panel closes.`, tone: "success" }
|
|
343
|
+
: { text: `No changes needed in ${result.path}.`, tone: "muted" };
|
|
344
|
+
this.screen = this.discovery.hasAnyConfig ? "setup" : "empty";
|
|
345
|
+
this.actionCursor = 0;
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
private async runBusy(fn: () => Promise<void>): Promise<void> {
|
|
350
|
+
this.busy = true;
|
|
351
|
+
this.notice = { text: "Working...", tone: "muted" };
|
|
352
|
+
this.tui.requestRender();
|
|
353
|
+
try {
|
|
354
|
+
await fn();
|
|
355
|
+
} catch (error) {
|
|
356
|
+
this.notice = {
|
|
357
|
+
text: error instanceof Error ? error.message : String(error),
|
|
358
|
+
tone: "warning",
|
|
359
|
+
};
|
|
360
|
+
} finally {
|
|
361
|
+
this.busy = false;
|
|
362
|
+
this.tui.requestRender();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
render(width: number): string[] {
|
|
367
|
+
const panelW = Math.max(MIN_PANEL_WIDTH, width);
|
|
368
|
+
const innerW = panelW - 2;
|
|
369
|
+
const contentW = this.contentWidth(innerW);
|
|
370
|
+
const lines: string[] = [];
|
|
371
|
+
const border = fg(this.t.border, "─".repeat(innerW));
|
|
372
|
+
lines.push(`┌${border}┐`);
|
|
373
|
+
lines.push(this.padLine(fg(this.t.title, "MCP setup"), innerW));
|
|
374
|
+
for (const line of wrapText(this.discoverySummaryLine(), contentW)) {
|
|
375
|
+
lines.push(this.padLine(line, innerW));
|
|
376
|
+
}
|
|
377
|
+
for (const line of wrapText(this.secondarySummaryLine(), contentW)) {
|
|
378
|
+
lines.push(this.padLine(fg(this.t.muted, line), innerW));
|
|
379
|
+
}
|
|
380
|
+
lines.push(this.padLine("", innerW));
|
|
381
|
+
|
|
382
|
+
if (this.notice) {
|
|
383
|
+
const tone = this.notice.tone === "success" ? this.t.success : this.notice.tone === "warning" ? this.t.warning : this.t.hint;
|
|
384
|
+
for (const line of wrapText(this.notice.text, contentW)) {
|
|
385
|
+
lines.push(this.padLine(fg(tone, line), innerW));
|
|
386
|
+
}
|
|
387
|
+
lines.push(this.padLine("", innerW));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
lines.push(`├${border}┤`);
|
|
391
|
+
|
|
392
|
+
if (this.screen === "imports") {
|
|
393
|
+
lines.push(...this.renderImports(innerW));
|
|
394
|
+
} else if (this.screen === "paths") {
|
|
395
|
+
lines.push(...this.renderPaths(innerW));
|
|
396
|
+
} else {
|
|
397
|
+
lines.push(...this.renderActions(innerW));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
lines.push(`└${border}┘`);
|
|
401
|
+
return lines;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
private renderActions(innerW: number): string[] {
|
|
405
|
+
const lines: string[] = [];
|
|
406
|
+
const actions = this.getActions();
|
|
407
|
+
const compact = innerW < COMPACT_WIDTH;
|
|
408
|
+
const { start, end } = compact
|
|
409
|
+
? this.visibleActionRange(actions.length)
|
|
410
|
+
: { start: 0, end: actions.length };
|
|
411
|
+
|
|
412
|
+
if (start > 0) {
|
|
413
|
+
lines.push(this.padLine(fg(this.t.muted, `… ${start} more above`), innerW));
|
|
414
|
+
}
|
|
415
|
+
for (let index = start; index < end; index++) {
|
|
416
|
+
const action = actions[index];
|
|
417
|
+
if (!action) continue;
|
|
418
|
+
if (action.id === "add-known-server" && (index === start || actions[index - 1]?.id !== "add-known-server")) {
|
|
419
|
+
lines.push(this.padLine(fg(this.t.title, "Add a known server"), innerW));
|
|
420
|
+
}
|
|
421
|
+
const selected = index === this.actionCursor;
|
|
422
|
+
const cursor = selected ? fg(this.t.selected, "›") : " ";
|
|
423
|
+
lines.push(this.padLine(`${cursor} ${truncateToWidth(action.label, this.contentWidth(innerW) - 2)}`, innerW));
|
|
424
|
+
}
|
|
425
|
+
if (end < actions.length) {
|
|
426
|
+
lines.push(this.padLine(fg(this.t.muted, `… ${actions.length - end} more below`), innerW));
|
|
427
|
+
}
|
|
428
|
+
lines.push(this.padLine("", innerW));
|
|
429
|
+
|
|
430
|
+
const preview = this.getActionPreview(this.getSelectedAction(), this.previewWidth(innerW));
|
|
431
|
+
for (const line of preview) {
|
|
432
|
+
lines.push(this.padLine(line, innerW));
|
|
433
|
+
}
|
|
434
|
+
lines.push(this.padLine("", innerW));
|
|
435
|
+
const hint = compact ? "Enter select · Esc back" : "Enter selects, Esc goes back, Ctrl+C closes.";
|
|
436
|
+
lines.push(this.padLine(fg(this.t.muted, hint), innerW));
|
|
437
|
+
return lines;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
private renderImports(innerW: number): string[] {
|
|
441
|
+
const lines: string[] = [];
|
|
442
|
+
lines.push(this.padLine("Select compatibility imports. Space toggles, Enter saves, Esc goes back.", innerW));
|
|
443
|
+
lines.push(this.padLine("", innerW));
|
|
444
|
+
for (let index = 0; index < this.discovery.imports.length; index++) {
|
|
445
|
+
const entry = this.discovery.imports[index];
|
|
446
|
+
if (!entry) continue;
|
|
447
|
+
const selected = this.selectedImports.has(entry.kind) ? "[x]" : "[ ]";
|
|
448
|
+
const cursor = index === this.importCursor ? fg(this.t.selected, "›") : " ";
|
|
449
|
+
lines.push(this.padLine(`${cursor} ${selected} ${entry.kind} ${entry.path}`, innerW));
|
|
450
|
+
}
|
|
451
|
+
lines.push(this.padLine("", innerW));
|
|
452
|
+
const selected = this.discovery.imports.filter((entry) => this.selectedImports.has(entry.kind)).map((entry) => entry.kind);
|
|
453
|
+
const preview = this.callbacks.previewImports(selected);
|
|
454
|
+
for (const line of this.formatWritePreview("Compatibility import write preview", preview, [], this.previewWidth(innerW))) {
|
|
455
|
+
lines.push(this.padLine(line, innerW));
|
|
456
|
+
}
|
|
457
|
+
return lines;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
private renderPaths(innerW: number): string[] {
|
|
461
|
+
const lines: string[] = [];
|
|
462
|
+
lines.push(this.padLine("Select a detected config path to open. Enter opens it, Esc goes back.", innerW));
|
|
463
|
+
lines.push(this.padLine("", innerW));
|
|
464
|
+
const paths = this.getDetectedPaths();
|
|
465
|
+
for (let index = 0; index < paths.length; index++) {
|
|
466
|
+
const cursor = index === this.pathCursor ? fg(this.t.selected, "›") : " ";
|
|
467
|
+
const path = paths[index];
|
|
468
|
+
if (path !== undefined) lines.push(this.padLine(`${cursor} ${path}`, innerW));
|
|
469
|
+
}
|
|
470
|
+
return lines;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
private discoverySummaryLine(): string {
|
|
474
|
+
if (!this.discovery.hasAnyConfig) {
|
|
475
|
+
return fg(this.t.warning, this.options.onboardingState.setupCompleted
|
|
476
|
+
? "No MCP servers are active right now."
|
|
477
|
+
: "No MCP config is active yet.");
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (this.discovery.totalServerCount === 0 && (this.discovery.imports.length > 0 || !!this.discovery.repoPrompt.executablePath)) {
|
|
481
|
+
return fg(this.t.warning, "Pi found MCP-related setup options, but none are active in Pi yet.");
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const shared = this.discovery.sources.filter((source) => source.kind === "shared" && source.serverCount > 0).length;
|
|
485
|
+
const piOwned = this.discovery.sources.filter((source) => source.kind === "pi" && source.serverCount > 0).length;
|
|
486
|
+
return fg(this.t.hint, `Detected ${this.discovery.totalServerCount} configured servers across ${shared} shared and ${piOwned} Pi-owned source${shared + piOwned === 1 ? "" : "s"}.`);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
private secondarySummaryLine(): string {
|
|
490
|
+
const hostNote = this.discovery.hostConfigs.length > 0
|
|
491
|
+
? ` Host discovery is ${this.discovery.hostConfigDiscovery}; ${this.discovery.hostConfigs.length} host source${this.discovery.hostConfigs.length === 1 ? "" : "s"} detected.`
|
|
492
|
+
: "";
|
|
493
|
+
const conflictNote = this.discovery.conflicts.length > 0
|
|
494
|
+
? ` ${this.discovery.conflicts.length} same-name conflict${this.discovery.conflicts.length === 1 ? "" : "s"} reported.`
|
|
495
|
+
: "";
|
|
496
|
+
if (!this.discovery.hasAnyConfig) {
|
|
497
|
+
return `Create a shared .mcp.json, adopt host imports, or quick-add RepoPrompt from this screen.${hostNote}${conflictNote}`;
|
|
498
|
+
}
|
|
499
|
+
if (this.discovery.totalServerCount === 0 && this.discovery.imports.length > 0) {
|
|
500
|
+
return `Detected ${this.discovery.imports.length} compatibility import source${this.discovery.imports.length === 1 ? "" : "s"}. Adopt them into Pi or inspect the underlying files.${hostNote}${conflictNote}`;
|
|
501
|
+
}
|
|
502
|
+
return `Shared MCP files are preferred. Pi-owned files are only for compatibility imports and adapter-specific overrides.${hostNote}${conflictNote}`;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
private visibleActionRange(total: number): { start: number; end: number } {
|
|
506
|
+
if (total <= COMPACT_ACTION_ROWS) return { start: 0, end: total };
|
|
507
|
+
const half = Math.floor(COMPACT_ACTION_ROWS / 2);
|
|
508
|
+
const start = Math.min(Math.max(0, this.actionCursor - half), Math.max(0, total - COMPACT_ACTION_ROWS));
|
|
509
|
+
return { start, end: Math.min(total, start + COMPACT_ACTION_ROWS) };
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
private contentWidth(innerW: number): number {
|
|
513
|
+
return Math.max(8, innerW - 4);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
private previewWidth(innerW: number): number {
|
|
517
|
+
return Math.max(12, Math.min(DESKTOP_PREVIEW_WIDTH, this.contentWidth(innerW)));
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
private getActionPreview(action?: Action, previewW = DESKTOP_PREVIEW_WIDTH): string[] {
|
|
521
|
+
switch (action?.id) {
|
|
522
|
+
case "run-setup":
|
|
523
|
+
return this.formatPreview([
|
|
524
|
+
"Run setup to adopt host-specific imports, inspect detected paths, and scaffold a minimal `.mcp.json` if needed.",
|
|
525
|
+
], previewW);
|
|
526
|
+
case "adopt-imports":
|
|
527
|
+
return this.formatWritePreview(
|
|
528
|
+
"Compatibility import write preview",
|
|
529
|
+
this.callbacks.previewImports(this.discovery.imports.filter((entry) => this.selectedImports.has(entry.kind)).map((entry) => entry.kind)),
|
|
530
|
+
[
|
|
531
|
+
`Detected imports: ${this.discovery.imports.map((entry) => `${entry.kind} (${entry.serverCount} servers)`).join(", ")}`,
|
|
532
|
+
"Selected imports are written into the Pi agent dir config as Pi-owned compatibility state.",
|
|
533
|
+
],
|
|
534
|
+
previewW,
|
|
535
|
+
);
|
|
536
|
+
case "view-example":
|
|
537
|
+
return this.formatPreview([
|
|
538
|
+
"Example shared `.mcp.json`:",
|
|
539
|
+
"{",
|
|
540
|
+
' "mcpServers": {',
|
|
541
|
+
' "chrome-devtools": {',
|
|
542
|
+
' "command": "npx",',
|
|
543
|
+
' "args": ["-y", "chrome-devtools-mcp@1.6.0"]',
|
|
544
|
+
" }",
|
|
545
|
+
" }",
|
|
546
|
+
"}",
|
|
547
|
+
"",
|
|
548
|
+
"Use Scaffold project `.mcp.json` when you want a safe empty shell instead of a live example server.",
|
|
549
|
+
], previewW);
|
|
550
|
+
case "show-precedence":
|
|
551
|
+
return this.formatPreview([
|
|
552
|
+
"Read order (later entries win):",
|
|
553
|
+
"0. detected host configs (opt-in lowest-precedence fallback)",
|
|
554
|
+
"1. ~/.config/mcp/mcp.json",
|
|
555
|
+
"2. ~/.agents/mcp.json",
|
|
556
|
+
"3. ~/.agents/mcp/mcp.json",
|
|
557
|
+
"4. <Pi agent dir>/mcp.json",
|
|
558
|
+
"5. .mcp.json",
|
|
559
|
+
"6. .pi/mcp.json",
|
|
560
|
+
`Host discovery: ${this.discovery.hostConfigDiscovery}. Conflicts reported: ${this.discovery.conflicts.length}.`,
|
|
561
|
+
...this.discovery.conflicts.slice(0, 8).map((conflict) =>
|
|
562
|
+
`${conflict.serverName}: ${conflict.sources.map((source) => source.path).join(" -> ")} (winner: ${conflict.winner.path})`,
|
|
563
|
+
),
|
|
564
|
+
"Pi writes compatibility imports and adapter-only overrides to Pi-owned files."
|
|
565
|
+
], previewW);
|
|
566
|
+
case "open-paths":
|
|
567
|
+
return this.formatPreview(this.getDetectedPaths().length > 0
|
|
568
|
+
? ["Detected paths:", ...this.getDetectedPaths()]
|
|
569
|
+
: ["No config paths were detected."], previewW);
|
|
570
|
+
case "add-repoprompt": {
|
|
571
|
+
const repoPrompt = this.discovery.repoPrompt;
|
|
572
|
+
const preview = this.callbacks.previewRepoPrompt();
|
|
573
|
+
if (!preview) {
|
|
574
|
+
return this.formatPreview(["RepoPrompt is not available to add from this setup screen."], previewW);
|
|
575
|
+
}
|
|
576
|
+
return this.formatWritePreview(
|
|
577
|
+
"RepoPrompt write preview",
|
|
578
|
+
preview,
|
|
579
|
+
[
|
|
580
|
+
`Executable: ${repoPrompt.executablePath ?? "not found"}`,
|
|
581
|
+
`Target: ${repoPrompt.targetPath ?? "n/a"}`,
|
|
582
|
+
`Server name: ${repoPrompt.serverName ?? "repoprompt"}`,
|
|
583
|
+
],
|
|
584
|
+
previewW,
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
case "add-known-server": {
|
|
588
|
+
const preset = action.preset;
|
|
589
|
+
if (!preset) return this.formatPreview(["Known server preset is unavailable."], previewW);
|
|
590
|
+
return this.formatWritePreview(
|
|
591
|
+
`${preset.name} write preview`,
|
|
592
|
+
this.callbacks.previewKnownServer(preset),
|
|
593
|
+
[preset.summary],
|
|
594
|
+
previewW,
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
case "scaffold-project":
|
|
598
|
+
return this.formatWritePreview(
|
|
599
|
+
"Starter project `.mcp.json` write preview",
|
|
600
|
+
this.callbacks.previewStarterProject(),
|
|
601
|
+
[
|
|
602
|
+
"This writes a minimal `.mcp.json` in the current project using the shared MCP layout.",
|
|
603
|
+
"It intentionally avoids adding a fake placeholder server that would fail on first reload.",
|
|
604
|
+
],
|
|
605
|
+
previewW,
|
|
606
|
+
);
|
|
607
|
+
case "close":
|
|
608
|
+
default:
|
|
609
|
+
return this.formatPreview(["Close the setup flow."], previewW);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
private formatPreview(lines: string[], width = DESKTOP_PREVIEW_WIDTH): string[] {
|
|
614
|
+
const preview: string[] = [];
|
|
615
|
+
for (const line of lines) {
|
|
616
|
+
preview.push(...wrapText(line, width));
|
|
617
|
+
}
|
|
618
|
+
return preview;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
private formatWritePreview(title: string, preview: ConfigWritePreview, intro: string[] = [], width = DESKTOP_PREVIEW_WIDTH): string[] {
|
|
622
|
+
const lines: string[] = [];
|
|
623
|
+
for (const line of intro) {
|
|
624
|
+
lines.push(...wrapText(line, width));
|
|
625
|
+
}
|
|
626
|
+
if (intro.length > 0) lines.push("");
|
|
627
|
+
lines.push(...wrapText(`${title}: ${preview.path}`, width));
|
|
628
|
+
lines.push(...wrapText(preview.existed ? "Existing file detected. Showing exact before/after diff." : "New file will be created. Showing exact content diff.", width));
|
|
629
|
+
lines.push("");
|
|
630
|
+
const diffLines = preview.diffText.split("\n");
|
|
631
|
+
const maxLines = 18;
|
|
632
|
+
const shown = diffLines.slice(0, maxLines);
|
|
633
|
+
for (const line of shown) {
|
|
634
|
+
lines.push(...wrapText(line, width));
|
|
635
|
+
}
|
|
636
|
+
if (diffLines.length > maxLines) {
|
|
637
|
+
lines.push(...wrapText(`… ${diffLines.length - maxLines} more diff line${diffLines.length - maxLines === 1 ? "" : "s"}`, width));
|
|
638
|
+
}
|
|
639
|
+
return lines;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
private padLine(text: string, innerW: number): string {
|
|
643
|
+
const inset = 2;
|
|
644
|
+
const contentW = Math.max(0, innerW - inset * 2);
|
|
645
|
+
const fitted = truncateToWidth(text, contentW, "…", true);
|
|
646
|
+
const plainWidth = visibleWidth(fitted);
|
|
647
|
+
const padding = Math.max(0, contentW - plainWidth);
|
|
648
|
+
return `│${" ".repeat(inset)}${fitted}${" ".repeat(padding)}${" ".repeat(inset)}│`;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
invalidate(): void {}
|
|
652
|
+
|
|
653
|
+
dispose(): void {
|
|
654
|
+
this.cleanup();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
export function createMcpSetupPanel(
|
|
659
|
+
discovery: McpDiscoverySummary,
|
|
660
|
+
callbacks: SetupPanelCallbacks,
|
|
661
|
+
options: SetupPanelOptions,
|
|
662
|
+
tui: { requestRender(): void },
|
|
663
|
+
done: () => void,
|
|
664
|
+
): McpSetupPanel & { dispose(): void } {
|
|
665
|
+
return new McpSetupPanel(discovery, callbacks, options, tui, done);
|
|
666
|
+
}
|