@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,635 @@
|
|
|
1
|
+
import { existsSync, readFileSync, rmSync, statSync, readdirSync, openSync, readSync, closeSync, realpathSync } from "node:fs";
|
|
2
|
+
import { execFile, spawn } from "node:child_process";
|
|
3
|
+
import { extname, join, resolve as resolvePath, sep as pathSep } from "node:path";
|
|
4
|
+
import { activityMonitor } from "./activity.js";
|
|
5
|
+
import { checkGhAvailable, checkRepoSize, fetchViaApi, showGhHint } from "./github-api.js";
|
|
6
|
+
import { getWebSearchConfigPath } from "./utils.js";
|
|
7
|
+
const CONFIG_PATH = getWebSearchConfigPath();
|
|
8
|
+
const BINARY_EXTENSIONS = new Set([
|
|
9
|
+
".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".webp", ".svg", ".tiff", ".tif",
|
|
10
|
+
".mp3", ".mp4", ".avi", ".mov", ".mkv", ".flv", ".wmv", ".wav", ".ogg", ".webm", ".flac", ".aac",
|
|
11
|
+
".zip", ".tar", ".gz", ".bz2", ".xz", ".7z", ".rar", ".zst",
|
|
12
|
+
".exe", ".dll", ".so", ".dylib", ".bin", ".o", ".a", ".lib",
|
|
13
|
+
".woff", ".woff2", ".ttf", ".otf", ".eot",
|
|
14
|
+
".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx",
|
|
15
|
+
".sqlite", ".db", ".sqlite3",
|
|
16
|
+
".pyc", ".pyo", ".class", ".jar", ".war",
|
|
17
|
+
".iso", ".img", ".dmg",
|
|
18
|
+
]);
|
|
19
|
+
const NOISE_DIRS = new Set([
|
|
20
|
+
"node_modules", "vendor", ".next", "dist", "build", "__pycache__",
|
|
21
|
+
".venv", "venv", ".tox", ".mypy_cache", ".pytest_cache",
|
|
22
|
+
"target", ".gradle", ".idea", ".vscode",
|
|
23
|
+
]);
|
|
24
|
+
const MAX_INLINE_FILE_CHARS = 100_000;
|
|
25
|
+
const MAX_TREE_ENTRIES = 200;
|
|
26
|
+
const cloneCache = new Map();
|
|
27
|
+
let cachedConfig = null;
|
|
28
|
+
function normalizeEnabled(value, fallback) {
|
|
29
|
+
return typeof value === "boolean" ? value : fallback;
|
|
30
|
+
}
|
|
31
|
+
function normalizePositiveNumber(value, fallback) {
|
|
32
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
33
|
+
return fallback;
|
|
34
|
+
return value > 0 ? value : fallback;
|
|
35
|
+
}
|
|
36
|
+
function expandPath(value) {
|
|
37
|
+
let expanded = value;
|
|
38
|
+
// Expand ~ at the start of the path
|
|
39
|
+
if (expanded.startsWith("~/") || expanded === "~") {
|
|
40
|
+
expanded = expanded.replace(/^~/, process.env.HOME || process.env.USERPROFILE || "");
|
|
41
|
+
}
|
|
42
|
+
// Expand environment variables like $HOME, $USER, etc.
|
|
43
|
+
expanded = expanded.replace(/\$([A-Z_][A-Z0-9_]*)/gi, (match, varName) => {
|
|
44
|
+
return process.env[varName] ?? match;
|
|
45
|
+
});
|
|
46
|
+
return expanded;
|
|
47
|
+
}
|
|
48
|
+
function normalizeClonePath(value, fallback) {
|
|
49
|
+
if (typeof value !== "string")
|
|
50
|
+
return fallback;
|
|
51
|
+
const normalized = value.trim();
|
|
52
|
+
if (normalized.length === 0)
|
|
53
|
+
return fallback;
|
|
54
|
+
return expandPath(normalized);
|
|
55
|
+
}
|
|
56
|
+
function loadGitHubConfig() {
|
|
57
|
+
if (cachedConfig)
|
|
58
|
+
return cachedConfig;
|
|
59
|
+
const defaults = {
|
|
60
|
+
enabled: true,
|
|
61
|
+
maxRepoSizeMB: 350,
|
|
62
|
+
cloneTimeoutSeconds: 30,
|
|
63
|
+
clonePath: "/tmp/pi-github-repos",
|
|
64
|
+
};
|
|
65
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
66
|
+
cachedConfig = defaults;
|
|
67
|
+
return cachedConfig;
|
|
68
|
+
}
|
|
69
|
+
const rawText = readFileSync(CONFIG_PATH, "utf-8");
|
|
70
|
+
let raw;
|
|
71
|
+
try {
|
|
72
|
+
raw = JSON.parse(rawText);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
76
|
+
throw new Error(`Failed to parse ${CONFIG_PATH}: ${message}`);
|
|
77
|
+
}
|
|
78
|
+
const gc = raw.githubClone ?? {};
|
|
79
|
+
cachedConfig = {
|
|
80
|
+
enabled: normalizeEnabled(gc.enabled, defaults.enabled),
|
|
81
|
+
maxRepoSizeMB: normalizePositiveNumber(gc.maxRepoSizeMB, defaults.maxRepoSizeMB),
|
|
82
|
+
cloneTimeoutSeconds: normalizePositiveNumber(gc.cloneTimeoutSeconds, defaults.cloneTimeoutSeconds),
|
|
83
|
+
clonePath: normalizeClonePath(gc.clonePath, defaults.clonePath),
|
|
84
|
+
};
|
|
85
|
+
return cachedConfig;
|
|
86
|
+
}
|
|
87
|
+
const NON_CODE_SEGMENTS = new Set([
|
|
88
|
+
"issues", "pull", "pulls", "discussions", "releases", "wiki",
|
|
89
|
+
"actions", "settings", "security", "projects", "graphs",
|
|
90
|
+
"compare", "commits", "tags", "branches", "stargazers",
|
|
91
|
+
"watchers", "network", "forks", "milestone", "labels",
|
|
92
|
+
"packages", "codespaces", "contribute", "community",
|
|
93
|
+
"sponsors", "invitations", "notifications", "insights",
|
|
94
|
+
]);
|
|
95
|
+
export function parseGitHubUrl(url) {
|
|
96
|
+
let parsed;
|
|
97
|
+
try {
|
|
98
|
+
parsed = new URL(url);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const host = parsed.hostname.toLowerCase();
|
|
104
|
+
if (host !== "github.com" && host !== "www.github.com")
|
|
105
|
+
return null;
|
|
106
|
+
const segments = parsed.pathname
|
|
107
|
+
.split("/")
|
|
108
|
+
.filter(Boolean)
|
|
109
|
+
.map((segment) => {
|
|
110
|
+
try {
|
|
111
|
+
return decodeURIComponent(segment);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return segment;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
if (segments.length < 2)
|
|
118
|
+
return null;
|
|
119
|
+
const owner = segments[0];
|
|
120
|
+
const repo = segments[1].replace(/\.git$/, "");
|
|
121
|
+
if (NON_CODE_SEGMENTS.has(segments[2]?.toLowerCase()))
|
|
122
|
+
return null;
|
|
123
|
+
if (segments.length === 2) {
|
|
124
|
+
return { owner, repo, refIsFullSha: false, type: "root" };
|
|
125
|
+
}
|
|
126
|
+
const action = segments[2];
|
|
127
|
+
if (action !== "blob" && action !== "tree")
|
|
128
|
+
return null;
|
|
129
|
+
if (segments.length < 4)
|
|
130
|
+
return null;
|
|
131
|
+
const ref = segments[3];
|
|
132
|
+
const refIsFullSha = /^[0-9a-f]{40}$/.test(ref);
|
|
133
|
+
const pathParts = segments.slice(4);
|
|
134
|
+
const path = pathParts.length > 0 ? pathParts.join("/") : "";
|
|
135
|
+
return {
|
|
136
|
+
owner,
|
|
137
|
+
repo,
|
|
138
|
+
ref,
|
|
139
|
+
refIsFullSha,
|
|
140
|
+
path,
|
|
141
|
+
type: action,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function cacheKey(owner, repo, ref) {
|
|
145
|
+
return ref ? `${owner}/${repo}@${ref}` : `${owner}/${repo}`;
|
|
146
|
+
}
|
|
147
|
+
function cloneDir(config, owner, repo, ref) {
|
|
148
|
+
const dirName = ref ? `${repo}@${ref}` : repo;
|
|
149
|
+
return join(config.clonePath, owner, dirName);
|
|
150
|
+
}
|
|
151
|
+
const PROCESS_KILL_GRACE_MS = 3000;
|
|
152
|
+
function terminateProcessTree(child) {
|
|
153
|
+
const pid = child.pid;
|
|
154
|
+
if (!pid)
|
|
155
|
+
return;
|
|
156
|
+
if (process.platform === "win32") {
|
|
157
|
+
const killer = execFile("taskkill", ["/pid", String(pid), "/T", "/F"], { windowsHide: true }, (err) => {
|
|
158
|
+
if (err)
|
|
159
|
+
child.kill();
|
|
160
|
+
});
|
|
161
|
+
killer.unref();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
// Clone commands run in their own process group so git/gh helpers cannot
|
|
166
|
+
// survive a timeout or cancellation and keep reading from the host TTY.
|
|
167
|
+
process.kill(-pid, "SIGTERM");
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
child.kill();
|
|
171
|
+
}
|
|
172
|
+
// A credential helper may handle or ignore SIGTERM. Escalate against the
|
|
173
|
+
// entire process group so neither git nor any descendant can block forever.
|
|
174
|
+
const forceKill = setTimeout(() => {
|
|
175
|
+
try {
|
|
176
|
+
process.kill(-pid, "SIGKILL");
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
child.kill("SIGKILL");
|
|
180
|
+
}
|
|
181
|
+
}, PROCESS_KILL_GRACE_MS);
|
|
182
|
+
forceKill.unref();
|
|
183
|
+
}
|
|
184
|
+
function execClone(args, localPath, timeoutMs, signal) {
|
|
185
|
+
return new Promise((resolve) => {
|
|
186
|
+
let settled = false;
|
|
187
|
+
let timeout;
|
|
188
|
+
let onAbort;
|
|
189
|
+
const finish = (success) => {
|
|
190
|
+
if (settled)
|
|
191
|
+
return;
|
|
192
|
+
settled = true;
|
|
193
|
+
if (timeout)
|
|
194
|
+
clearTimeout(timeout);
|
|
195
|
+
if (signal && onAbort)
|
|
196
|
+
signal.removeEventListener("abort", onAbort);
|
|
197
|
+
if (!success) {
|
|
198
|
+
try {
|
|
199
|
+
rmSync(localPath, { recursive: true, force: true });
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
}
|
|
203
|
+
resolve(null);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
resolve(localPath);
|
|
207
|
+
};
|
|
208
|
+
const child = spawn(args[0], args.slice(1), {
|
|
209
|
+
detached: process.platform !== "win32",
|
|
210
|
+
env: {
|
|
211
|
+
...process.env,
|
|
212
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
213
|
+
GCM_INTERACTIVE: "Never",
|
|
214
|
+
GH_PROMPT_DISABLED: "1",
|
|
215
|
+
},
|
|
216
|
+
stdio: "ignore",
|
|
217
|
+
windowsHide: true,
|
|
218
|
+
});
|
|
219
|
+
child.once("error", () => finish(false));
|
|
220
|
+
child.once("close", (code) => finish(code === 0));
|
|
221
|
+
timeout = setTimeout(() => terminateProcessTree(child), timeoutMs);
|
|
222
|
+
timeout.unref();
|
|
223
|
+
if (signal) {
|
|
224
|
+
onAbort = () => {
|
|
225
|
+
if (timeout)
|
|
226
|
+
clearTimeout(timeout);
|
|
227
|
+
terminateProcessTree(child);
|
|
228
|
+
};
|
|
229
|
+
if (signal.aborted)
|
|
230
|
+
onAbort();
|
|
231
|
+
else
|
|
232
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
async function cloneRepo(owner, repo, ref, config, signal) {
|
|
237
|
+
const localPath = cloneDir(config, owner, repo, ref);
|
|
238
|
+
try {
|
|
239
|
+
rmSync(localPath, { recursive: true, force: true });
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
}
|
|
243
|
+
const timeoutMs = config.cloneTimeoutSeconds * 1000;
|
|
244
|
+
const hasGh = await checkGhAvailable();
|
|
245
|
+
if (hasGh) {
|
|
246
|
+
const args = ["gh", "repo", "clone", `${owner}/${repo}`, localPath, "--", "--depth", "1", "--single-branch"];
|
|
247
|
+
if (ref)
|
|
248
|
+
args.push("--branch", ref);
|
|
249
|
+
return execClone(args, localPath, timeoutMs, signal);
|
|
250
|
+
}
|
|
251
|
+
showGhHint();
|
|
252
|
+
const gitUrl = `https://github.com/${owner}/${repo}.git`;
|
|
253
|
+
const args = ["git", "clone", "--depth", "1", "--single-branch"];
|
|
254
|
+
if (ref)
|
|
255
|
+
args.push("--branch", ref);
|
|
256
|
+
args.push(gitUrl, localPath);
|
|
257
|
+
return execClone(args, localPath, timeoutMs, signal);
|
|
258
|
+
}
|
|
259
|
+
function isBinaryFile(filePath) {
|
|
260
|
+
const ext = extname(filePath).toLowerCase();
|
|
261
|
+
if (BINARY_EXTENSIONS.has(ext))
|
|
262
|
+
return true;
|
|
263
|
+
let fd;
|
|
264
|
+
try {
|
|
265
|
+
fd = openSync(filePath, "r");
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
const buf = Buffer.alloc(512);
|
|
272
|
+
const bytesRead = readSync(fd, buf, 0, 512, 0);
|
|
273
|
+
for (let i = 0; i < bytesRead; i++) {
|
|
274
|
+
if (buf[i] === 0)
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
closeSync(fd);
|
|
283
|
+
}
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
function formatFileSize(bytes) {
|
|
287
|
+
if (bytes < 1024)
|
|
288
|
+
return `${bytes} B`;
|
|
289
|
+
if (bytes < 1024 * 1024)
|
|
290
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
291
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
292
|
+
}
|
|
293
|
+
function resolveWithinRepo(rootPath, relativePath) {
|
|
294
|
+
const normalizedRoot = resolvePath(rootPath);
|
|
295
|
+
const candidate = resolvePath(normalizedRoot, relativePath);
|
|
296
|
+
if (candidate !== normalizedRoot) {
|
|
297
|
+
const rootPrefix = normalizedRoot.endsWith(pathSep) ? normalizedRoot : normalizedRoot + pathSep;
|
|
298
|
+
if (!candidate.startsWith(rootPrefix))
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
if (!existsSync(candidate))
|
|
302
|
+
return candidate;
|
|
303
|
+
try {
|
|
304
|
+
const realRoot = realpathSync(normalizedRoot);
|
|
305
|
+
const realCandidate = realpathSync(candidate);
|
|
306
|
+
if (realCandidate === realRoot)
|
|
307
|
+
return candidate;
|
|
308
|
+
const realRootPrefix = realRoot.endsWith(pathSep) ? realRoot : realRoot + pathSep;
|
|
309
|
+
return realCandidate.startsWith(realRootPrefix) ? candidate : null;
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function readTextFile(path) {
|
|
316
|
+
try {
|
|
317
|
+
return readFileSync(path, "utf-8");
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function buildTree(rootPath) {
|
|
324
|
+
const entries = [];
|
|
325
|
+
function walk(dir, relPath) {
|
|
326
|
+
if (entries.length >= MAX_TREE_ENTRIES)
|
|
327
|
+
return;
|
|
328
|
+
let items;
|
|
329
|
+
try {
|
|
330
|
+
items = readdirSync(dir).sort();
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
for (const item of items) {
|
|
336
|
+
if (entries.length >= MAX_TREE_ENTRIES)
|
|
337
|
+
return;
|
|
338
|
+
if (item === ".git")
|
|
339
|
+
continue;
|
|
340
|
+
const rel = relPath ? `${relPath}/${item}` : item;
|
|
341
|
+
const safePath = resolveWithinRepo(rootPath, rel);
|
|
342
|
+
if (!safePath) {
|
|
343
|
+
entries.push(`${rel} [outside repo skipped]`);
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
let stat;
|
|
347
|
+
try {
|
|
348
|
+
stat = statSync(safePath);
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
if (stat.isDirectory()) {
|
|
354
|
+
if (NOISE_DIRS.has(item)) {
|
|
355
|
+
entries.push(`${rel}/ [skipped]`);
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
entries.push(`${rel}/`);
|
|
359
|
+
walk(safePath, rel);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
entries.push(rel);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
walk(rootPath, "");
|
|
367
|
+
if (entries.length >= MAX_TREE_ENTRIES) {
|
|
368
|
+
entries.push(`... (truncated at ${MAX_TREE_ENTRIES} entries)`);
|
|
369
|
+
}
|
|
370
|
+
return entries.join("\n");
|
|
371
|
+
}
|
|
372
|
+
function buildDirListing(rootPath, subPath) {
|
|
373
|
+
const targetPath = resolveWithinRepo(rootPath, subPath);
|
|
374
|
+
if (!targetPath)
|
|
375
|
+
return "(path escapes repository root)";
|
|
376
|
+
const lines = [];
|
|
377
|
+
let items;
|
|
378
|
+
try {
|
|
379
|
+
items = readdirSync(targetPath).sort();
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
return "(directory not readable)";
|
|
383
|
+
}
|
|
384
|
+
for (const item of items) {
|
|
385
|
+
if (item === ".git")
|
|
386
|
+
continue;
|
|
387
|
+
const rel = subPath ? `${subPath}/${item}` : item;
|
|
388
|
+
const safePath = resolveWithinRepo(rootPath, rel);
|
|
389
|
+
if (!safePath) {
|
|
390
|
+
lines.push(` ${item} (outside repo)`);
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
try {
|
|
394
|
+
const stat = statSync(safePath);
|
|
395
|
+
if (stat.isDirectory()) {
|
|
396
|
+
lines.push(` ${item}/`);
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
lines.push(` ${item} (${formatFileSize(stat.size)})`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
lines.push(` ${item} (unreadable)`);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return lines.join("\n");
|
|
407
|
+
}
|
|
408
|
+
function readReadme(localPath) {
|
|
409
|
+
const candidates = ["README.md", "readme.md", "README", "README.txt", "README.rst"];
|
|
410
|
+
for (const name of candidates) {
|
|
411
|
+
const readmePath = join(localPath, name);
|
|
412
|
+
if (existsSync(readmePath)) {
|
|
413
|
+
try {
|
|
414
|
+
const content = readFileSync(readmePath, "utf-8");
|
|
415
|
+
return content.length > 8192 ? content.slice(0, 8192) + "\n\n[README truncated at 8K chars]" : content;
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
function generateContent(localPath, info) {
|
|
425
|
+
const lines = [];
|
|
426
|
+
lines.push(`Repository cloned to: ${localPath}`);
|
|
427
|
+
lines.push("");
|
|
428
|
+
if (info.type === "root") {
|
|
429
|
+
lines.push("## Structure");
|
|
430
|
+
lines.push(buildTree(localPath));
|
|
431
|
+
lines.push("");
|
|
432
|
+
const readme = readReadme(localPath);
|
|
433
|
+
if (readme) {
|
|
434
|
+
lines.push("## README.md");
|
|
435
|
+
lines.push(readme);
|
|
436
|
+
lines.push("");
|
|
437
|
+
}
|
|
438
|
+
lines.push("Use `read` and `bash` tools at the path above to explore further.");
|
|
439
|
+
return lines.join("\n");
|
|
440
|
+
}
|
|
441
|
+
if (info.type === "tree") {
|
|
442
|
+
const dirPath = info.path || "";
|
|
443
|
+
const fullDirPath = resolveWithinRepo(localPath, dirPath);
|
|
444
|
+
if (!fullDirPath || !existsSync(fullDirPath)) {
|
|
445
|
+
lines.push(`Path \`${dirPath}\` not found in clone. Showing repository root instead.`);
|
|
446
|
+
lines.push("");
|
|
447
|
+
lines.push("## Structure");
|
|
448
|
+
lines.push(buildTree(localPath));
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
lines.push(`## ${dirPath || "/"}`);
|
|
452
|
+
lines.push(buildDirListing(localPath, dirPath));
|
|
453
|
+
}
|
|
454
|
+
lines.push("");
|
|
455
|
+
lines.push("Use `read` and `bash` tools at the path above to explore further.");
|
|
456
|
+
return lines.join("\n");
|
|
457
|
+
}
|
|
458
|
+
if (info.type === "blob") {
|
|
459
|
+
const filePath = info.path || "";
|
|
460
|
+
const fullFilePath = resolveWithinRepo(localPath, filePath);
|
|
461
|
+
if (!fullFilePath || !existsSync(fullFilePath)) {
|
|
462
|
+
lines.push(`Path \`${filePath}\` not found in clone. Showing repository root instead.`);
|
|
463
|
+
lines.push("");
|
|
464
|
+
lines.push("## Structure");
|
|
465
|
+
lines.push(buildTree(localPath));
|
|
466
|
+
lines.push("");
|
|
467
|
+
lines.push("Use `read` and `bash` tools at the path above to explore further.");
|
|
468
|
+
return lines.join("\n");
|
|
469
|
+
}
|
|
470
|
+
let stat;
|
|
471
|
+
try {
|
|
472
|
+
stat = statSync(fullFilePath);
|
|
473
|
+
}
|
|
474
|
+
catch (err) {
|
|
475
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
476
|
+
lines.push(`Could not inspect \`${filePath}\`: ${message}`);
|
|
477
|
+
lines.push("");
|
|
478
|
+
lines.push("Use `read` and `bash` tools at the path above to explore further.");
|
|
479
|
+
return lines.join("\n");
|
|
480
|
+
}
|
|
481
|
+
if (stat.isDirectory()) {
|
|
482
|
+
lines.push(`## ${filePath || "/"}`);
|
|
483
|
+
lines.push(buildDirListing(localPath, filePath));
|
|
484
|
+
lines.push("");
|
|
485
|
+
lines.push("Use `read` and `bash` tools at the path above to explore further.");
|
|
486
|
+
return lines.join("\n");
|
|
487
|
+
}
|
|
488
|
+
if (isBinaryFile(fullFilePath)) {
|
|
489
|
+
const ext = extname(filePath).replace(".", "");
|
|
490
|
+
lines.push(`## ${filePath}`);
|
|
491
|
+
lines.push(`Binary file (${ext}, ${formatFileSize(stat.size)}). Use \`read\` or \`bash\` tools at the path above to inspect.`);
|
|
492
|
+
return lines.join("\n");
|
|
493
|
+
}
|
|
494
|
+
const content = readTextFile(fullFilePath);
|
|
495
|
+
if (content === null) {
|
|
496
|
+
lines.push(`Could not read \`${filePath}\` as UTF-8 text.`);
|
|
497
|
+
lines.push("");
|
|
498
|
+
lines.push("Use `read` and `bash` tools at the path above to explore further.");
|
|
499
|
+
return lines.join("\n");
|
|
500
|
+
}
|
|
501
|
+
lines.push(`## ${filePath}`);
|
|
502
|
+
if (content.length > MAX_INLINE_FILE_CHARS) {
|
|
503
|
+
lines.push(content.slice(0, MAX_INLINE_FILE_CHARS));
|
|
504
|
+
lines.push("");
|
|
505
|
+
lines.push(`[File truncated at 100K chars. Full file: ${fullFilePath}]`);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
lines.push(content);
|
|
509
|
+
}
|
|
510
|
+
lines.push("");
|
|
511
|
+
lines.push("Use `read` and `bash` tools at the path above to explore further.");
|
|
512
|
+
return lines.join("\n");
|
|
513
|
+
}
|
|
514
|
+
return lines.join("\n");
|
|
515
|
+
}
|
|
516
|
+
async function awaitCachedClone(cached, url, owner, repo, info, signal) {
|
|
517
|
+
if (signal?.aborted)
|
|
518
|
+
return null;
|
|
519
|
+
const result = await cached.clonePromise;
|
|
520
|
+
if (signal?.aborted)
|
|
521
|
+
return null;
|
|
522
|
+
if (result) {
|
|
523
|
+
const content = generateContent(result, info);
|
|
524
|
+
const title = info.path ? `${owner}/${repo} - ${info.path}` : `${owner}/${repo}`;
|
|
525
|
+
return { url, title, content, error: null };
|
|
526
|
+
}
|
|
527
|
+
return fetchViaApi(url, owner, repo, info);
|
|
528
|
+
}
|
|
529
|
+
export async function extractGitHub(url, signal, forceClone) {
|
|
530
|
+
const info = parseGitHubUrl(url);
|
|
531
|
+
if (!info)
|
|
532
|
+
return null;
|
|
533
|
+
if (signal?.aborted)
|
|
534
|
+
return null;
|
|
535
|
+
const config = loadGitHubConfig();
|
|
536
|
+
if (!config.enabled)
|
|
537
|
+
return null;
|
|
538
|
+
const { owner, repo } = info;
|
|
539
|
+
const key = cacheKey(owner, repo, info.ref);
|
|
540
|
+
const cached = cloneCache.get(key);
|
|
541
|
+
if (cached)
|
|
542
|
+
return awaitCachedClone(cached, url, owner, repo, info, signal);
|
|
543
|
+
if (info.refIsFullSha) {
|
|
544
|
+
if (signal?.aborted)
|
|
545
|
+
return null;
|
|
546
|
+
const sizeNote = `Note: Commit SHA URLs use the GitHub API instead of cloning.`;
|
|
547
|
+
return fetchViaApi(url, owner, repo, info, sizeNote);
|
|
548
|
+
}
|
|
549
|
+
const activityId = activityMonitor.logStart({ type: "fetch", url: `github.com/${owner}/${repo}` });
|
|
550
|
+
if (!forceClone) {
|
|
551
|
+
const sizeKB = await checkRepoSize(owner, repo);
|
|
552
|
+
if (signal?.aborted) {
|
|
553
|
+
activityMonitor.logComplete(activityId, 0);
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
if (sizeKB !== null) {
|
|
557
|
+
const sizeMB = sizeKB / 1024;
|
|
558
|
+
if (sizeMB > config.maxRepoSizeMB) {
|
|
559
|
+
if (signal?.aborted) {
|
|
560
|
+
activityMonitor.logComplete(activityId, 0);
|
|
561
|
+
return null;
|
|
562
|
+
}
|
|
563
|
+
const sizeNote = `Note: Repository is ${Math.round(sizeMB)}MB (threshold: ${config.maxRepoSizeMB}MB). ` +
|
|
564
|
+
`Showing API-fetched content instead of full clone. Ask the user if they'd like to clone the full repo -- ` +
|
|
565
|
+
`if yes, call fetch_content again with the same URL and add forceClone: true to the params.`;
|
|
566
|
+
const apiView = await fetchViaApi(url, owner, repo, info, sizeNote);
|
|
567
|
+
if (apiView) {
|
|
568
|
+
activityMonitor.logComplete(activityId, 200);
|
|
569
|
+
return apiView;
|
|
570
|
+
}
|
|
571
|
+
activityMonitor.logError(activityId, "api fallback unavailable for oversized repository");
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (signal?.aborted) {
|
|
577
|
+
activityMonitor.logComplete(activityId, 0);
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
// Re-check: another concurrent caller may have started a clone while we awaited the size check
|
|
581
|
+
const cachedAfterSizeCheck = cloneCache.get(key);
|
|
582
|
+
if (cachedAfterSizeCheck) {
|
|
583
|
+
const cachedResult = await awaitCachedClone(cachedAfterSizeCheck, url, owner, repo, info, signal);
|
|
584
|
+
if (signal?.aborted) {
|
|
585
|
+
activityMonitor.logComplete(activityId, 0);
|
|
586
|
+
}
|
|
587
|
+
else if (cachedResult) {
|
|
588
|
+
activityMonitor.logComplete(activityId, 200);
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
activityMonitor.logError(activityId, "clone failed");
|
|
592
|
+
}
|
|
593
|
+
return cachedResult;
|
|
594
|
+
}
|
|
595
|
+
const clonePromise = cloneRepo(owner, repo, info.ref, config, signal);
|
|
596
|
+
const localPath = cloneDir(config, owner, repo, info.ref);
|
|
597
|
+
cloneCache.set(key, { localPath, clonePromise });
|
|
598
|
+
const result = await clonePromise;
|
|
599
|
+
if (signal?.aborted) {
|
|
600
|
+
if (!result)
|
|
601
|
+
cloneCache.delete(key);
|
|
602
|
+
activityMonitor.logComplete(activityId, 0);
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
605
|
+
if (!result) {
|
|
606
|
+
cloneCache.delete(key);
|
|
607
|
+
if (signal?.aborted) {
|
|
608
|
+
activityMonitor.logComplete(activityId, 0);
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
const apiFallback = await fetchViaApi(url, owner, repo, info);
|
|
612
|
+
if (apiFallback) {
|
|
613
|
+
activityMonitor.logComplete(activityId, 200);
|
|
614
|
+
return apiFallback;
|
|
615
|
+
}
|
|
616
|
+
activityMonitor.logError(activityId, "clone and API fallback failed");
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
activityMonitor.logComplete(activityId, 200);
|
|
620
|
+
const content = generateContent(result, info);
|
|
621
|
+
const title = info.path ? `${owner}/${repo} - ${info.path}` : `${owner}/${repo}`;
|
|
622
|
+
return { url, title, content, error: null };
|
|
623
|
+
}
|
|
624
|
+
export function clearCloneCache() {
|
|
625
|
+
for (const entry of cloneCache.values()) {
|
|
626
|
+
try {
|
|
627
|
+
rmSync(entry.localPath, { recursive: true, force: true });
|
|
628
|
+
}
|
|
629
|
+
catch {
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
cloneCache.clear();
|
|
633
|
+
cachedConfig = null;
|
|
634
|
+
}
|
|
635
|
+
//# sourceMappingURL=github-extract.js.map
|