@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,570 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import net from "node:net";
|
|
4
|
+
import { UrlElicitationRequiredError, type CallToolResult } from "@modelcontextprotocol/client";
|
|
5
|
+
import type { McpExtensionState } from "./state.ts";
|
|
6
|
+
import {
|
|
7
|
+
createUiModelContextUpdate,
|
|
8
|
+
extractUiPromptText,
|
|
9
|
+
UI_STREAM_HOST_CONTEXT_KEY,
|
|
10
|
+
UI_STREAM_REQUEST_META_KEY,
|
|
11
|
+
UI_STREAM_STRUCTURED_CONTENT_KEY,
|
|
12
|
+
type UiHostContext,
|
|
13
|
+
type UiMessageParams,
|
|
14
|
+
type UiModelContextParams,
|
|
15
|
+
type UiStreamMode,
|
|
16
|
+
} from "./types.ts";
|
|
17
|
+
import { logger } from "./logger.ts";
|
|
18
|
+
import { startUiServer, type UiServerHandle } from "./ui-server.ts";
|
|
19
|
+
import { isGlimpseAvailable, openGlimpseWindow } from "./glimpse-ui.ts";
|
|
20
|
+
import type { SessionRecoveryDeps } from "./session-recovery.ts";
|
|
21
|
+
import { combineAbortSignals, isAbortError } from "./runtime-owner.ts";
|
|
22
|
+
import { throwIfAborted } from "./abort.ts";
|
|
23
|
+
|
|
24
|
+
let activeGlimpseWindow: { close(): void } | null = null;
|
|
25
|
+
|
|
26
|
+
export interface UiSessionRequest {
|
|
27
|
+
serverName: string;
|
|
28
|
+
toolName: string;
|
|
29
|
+
toolArgs: Record<string, unknown>;
|
|
30
|
+
uiResourceUri: string;
|
|
31
|
+
streamMode?: UiStreamMode;
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
onNeedsAuth?: SessionRecoveryDeps["onNeedsAuth"];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type UiSessionViewer = "browser" | "glimpse" | "suppressed";
|
|
37
|
+
|
|
38
|
+
export interface UiSessionRuntime {
|
|
39
|
+
serverName: string;
|
|
40
|
+
toolName: string;
|
|
41
|
+
reused: boolean;
|
|
42
|
+
streamId?: string;
|
|
43
|
+
streamToken?: string;
|
|
44
|
+
streamMode?: UiStreamMode;
|
|
45
|
+
requestMeta?: Record<string, unknown>;
|
|
46
|
+
url: string;
|
|
47
|
+
viewer: UiSessionViewer;
|
|
48
|
+
windowOpen: boolean;
|
|
49
|
+
isActive: () => boolean;
|
|
50
|
+
sendToolResult: (result: CallToolResult) => void;
|
|
51
|
+
sendResultPatch: (result: CallToolResult) => void;
|
|
52
|
+
sendToolCancelled: (reason: string) => void;
|
|
53
|
+
close: (reason?: string) => void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface UiSessionResultSummary {
|
|
57
|
+
message: string;
|
|
58
|
+
uiOpen: boolean;
|
|
59
|
+
uiViewer?: UiSessionViewer;
|
|
60
|
+
uiUrl?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function summarizeUiSessionResult(uiSession: UiSessionRuntime | null): UiSessionResultSummary {
|
|
64
|
+
if (!uiSession) {
|
|
65
|
+
return {
|
|
66
|
+
message: "Interactive UI was unavailable; returning the tool result inline.",
|
|
67
|
+
uiOpen: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!uiSession.windowOpen) {
|
|
72
|
+
const action = uiSession.reused ? "Updated the suppressed MCP UI session." : "MCP UI window was suppressed.";
|
|
73
|
+
return {
|
|
74
|
+
message: `${action} Open manually: ${uiSession.url}`,
|
|
75
|
+
uiOpen: false,
|
|
76
|
+
uiViewer: uiSession.viewer,
|
|
77
|
+
uiUrl: uiSession.url,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
message: uiSession.reused
|
|
83
|
+
? "Updated the open UI."
|
|
84
|
+
: "Interactive UI is open. I'll respond to your prompts and intents as you interact with it.",
|
|
85
|
+
uiOpen: true,
|
|
86
|
+
uiViewer: uiSession.viewer,
|
|
87
|
+
uiUrl: uiSession.url,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const MAX_COMPLETED_SESSIONS = 10;
|
|
92
|
+
|
|
93
|
+
function withStreamEnvelope(
|
|
94
|
+
result: CallToolResult,
|
|
95
|
+
streamId: string | undefined,
|
|
96
|
+
sequence: number,
|
|
97
|
+
): CallToolResult {
|
|
98
|
+
if (!streamId) {
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const structuredContent: Record<string, unknown> = result.structuredContent
|
|
103
|
+
&& typeof result.structuredContent === "object"
|
|
104
|
+
&& !Array.isArray(result.structuredContent)
|
|
105
|
+
? { ...(result.structuredContent as Record<string, unknown>) }
|
|
106
|
+
: {};
|
|
107
|
+
|
|
108
|
+
const rawEnvelope = structuredContent[UI_STREAM_STRUCTURED_CONTENT_KEY];
|
|
109
|
+
const envelope = rawEnvelope && typeof rawEnvelope === "object" && !Array.isArray(rawEnvelope)
|
|
110
|
+
? { ...rawEnvelope as Record<string, unknown> }
|
|
111
|
+
: {
|
|
112
|
+
frameType: "final",
|
|
113
|
+
phase: "settled",
|
|
114
|
+
status: result.isError ? "error" : "ok",
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
structuredContent[UI_STREAM_STRUCTURED_CONTENT_KEY] = {
|
|
118
|
+
...envelope,
|
|
119
|
+
streamId,
|
|
120
|
+
sequence,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
...result,
|
|
125
|
+
structuredContent,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function openInBrowser(state: McpExtensionState, url: string, signal: AbortSignal): Promise<string | null> {
|
|
130
|
+
throwIfAborted(signal);
|
|
131
|
+
try {
|
|
132
|
+
await state.openBrowser(url);
|
|
133
|
+
throwIfAborted(signal);
|
|
134
|
+
return null;
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (isAbortError(error, signal)) throw error;
|
|
137
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
138
|
+
if (state.owner?.isActive() === false) return null;
|
|
139
|
+
state.ui?.notify(`MCP UI browser open failed: ${message}`, "warning");
|
|
140
|
+
return message;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isRemoteSession(): boolean {
|
|
145
|
+
return Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function hasActiveRemoteLogin(): Promise<boolean> {
|
|
149
|
+
return new Promise((resolve) => {
|
|
150
|
+
execFile("who", { encoding: "utf8", timeout: 2000 }, (error, out) => {
|
|
151
|
+
if (error) {
|
|
152
|
+
resolve(false);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
resolve(/\(.+\)\s*$/m.test(out));
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function probeMoshiGateway(): Promise<boolean> {
|
|
161
|
+
return new Promise((resolve) => {
|
|
162
|
+
const socket = net.connect({ host: "127.0.0.1", port: 24543 });
|
|
163
|
+
const done = (ok: boolean) => {
|
|
164
|
+
socket.destroy();
|
|
165
|
+
resolve(ok);
|
|
166
|
+
};
|
|
167
|
+
socket.setTimeout(300);
|
|
168
|
+
socket.once("connect", () => done(true));
|
|
169
|
+
socket.once("timeout", () => done(false));
|
|
170
|
+
socket.once("error", () => done(false));
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function remoteAccessHint(opts: { url: string; port: number; moshi: boolean; openError: string | null; openedOnHost?: boolean }): string {
|
|
175
|
+
const lines = [
|
|
176
|
+
opts.openError !== null
|
|
177
|
+
? "Couldn't open MCP UI here. Open it from your own device:"
|
|
178
|
+
: opts.openedOnHost
|
|
179
|
+
? "MCP UI opened on this host. If you're controlling this session remotely, open it from your own device:"
|
|
180
|
+
: "This looks like a remote session - if no MCP UI appeared, open it from your own device:",
|
|
181
|
+
` ${opts.url}`,
|
|
182
|
+
];
|
|
183
|
+
if (opts.openError !== null) {
|
|
184
|
+
lines.push(`Browser launch failed: ${opts.openError}`);
|
|
185
|
+
}
|
|
186
|
+
if (opts.moshi) {
|
|
187
|
+
lines.push("Moshi: tap the preview button in the terminal title bar and pick this MCP UI server.");
|
|
188
|
+
}
|
|
189
|
+
lines.push(
|
|
190
|
+
`SSH: run \`ssh -L ${opts.port}:127.0.0.1:${opts.port} <this-host>\` on your local machine, then open the URL above.`,
|
|
191
|
+
"mosh can't forward ports - run that ssh command in a separate terminal.",
|
|
192
|
+
);
|
|
193
|
+
return lines.join("\n");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export async function maybeStartUiSession(
|
|
197
|
+
state: McpExtensionState,
|
|
198
|
+
request: UiSessionRequest,
|
|
199
|
+
): Promise<UiSessionRuntime | null> {
|
|
200
|
+
const log = logger.child({
|
|
201
|
+
component: "UiSession",
|
|
202
|
+
server: request.serverName,
|
|
203
|
+
tool: request.toolName,
|
|
204
|
+
});
|
|
205
|
+
const runtimeSignal = combineAbortSignals(state.owner?.signal, request.signal) ?? new AbortController().signal;
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
throwIfAborted(runtimeSignal);
|
|
209
|
+
if (
|
|
210
|
+
state.uiServer &&
|
|
211
|
+
state.uiServer.serverName === request.serverName &&
|
|
212
|
+
state.uiServer.toolName === request.toolName
|
|
213
|
+
) {
|
|
214
|
+
const existingHandle = state.uiServer;
|
|
215
|
+
const streamMode = request.streamMode;
|
|
216
|
+
const streamId = streamMode ? randomUUID() : undefined;
|
|
217
|
+
const streamToken = streamMode ? randomUUID() : undefined;
|
|
218
|
+
let active = true;
|
|
219
|
+
let nextStreamSequence = 0;
|
|
220
|
+
|
|
221
|
+
const cleanupStreamListener = () => {
|
|
222
|
+
if (streamToken) {
|
|
223
|
+
state.manager.removeUiStreamListener(streamToken);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
existingHandle.sendToolInput(request.toolArgs);
|
|
228
|
+
|
|
229
|
+
if (streamToken) {
|
|
230
|
+
state.manager.registerUiStreamListener(streamToken, (serverName, notification) => {
|
|
231
|
+
if (!active || state.uiServer !== existingHandle) return;
|
|
232
|
+
if (serverName !== request.serverName) return;
|
|
233
|
+
nextStreamSequence += 1;
|
|
234
|
+
existingHandle.sendResultPatch(
|
|
235
|
+
withStreamEnvelope(notification.result as CallToolResult, streamId, nextStreamSequence),
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
serverName: request.serverName,
|
|
242
|
+
toolName: request.toolName,
|
|
243
|
+
reused: true,
|
|
244
|
+
...(streamId !== undefined ? { streamId } : {}),
|
|
245
|
+
...(streamToken !== undefined ? { streamToken } : {}),
|
|
246
|
+
...(streamMode !== undefined ? { streamMode } : {}),
|
|
247
|
+
...(streamToken ? { requestMeta: { [UI_STREAM_REQUEST_META_KEY]: streamToken } } : {}),
|
|
248
|
+
url: existingHandle.url,
|
|
249
|
+
viewer: existingHandle.viewer ?? "browser",
|
|
250
|
+
windowOpen: existingHandle.windowOpen ?? true,
|
|
251
|
+
isActive: () => active && state.uiServer === existingHandle,
|
|
252
|
+
sendToolResult: (result: CallToolResult) => {
|
|
253
|
+
if (!active || state.uiServer !== existingHandle) return;
|
|
254
|
+
nextStreamSequence += 1;
|
|
255
|
+
existingHandle.sendToolResult(withStreamEnvelope(result, streamId, nextStreamSequence));
|
|
256
|
+
},
|
|
257
|
+
sendResultPatch: (result: CallToolResult) => {
|
|
258
|
+
if (!active || state.uiServer !== existingHandle) return;
|
|
259
|
+
nextStreamSequence += 1;
|
|
260
|
+
existingHandle.sendResultPatch(withStreamEnvelope(result, streamId, nextStreamSequence));
|
|
261
|
+
},
|
|
262
|
+
sendToolCancelled: (reason: string) => {
|
|
263
|
+
if (!active || state.uiServer !== existingHandle) return;
|
|
264
|
+
nextStreamSequence += 1;
|
|
265
|
+
existingHandle.sendToolResult(
|
|
266
|
+
withStreamEnvelope(
|
|
267
|
+
{
|
|
268
|
+
isError: true,
|
|
269
|
+
content: [{ type: "text", text: reason }],
|
|
270
|
+
},
|
|
271
|
+
streamId,
|
|
272
|
+
nextStreamSequence,
|
|
273
|
+
),
|
|
274
|
+
);
|
|
275
|
+
},
|
|
276
|
+
close: () => {
|
|
277
|
+
active = false;
|
|
278
|
+
cleanupStreamListener();
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const resource = await state.uiResourceHandler.readUiResource(request.serverName, request.uiResourceUri, {
|
|
284
|
+
config: state.config,
|
|
285
|
+
signal: runtimeSignal,
|
|
286
|
+
onNeedsAuth: request.onNeedsAuth,
|
|
287
|
+
});
|
|
288
|
+
throwIfAborted(runtimeSignal);
|
|
289
|
+
|
|
290
|
+
if (state.uiServer) {
|
|
291
|
+
state.uiServer.close("replaced");
|
|
292
|
+
state.uiServer = null;
|
|
293
|
+
}
|
|
294
|
+
if (activeGlimpseWindow) {
|
|
295
|
+
activeGlimpseWindow.close();
|
|
296
|
+
activeGlimpseWindow = null;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const streamMode = request.streamMode;
|
|
300
|
+
const streamId = streamMode ? randomUUID() : undefined;
|
|
301
|
+
const streamToken = streamMode ? randomUUID() : undefined;
|
|
302
|
+
const hostContext: UiHostContext | undefined = streamMode && streamId
|
|
303
|
+
? {
|
|
304
|
+
[UI_STREAM_HOST_CONTEXT_KEY]: {
|
|
305
|
+
mode: streamMode,
|
|
306
|
+
streamId,
|
|
307
|
+
intermediateResultPatches: streamMode === "stream-first",
|
|
308
|
+
partialInput: false,
|
|
309
|
+
},
|
|
310
|
+
}
|
|
311
|
+
: undefined;
|
|
312
|
+
|
|
313
|
+
let active = true;
|
|
314
|
+
let nextStreamSequence = 0;
|
|
315
|
+
let handle: UiServerHandle;
|
|
316
|
+
|
|
317
|
+
const cleanupStreamListener = () => {
|
|
318
|
+
if (streamToken) {
|
|
319
|
+
state.manager.removeUiStreamListener(streamToken);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
handle = await startUiServer({
|
|
324
|
+
serverName: request.serverName,
|
|
325
|
+
toolName: request.toolName,
|
|
326
|
+
toolArgs: streamMode === "stream-first" ? {} : request.toolArgs,
|
|
327
|
+
resource,
|
|
328
|
+
manager: state.manager,
|
|
329
|
+
config: state.config,
|
|
330
|
+
state,
|
|
331
|
+
...(request.onNeedsAuth ? { onNeedsAuth: request.onNeedsAuth } : {}),
|
|
332
|
+
consentManager: state.consentManager,
|
|
333
|
+
...(hostContext !== undefined ? { hostContext } : {}),
|
|
334
|
+
|
|
335
|
+
onMessage: (params: UiMessageParams) => {
|
|
336
|
+
const prompt = extractUiPromptText(params);
|
|
337
|
+
if (prompt) {
|
|
338
|
+
if (state.sendMessage) {
|
|
339
|
+
state.sendMessage(
|
|
340
|
+
{
|
|
341
|
+
customType: "mcp-ui-prompt",
|
|
342
|
+
content: [{ type: "text", text: `User sent prompt from ${request.serverName} UI: "${prompt}"` }],
|
|
343
|
+
display: `💬 UI Prompt: ${prompt}`,
|
|
344
|
+
details: { server: request.serverName, tool: request.toolName, prompt },
|
|
345
|
+
},
|
|
346
|
+
{ triggerTurn: true },
|
|
347
|
+
);
|
|
348
|
+
log.debug("Triggered agent turn for UI prompt", { prompt: prompt.slice(0, 50) });
|
|
349
|
+
}
|
|
350
|
+
} else if (params.type === "intent" || params.intent) {
|
|
351
|
+
const intent = params.intent ?? "";
|
|
352
|
+
const intentParams = params.params;
|
|
353
|
+
if (intent && state.sendMessage) {
|
|
354
|
+
const paramsStr = intentParams ? ` ${JSON.stringify(intentParams)}` : "";
|
|
355
|
+
state.sendMessage(
|
|
356
|
+
{
|
|
357
|
+
customType: "mcp-ui-intent",
|
|
358
|
+
content: [{ type: "text", text: `User triggered intent from ${request.serverName} UI: ${intent}${paramsStr}` }],
|
|
359
|
+
display: `🎯 UI Intent: ${intent}`,
|
|
360
|
+
details: { server: request.serverName, tool: request.toolName, intent, params: intentParams },
|
|
361
|
+
},
|
|
362
|
+
{ triggerTurn: true },
|
|
363
|
+
);
|
|
364
|
+
log.debug("Triggered agent turn for UI intent", { intent });
|
|
365
|
+
}
|
|
366
|
+
} else if (params.type === "notify" || params.message) {
|
|
367
|
+
const text = params.message ?? "";
|
|
368
|
+
if (text && state.ui) {
|
|
369
|
+
state.ui.notify(`[${request.serverName}] ${text}`, "info");
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
onContextUpdate: (params: UiModelContextParams) => {
|
|
375
|
+
const update = createUiModelContextUpdate(params);
|
|
376
|
+
log.debug("Model context update from UI", {
|
|
377
|
+
hasContent: !!params.content,
|
|
378
|
+
hasStructured: !!params.structuredContent,
|
|
379
|
+
hasUpdate: !!update,
|
|
380
|
+
});
|
|
381
|
+
if (update && state.sendMessage) {
|
|
382
|
+
state.sendMessage(
|
|
383
|
+
{
|
|
384
|
+
customType: "mcp-ui-context",
|
|
385
|
+
content: [{ type: "text", text: `User submitted model context from ${request.serverName} UI:\n${update.summary}` }],
|
|
386
|
+
display: "UI Context submitted",
|
|
387
|
+
details: { server: request.serverName, tool: request.toolName, context: update },
|
|
388
|
+
},
|
|
389
|
+
{ triggerTurn: true },
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
onComplete: (reason: string) => {
|
|
395
|
+
active = false;
|
|
396
|
+
cleanupStreamListener();
|
|
397
|
+
|
|
398
|
+
if (state.uiServer === handle) {
|
|
399
|
+
const messages = handle.getSessionMessages();
|
|
400
|
+
const stream = handle.getStreamSummary();
|
|
401
|
+
const hasContent =
|
|
402
|
+
messages.prompts.length > 0 ||
|
|
403
|
+
messages.intents.length > 0 ||
|
|
404
|
+
messages.notifications.length > 0 ||
|
|
405
|
+
messages.contexts.length > 0 ||
|
|
406
|
+
!!stream;
|
|
407
|
+
|
|
408
|
+
if (hasContent) {
|
|
409
|
+
state.completedUiSessions.push({
|
|
410
|
+
serverName: handle.serverName,
|
|
411
|
+
toolName: handle.toolName,
|
|
412
|
+
completedAt: new Date(),
|
|
413
|
+
reason,
|
|
414
|
+
messages,
|
|
415
|
+
...(stream !== undefined ? { stream } : {}),
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
while (state.completedUiSessions.length > MAX_COMPLETED_SESSIONS) {
|
|
419
|
+
state.completedUiSessions.shift();
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
log.debug("Session completed", {
|
|
423
|
+
reason,
|
|
424
|
+
prompts: messages.prompts.length,
|
|
425
|
+
intents: messages.intents.length,
|
|
426
|
+
notifications: messages.notifications.length,
|
|
427
|
+
contexts: messages.contexts.length,
|
|
428
|
+
streamFrames: stream?.frames ?? 0,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
state.uiServer = null;
|
|
433
|
+
if (activeGlimpseWindow) {
|
|
434
|
+
activeGlimpseWindow.close();
|
|
435
|
+
activeGlimpseWindow = null;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
if (state.owner?.isActive() === false || runtimeSignal.aborted) {
|
|
442
|
+
handle.close("runtime_owner_stopped");
|
|
443
|
+
throwIfAborted(runtimeSignal);
|
|
444
|
+
throw new Error("MCP UI session became stale before registration");
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (streamToken) {
|
|
448
|
+
state.manager.registerUiStreamListener(streamToken, (serverName, notification) => {
|
|
449
|
+
if (!active || state.uiServer !== handle) return;
|
|
450
|
+
if (serverName !== request.serverName) return;
|
|
451
|
+
nextStreamSequence += 1;
|
|
452
|
+
handle.sendResultPatch(withStreamEnvelope(notification.result as CallToolResult, streamId, nextStreamSequence));
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
state.uiServer = handle;
|
|
457
|
+
|
|
458
|
+
const viewerPref = process.env.MCP_UI_VIEWER?.toLowerCase();
|
|
459
|
+
const uiSuppressed = viewerPref === "none" || viewerPref === "off" || viewerPref === "disabled";
|
|
460
|
+
|
|
461
|
+
let viewer: UiSessionViewer = "browser";
|
|
462
|
+
let windowOpen = true;
|
|
463
|
+
const remoteByEnv = isRemoteSession();
|
|
464
|
+
|
|
465
|
+
if (uiSuppressed) {
|
|
466
|
+
viewer = "suppressed";
|
|
467
|
+
windowOpen = false;
|
|
468
|
+
state.ui?.notify(`MCP UI window suppressed (MCP_UI_VIEWER=${viewerPref}). Open manually: ${handle.url}`, "info");
|
|
469
|
+
log.info("Suppressing MCP UI window (MCP_UI_VIEWER=" + viewerPref + ")", { url: handle.url });
|
|
470
|
+
} else {
|
|
471
|
+
const remoteLikely = remoteByEnv || await hasActiveRemoteLogin();
|
|
472
|
+
const emitRemoteHint = async (openError: string | null, openedOnHost = false) => {
|
|
473
|
+
state.ui?.notify(remoteAccessHint({
|
|
474
|
+
url: handle.url,
|
|
475
|
+
port: handle.port,
|
|
476
|
+
moshi: await probeMoshiGateway(),
|
|
477
|
+
openError,
|
|
478
|
+
openedOnHost,
|
|
479
|
+
}), openError === null ? "info" : "warning");
|
|
480
|
+
};
|
|
481
|
+
const glimpseDetected = !remoteByEnv && isGlimpseAvailable();
|
|
482
|
+
const useGlimpse = !remoteByEnv && (viewerPref === "glimpse" ||
|
|
483
|
+
(viewerPref !== "browser" && glimpseDetected));
|
|
484
|
+
|
|
485
|
+
if (useGlimpse) {
|
|
486
|
+
try {
|
|
487
|
+
const glimpseHtml = `<!DOCTYPE html><html><head><meta charset="utf-8"><style>body{margin:0;padding:0;width:100vw;height:100vh;overflow:hidden}iframe{width:100%;height:100%;border:none}</style></head><body><iframe src="${handle.url}"></iframe></body></html>`;
|
|
488
|
+
const glimpseWindow = await openGlimpseWindow(glimpseHtml, {
|
|
489
|
+
title: `MCP · ${request.serverName} · ${request.toolName}`,
|
|
490
|
+
width: 1000,
|
|
491
|
+
height: 800,
|
|
492
|
+
onClosed: () => {
|
|
493
|
+
if (active) handle.close("glimpse-closed");
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
if (state.owner?.isActive() === false || runtimeSignal.aborted) {
|
|
497
|
+
glimpseWindow.close();
|
|
498
|
+
throwIfAborted(runtimeSignal);
|
|
499
|
+
throw new Error("MCP Glimpse window became stale before registration");
|
|
500
|
+
}
|
|
501
|
+
activeGlimpseWindow = glimpseWindow;
|
|
502
|
+
viewer = "glimpse";
|
|
503
|
+
if (remoteLikely) {
|
|
504
|
+
await emitRemoteHint(null, true);
|
|
505
|
+
}
|
|
506
|
+
} catch (error) {
|
|
507
|
+
log.debug("Glimpse unavailable, using browser", {
|
|
508
|
+
error: error instanceof Error ? error.message : String(error),
|
|
509
|
+
});
|
|
510
|
+
const openError = await openInBrowser(state, handle.url, runtimeSignal);
|
|
511
|
+
if (openError !== null || remoteLikely) {
|
|
512
|
+
await emitRemoteHint(openError);
|
|
513
|
+
}
|
|
514
|
+
viewer = "browser";
|
|
515
|
+
}
|
|
516
|
+
} else {
|
|
517
|
+
const openError = await openInBrowser(state, handle.url, runtimeSignal);
|
|
518
|
+
if (openError !== null || remoteLikely) {
|
|
519
|
+
await emitRemoteHint(openError);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
throwIfAborted(runtimeSignal);
|
|
525
|
+
handle.viewer = viewer;
|
|
526
|
+
handle.windowOpen = windowOpen;
|
|
527
|
+
|
|
528
|
+
return {
|
|
529
|
+
serverName: request.serverName,
|
|
530
|
+
toolName: request.toolName,
|
|
531
|
+
reused: false,
|
|
532
|
+
...(streamId !== undefined ? { streamId } : {}),
|
|
533
|
+
...(streamToken !== undefined ? { streamToken } : {}),
|
|
534
|
+
...(streamMode !== undefined ? { streamMode } : {}),
|
|
535
|
+
...(streamToken ? { requestMeta: { [UI_STREAM_REQUEST_META_KEY]: streamToken } } : {}),
|
|
536
|
+
url: handle.url,
|
|
537
|
+
viewer,
|
|
538
|
+
windowOpen,
|
|
539
|
+
isActive: () => active && state.uiServer === handle,
|
|
540
|
+
sendToolResult: (result: CallToolResult) => {
|
|
541
|
+
if (!active || state.uiServer !== handle) return;
|
|
542
|
+
nextStreamSequence += 1;
|
|
543
|
+
handle.sendToolResult(withStreamEnvelope(result, streamId, nextStreamSequence));
|
|
544
|
+
},
|
|
545
|
+
sendResultPatch: (result: CallToolResult) => {
|
|
546
|
+
if (!active || state.uiServer !== handle) return;
|
|
547
|
+
nextStreamSequence += 1;
|
|
548
|
+
handle.sendResultPatch(withStreamEnvelope(result, streamId, nextStreamSequence));
|
|
549
|
+
},
|
|
550
|
+
sendToolCancelled: (reason: string) => {
|
|
551
|
+
if (!active || state.uiServer !== handle) return;
|
|
552
|
+
handle.sendToolCancelled(reason);
|
|
553
|
+
},
|
|
554
|
+
close: (reason?: string) => {
|
|
555
|
+
active = false;
|
|
556
|
+
cleanupStreamListener();
|
|
557
|
+
handle.close(reason);
|
|
558
|
+
},
|
|
559
|
+
};
|
|
560
|
+
} catch (error) {
|
|
561
|
+
if (error instanceof UrlElicitationRequiredError || isAbortError(error, runtimeSignal)) throw error;
|
|
562
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
563
|
+
log.error("Failed to start UI session", error instanceof Error ? error : undefined);
|
|
564
|
+
state.ui?.notify(
|
|
565
|
+
`MCP UI unavailable for ${request.toolName} (${request.serverName}): ${message}`,
|
|
566
|
+
"warning",
|
|
567
|
+
);
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const UI_STREAM_HOST_CONTEXT_KEY = "pi-mcp-adapter/stream";
|
|
4
|
+
export const UI_STREAM_REQUEST_META_KEY = "pi-mcp-adapter/stream-token";
|
|
5
|
+
export const UI_STREAM_RESULT_PATCH_METHOD = "notifications/pi-mcp-adapter/ui-result-patch";
|
|
6
|
+
export const SERVER_STREAM_RESULT_PATCH_METHOD = "notifications/pi-mcp-adapter/result-patch";
|
|
7
|
+
export const UI_STREAM_STRUCTURED_CONTENT_KEY = "pi-mcp-adapter/stream";
|
|
8
|
+
|
|
9
|
+
export const uiStreamModeSchema = z.enum(["eager", "stream-first"]);
|
|
10
|
+
export type UiStreamMode = z.infer<typeof uiStreamModeSchema>;
|
|
11
|
+
|
|
12
|
+
export const visualizationStreamPhaseSchema = z.enum(["shell", "narrative", "structure", "detail", "settled"]);
|
|
13
|
+
export type VisualizationStreamPhase = z.infer<typeof visualizationStreamPhaseSchema>;
|
|
14
|
+
|
|
15
|
+
export const visualizationStreamFrameTypeSchema = z.enum(["patch", "checkpoint", "final"]);
|
|
16
|
+
export type VisualizationStreamFrameType = z.infer<typeof visualizationStreamFrameTypeSchema>;
|
|
17
|
+
|
|
18
|
+
export const visualizationStreamStatusSchema = z.enum(["ok", "error"]);
|
|
19
|
+
export type VisualizationStreamStatus = z.infer<typeof visualizationStreamStatusSchema>;
|
|
20
|
+
|
|
21
|
+
const looseRecordSchema = z.record(z.string(), z.unknown());
|
|
22
|
+
const looseArraySchema = z.array(z.unknown());
|
|
23
|
+
|
|
24
|
+
export const uiStreamHostContextSchema = z.object({
|
|
25
|
+
mode: uiStreamModeSchema,
|
|
26
|
+
streamId: z.string().min(1),
|
|
27
|
+
intermediateResultPatches: z.boolean(),
|
|
28
|
+
partialInput: z.boolean(),
|
|
29
|
+
});
|
|
30
|
+
export type UiStreamHostContext = z.infer<typeof uiStreamHostContextSchema>;
|
|
31
|
+
|
|
32
|
+
export const visualizationStreamEnvelopeSchema = z.object({
|
|
33
|
+
streamId: z.string().min(1),
|
|
34
|
+
sequence: z.number().int().nonnegative(),
|
|
35
|
+
frameType: visualizationStreamFrameTypeSchema,
|
|
36
|
+
phase: visualizationStreamPhaseSchema,
|
|
37
|
+
status: visualizationStreamStatusSchema,
|
|
38
|
+
message: z.string().optional(),
|
|
39
|
+
spec: looseRecordSchema.optional(),
|
|
40
|
+
checkpoint: looseRecordSchema.optional(),
|
|
41
|
+
});
|
|
42
|
+
export type VisualizationStreamEnvelope = z.infer<typeof visualizationStreamEnvelopeSchema>;
|
|
43
|
+
|
|
44
|
+
export const uiStreamCallToolResultSchema = z.object({
|
|
45
|
+
content: looseArraySchema.optional(),
|
|
46
|
+
structuredContent: looseRecordSchema.optional(),
|
|
47
|
+
isError: z.boolean().optional(),
|
|
48
|
+
_meta: looseRecordSchema.optional(),
|
|
49
|
+
}).passthrough();
|
|
50
|
+
export type UiStreamCallToolResult = z.infer<typeof uiStreamCallToolResultSchema>;
|
|
51
|
+
|
|
52
|
+
export const uiStreamResultPatchNotificationSchema = z.object({
|
|
53
|
+
method: z.literal(UI_STREAM_RESULT_PATCH_METHOD),
|
|
54
|
+
params: uiStreamCallToolResultSchema,
|
|
55
|
+
});
|
|
56
|
+
export type UiStreamResultPatchNotification = z.infer<typeof uiStreamResultPatchNotificationSchema>;
|
|
57
|
+
|
|
58
|
+
export const serverStreamResultPatchNotificationSchema = z.object({
|
|
59
|
+
method: z.literal(SERVER_STREAM_RESULT_PATCH_METHOD),
|
|
60
|
+
params: z.object({
|
|
61
|
+
streamToken: z.string().min(1),
|
|
62
|
+
result: uiStreamCallToolResultSchema,
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
export type ServerStreamResultPatchNotification = z.infer<typeof serverStreamResultPatchNotificationSchema>;
|
|
66
|
+
|
|
67
|
+
export interface UiStreamSummary {
|
|
68
|
+
streamId: string;
|
|
69
|
+
mode: UiStreamMode;
|
|
70
|
+
frames: number;
|
|
71
|
+
phases: VisualizationStreamPhase[];
|
|
72
|
+
finalStatus?: VisualizationStreamStatus;
|
|
73
|
+
lastMessage?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function getUiStreamHostContext(hostContext: Record<string, unknown> | undefined): UiStreamHostContext | undefined {
|
|
77
|
+
const candidate = hostContext?.[UI_STREAM_HOST_CONTEXT_KEY];
|
|
78
|
+
const parsed = uiStreamHostContextSchema.safeParse(candidate);
|
|
79
|
+
return parsed.success ? parsed.data : undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function getVisualizationStreamEnvelope(structuredContent: unknown): VisualizationStreamEnvelope | undefined {
|
|
83
|
+
if (!structuredContent || typeof structuredContent !== "object" || Array.isArray(structuredContent)) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const candidate = (structuredContent as Record<string, unknown>)[UI_STREAM_STRUCTURED_CONTENT_KEY];
|
|
87
|
+
const parsed = visualizationStreamEnvelopeSchema.safeParse(candidate);
|
|
88
|
+
return parsed.success ? parsed.data : undefined;
|
|
89
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type UiToolVisibility = "model" | "app";
|
|
2
|
+
|
|
3
|
+
export function extractUiToolVisibility(meta: Record<string, unknown> | undefined): UiToolVisibility[] | undefined {
|
|
4
|
+
if (!meta || typeof meta !== "object") return undefined;
|
|
5
|
+
const ui = meta.ui;
|
|
6
|
+
if (!ui || typeof ui !== "object" || Array.isArray(ui)) return undefined;
|
|
7
|
+
const visibility = (ui as Record<string, unknown>).visibility;
|
|
8
|
+
if (visibility === undefined) return undefined;
|
|
9
|
+
if (!Array.isArray(visibility)) return [];
|
|
10
|
+
|
|
11
|
+
const values: UiToolVisibility[] = [];
|
|
12
|
+
for (const entry of visibility) {
|
|
13
|
+
if (entry !== "model" && entry !== "app") return [];
|
|
14
|
+
if (!values.includes(entry)) values.push(entry);
|
|
15
|
+
}
|
|
16
|
+
return values;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isUiToolVisibleToModel(visibility: readonly UiToolVisibility[] | undefined): boolean {
|
|
20
|
+
return visibility === undefined || visibility.includes("model");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isUiToolCallableByApp(visibility: readonly UiToolVisibility[] | undefined): boolean {
|
|
24
|
+
return visibility === undefined || visibility.includes("app");
|
|
25
|
+
}
|