@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,354 @@
|
|
|
1
|
+
import type { ToolInfo } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { formatWithOptions } from "node:util";
|
|
3
|
+
import { Worker } from "node:worker_threads";
|
|
4
|
+
import { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from "./mcp-output-guard.ts";
|
|
5
|
+
import { executeCall } from "./proxy-modes.ts";
|
|
6
|
+
import { combineAbortSignals } from "./runtime-owner.ts";
|
|
7
|
+
import { paginate, rankSuggestions, rankToolMatches } from "./search-ranking.ts";
|
|
8
|
+
import type { McpExtensionState } from "./state.ts";
|
|
9
|
+
import { findToolByName, formatSchema } from "./tool-metadata.ts";
|
|
10
|
+
import { renderTsShape } from "./ts-shape.ts";
|
|
11
|
+
import type { ContentBlock } from "./types.ts";
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_MCP_SCRIPT_TIMEOUT_MS = 30_000;
|
|
14
|
+
|
|
15
|
+
class McpScriptTimeoutError extends Error {
|
|
16
|
+
constructor(timeoutMs: number) {
|
|
17
|
+
super(`mcpScript timed out after ${timeoutMs}ms`);
|
|
18
|
+
this.name = "McpScriptTimeoutError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type SearchInput = { query?: unknown; server?: unknown; limit?: unknown; offset?: unknown };
|
|
23
|
+
type DescribeInput = { path?: unknown };
|
|
24
|
+
type WorkerMessage =
|
|
25
|
+
| { type: "emit"; block: unknown }
|
|
26
|
+
| { type: "call"; id: number; path: string; args?: unknown }
|
|
27
|
+
| { type: "search"; id: number; input?: unknown }
|
|
28
|
+
| { type: "describe"; id: number; input?: unknown }
|
|
29
|
+
| { type: "done"; returnBlock?: unknown }
|
|
30
|
+
| { type: "error"; message: string };
|
|
31
|
+
|
|
32
|
+
type WorkerResultMessage = { type: "result"; id: number; envelope: unknown };
|
|
33
|
+
|
|
34
|
+
function needsInspectableFormatting(value: unknown, stack = new WeakSet<object>()): boolean {
|
|
35
|
+
if (value === undefined || typeof value === "bigint" || typeof value === "function" || typeof value === "symbol") return true;
|
|
36
|
+
if (typeof value !== "object" || value === null) return false;
|
|
37
|
+
if (stack.has(value)) return true;
|
|
38
|
+
if (value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) return true;
|
|
39
|
+
stack.add(value);
|
|
40
|
+
try {
|
|
41
|
+
return Object.values(value).some((entry) => needsInspectableFormatting(entry, stack));
|
|
42
|
+
} finally {
|
|
43
|
+
stack.delete(value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function formatValue(value: unknown): string {
|
|
48
|
+
if (typeof value === "string") return value;
|
|
49
|
+
try {
|
|
50
|
+
if (!needsInspectableFormatting(value)) {
|
|
51
|
+
const json = JSON.stringify(value, null, 2);
|
|
52
|
+
if (json !== undefined) return json;
|
|
53
|
+
}
|
|
54
|
+
return formatWithOptions({ colors: false, depth: 6 }, value);
|
|
55
|
+
} catch {
|
|
56
|
+
return "[unserializable value]";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function toContentBlock(value: unknown): ContentBlock {
|
|
61
|
+
if (typeof value === "object" && value !== null) {
|
|
62
|
+
const block = value as Record<string, unknown>;
|
|
63
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
64
|
+
return { type: "text", text: block.text };
|
|
65
|
+
}
|
|
66
|
+
if (block.type === "image" && typeof block.data === "string" && typeof block.mimeType === "string") {
|
|
67
|
+
return { type: "image", data: block.data, mimeType: block.mimeType };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { type: "text", text: formatValue(value) };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function textFromContent(content: ContentBlock[]): string {
|
|
74
|
+
return content
|
|
75
|
+
.filter((block) => block.type === "text")
|
|
76
|
+
.map((block) => block.text)
|
|
77
|
+
.join("\n");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function abortReasonError(reason: unknown): Error {
|
|
81
|
+
return reason instanceof Error ? reason : new Error(String(reason ?? "MCP request aborted"));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function parseWorkerMessage(value: unknown): WorkerMessage | null {
|
|
85
|
+
if (typeof value !== "object" || value === null) return null;
|
|
86
|
+
const message = value as Record<string, unknown>;
|
|
87
|
+
if (message.type === "emit" && "block" in message) return { type: "emit", block: message.block };
|
|
88
|
+
if (message.type === "call" && typeof message.id === "number" && typeof message.path === "string") {
|
|
89
|
+
return "args" in message
|
|
90
|
+
? { type: "call", id: message.id, path: message.path, args: message.args }
|
|
91
|
+
: { type: "call", id: message.id, path: message.path };
|
|
92
|
+
}
|
|
93
|
+
if ((message.type === "search" || message.type === "describe") && typeof message.id === "number") {
|
|
94
|
+
return "input" in message
|
|
95
|
+
? { type: message.type, id: message.id, input: message.input }
|
|
96
|
+
: { type: message.type, id: message.id };
|
|
97
|
+
}
|
|
98
|
+
if (message.type === "done") {
|
|
99
|
+
return "returnBlock" in message ? { type: "done", returnBlock: message.returnBlock } : { type: "done" };
|
|
100
|
+
}
|
|
101
|
+
if (message.type === "error" && typeof message.message === "string") {
|
|
102
|
+
return { type: "error", message: message.message };
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function runMcpScript(
|
|
108
|
+
state: McpExtensionState,
|
|
109
|
+
code: string,
|
|
110
|
+
timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_MS,
|
|
111
|
+
getPiTools?: () => ToolInfo[],
|
|
112
|
+
signal?: AbortSignal,
|
|
113
|
+
) {
|
|
114
|
+
const resolvedTimeoutMs = Number.isFinite(timeoutMs) && timeoutMs > 0
|
|
115
|
+
? Math.floor(timeoutMs)
|
|
116
|
+
: DEFAULT_MCP_SCRIPT_TIMEOUT_MS;
|
|
117
|
+
const output: ContentBlock[] = [];
|
|
118
|
+
const externalSignal = combineAbortSignals(state.owner?.signal, signal);
|
|
119
|
+
const timeoutController = new AbortController();
|
|
120
|
+
const callSignal = combineAbortSignals(externalSignal, timeoutController.signal);
|
|
121
|
+
|
|
122
|
+
type ScriptOperation =
|
|
123
|
+
| { operation: "call"; path: string; ok: true; durationMs: number }
|
|
124
|
+
| { operation: "call"; path: string; ok: false; error: string; durationMs: number }
|
|
125
|
+
| { operation: "search"; query: string; ok: true; durationMs: number }
|
|
126
|
+
| { operation: "search"; query: string; ok: false; error: string; durationMs: number }
|
|
127
|
+
| { operation: "describe"; path: string; ok: true; durationMs: number }
|
|
128
|
+
| { operation: "describe"; path: string; ok: false; error: string; durationMs: number };
|
|
129
|
+
type TrackedScriptOperation = ScriptOperation & { startedAt: number };
|
|
130
|
+
const calls: TrackedScriptOperation[] = [];
|
|
131
|
+
const snapshotCalls = (): ScriptOperation[] => calls.map(({ startedAt, ...operation }) => ({
|
|
132
|
+
...operation,
|
|
133
|
+
durationMs: "error" in operation && operation.error === "incomplete"
|
|
134
|
+
? Math.max(0, Date.now() - startedAt)
|
|
135
|
+
: operation.durationMs,
|
|
136
|
+
}));
|
|
137
|
+
let callsSnapshot: ScriptOperation[] | undefined;
|
|
138
|
+
const callTool = async (path: string, args?: Record<string, unknown>) => {
|
|
139
|
+
// Record before dispatch so calls still in flight at timeout/abort appear in the trace.
|
|
140
|
+
const startedAt = Date.now();
|
|
141
|
+
const index = calls.push({ operation: "call", path, ok: false, error: "incomplete", durationMs: 0, startedAt }) - 1;
|
|
142
|
+
const result = await executeCall(state, path, args, undefined, getPiTools, callSignal, "script");
|
|
143
|
+
const details = result.details;
|
|
144
|
+
if (details.error !== undefined) {
|
|
145
|
+
const errorCode = String(details.error);
|
|
146
|
+
const suggestions = Array.isArray(details.suggestions)
|
|
147
|
+
? details.suggestions.filter((suggestion): suggestion is string => typeof suggestion === "string")
|
|
148
|
+
: [];
|
|
149
|
+
const message = errorCode === "tool_not_found"
|
|
150
|
+
? `Tool "${path}" not found. Use await tools.search({ query: "..." }) inside mcpScript.${suggestions.length > 0 ? ` Did you mean: ${suggestions.join(", ")}` : ""}`
|
|
151
|
+
: typeof details.message === "string"
|
|
152
|
+
? details.message
|
|
153
|
+
: textFromContent(result.content);
|
|
154
|
+
calls[index] = { operation: "call", path, ok: false, error: errorCode, durationMs: Date.now() - startedAt, startedAt };
|
|
155
|
+
return {
|
|
156
|
+
ok: false as const,
|
|
157
|
+
error: { code: errorCode, message },
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
calls[index] = { operation: "call", path, ok: true, durationMs: Date.now() - startedAt, startedAt };
|
|
161
|
+
return {
|
|
162
|
+
ok: true as const,
|
|
163
|
+
data: details.mcpResult !== undefined ? details.mcpResult : textFromContent(result.content),
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const searchTools = (input?: SearchInput) => {
|
|
168
|
+
const startedAt = Date.now();
|
|
169
|
+
const query = typeof input?.query === "string" ? input.query : "";
|
|
170
|
+
let error: unknown;
|
|
171
|
+
try {
|
|
172
|
+
if (query.trim() === "") {
|
|
173
|
+
return { items: [], total: 0, hasMore: false, nextOffset: null };
|
|
174
|
+
}
|
|
175
|
+
const server = typeof input?.server === "string" ? input.server : undefined;
|
|
176
|
+
const limit = typeof input?.limit === "number" ? input.limit : 12;
|
|
177
|
+
const offset = typeof input?.offset === "number" ? input.offset : 0;
|
|
178
|
+
const page = paginate(rankToolMatches(state, query, server), offset, limit);
|
|
179
|
+
return {
|
|
180
|
+
...page,
|
|
181
|
+
items: page.items.map(({ server: matchServer, tool, score }) => ({
|
|
182
|
+
path: tool.name,
|
|
183
|
+
name: tool.originalName,
|
|
184
|
+
server: matchServer,
|
|
185
|
+
...(tool.description ? { description: tool.description } : {}),
|
|
186
|
+
score,
|
|
187
|
+
})),
|
|
188
|
+
};
|
|
189
|
+
} catch (caught) {
|
|
190
|
+
error = caught;
|
|
191
|
+
throw caught;
|
|
192
|
+
} finally {
|
|
193
|
+
calls.push(error === undefined
|
|
194
|
+
? { operation: "search", query, ok: true, durationMs: Date.now() - startedAt, startedAt }
|
|
195
|
+
: { operation: "search", query, ok: false, error: error instanceof Error ? error.message : String(error), durationMs: Date.now() - startedAt, startedAt });
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const describeTool = (input?: DescribeInput) => {
|
|
200
|
+
const startedAt = Date.now();
|
|
201
|
+
const path = typeof input?.path === "string" ? input.path : "";
|
|
202
|
+
let error: unknown;
|
|
203
|
+
try {
|
|
204
|
+
for (const [server, metadata] of state.toolMetadata) {
|
|
205
|
+
const tool = findToolByName(metadata, path);
|
|
206
|
+
if (!tool) continue;
|
|
207
|
+
const inputTypeScript = tool.inputSchema
|
|
208
|
+
? renderTsShape(tool.inputSchema) ?? formatSchema(tool.inputSchema)
|
|
209
|
+
: null;
|
|
210
|
+
return {
|
|
211
|
+
path: tool.name,
|
|
212
|
+
name: tool.originalName,
|
|
213
|
+
server,
|
|
214
|
+
...(tool.description ? { description: tool.description } : {}),
|
|
215
|
+
...(inputTypeScript ? { inputTypeScript } : {}),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const suggestions = path ? rankSuggestions(state, path, 5) : [];
|
|
219
|
+
error = "tool_not_found";
|
|
220
|
+
return {
|
|
221
|
+
path,
|
|
222
|
+
error: {
|
|
223
|
+
code: "tool_not_found",
|
|
224
|
+
message: `Tool not found: ${path}`,
|
|
225
|
+
suggestions,
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
} catch (caught) {
|
|
229
|
+
error = caught;
|
|
230
|
+
throw caught;
|
|
231
|
+
} finally {
|
|
232
|
+
calls.push(error === undefined
|
|
233
|
+
? { operation: "describe", path, ok: true, durationMs: Date.now() - startedAt, startedAt }
|
|
234
|
+
: { operation: "describe", path, ok: false, error: error instanceof Error ? error.message : String(error), durationMs: Date.now() - startedAt, startedAt });
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
let worker: Worker | undefined;
|
|
239
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
240
|
+
let removeAbortListener = () => {};
|
|
241
|
+
let errorCode: "timeout" | "aborted" | "script_error" | undefined;
|
|
242
|
+
let errorMessage: string | undefined;
|
|
243
|
+
|
|
244
|
+
try {
|
|
245
|
+
if (externalSignal?.aborted) {
|
|
246
|
+
throw abortReasonError(externalSignal.reason);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
worker = new Worker(new URL("./mcp-script-worker.mjs", import.meta.url), {
|
|
250
|
+
workerData: { code },
|
|
251
|
+
env: {},
|
|
252
|
+
});
|
|
253
|
+
const activeWorker = worker;
|
|
254
|
+
const execution = new Promise<void>((resolve, reject) => {
|
|
255
|
+
let completed = false;
|
|
256
|
+
activeWorker.on("message", (value: unknown) => {
|
|
257
|
+
const message = parseWorkerMessage(value);
|
|
258
|
+
if (!message || completed) return;
|
|
259
|
+
if (message.type === "emit") {
|
|
260
|
+
output.push(toContentBlock(message.block));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (message.type === "done") {
|
|
264
|
+
completed = true;
|
|
265
|
+
if ("returnBlock" in message) output.push(toContentBlock(message.returnBlock));
|
|
266
|
+
resolve();
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (message.type === "error") {
|
|
270
|
+
completed = true;
|
|
271
|
+
reject(new Error(message.message));
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
void (async () => {
|
|
276
|
+
let envelope: unknown;
|
|
277
|
+
if (message.type === "call") {
|
|
278
|
+
envelope = await callTool(message.path, message.args as Record<string, unknown> | undefined);
|
|
279
|
+
} else if (message.type === "search") {
|
|
280
|
+
envelope = searchTools(message.input as SearchInput | undefined);
|
|
281
|
+
} else {
|
|
282
|
+
envelope = describeTool(message.input as DescribeInput | undefined);
|
|
283
|
+
}
|
|
284
|
+
const response: WorkerResultMessage = { type: "result", id: message.id, envelope };
|
|
285
|
+
activeWorker.postMessage(response);
|
|
286
|
+
})().catch(reject);
|
|
287
|
+
});
|
|
288
|
+
activeWorker.once("error", reject);
|
|
289
|
+
activeWorker.once("exit", (code) => {
|
|
290
|
+
if (!completed && code !== 0) reject(new Error(`mcpScript worker exited with code ${code}`));
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
const timeoutError = new McpScriptTimeoutError(resolvedTimeoutMs);
|
|
294
|
+
const timeout = new Promise<never>((_resolve, reject) => {
|
|
295
|
+
timer = setTimeout(() => {
|
|
296
|
+
callsSnapshot = snapshotCalls();
|
|
297
|
+
timeoutController.abort(timeoutError);
|
|
298
|
+
void activeWorker.terminate();
|
|
299
|
+
reject(timeoutError);
|
|
300
|
+
}, resolvedTimeoutMs);
|
|
301
|
+
});
|
|
302
|
+
const aborted = externalSignal
|
|
303
|
+
? new Promise<never>((_resolve, reject) => {
|
|
304
|
+
const onAbort = () => {
|
|
305
|
+
callsSnapshot = snapshotCalls();
|
|
306
|
+
void activeWorker.terminate();
|
|
307
|
+
reject(abortReasonError(externalSignal.reason));
|
|
308
|
+
};
|
|
309
|
+
externalSignal.addEventListener("abort", onAbort, { once: true });
|
|
310
|
+
removeAbortListener = () => externalSignal.removeEventListener("abort", onAbort);
|
|
311
|
+
})
|
|
312
|
+
: new Promise<never>(() => {});
|
|
313
|
+
|
|
314
|
+
await Promise.race([execution, timeout, aborted]);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
if (error instanceof McpScriptTimeoutError) {
|
|
317
|
+
errorCode = "timeout";
|
|
318
|
+
errorMessage = `mcpScript timed out after ${resolvedTimeoutMs}ms`;
|
|
319
|
+
} else if (externalSignal?.aborted) {
|
|
320
|
+
errorCode = "aborted";
|
|
321
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
322
|
+
} else {
|
|
323
|
+
errorCode = "script_error";
|
|
324
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
325
|
+
}
|
|
326
|
+
output.push({ type: "text", text: errorMessage });
|
|
327
|
+
} finally {
|
|
328
|
+
clearTimeout(timer);
|
|
329
|
+
removeAbortListener();
|
|
330
|
+
// "incomplete" means the call had not settled when the script finished
|
|
331
|
+
// (deadline, abort, or early return). Snapshot before aborting stragglers.
|
|
332
|
+
callsSnapshot ??= snapshotCalls();
|
|
333
|
+
// A script may finish without awaiting every call; abort leftovers so
|
|
334
|
+
// parent-side dispatches do not outlive the script.
|
|
335
|
+
timeoutController.abort(new Error("mcpScript finished"));
|
|
336
|
+
await worker?.terminate();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Snapshot before the asynchronous output guard; the terminated worker can no longer emit.
|
|
340
|
+
const guarded = await guardMcpOutput(
|
|
341
|
+
output.length > 0 ? [...output] : [{ type: "text", text: "(no output)" }],
|
|
342
|
+
resolveMcpOutputGuardOptions(state.config.settings),
|
|
343
|
+
);
|
|
344
|
+
return {
|
|
345
|
+
content: guarded.content,
|
|
346
|
+
details: {
|
|
347
|
+
mode: "script",
|
|
348
|
+
...(errorCode ? { error: errorCode, message: errorMessage } : {}),
|
|
349
|
+
timeoutMs: resolvedTimeoutMs,
|
|
350
|
+
...(callsSnapshot.length > 0 ? { calls: callsSnapshot } : {}),
|
|
351
|
+
...guardedMcpDetails(guarded),
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { createRequire } = require('node:module');
|
|
5
|
+
const { dirname, join } = require('node:path');
|
|
6
|
+
|
|
7
|
+
const requireFromHere = createRequire(__filename);
|
|
8
|
+
|
|
9
|
+
function loadKeyringEntryClass() {
|
|
10
|
+
try {
|
|
11
|
+
return requireFromHere('@napi-rs/keyring').Entry;
|
|
12
|
+
} catch (loaderError) {
|
|
13
|
+
const suffixes = getNativeBindingSuffixes(process.platform, process.arch);
|
|
14
|
+
let lastError;
|
|
15
|
+
for (const suffix of suffixes) {
|
|
16
|
+
try {
|
|
17
|
+
const packageJsonPath = requireFromHere.resolve(`@napi-rs/keyring-${suffix}/package.json`);
|
|
18
|
+
return requireFromHere(join(dirname(packageJsonPath), `keyring.${suffix}.node`)).Entry;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
lastError = error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const error = new Error(`Failed to load @napi-rs/keyring in recovery helper: ${lastError?.message ?? loaderError.message}`);
|
|
24
|
+
error.cause = loaderError;
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getNativeBindingSuffixes(platform, arch) {
|
|
30
|
+
if (platform === 'linux') {
|
|
31
|
+
if (arch === 'arm64') return ['linux-arm64-gnu', 'linux-arm64-musl'];
|
|
32
|
+
if (arch === 'arm') return ['linux-arm-gnueabihf'];
|
|
33
|
+
if (arch === 'riscv64') return ['linux-riscv64-gnu'];
|
|
34
|
+
if (arch === 'x64') return ['linux-x64-gnu', 'linux-x64-musl'];
|
|
35
|
+
}
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function readStdin() {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
let input = '';
|
|
42
|
+
process.stdin.setEncoding('utf8');
|
|
43
|
+
process.stdin.on('data', chunk => {
|
|
44
|
+
input += chunk;
|
|
45
|
+
if (input.length > 1024 * 1024) {
|
|
46
|
+
reject(new Error('request too large'));
|
|
47
|
+
process.stdin.destroy();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
process.stdin.on('error', reject);
|
|
51
|
+
process.stdin.on('end', () => resolve(input));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function writeResponse(response) {
|
|
56
|
+
process.stdout.write(`${JSON.stringify(response)}\n`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
(async () => {
|
|
60
|
+
try {
|
|
61
|
+
const request = JSON.parse(await readStdin());
|
|
62
|
+
if (!request || typeof request !== 'object') throw new Error('invalid request');
|
|
63
|
+
const { operation, service, account, payload } = request;
|
|
64
|
+
if (!['read', 'write', 'remove'].includes(operation)) throw new Error('invalid operation');
|
|
65
|
+
if (typeof service !== 'string' || !service) throw new Error('invalid service');
|
|
66
|
+
if (typeof account !== 'string' || !account) throw new Error('invalid account');
|
|
67
|
+
|
|
68
|
+
const Entry = loadKeyringEntryClass();
|
|
69
|
+
const entry = new Entry(service, account);
|
|
70
|
+
|
|
71
|
+
if (operation === 'read') {
|
|
72
|
+
const value = entry.getPassword();
|
|
73
|
+
writeResponse(value === null ? { ok: true, found: false } : { ok: true, found: true, value });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (operation === 'write') {
|
|
77
|
+
if (typeof payload !== 'string') throw new Error('invalid payload');
|
|
78
|
+
entry.setPassword(payload);
|
|
79
|
+
writeResponse({ ok: true });
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
entry.deleteCredential();
|
|
84
|
+
writeResponse({ ok: true });
|
|
85
|
+
} catch (error) {
|
|
86
|
+
writeResponse({ ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
}
|
|
89
|
+
})();
|