@humain/terminal 0.0.2 → 0.0.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +251 -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/config.d.ts.map +1 -1
- package/dist/config.js +4 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +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 +673 -0
- package/dist/humain/mcp-adapter/vendor/LICENSE +21 -0
- package/dist/humain/mcp-adapter/vendor/README.md +736 -0
- package/dist/humain/mcp-adapter/vendor/abort.ts +34 -0
- package/dist/humain/mcp-adapter/vendor/agent-dir.ts +68 -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 +230 -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 +607 -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 +16279 -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 +667 -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 +363 -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 +179 -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/request-headers-command.ts +336 -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 +1129 -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 +296 -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 +942 -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/auth-fetch.d.ts +13 -0
- package/dist/humain/web-access/vendor/auth-fetch.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/auth-fetch.js +134 -0
- package/dist/humain/web-access/vendor/auth-fetch.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 +23 -0
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/chrome-cookies.js +522 -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 +30 -0
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/curator-page.js +3556 -0
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -0
- package/dist/humain/web-access/vendor/curator-server.d.ts +94 -0
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/curator-server.js +690 -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 +48 -0
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/extract.js +1126 -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 +27 -0
- package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/fetch-params.js +71 -0
- package/dist/humain/web-access/vendor/fetch-params.js.map +1 -0
- package/dist/humain/web-access/vendor/firecrawl.d.ts +19 -0
- package/dist/humain/web-access/vendor/firecrawl.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/firecrawl.js +370 -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 +832 -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 +3076 -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 +26 -0
- package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/summary-review.js +344 -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 +673 -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,348 @@
|
|
|
1
|
+
import type { ExtensionUIContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { Client } from "@modelcontextprotocol/client";
|
|
3
|
+
import {
|
|
4
|
+
ProtocolError,
|
|
5
|
+
ProtocolErrorCode,
|
|
6
|
+
type ElicitRequest,
|
|
7
|
+
type ElicitRequestFormParams,
|
|
8
|
+
type ElicitRequestURLParams,
|
|
9
|
+
type ElicitResult,
|
|
10
|
+
} from "@modelcontextprotocol/client";
|
|
11
|
+
import { AjvJsonSchemaValidator } from "@modelcontextprotocol/client/validators/ajv";
|
|
12
|
+
import type { JsonSchemaType } from "@modelcontextprotocol/client";
|
|
13
|
+
import open from "open";
|
|
14
|
+
|
|
15
|
+
export type ElicitationValue = string | number | boolean | string[] | undefined;
|
|
16
|
+
type FormProperty = ElicitRequestFormParams["requestedSchema"]["properties"][string];
|
|
17
|
+
type FieldCollectionResult = { status: "cancelled" } | { status: "collected"; value: ElicitationValue };
|
|
18
|
+
|
|
19
|
+
export type ElicitationUIContext = Pick<ExtensionUIContext, "select" | "input" | "notify">;
|
|
20
|
+
|
|
21
|
+
export interface ElicitationHandlerOptions {
|
|
22
|
+
serverName: string;
|
|
23
|
+
ui: ElicitationUIContext;
|
|
24
|
+
allowUrl: boolean;
|
|
25
|
+
onUrlAccepted?: (elicitationId: string) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ServerElicitationConfig = Omit<ElicitationHandlerOptions, "serverName" | "onUrlAccepted">;
|
|
29
|
+
|
|
30
|
+
export function registerElicitationHandler(client: Client, options: ElicitationHandlerOptions): void {
|
|
31
|
+
client.setRequestHandler("elicitation/create", request =>
|
|
32
|
+
handleElicitationRequest(options, request));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function handleElicitationRequest(
|
|
36
|
+
options: ElicitationHandlerOptions,
|
|
37
|
+
request: ElicitRequest,
|
|
38
|
+
): Promise<ElicitResult> {
|
|
39
|
+
return request.params.mode === "url"
|
|
40
|
+
? handleUrlElicitation(options, request.params)
|
|
41
|
+
: handleFormElicitation(options, request.params);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function handleFormElicitation(
|
|
45
|
+
options: ElicitationHandlerOptions,
|
|
46
|
+
params: ElicitRequestFormParams,
|
|
47
|
+
): Promise<ElicitResult> {
|
|
48
|
+
const properties = Object.entries(params.requestedSchema.properties);
|
|
49
|
+
const decision = await options.ui.select(
|
|
50
|
+
`MCP Input Request\nServer: ${options.serverName}\n\n${params.message}`,
|
|
51
|
+
["Continue", "Decline"],
|
|
52
|
+
);
|
|
53
|
+
if (decision === undefined) return { action: "cancel" };
|
|
54
|
+
if (decision === "Decline") return { action: "decline" };
|
|
55
|
+
if (properties.length === 0) return { action: "accept", content: {} };
|
|
56
|
+
|
|
57
|
+
const values: Record<string, ElicitationValue> = {};
|
|
58
|
+
for (const [name, schema] of properties) {
|
|
59
|
+
const value = await collectValidField(options.ui, params, name, schema);
|
|
60
|
+
if (value.status === "cancelled") return { action: "cancel" };
|
|
61
|
+
values[name] = value.value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
while (true) {
|
|
65
|
+
const content = coerceAndValidateFormValues(params, values);
|
|
66
|
+
const action = await options.ui.select(
|
|
67
|
+
formatReview(options.serverName, properties, content),
|
|
68
|
+
["Submit", "Edit", "Decline"],
|
|
69
|
+
);
|
|
70
|
+
if (action === undefined) return { action: "cancel" };
|
|
71
|
+
if (action === "Decline") return { action: "decline" };
|
|
72
|
+
if (action === "Submit") return { action: "accept", content };
|
|
73
|
+
|
|
74
|
+
const labels = properties.map(([name, schema]) => `${schema.title ?? humanizeName(name)} (${name})`);
|
|
75
|
+
const selected = await options.ui.select("Choose a field to edit", labels);
|
|
76
|
+
if (selected === undefined) return { action: "cancel" };
|
|
77
|
+
const property = properties[labels.indexOf(selected)];
|
|
78
|
+
if (!property) continue;
|
|
79
|
+
const [name, schema] = property;
|
|
80
|
+
const value = await collectValidField(options.ui, params, name, schema, values[name]);
|
|
81
|
+
if (value.status === "cancelled") return { action: "cancel" };
|
|
82
|
+
values[name] = value.value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function collectValidField(
|
|
87
|
+
ui: ElicitationUIContext,
|
|
88
|
+
params: ElicitRequestFormParams,
|
|
89
|
+
name: string,
|
|
90
|
+
schema: FormProperty,
|
|
91
|
+
current?: ElicitationValue,
|
|
92
|
+
): Promise<FieldCollectionResult> {
|
|
93
|
+
const required = params.requestedSchema.required?.includes(name) === true;
|
|
94
|
+
while (true) {
|
|
95
|
+
const result = await collectField(ui, params, name, schema, current);
|
|
96
|
+
if (result.status === "cancelled") return result;
|
|
97
|
+
try {
|
|
98
|
+
coerceAndValidateFormValues({
|
|
99
|
+
...params,
|
|
100
|
+
requestedSchema: {
|
|
101
|
+
type: "object",
|
|
102
|
+
properties: { [name]: schema },
|
|
103
|
+
...(required ? { required: [name] } : {}),
|
|
104
|
+
},
|
|
105
|
+
}, { [name]: result.value });
|
|
106
|
+
return result;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
109
|
+
current = result.value;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function collectField(
|
|
115
|
+
ui: ElicitationUIContext,
|
|
116
|
+
params: ElicitRequestFormParams,
|
|
117
|
+
name: string,
|
|
118
|
+
schema: FormProperty,
|
|
119
|
+
current?: ElicitationValue,
|
|
120
|
+
): Promise<FieldCollectionResult> {
|
|
121
|
+
const required = params.requestedSchema.required?.includes(name) === true;
|
|
122
|
+
const title = [schema.title ?? humanizeName(name), required ? "(required)" : "", schema.description]
|
|
123
|
+
.filter(Boolean)
|
|
124
|
+
.join(" ");
|
|
125
|
+
|
|
126
|
+
if (schema.type === "string" && ("enum" in schema || "oneOf" in schema)) {
|
|
127
|
+
const choices = "oneOf" in schema
|
|
128
|
+
? schema.oneOf.map(option => ({ value: option.const, display: formatChoice(option.const, option.title) }))
|
|
129
|
+
: schema.enum.map((value, index) => ({
|
|
130
|
+
value,
|
|
131
|
+
display: formatChoice(value, "enumNames" in schema ? schema.enumNames?.[index] : undefined),
|
|
132
|
+
}));
|
|
133
|
+
const displays = uniqueLabels(choices.map(choice => choice.display));
|
|
134
|
+
const actions = [...displays];
|
|
135
|
+
const useDefault = schema.default === undefined ? undefined : uniqueAction("Use default", actions);
|
|
136
|
+
if (useDefault) actions.push(useDefault);
|
|
137
|
+
const omit = required ? undefined : uniqueAction("Omit", actions);
|
|
138
|
+
if (omit) actions.push(omit);
|
|
139
|
+
const action = await ui.select(title, actions);
|
|
140
|
+
if (action === undefined) return { status: "cancelled" };
|
|
141
|
+
if (action === useDefault) return { status: "collected", value: schema.default };
|
|
142
|
+
if (action === omit) return { status: "collected", value: undefined };
|
|
143
|
+
return { status: "collected", value: choices[displays.indexOf(action)]?.value };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (schema.type === "boolean") {
|
|
147
|
+
const actions = ["Yes", "No"];
|
|
148
|
+
if (schema.default !== undefined) actions.push("Use default");
|
|
149
|
+
if (!required) actions.push("Omit");
|
|
150
|
+
const action = await ui.select(title, actions);
|
|
151
|
+
if (action === undefined) return { status: "cancelled" };
|
|
152
|
+
if (action === "Use default") return { status: "collected", value: schema.default };
|
|
153
|
+
if (action === "Omit") return { status: "collected", value: undefined };
|
|
154
|
+
return { status: "collected", value: action === "Yes" };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (schema.type === "array") {
|
|
158
|
+
const actions = ["Choose values"];
|
|
159
|
+
if (schema.default !== undefined) actions.push("Use default");
|
|
160
|
+
if (!required) actions.push("Omit");
|
|
161
|
+
const action = await ui.select(title, actions);
|
|
162
|
+
if (action === undefined) return { status: "cancelled" };
|
|
163
|
+
if (action === "Use default") return { status: "collected", value: schema.default };
|
|
164
|
+
if (action === "Omit") return { status: "collected", value: undefined };
|
|
165
|
+
|
|
166
|
+
const choices = extractMultiSelectOptions(schema);
|
|
167
|
+
const selected = new Set(Array.isArray(current) ? current : []);
|
|
168
|
+
while (true) {
|
|
169
|
+
const displays = uniqueLabels(choices.map(choice => selected.has(choice.value) ? `✓ ${choice.display}` : choice.display));
|
|
170
|
+
const done = uniqueAction("Done", displays);
|
|
171
|
+
const picked = await ui.select(title, [...displays, done]);
|
|
172
|
+
if (picked === undefined) return { status: "cancelled" };
|
|
173
|
+
if (picked === done) return { status: "collected", value: [...selected] };
|
|
174
|
+
const choice = choices[displays.indexOf(picked)];
|
|
175
|
+
if (!choice) continue;
|
|
176
|
+
if (selected.has(choice.value)) selected.delete(choice.value);
|
|
177
|
+
else selected.add(choice.value);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const actions = ["Enter value"];
|
|
182
|
+
if (schema.default !== undefined) actions.push("Use default");
|
|
183
|
+
if (!required) actions.push("Omit");
|
|
184
|
+
const action = await ui.select(title, actions);
|
|
185
|
+
if (action === undefined) return { status: "cancelled" };
|
|
186
|
+
if (action === "Use default") return { status: "collected", value: schema.default };
|
|
187
|
+
if (action === "Omit") return { status: "collected", value: undefined };
|
|
188
|
+
const entered = await ui.input(title, current === undefined ? undefined : String(current));
|
|
189
|
+
return entered === undefined ? { status: "cancelled" } : { status: "collected", value: entered };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function coerceAndValidateFormValues(
|
|
193
|
+
params: ElicitRequestFormParams,
|
|
194
|
+
values: Record<string, ElicitationValue>,
|
|
195
|
+
): Record<string, string | number | boolean | string[]> {
|
|
196
|
+
const output: Record<string, string | number | boolean | string[]> = {};
|
|
197
|
+
const required = new Set(params.requestedSchema.required ?? []);
|
|
198
|
+
for (const [name, schema] of Object.entries(params.requestedSchema.properties)) {
|
|
199
|
+
const value = values[name];
|
|
200
|
+
if (value === undefined) {
|
|
201
|
+
if (required.has(name)) throw new Error(`Missing required elicitation field: ${name}`);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (schema.type === "string") {
|
|
205
|
+
const stringValue = String(value);
|
|
206
|
+
const limits = schema as typeof schema & { minLength?: number; maxLength?: number };
|
|
207
|
+
if (limits.minLength !== undefined && stringValue.length < limits.minLength) {
|
|
208
|
+
throw new Error(`Elicitation field ${name} is shorter than minimum length ${limits.minLength}`);
|
|
209
|
+
}
|
|
210
|
+
if (limits.maxLength !== undefined && stringValue.length > limits.maxLength) {
|
|
211
|
+
throw new Error(`Elicitation field ${name} is longer than maximum length ${limits.maxLength}`);
|
|
212
|
+
}
|
|
213
|
+
if ("enum" in schema && !schema.enum.includes(stringValue)) {
|
|
214
|
+
throw new Error(`Elicitation field ${name} is not an allowed value`);
|
|
215
|
+
}
|
|
216
|
+
if ("oneOf" in schema && !schema.oneOf.some(option => option.const === stringValue)) {
|
|
217
|
+
throw new Error(`Elicitation field ${name} is not an allowed value`);
|
|
218
|
+
}
|
|
219
|
+
output[name] = stringValue;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (schema.type === "number" || schema.type === "integer") {
|
|
223
|
+
if (typeof value === "string" && value.trim() === "") {
|
|
224
|
+
throw new Error(`Elicitation field ${name} must be a number`);
|
|
225
|
+
}
|
|
226
|
+
const numberValue = typeof value === "number" ? value : Number(value);
|
|
227
|
+
if (!Number.isFinite(numberValue)) throw new Error(`Elicitation field ${name} must be a number`);
|
|
228
|
+
if (schema.type === "integer" && !Number.isInteger(numberValue)) {
|
|
229
|
+
throw new Error(`Elicitation field ${name} must be an integer`);
|
|
230
|
+
}
|
|
231
|
+
if (schema.minimum !== undefined && numberValue < schema.minimum) {
|
|
232
|
+
throw new Error(`Elicitation field ${name} is below minimum ${schema.minimum}`);
|
|
233
|
+
}
|
|
234
|
+
if (schema.maximum !== undefined && numberValue > schema.maximum) {
|
|
235
|
+
throw new Error(`Elicitation field ${name} is above maximum ${schema.maximum}`);
|
|
236
|
+
}
|
|
237
|
+
output[name] = numberValue;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (schema.type === "boolean") {
|
|
241
|
+
output[name] = typeof value === "boolean" ? value : value === "true";
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (schema.type === "array") {
|
|
245
|
+
if (!Array.isArray(value)) throw new Error(`Elicitation field ${name} must be a list`);
|
|
246
|
+
const allowed = new Set(extractMultiSelectOptions(schema).map(option => option.value));
|
|
247
|
+
const arrayValue = value.map(String);
|
|
248
|
+
if (schema.minItems !== undefined && arrayValue.length < schema.minItems) {
|
|
249
|
+
throw new Error(`Elicitation field ${name} has fewer than ${schema.minItems} selections`);
|
|
250
|
+
}
|
|
251
|
+
if (schema.maxItems !== undefined && arrayValue.length > schema.maxItems) {
|
|
252
|
+
throw new Error(`Elicitation field ${name} has more than ${schema.maxItems} selections`);
|
|
253
|
+
}
|
|
254
|
+
if (arrayValue.some(item => !allowed.has(item))) {
|
|
255
|
+
throw new Error(`Elicitation field ${name} contains an invalid selection`);
|
|
256
|
+
}
|
|
257
|
+
output[name] = arrayValue;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const validation = new AjvJsonSchemaValidator()
|
|
261
|
+
.getValidator(params.requestedSchema as JsonSchemaType)(output);
|
|
262
|
+
if (!validation.valid) {
|
|
263
|
+
throw new Error(`Invalid elicitation response: ${validation.errorMessage}`);
|
|
264
|
+
}
|
|
265
|
+
return output;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function formatChoice(value: string, title?: string): string {
|
|
269
|
+
return title && title !== value ? `${title} (${value})` : value;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function uniqueLabels(labels: string[]): string[] {
|
|
273
|
+
const used = new Set<string>();
|
|
274
|
+
return labels.map(label => {
|
|
275
|
+
let unique = label;
|
|
276
|
+
while (used.has(unique)) unique += "…";
|
|
277
|
+
used.add(unique);
|
|
278
|
+
return unique;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function uniqueAction(label: string, choices: string[]): string {
|
|
283
|
+
let unique = label;
|
|
284
|
+
while (choices.includes(unique)) unique += "…";
|
|
285
|
+
return unique;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function extractMultiSelectOptions(schema: Extract<FormProperty, { type: "array" }>): Array<{ value: string; display: string }> {
|
|
289
|
+
const items = schema.items as { enum?: string[]; anyOf?: Array<{ const: string; title: string }> };
|
|
290
|
+
return items.anyOf
|
|
291
|
+
? items.anyOf.map(option => ({ value: option.const, display: formatChoice(option.const, option.title) }))
|
|
292
|
+
: (items.enum ?? []).map(value => ({ value, display: value }));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function formatReview(
|
|
296
|
+
serverName: string,
|
|
297
|
+
properties: Array<[string, FormProperty]>,
|
|
298
|
+
content: Record<string, string | number | boolean | string[]>,
|
|
299
|
+
): string {
|
|
300
|
+
const rows = properties.map(([name, schema]) =>
|
|
301
|
+
`${schema.title ?? humanizeName(name)}: ${content[name] === undefined ? "(omitted)" : String(content[name])}`);
|
|
302
|
+
return [`Review input for ${serverName}`, "", ...rows].join("\n");
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export async function handleUrlElicitation(
|
|
306
|
+
options: ElicitationHandlerOptions,
|
|
307
|
+
params: ElicitRequestURLParams,
|
|
308
|
+
): Promise<ElicitResult> {
|
|
309
|
+
if (!options.allowUrl) throw new ProtocolError(ProtocolErrorCode.InvalidParams, "URL elicitation is not supported");
|
|
310
|
+
|
|
311
|
+
let parsed: URL;
|
|
312
|
+
try {
|
|
313
|
+
parsed = new URL(params.url);
|
|
314
|
+
} catch {
|
|
315
|
+
throw new ProtocolError(ProtocolErrorCode.InvalidParams, "URL elicitation supplied an invalid URL");
|
|
316
|
+
}
|
|
317
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
318
|
+
throw new ProtocolError(ProtocolErrorCode.InvalidParams, "URL elicitation only supports HTTP and HTTPS URLs");
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const decision = await options.ui.select([
|
|
322
|
+
"MCP Browser Request",
|
|
323
|
+
`Server: ${options.serverName}`,
|
|
324
|
+
"",
|
|
325
|
+
params.message,
|
|
326
|
+
"",
|
|
327
|
+
`Host: ${parsed.host}`,
|
|
328
|
+
`Full URL: ${params.url}`,
|
|
329
|
+
"",
|
|
330
|
+
"Open this URL in your browser?",
|
|
331
|
+
].join("\n"), ["Open", "Decline"]);
|
|
332
|
+
if (decision === undefined) return { action: "cancel" };
|
|
333
|
+
if (decision === "Decline") return { action: "decline" };
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
await open(params.url);
|
|
337
|
+
} catch (error) {
|
|
338
|
+
options.ui.notify(`Could not open MCP elicitation URL: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
339
|
+
return { action: "cancel" };
|
|
340
|
+
}
|
|
341
|
+
options.onUrlAccepted?.(params.elicitationId);
|
|
342
|
+
options.ui.notify("Opened browser for MCP elicitation.", "info");
|
|
343
|
+
return { action: "accept" };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function humanizeName(name: string): string {
|
|
347
|
+
return name.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/^./, char => char.toUpperCase());
|
|
348
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decide the `isError` override for a finished tool result in the `tool_result` hook.
|
|
3
|
+
*
|
|
4
|
+
* A failed MCP tool call is *returned* (not thrown), tagged `details.error: "tool_error"` (the server
|
|
5
|
+
* returned an error result) or `"call_failed"` (the call itself threw and was caught). pi never reads a
|
|
6
|
+
* result-level `isError`, so without this such a call is recorded as a success. Returning
|
|
7
|
+
* `{ isError: true }` (and nothing else) flips the flag; pi's field-by-field merge keeps the original
|
|
8
|
+
* `content` and `details` intact.
|
|
9
|
+
*
|
|
10
|
+
* Limited to those two codes: the adapter's other `details.error` values (`auth_required`, connection
|
|
11
|
+
* states, search/validation feedback, ...) are not failed tool calls, so they get no override.
|
|
12
|
+
*/
|
|
13
|
+
export function toolErrorOverride(details: unknown): { isError: true } | undefined {
|
|
14
|
+
if (details && typeof details === "object" && "error" in details) {
|
|
15
|
+
const code = (details as { error?: unknown }).error;
|
|
16
|
+
if (code === "tool_error" || code === "call_failed") {
|
|
17
|
+
return { isError: true };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error types for MCP UI operations.
|
|
3
|
+
* Provides structured errors with context and recovery hints.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface McpUiErrorContext {
|
|
7
|
+
server?: string;
|
|
8
|
+
tool?: string;
|
|
9
|
+
uri?: string;
|
|
10
|
+
session?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Base error class for MCP UI errors.
|
|
16
|
+
*/
|
|
17
|
+
export class McpUiError extends Error {
|
|
18
|
+
readonly code: string;
|
|
19
|
+
readonly context: McpUiErrorContext;
|
|
20
|
+
readonly recoveryHint: string | undefined;
|
|
21
|
+
readonly cause: Error | undefined;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
message: string,
|
|
25
|
+
options: {
|
|
26
|
+
code: string;
|
|
27
|
+
context?: McpUiErrorContext;
|
|
28
|
+
recoveryHint?: string;
|
|
29
|
+
cause?: Error;
|
|
30
|
+
}
|
|
31
|
+
) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = "McpUiError";
|
|
34
|
+
this.code = options.code;
|
|
35
|
+
this.context = options.context ?? {};
|
|
36
|
+
this.recoveryHint = options.recoveryHint;
|
|
37
|
+
this.cause = options.cause;
|
|
38
|
+
|
|
39
|
+
// Maintain proper stack trace
|
|
40
|
+
if (Error.captureStackTrace) {
|
|
41
|
+
Error.captureStackTrace(this, this.constructor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
toJSON(): Record<string, unknown> {
|
|
46
|
+
return {
|
|
47
|
+
name: this.name,
|
|
48
|
+
code: this.code,
|
|
49
|
+
message: this.message,
|
|
50
|
+
context: this.context,
|
|
51
|
+
recoveryHint: this.recoveryHint,
|
|
52
|
+
stack: this.stack,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Error fetching a UI resource from the MCP server.
|
|
59
|
+
*/
|
|
60
|
+
export class ResourceFetchError extends McpUiError {
|
|
61
|
+
constructor(
|
|
62
|
+
uri: string,
|
|
63
|
+
reason: string,
|
|
64
|
+
options?: { server?: string; cause?: Error }
|
|
65
|
+
) {
|
|
66
|
+
super(`Failed to fetch UI resource "${uri}": ${reason}`, {
|
|
67
|
+
code: "RESOURCE_FETCH_ERROR",
|
|
68
|
+
context: { uri, ...(options?.server !== undefined ? { server: options.server } : {}) },
|
|
69
|
+
recoveryHint: "Check that the MCP server is connected and the resource URI is valid.",
|
|
70
|
+
...(options?.cause !== undefined ? { cause: options.cause } : {}),
|
|
71
|
+
});
|
|
72
|
+
this.name = "ResourceFetchError";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Error parsing or validating UI resource content.
|
|
78
|
+
*/
|
|
79
|
+
export class ResourceParseError extends McpUiError {
|
|
80
|
+
constructor(
|
|
81
|
+
uri: string,
|
|
82
|
+
reason: string,
|
|
83
|
+
options?: { server?: string; mimeType?: string }
|
|
84
|
+
) {
|
|
85
|
+
super(`Invalid UI resource "${uri}": ${reason}`, {
|
|
86
|
+
code: "RESOURCE_PARSE_ERROR",
|
|
87
|
+
context: {
|
|
88
|
+
uri,
|
|
89
|
+
...(options?.server !== undefined ? { server: options.server } : {}),
|
|
90
|
+
...(options?.mimeType !== undefined ? { mimeType: options.mimeType } : {}),
|
|
91
|
+
},
|
|
92
|
+
recoveryHint: "Ensure the resource returns valid HTML with the correct MIME type.",
|
|
93
|
+
});
|
|
94
|
+
this.name = "ResourceParseError";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Error connecting to the AppBridge.
|
|
100
|
+
*/
|
|
101
|
+
export class BridgeConnectionError extends McpUiError {
|
|
102
|
+
constructor(reason: string, options?: { session?: string; cause?: Error }) {
|
|
103
|
+
super(`AppBridge connection failed: ${reason}`, {
|
|
104
|
+
code: "BRIDGE_CONNECTION_ERROR",
|
|
105
|
+
context: options?.session !== undefined ? { session: options.session } : {},
|
|
106
|
+
recoveryHint: "Check browser console for detailed errors. The iframe may have failed to load.",
|
|
107
|
+
...(options?.cause !== undefined ? { cause: options.cause } : {}),
|
|
108
|
+
});
|
|
109
|
+
this.name = "BridgeConnectionError";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Error related to user consent for tool calls.
|
|
115
|
+
*/
|
|
116
|
+
export class ConsentError extends McpUiError {
|
|
117
|
+
readonly denied: boolean;
|
|
118
|
+
|
|
119
|
+
constructor(
|
|
120
|
+
server: string,
|
|
121
|
+
options: { denied?: boolean; requiresApproval?: boolean }
|
|
122
|
+
) {
|
|
123
|
+
const message = options.denied
|
|
124
|
+
? `Tool calls for "${server}" were denied for this session`
|
|
125
|
+
: `Tool call approval required for "${server}"`;
|
|
126
|
+
|
|
127
|
+
super(message, {
|
|
128
|
+
code: options.denied ? "CONSENT_DENIED" : "CONSENT_REQUIRED",
|
|
129
|
+
context: { server },
|
|
130
|
+
recoveryHint: options.denied
|
|
131
|
+
? "The user denied tool access. Start a new session to try again."
|
|
132
|
+
: "Prompt the user for consent before calling tools.",
|
|
133
|
+
});
|
|
134
|
+
this.name = "ConsentError";
|
|
135
|
+
this.denied = options.denied ?? false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Error with UI server session management.
|
|
141
|
+
*/
|
|
142
|
+
export class SessionError extends McpUiError {
|
|
143
|
+
constructor(
|
|
144
|
+
reason: string,
|
|
145
|
+
options?: { session?: string; cause?: Error }
|
|
146
|
+
) {
|
|
147
|
+
super(`Session error: ${reason}`, {
|
|
148
|
+
code: "SESSION_ERROR",
|
|
149
|
+
context: options?.session !== undefined ? { session: options.session } : {},
|
|
150
|
+
recoveryHint: "The session may have expired or been closed. Try opening the UI again.",
|
|
151
|
+
...(options?.cause !== undefined ? { cause: options.cause } : {}),
|
|
152
|
+
});
|
|
153
|
+
this.name = "SessionError";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Error starting or operating the UI server.
|
|
159
|
+
*/
|
|
160
|
+
export class ServerError extends McpUiError {
|
|
161
|
+
constructor(
|
|
162
|
+
reason: string,
|
|
163
|
+
options?: { port?: number; cause?: Error }
|
|
164
|
+
) {
|
|
165
|
+
super(`UI server error: ${reason}`, {
|
|
166
|
+
code: "SERVER_ERROR",
|
|
167
|
+
context: options?.port !== undefined ? { port: options.port } : {},
|
|
168
|
+
recoveryHint: "Check if the port is available. Another process may be using it.",
|
|
169
|
+
...(options?.cause !== undefined ? { cause: options.cause } : {}),
|
|
170
|
+
});
|
|
171
|
+
this.name = "ServerError";
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Error communicating with the MCP server.
|
|
177
|
+
*/
|
|
178
|
+
export class McpServerError extends McpUiError {
|
|
179
|
+
constructor(
|
|
180
|
+
server: string,
|
|
181
|
+
reason: string,
|
|
182
|
+
options?: { tool?: string; cause?: Error }
|
|
183
|
+
) {
|
|
184
|
+
super(`MCP server "${server}" error: ${reason}`, {
|
|
185
|
+
code: "MCP_SERVER_ERROR",
|
|
186
|
+
context: { server, ...(options?.tool !== undefined ? { tool: options.tool } : {}) },
|
|
187
|
+
recoveryHint: "Check that the MCP server is running and responsive.",
|
|
188
|
+
...(options?.cause !== undefined ? { cause: options.cause } : {}),
|
|
189
|
+
});
|
|
190
|
+
this.name = "McpServerError";
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Wrap an unknown error into an McpUiError.
|
|
196
|
+
*/
|
|
197
|
+
export function wrapError(error: unknown, context?: McpUiErrorContext): McpUiError {
|
|
198
|
+
if (error instanceof McpUiError) {
|
|
199
|
+
// Merge contexts
|
|
200
|
+
return new McpUiError(error.message, {
|
|
201
|
+
code: error.code,
|
|
202
|
+
context: { ...error.context, ...context },
|
|
203
|
+
...(error.recoveryHint !== undefined ? { recoveryHint: error.recoveryHint } : {}),
|
|
204
|
+
...(error.cause !== undefined ? { cause: error.cause } : {}),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const cause = error instanceof Error ? error : undefined;
|
|
209
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
210
|
+
|
|
211
|
+
return new McpUiError(message, {
|
|
212
|
+
code: "UNKNOWN_ERROR",
|
|
213
|
+
...(context !== undefined ? { context } : {}),
|
|
214
|
+
...(cause !== undefined ? { cause } : {}),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Check if an error is a specific MCP UI error type.
|
|
220
|
+
*/
|
|
221
|
+
export function isErrorCode(error: unknown, code: string): boolean {
|
|
222
|
+
return error instanceof McpUiError && error.code === code;
|
|
223
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { join, dirname } from "node:path";
|
|
4
|
+
import { platform } from "node:os";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
|
|
7
|
+
let glimpseAvailable: boolean | null = null;
|
|
8
|
+
let resolvedBinaryPath: string | null = null;
|
|
9
|
+
|
|
10
|
+
export function isGlimpseAvailable(): boolean {
|
|
11
|
+
if (glimpseAvailable !== null) return glimpseAvailable;
|
|
12
|
+
|
|
13
|
+
if (platform() !== "darwin") {
|
|
14
|
+
glimpseAvailable = false;
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
resolvedBinaryPath = getGlimpseBinaryPath();
|
|
19
|
+
glimpseAvailable = resolvedBinaryPath !== null;
|
|
20
|
+
return glimpseAvailable;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getGlimpseBinaryPath(): string | null {
|
|
24
|
+
if (process.env.GLIMPSE_BINARY && existsSync(process.env.GLIMPSE_BINARY)) {
|
|
25
|
+
return process.env.GLIMPSE_BINARY;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Local node_modules
|
|
29
|
+
try {
|
|
30
|
+
const require = createRequire(import.meta.url);
|
|
31
|
+
const glimpseuiPath = require.resolve("glimpseui");
|
|
32
|
+
const binaryPath = join(dirname(glimpseuiPath), "glimpse");
|
|
33
|
+
if (existsSync(binaryPath)) return binaryPath;
|
|
34
|
+
} catch {}
|
|
35
|
+
|
|
36
|
+
// Global npm install
|
|
37
|
+
try {
|
|
38
|
+
const globalRoot = execFileSync("npm", ["root", "-g"], { encoding: "utf-8" }).trim();
|
|
39
|
+
const binaryPath = join(globalRoot, "glimpseui", "src", "glimpse");
|
|
40
|
+
if (existsSync(binaryPath)) return binaryPath;
|
|
41
|
+
} catch {}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function openGlimpseWindow(
|
|
47
|
+
html: string,
|
|
48
|
+
options: {
|
|
49
|
+
title: string;
|
|
50
|
+
width?: number;
|
|
51
|
+
height?: number;
|
|
52
|
+
onClosed: () => void;
|
|
53
|
+
},
|
|
54
|
+
) {
|
|
55
|
+
const modulePath = resolvedBinaryPath
|
|
56
|
+
? join(dirname(resolvedBinaryPath), "glimpse.mjs")
|
|
57
|
+
: "glimpseui";
|
|
58
|
+
const glimpse = await import(modulePath);
|
|
59
|
+
|
|
60
|
+
let active = true;
|
|
61
|
+
const win = glimpse.open(html, {
|
|
62
|
+
width: options.width ?? 900,
|
|
63
|
+
height: options.height ?? 700,
|
|
64
|
+
title: options.title,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
win.on("closed", () => {
|
|
68
|
+
if (!active) return;
|
|
69
|
+
active = false;
|
|
70
|
+
options.onClosed();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
close: () => {
|
|
75
|
+
if (!active) return;
|
|
76
|
+
active = false;
|
|
77
|
+
win.close();
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|