@aria-cli/tools 1.0.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/dist/.aria-build-stamp.json +4 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/ask-user-interaction.d.ts +11 -0
- package/dist/ask-user-interaction.d.ts.map +1 -0
- package/dist/ask-user-interaction.js +23 -0
- package/dist/ask-user-interaction.js.map +1 -0
- package/dist/cache/web-cache.d.ts +53 -0
- package/dist/cache/web-cache.d.ts.map +1 -0
- package/dist/cache/web-cache.js +67 -0
- package/dist/cache/web-cache.js.map +1 -0
- package/dist/definitions/arion.d.ts +9 -0
- package/dist/definitions/arion.d.ts.map +1 -0
- package/dist/definitions/arion.js +105 -0
- package/dist/definitions/arion.js.map +1 -0
- package/dist/definitions/browser/browser.d.ts +3 -0
- package/dist/definitions/browser/browser.d.ts.map +1 -0
- package/dist/definitions/browser/browser.js +419 -0
- package/dist/definitions/browser/browser.js.map +1 -0
- package/dist/definitions/browser/index.d.ts +2 -0
- package/dist/definitions/browser/index.d.ts.map +1 -0
- package/dist/definitions/browser/index.js +5 -0
- package/dist/definitions/browser/index.js.map +1 -0
- package/dist/definitions/browser/pw-downloads.d.ts +14 -0
- package/dist/definitions/browser/pw-downloads.d.ts.map +1 -0
- package/dist/definitions/browser/pw-downloads.js +115 -0
- package/dist/definitions/browser/pw-downloads.js.map +1 -0
- package/dist/definitions/browser/pw-interactions.d.ts +79 -0
- package/dist/definitions/browser/pw-interactions.d.ts.map +1 -0
- package/dist/definitions/browser/pw-interactions.js +200 -0
- package/dist/definitions/browser/pw-interactions.js.map +1 -0
- package/dist/definitions/browser/pw-responses.d.ts +29 -0
- package/dist/definitions/browser/pw-responses.d.ts.map +1 -0
- package/dist/definitions/browser/pw-responses.js +77 -0
- package/dist/definitions/browser/pw-responses.js.map +1 -0
- package/dist/definitions/browser/pw-session.d.ts +66 -0
- package/dist/definitions/browser/pw-session.d.ts.map +1 -0
- package/dist/definitions/browser/pw-session.js +311 -0
- package/dist/definitions/browser/pw-session.js.map +1 -0
- package/dist/definitions/browser/pw-shared.d.ts +23 -0
- package/dist/definitions/browser/pw-shared.d.ts.map +1 -0
- package/dist/definitions/browser/pw-shared.js +67 -0
- package/dist/definitions/browser/pw-shared.js.map +1 -0
- package/dist/definitions/browser/pw-snapshot.d.ts +35 -0
- package/dist/definitions/browser/pw-snapshot.d.ts.map +1 -0
- package/dist/definitions/browser/pw-snapshot.js +302 -0
- package/dist/definitions/browser/pw-snapshot.js.map +1 -0
- package/dist/definitions/browser/pw-state.d.ts +23 -0
- package/dist/definitions/browser/pw-state.d.ts.map +1 -0
- package/dist/definitions/browser/pw-state.js +63 -0
- package/dist/definitions/browser/pw-state.js.map +1 -0
- package/dist/definitions/browser/types.d.ts +278 -0
- package/dist/definitions/browser/types.d.ts.map +1 -0
- package/dist/definitions/browser/types.js +5 -0
- package/dist/definitions/browser/types.js.map +1 -0
- package/dist/definitions/core.d.ts +45 -0
- package/dist/definitions/core.d.ts.map +1 -0
- package/dist/definitions/core.js +98 -0
- package/dist/definitions/core.js.map +1 -0
- package/dist/definitions/delegation.d.ts +12 -0
- package/dist/definitions/delegation.d.ts.map +1 -0
- package/dist/definitions/delegation.js +513 -0
- package/dist/definitions/delegation.js.map +1 -0
- package/dist/definitions/deploy.d.ts +16 -0
- package/dist/definitions/deploy.d.ts.map +1 -0
- package/dist/definitions/deploy.js +66 -0
- package/dist/definitions/deploy.js.map +1 -0
- package/dist/definitions/filesystem.d.ts +9 -0
- package/dist/definitions/filesystem.d.ts.map +1 -0
- package/dist/definitions/filesystem.js +231 -0
- package/dist/definitions/filesystem.js.map +1 -0
- package/dist/definitions/index.d.ts +17 -0
- package/dist/definitions/index.d.ts.map +1 -0
- package/dist/definitions/index.js +18 -0
- package/dist/definitions/index.js.map +1 -0
- package/dist/definitions/memory.d.ts +9 -0
- package/dist/definitions/memory.d.ts.map +1 -0
- package/dist/definitions/memory.js +124 -0
- package/dist/definitions/memory.js.map +1 -0
- package/dist/definitions/messaging.d.ts +12 -0
- package/dist/definitions/messaging.d.ts.map +1 -0
- package/dist/definitions/messaging.js +626 -0
- package/dist/definitions/messaging.js.map +1 -0
- package/dist/definitions/meta.d.ts +12 -0
- package/dist/definitions/meta.d.ts.map +1 -0
- package/dist/definitions/meta.js +350 -0
- package/dist/definitions/meta.js.map +1 -0
- package/dist/definitions/network.d.ts +12 -0
- package/dist/definitions/network.d.ts.map +1 -0
- package/dist/definitions/network.js +160 -0
- package/dist/definitions/network.js.map +1 -0
- package/dist/definitions/outlook.d.ts +3 -0
- package/dist/definitions/outlook.d.ts.map +1 -0
- package/dist/definitions/outlook.js +278 -0
- package/dist/definitions/outlook.js.map +1 -0
- package/dist/definitions/patch/apply-patch.d.ts +12 -0
- package/dist/definitions/patch/apply-patch.d.ts.map +1 -0
- package/dist/definitions/patch/apply-patch.js +185 -0
- package/dist/definitions/patch/apply-patch.js.map +1 -0
- package/dist/definitions/patch/fuzzy-match.d.ts +11 -0
- package/dist/definitions/patch/fuzzy-match.d.ts.map +1 -0
- package/dist/definitions/patch/fuzzy-match.js +167 -0
- package/dist/definitions/patch/fuzzy-match.js.map +1 -0
- package/dist/definitions/patch/index.d.ts +2 -0
- package/dist/definitions/patch/index.d.ts.map +1 -0
- package/dist/definitions/patch/index.js +2 -0
- package/dist/definitions/patch/index.js.map +1 -0
- package/dist/definitions/patch/patch-parser.d.ts +51 -0
- package/dist/definitions/patch/patch-parser.d.ts.map +1 -0
- package/dist/definitions/patch/patch-parser.js +208 -0
- package/dist/definitions/patch/patch-parser.js.map +1 -0
- package/dist/definitions/patch/sandbox-paths.d.ts +19 -0
- package/dist/definitions/patch/sandbox-paths.d.ts.map +1 -0
- package/dist/definitions/patch/sandbox-paths.js +106 -0
- package/dist/definitions/patch/sandbox-paths.js.map +1 -0
- package/dist/definitions/process/index.d.ts +2 -0
- package/dist/definitions/process/index.d.ts.map +1 -0
- package/dist/definitions/process/index.js +5 -0
- package/dist/definitions/process/index.js.map +1 -0
- package/dist/definitions/process/process-registry.d.ts +68 -0
- package/dist/definitions/process/process-registry.d.ts.map +1 -0
- package/dist/definitions/process/process-registry.js +214 -0
- package/dist/definitions/process/process-registry.js.map +1 -0
- package/dist/definitions/process/process.d.ts +10 -0
- package/dist/definitions/process/process.d.ts.map +1 -0
- package/dist/definitions/process/process.js +387 -0
- package/dist/definitions/process/process.js.map +1 -0
- package/dist/definitions/process/pty-keys.d.ts +14 -0
- package/dist/definitions/process/pty-keys.d.ts.map +1 -0
- package/dist/definitions/process/pty-keys.js +255 -0
- package/dist/definitions/process/pty-keys.js.map +1 -0
- package/dist/definitions/process/session-slug.d.ts +2 -0
- package/dist/definitions/process/session-slug.d.ts.map +1 -0
- package/dist/definitions/process/session-slug.js +143 -0
- package/dist/definitions/process/session-slug.js.map +1 -0
- package/dist/definitions/quip.d.ts +3 -0
- package/dist/definitions/quip.d.ts.map +1 -0
- package/dist/definitions/quip.js +196 -0
- package/dist/definitions/quip.js.map +1 -0
- package/dist/definitions/session-history.d.ts +12 -0
- package/dist/definitions/session-history.d.ts.map +1 -0
- package/dist/definitions/session-history.js +70 -0
- package/dist/definitions/session-history.js.map +1 -0
- package/dist/definitions/shell.d.ts +9 -0
- package/dist/definitions/shell.d.ts.map +1 -0
- package/dist/definitions/shell.js +182 -0
- package/dist/definitions/shell.js.map +1 -0
- package/dist/definitions/slack.d.ts +3 -0
- package/dist/definitions/slack.d.ts.map +1 -0
- package/dist/definitions/slack.js +181 -0
- package/dist/definitions/slack.js.map +1 -0
- package/dist/definitions/web.d.ts +9 -0
- package/dist/definitions/web.d.ts.map +1 -0
- package/dist/definitions/web.js +110 -0
- package/dist/definitions/web.js.map +1 -0
- package/dist/executors/apply-patch.d.ts +52 -0
- package/dist/executors/apply-patch.d.ts.map +1 -0
- package/dist/executors/apply-patch.js +884 -0
- package/dist/executors/apply-patch.js.map +1 -0
- package/dist/executors/arion.d.ts +51 -0
- package/dist/executors/arion.d.ts.map +1 -0
- package/dist/executors/arion.js +120 -0
- package/dist/executors/arion.js.map +1 -0
- package/dist/executors/deploy.d.ts +170 -0
- package/dist/executors/deploy.d.ts.map +1 -0
- package/dist/executors/deploy.js +849 -0
- package/dist/executors/deploy.js.map +1 -0
- package/dist/executors/filesystem.d.ts +151 -0
- package/dist/executors/filesystem.d.ts.map +1 -0
- package/dist/executors/filesystem.js +1117 -0
- package/dist/executors/filesystem.js.map +1 -0
- package/dist/executors/index.d.ts +39 -0
- package/dist/executors/index.d.ts.map +1 -0
- package/dist/executors/index.js +42 -0
- package/dist/executors/index.js.map +1 -0
- package/dist/executors/learning-meta.d.ts +88 -0
- package/dist/executors/learning-meta.d.ts.map +1 -0
- package/dist/executors/learning-meta.js +1147 -0
- package/dist/executors/learning-meta.js.map +1 -0
- package/dist/executors/memory.d.ts +204 -0
- package/dist/executors/memory.d.ts.map +1 -0
- package/dist/executors/memory.js +751 -0
- package/dist/executors/memory.js.map +1 -0
- package/dist/executors/meta.d.ts +74 -0
- package/dist/executors/meta.d.ts.map +1 -0
- package/dist/executors/meta.js +221 -0
- package/dist/executors/meta.js.map +1 -0
- package/dist/executors/process-registry.d.ts +99 -0
- package/dist/executors/process-registry.d.ts.map +1 -0
- package/dist/executors/process-registry.js +466 -0
- package/dist/executors/process-registry.js.map +1 -0
- package/dist/executors/pty-session-store.d.ts +15 -0
- package/dist/executors/pty-session-store.d.ts.map +1 -0
- package/dist/executors/pty-session-store.js +31 -0
- package/dist/executors/pty-session-store.js.map +1 -0
- package/dist/executors/pty.d.ts +134 -0
- package/dist/executors/pty.d.ts.map +1 -0
- package/dist/executors/pty.js +272 -0
- package/dist/executors/pty.js.map +1 -0
- package/dist/executors/restart.d.ts +19 -0
- package/dist/executors/restart.d.ts.map +1 -0
- package/dist/executors/restart.js +151 -0
- package/dist/executors/restart.js.map +1 -0
- package/dist/executors/search-types.d.ts +53 -0
- package/dist/executors/search-types.d.ts.map +1 -0
- package/dist/executors/search-types.js +53 -0
- package/dist/executors/search-types.js.map +1 -0
- package/dist/executors/self-diagnose.d.ts +90 -0
- package/dist/executors/self-diagnose.d.ts.map +1 -0
- package/dist/executors/self-diagnose.js +399 -0
- package/dist/executors/self-diagnose.js.map +1 -0
- package/dist/executors/session-history.d.ts +76 -0
- package/dist/executors/session-history.d.ts.map +1 -0
- package/dist/executors/session-history.js +284 -0
- package/dist/executors/session-history.js.map +1 -0
- package/dist/executors/shell-safety.d.ts +28 -0
- package/dist/executors/shell-safety.d.ts.map +1 -0
- package/dist/executors/shell-safety.js +474 -0
- package/dist/executors/shell-safety.js.map +1 -0
- package/dist/executors/shell.d.ts +169 -0
- package/dist/executors/shell.d.ts.map +1 -0
- package/dist/executors/shell.js +955 -0
- package/dist/executors/shell.js.map +1 -0
- package/dist/executors/utils.d.ts +21 -0
- package/dist/executors/utils.d.ts.map +1 -0
- package/dist/executors/utils.js +34 -0
- package/dist/executors/utils.js.map +1 -0
- package/dist/executors/web.d.ts +90 -0
- package/dist/executors/web.d.ts.map +1 -0
- package/dist/executors/web.js +543 -0
- package/dist/executors/web.js.map +1 -0
- package/dist/extraction/content-extraction.d.ts +49 -0
- package/dist/extraction/content-extraction.d.ts.map +1 -0
- package/dist/extraction/content-extraction.js +236 -0
- package/dist/extraction/content-extraction.js.map +1 -0
- package/dist/extraction/index.d.ts +5 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +5 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/headless-control-contract.d.ts +3171 -0
- package/dist/headless-control-contract.d.ts.map +1 -0
- package/dist/headless-control-contract.js +968 -0
- package/dist/headless-control-contract.js.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/local-control-http-auth.d.ts +3 -0
- package/dist/local-control-http-auth.d.ts.map +1 -0
- package/dist/local-control-http-auth.js +3 -0
- package/dist/local-control-http-auth.js.map +1 -0
- package/dist/mcp/client.d.ts +69 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +182 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/connection.d.ts +55 -0
- package/dist/mcp/connection.d.ts.map +1 -0
- package/dist/mcp/connection.js +481 -0
- package/dist/mcp/connection.js.map +1 -0
- package/dist/mcp/index.d.ts +11 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +11 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/jsonrpc.d.ts +37 -0
- package/dist/mcp/jsonrpc.d.ts.map +1 -0
- package/dist/mcp/jsonrpc.js +145 -0
- package/dist/mcp/jsonrpc.js.map +1 -0
- package/dist/mcp/types.d.ts +179 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +8 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/network-control-adapter.d.ts +5 -0
- package/dist/network-control-adapter.d.ts.map +1 -0
- package/dist/network-control-adapter.js +73 -0
- package/dist/network-control-adapter.js.map +1 -0
- package/dist/network-runtime/address-types.d.ts +202 -0
- package/dist/network-runtime/address-types.d.ts.map +1 -0
- package/dist/network-runtime/address-types.js +166 -0
- package/dist/network-runtime/address-types.js.map +1 -0
- package/dist/network-runtime/db-owner-fencing.d.ts +44 -0
- package/dist/network-runtime/db-owner-fencing.d.ts.map +1 -0
- package/dist/network-runtime/db-owner-fencing.js +70 -0
- package/dist/network-runtime/db-owner-fencing.js.map +1 -0
- package/dist/network-runtime/delivery-receipts.d.ts +118 -0
- package/dist/network-runtime/delivery-receipts.d.ts.map +1 -0
- package/dist/network-runtime/delivery-receipts.js +268 -0
- package/dist/network-runtime/delivery-receipts.js.map +1 -0
- package/dist/network-runtime/direct-endpoint-authority.d.ts +9 -0
- package/dist/network-runtime/direct-endpoint-authority.d.ts.map +1 -0
- package/dist/network-runtime/direct-endpoint-authority.js +26 -0
- package/dist/network-runtime/direct-endpoint-authority.js.map +1 -0
- package/dist/network-runtime/index.d.ts +25 -0
- package/dist/network-runtime/index.d.ts.map +1 -0
- package/dist/network-runtime/index.js +13 -0
- package/dist/network-runtime/index.js.map +1 -0
- package/dist/network-runtime/local-control-contract.d.ts +753 -0
- package/dist/network-runtime/local-control-contract.d.ts.map +1 -0
- package/dist/network-runtime/local-control-contract.js +622 -0
- package/dist/network-runtime/local-control-contract.js.map +1 -0
- package/dist/network-runtime/node-store-contract.d.ts +50 -0
- package/dist/network-runtime/node-store-contract.d.ts.map +1 -0
- package/dist/network-runtime/node-store-contract.js +35 -0
- package/dist/network-runtime/node-store-contract.js.map +1 -0
- package/dist/network-runtime/pair-route-contract.d.ts +101 -0
- package/dist/network-runtime/pair-route-contract.d.ts.map +1 -0
- package/dist/network-runtime/pair-route-contract.js +78 -0
- package/dist/network-runtime/pair-route-contract.js.map +1 -0
- package/dist/network-runtime/peer-capabilities.d.ts +11 -0
- package/dist/network-runtime/peer-capabilities.d.ts.map +1 -0
- package/dist/network-runtime/peer-capabilities.js +29 -0
- package/dist/network-runtime/peer-capabilities.js.map +1 -0
- package/dist/network-runtime/peer-principal-ref.d.ts +10 -0
- package/dist/network-runtime/peer-principal-ref.d.ts.map +1 -0
- package/dist/network-runtime/peer-principal-ref.js +13 -0
- package/dist/network-runtime/peer-principal-ref.js.map +1 -0
- package/dist/network-runtime/peer-state-machine.d.ts +71 -0
- package/dist/network-runtime/peer-state-machine.d.ts.map +1 -0
- package/dist/network-runtime/peer-state-machine.js +122 -0
- package/dist/network-runtime/peer-state-machine.js.map +1 -0
- package/dist/network-runtime/protocol-schemas.d.ts +329 -0
- package/dist/network-runtime/protocol-schemas.d.ts.map +1 -0
- package/dist/network-runtime/protocol-schemas.js +206 -0
- package/dist/network-runtime/protocol-schemas.js.map +1 -0
- package/dist/network-runtime/runtime-bootstrap-contract.d.ts +82 -0
- package/dist/network-runtime/runtime-bootstrap-contract.d.ts.map +1 -0
- package/dist/network-runtime/runtime-bootstrap-contract.js +61 -0
- package/dist/network-runtime/runtime-bootstrap-contract.js.map +1 -0
- package/dist/outlook/desktop-session.d.ts +69 -0
- package/dist/outlook/desktop-session.d.ts.map +1 -0
- package/dist/outlook/desktop-session.js +280 -0
- package/dist/outlook/desktop-session.js.map +1 -0
- package/dist/policy.d.ts +44 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +150 -0
- package/dist/policy.js.map +1 -0
- package/dist/providers/brave.d.ts +11 -0
- package/dist/providers/brave.d.ts.map +1 -0
- package/dist/providers/brave.js +63 -0
- package/dist/providers/brave.js.map +1 -0
- package/dist/providers/duckduckgo.d.ts +19 -0
- package/dist/providers/duckduckgo.d.ts.map +1 -0
- package/dist/providers/duckduckgo.js +177 -0
- package/dist/providers/duckduckgo.js.map +1 -0
- package/dist/providers/exa.d.ts +11 -0
- package/dist/providers/exa.d.ts.map +1 -0
- package/dist/providers/exa.js +64 -0
- package/dist/providers/exa.js.map +1 -0
- package/dist/providers/firecrawl.d.ts +11 -0
- package/dist/providers/firecrawl.d.ts.map +1 -0
- package/dist/providers/firecrawl.js +56 -0
- package/dist/providers/firecrawl.js.map +1 -0
- package/dist/providers/index.d.ts +9 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +8 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/jina.d.ts +11 -0
- package/dist/providers/jina.d.ts.map +1 -0
- package/dist/providers/jina.js +50 -0
- package/dist/providers/jina.js.map +1 -0
- package/dist/providers/router.d.ts +22 -0
- package/dist/providers/router.d.ts.map +1 -0
- package/dist/providers/router.js +97 -0
- package/dist/providers/router.js.map +1 -0
- package/dist/providers/search-provider.d.ts +36 -0
- package/dist/providers/search-provider.d.ts.map +1 -0
- package/dist/providers/search-provider.js +33 -0
- package/dist/providers/search-provider.js.map +1 -0
- package/dist/providers/tavily.d.ts +11 -0
- package/dist/providers/tavily.d.ts.map +1 -0
- package/dist/providers/tavily.js +55 -0
- package/dist/providers/tavily.js.map +1 -0
- package/dist/quip/desktop-session.d.ts +70 -0
- package/dist/quip/desktop-session.d.ts.map +1 -0
- package/dist/quip/desktop-session.js +318 -0
- package/dist/quip/desktop-session.js.map +1 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +2 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/registry.d.ts +157 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +757 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/runtime-socket-local-control-client.d.ts +11 -0
- package/dist/runtime-socket-local-control-client.d.ts.map +1 -0
- package/dist/runtime-socket-local-control-client.js +331 -0
- package/dist/runtime-socket-local-control-client.js.map +1 -0
- package/dist/security/dns-normalization.d.ts +7 -0
- package/dist/security/dns-normalization.d.ts.map +1 -0
- package/dist/security/dns-normalization.js +20 -0
- package/dist/security/dns-normalization.js.map +1 -0
- package/dist/security/dns-pinning.d.ts +28 -0
- package/dist/security/dns-pinning.d.ts.map +1 -0
- package/dist/security/dns-pinning.js +124 -0
- package/dist/security/dns-pinning.js.map +1 -0
- package/dist/security/external-content.d.ts +41 -0
- package/dist/security/external-content.d.ts.map +1 -0
- package/dist/security/external-content.js +92 -0
- package/dist/security/external-content.js.map +1 -0
- package/dist/security/ssrf.d.ts +41 -0
- package/dist/security/ssrf.d.ts.map +1 -0
- package/dist/security/ssrf.js +182 -0
- package/dist/security/ssrf.js.map +1 -0
- package/dist/slack/desktop-session.d.ts +70 -0
- package/dist/slack/desktop-session.d.ts.map +1 -0
- package/dist/slack/desktop-session.js +325 -0
- package/dist/slack/desktop-session.js.map +1 -0
- package/dist/tool-factory.d.ts +47 -0
- package/dist/tool-factory.d.ts.map +1 -0
- package/dist/tool-factory.js +48 -0
- package/dist/tool-factory.js.map +1 -0
- package/dist/types.d.ts +1189 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/retry.d.ts +12 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +133 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/safe-parse-json.d.ts +27 -0
- package/dist/utils/safe-parse-json.d.ts.map +1 -0
- package/dist/utils/safe-parse-json.js +161 -0
- package/dist/utils/safe-parse-json.js.map +1 -0
- package/dist/utils/url.d.ts +11 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +20 -0
- package/dist/utils/url.js.map +1 -0
- package/dist-cjs/.tsbuildinfo +1 -0
- package/dist-cjs/ask-user-interaction.d.ts +10 -0
- package/dist-cjs/ask-user-interaction.js +28 -0
- package/dist-cjs/ask-user-interaction.js.map +1 -0
- package/dist-cjs/cache/web-cache.d.ts +52 -0
- package/dist-cjs/cache/web-cache.js +71 -0
- package/dist-cjs/cache/web-cache.js.map +1 -0
- package/dist-cjs/definitions/arion.d.ts +8 -0
- package/dist-cjs/definitions/arion.js +108 -0
- package/dist-cjs/definitions/arion.js.map +1 -0
- package/dist-cjs/definitions/browser/browser.d.ts +2 -0
- package/dist-cjs/definitions/browser/browser.js +422 -0
- package/dist-cjs/definitions/browser/browser.js.map +1 -0
- package/dist-cjs/definitions/browser/index.d.ts +1 -0
- package/dist-cjs/definitions/browser/index.js +9 -0
- package/dist-cjs/definitions/browser/index.js.map +1 -0
- package/dist-cjs/definitions/browser/pw-downloads.d.ts +13 -0
- package/dist-cjs/definitions/browser/pw-downloads.js +118 -0
- package/dist-cjs/definitions/browser/pw-downloads.js.map +1 -0
- package/dist-cjs/definitions/browser/pw-interactions.d.ts +78 -0
- package/dist-cjs/definitions/browser/pw-interactions.js +214 -0
- package/dist-cjs/definitions/browser/pw-interactions.js.map +1 -0
- package/dist-cjs/definitions/browser/pw-responses.d.ts +28 -0
- package/dist-cjs/definitions/browser/pw-responses.js +85 -0
- package/dist-cjs/definitions/browser/pw-responses.js.map +1 -0
- package/dist-cjs/definitions/browser/pw-session.d.ts +65 -0
- package/dist-cjs/definitions/browser/pw-session.js +327 -0
- package/dist-cjs/definitions/browser/pw-session.js.map +1 -0
- package/dist-cjs/definitions/browser/pw-shared.d.ts +22 -0
- package/dist-cjs/definitions/browser/pw-shared.js +73 -0
- package/dist-cjs/definitions/browser/pw-shared.js.map +1 -0
- package/dist-cjs/definitions/browser/pw-snapshot.d.ts +34 -0
- package/dist-cjs/definitions/browser/pw-snapshot.js +308 -0
- package/dist-cjs/definitions/browser/pw-snapshot.js.map +1 -0
- package/dist-cjs/definitions/browser/pw-state.d.ts +22 -0
- package/dist-cjs/definitions/browser/pw-state.js +71 -0
- package/dist-cjs/definitions/browser/pw-state.js.map +1 -0
- package/dist-cjs/definitions/browser/types.d.ts +277 -0
- package/dist-cjs/definitions/browser/types.js +6 -0
- package/dist-cjs/definitions/browser/types.js.map +1 -0
- package/dist-cjs/definitions/core.d.ts +44 -0
- package/dist-cjs/definitions/core.js +119 -0
- package/dist-cjs/definitions/core.js.map +1 -0
- package/dist-cjs/definitions/delegation.d.ts +11 -0
- package/dist-cjs/definitions/delegation.js +516 -0
- package/dist-cjs/definitions/delegation.js.map +1 -0
- package/dist-cjs/definitions/deploy.d.ts +15 -0
- package/dist-cjs/definitions/deploy.js +69 -0
- package/dist-cjs/definitions/deploy.js.map +1 -0
- package/dist-cjs/definitions/filesystem.d.ts +8 -0
- package/dist-cjs/definitions/filesystem.js +234 -0
- package/dist-cjs/definitions/filesystem.js.map +1 -0
- package/dist-cjs/definitions/index.d.ts +16 -0
- package/dist-cjs/definitions/index.js +38 -0
- package/dist-cjs/definitions/index.js.map +1 -0
- package/dist-cjs/definitions/memory.d.ts +8 -0
- package/dist-cjs/definitions/memory.js +127 -0
- package/dist-cjs/definitions/memory.js.map +1 -0
- package/dist-cjs/definitions/messaging.d.ts +11 -0
- package/dist-cjs/definitions/messaging.js +632 -0
- package/dist-cjs/definitions/messaging.js.map +1 -0
- package/dist-cjs/definitions/meta.d.ts +11 -0
- package/dist-cjs/definitions/meta.js +353 -0
- package/dist-cjs/definitions/meta.js.map +1 -0
- package/dist-cjs/definitions/network.d.ts +11 -0
- package/dist-cjs/definitions/network.js +163 -0
- package/dist-cjs/definitions/network.js.map +1 -0
- package/dist-cjs/definitions/outlook.d.ts +2 -0
- package/dist-cjs/definitions/outlook.js +281 -0
- package/dist-cjs/definitions/outlook.js.map +1 -0
- package/dist-cjs/definitions/patch/apply-patch.d.ts +11 -0
- package/dist-cjs/definitions/patch/apply-patch.js +192 -0
- package/dist-cjs/definitions/patch/apply-patch.js.map +1 -0
- package/dist-cjs/definitions/patch/fuzzy-match.d.ts +10 -0
- package/dist-cjs/definitions/patch/fuzzy-match.js +173 -0
- package/dist-cjs/definitions/patch/fuzzy-match.js.map +1 -0
- package/dist-cjs/definitions/patch/index.d.ts +1 -0
- package/dist-cjs/definitions/patch/index.js +6 -0
- package/dist-cjs/definitions/patch/index.js.map +1 -0
- package/dist-cjs/definitions/patch/patch-parser.d.ts +50 -0
- package/dist-cjs/definitions/patch/patch-parser.js +216 -0
- package/dist-cjs/definitions/patch/patch-parser.js.map +1 -0
- package/dist-cjs/definitions/patch/sandbox-paths.d.ts +18 -0
- package/dist-cjs/definitions/patch/sandbox-paths.js +114 -0
- package/dist-cjs/definitions/patch/sandbox-paths.js.map +1 -0
- package/dist-cjs/definitions/process/index.d.ts +1 -0
- package/dist-cjs/definitions/process/index.js +9 -0
- package/dist-cjs/definitions/process/index.js.map +1 -0
- package/dist-cjs/definitions/process/process-registry.d.ts +67 -0
- package/dist-cjs/definitions/process/process-registry.js +232 -0
- package/dist-cjs/definitions/process/process-registry.js.map +1 -0
- package/dist-cjs/definitions/process/process.d.ts +9 -0
- package/dist-cjs/definitions/process/process.js +390 -0
- package/dist-cjs/definitions/process/process.js.map +1 -0
- package/dist-cjs/definitions/process/pty-keys.d.ts +13 -0
- package/dist-cjs/definitions/process/pty-keys.js +260 -0
- package/dist-cjs/definitions/process/pty-keys.js.map +1 -0
- package/dist-cjs/definitions/process/session-slug.d.ts +1 -0
- package/dist-cjs/definitions/process/session-slug.js +146 -0
- package/dist-cjs/definitions/process/session-slug.js.map +1 -0
- package/dist-cjs/definitions/quip.d.ts +2 -0
- package/dist-cjs/definitions/quip.js +199 -0
- package/dist-cjs/definitions/quip.js.map +1 -0
- package/dist-cjs/definitions/session-history.d.ts +11 -0
- package/dist-cjs/definitions/session-history.js +73 -0
- package/dist-cjs/definitions/session-history.js.map +1 -0
- package/dist-cjs/definitions/shell.d.ts +8 -0
- package/dist-cjs/definitions/shell.js +185 -0
- package/dist-cjs/definitions/shell.js.map +1 -0
- package/dist-cjs/definitions/slack.d.ts +2 -0
- package/dist-cjs/definitions/slack.js +184 -0
- package/dist-cjs/definitions/slack.js.map +1 -0
- package/dist-cjs/definitions/web.d.ts +8 -0
- package/dist-cjs/definitions/web.js +113 -0
- package/dist-cjs/definitions/web.js.map +1 -0
- package/dist-cjs/executors/apply-patch.d.ts +51 -0
- package/dist-cjs/executors/apply-patch.js +921 -0
- package/dist-cjs/executors/apply-patch.js.map +1 -0
- package/dist-cjs/executors/arion.d.ts +50 -0
- package/dist-cjs/executors/arion.js +126 -0
- package/dist-cjs/executors/arion.js.map +1 -0
- package/dist-cjs/executors/deploy.d.ts +169 -0
- package/dist-cjs/executors/deploy.js +870 -0
- package/dist-cjs/executors/deploy.js.map +1 -0
- package/dist-cjs/executors/filesystem.d.ts +150 -0
- package/dist-cjs/executors/filesystem.js +1159 -0
- package/dist-cjs/executors/filesystem.js.map +1 -0
- package/dist-cjs/executors/index.d.ts +38 -0
- package/dist-cjs/executors/index.js +112 -0
- package/dist-cjs/executors/index.js.map +1 -0
- package/dist-cjs/executors/learning-meta.d.ts +87 -0
- package/dist-cjs/executors/learning-meta.js +1166 -0
- package/dist-cjs/executors/learning-meta.js.map +1 -0
- package/dist-cjs/executors/memory.d.ts +203 -0
- package/dist-cjs/executors/memory.js +797 -0
- package/dist-cjs/executors/memory.js.map +1 -0
- package/dist-cjs/executors/meta.d.ts +73 -0
- package/dist-cjs/executors/meta.js +227 -0
- package/dist-cjs/executors/meta.js.map +1 -0
- package/dist-cjs/executors/process-registry.d.ts +98 -0
- package/dist-cjs/executors/process-registry.js +470 -0
- package/dist-cjs/executors/process-registry.js.map +1 -0
- package/dist-cjs/executors/pty-session-store.d.ts +14 -0
- package/dist-cjs/executors/pty-session-store.js +35 -0
- package/dist-cjs/executors/pty-session-store.js.map +1 -0
- package/dist-cjs/executors/pty.d.ts +133 -0
- package/dist-cjs/executors/pty.js +313 -0
- package/dist-cjs/executors/pty.js.map +1 -0
- package/dist-cjs/executors/restart.d.ts +18 -0
- package/dist-cjs/executors/restart.js +187 -0
- package/dist-cjs/executors/restart.js.map +1 -0
- package/dist-cjs/executors/search-types.d.ts +52 -0
- package/dist-cjs/executors/search-types.js +57 -0
- package/dist-cjs/executors/search-types.js.map +1 -0
- package/dist-cjs/executors/self-diagnose.d.ts +89 -0
- package/dist-cjs/executors/self-diagnose.js +435 -0
- package/dist-cjs/executors/self-diagnose.js.map +1 -0
- package/dist-cjs/executors/session-history.d.ts +75 -0
- package/dist-cjs/executors/session-history.js +321 -0
- package/dist-cjs/executors/session-history.js.map +1 -0
- package/dist-cjs/executors/shell-safety.d.ts +27 -0
- package/dist-cjs/executors/shell-safety.js +479 -0
- package/dist-cjs/executors/shell-safety.js.map +1 -0
- package/dist-cjs/executors/shell.d.ts +168 -0
- package/dist-cjs/executors/shell.js +1002 -0
- package/dist-cjs/executors/shell.js.map +1 -0
- package/dist-cjs/executors/utils.d.ts +20 -0
- package/dist-cjs/executors/utils.js +74 -0
- package/dist-cjs/executors/utils.js.map +1 -0
- package/dist-cjs/executors/web.d.ts +89 -0
- package/dist-cjs/executors/web.js +548 -0
- package/dist-cjs/executors/web.js.map +1 -0
- package/dist-cjs/extraction/content-extraction.d.ts +48 -0
- package/dist-cjs/extraction/content-extraction.js +244 -0
- package/dist-cjs/extraction/content-extraction.js.map +1 -0
- package/dist-cjs/extraction/index.d.ts +4 -0
- package/dist-cjs/extraction/index.js +9 -0
- package/dist-cjs/extraction/index.js.map +1 -0
- package/dist-cjs/headless-control-contract.d.ts +3170 -0
- package/dist-cjs/headless-control-contract.js +973 -0
- package/dist-cjs/headless-control-contract.js.map +1 -0
- package/dist-cjs/index.d.ts +62 -0
- package/dist-cjs/index.js +418 -0
- package/dist-cjs/index.js.map +1 -0
- package/dist-cjs/local-control-http-auth.d.ts +2 -0
- package/dist-cjs/local-control-http-auth.js +6 -0
- package/dist-cjs/local-control-http-auth.js.map +1 -0
- package/dist-cjs/mcp/client.d.ts +68 -0
- package/dist-cjs/mcp/client.js +186 -0
- package/dist-cjs/mcp/client.js.map +1 -0
- package/dist-cjs/mcp/connection.d.ts +54 -0
- package/dist-cjs/mcp/connection.js +485 -0
- package/dist-cjs/mcp/connection.js.map +1 -0
- package/dist-cjs/mcp/index.d.ts +10 -0
- package/dist-cjs/mcp/index.js +31 -0
- package/dist-cjs/mcp/index.js.map +1 -0
- package/dist-cjs/mcp/jsonrpc.d.ts +36 -0
- package/dist-cjs/mcp/jsonrpc.js +149 -0
- package/dist-cjs/mcp/jsonrpc.js.map +1 -0
- package/dist-cjs/mcp/types.d.ts +178 -0
- package/dist-cjs/mcp/types.js +9 -0
- package/dist-cjs/mcp/types.js.map +1 -0
- package/dist-cjs/network-control-adapter.d.ts +4 -0
- package/dist-cjs/network-control-adapter.js +78 -0
- package/dist-cjs/network-control-adapter.js.map +1 -0
- package/dist-cjs/network-runtime/address-types.d.ts +201 -0
- package/dist-cjs/network-runtime/address-types.js +169 -0
- package/dist-cjs/network-runtime/address-types.js.map +1 -0
- package/dist-cjs/network-runtime/db-owner-fencing.d.ts +43 -0
- package/dist-cjs/network-runtime/db-owner-fencing.js +77 -0
- package/dist-cjs/network-runtime/db-owner-fencing.js.map +1 -0
- package/dist-cjs/network-runtime/delivery-receipts.d.ts +117 -0
- package/dist-cjs/network-runtime/delivery-receipts.js +277 -0
- package/dist-cjs/network-runtime/delivery-receipts.js.map +1 -0
- package/dist-cjs/network-runtime/direct-endpoint-authority.d.ts +8 -0
- package/dist-cjs/network-runtime/direct-endpoint-authority.js +30 -0
- package/dist-cjs/network-runtime/direct-endpoint-authority.js.map +1 -0
- package/dist-cjs/network-runtime/index.d.ts +24 -0
- package/dist-cjs/network-runtime/index.js +173 -0
- package/dist-cjs/network-runtime/index.js.map +1 -0
- package/dist-cjs/network-runtime/local-control-contract.d.ts +752 -0
- package/dist-cjs/network-runtime/local-control-contract.js +628 -0
- package/dist-cjs/network-runtime/local-control-contract.js.map +1 -0
- package/dist-cjs/network-runtime/node-store-contract.d.ts +49 -0
- package/dist-cjs/network-runtime/node-store-contract.js +39 -0
- package/dist-cjs/network-runtime/node-store-contract.js.map +1 -0
- package/dist-cjs/network-runtime/pair-route-contract.d.ts +100 -0
- package/dist-cjs/network-runtime/pair-route-contract.js +81 -0
- package/dist-cjs/network-runtime/pair-route-contract.js.map +1 -0
- package/dist-cjs/network-runtime/peer-capabilities.d.ts +10 -0
- package/dist-cjs/network-runtime/peer-capabilities.js +38 -0
- package/dist-cjs/network-runtime/peer-capabilities.js.map +1 -0
- package/dist-cjs/network-runtime/peer-principal-ref.d.ts +9 -0
- package/dist-cjs/network-runtime/peer-principal-ref.js +16 -0
- package/dist-cjs/network-runtime/peer-principal-ref.js.map +1 -0
- package/dist-cjs/network-runtime/peer-state-machine.d.ts +70 -0
- package/dist-cjs/network-runtime/peer-state-machine.js +130 -0
- package/dist-cjs/network-runtime/peer-state-machine.js.map +1 -0
- package/dist-cjs/network-runtime/protocol-schemas.d.ts +328 -0
- package/dist-cjs/network-runtime/protocol-schemas.js +213 -0
- package/dist-cjs/network-runtime/protocol-schemas.js.map +1 -0
- package/dist-cjs/network-runtime/runtime-bootstrap-contract.d.ts +81 -0
- package/dist-cjs/network-runtime/runtime-bootstrap-contract.js +64 -0
- package/dist-cjs/network-runtime/runtime-bootstrap-contract.js.map +1 -0
- package/dist-cjs/outlook/desktop-session.d.ts +68 -0
- package/dist-cjs/outlook/desktop-session.js +319 -0
- package/dist-cjs/outlook/desktop-session.js.map +1 -0
- package/dist-cjs/package.json +3 -0
- package/dist-cjs/policy.d.ts +43 -0
- package/dist-cjs/policy.js +156 -0
- package/dist-cjs/policy.js.map +1 -0
- package/dist-cjs/providers/brave.d.ts +10 -0
- package/dist-cjs/providers/brave.js +67 -0
- package/dist-cjs/providers/brave.js.map +1 -0
- package/dist-cjs/providers/duckduckgo.d.ts +18 -0
- package/dist-cjs/providers/duckduckgo.js +181 -0
- package/dist-cjs/providers/duckduckgo.js.map +1 -0
- package/dist-cjs/providers/exa.d.ts +10 -0
- package/dist-cjs/providers/exa.js +68 -0
- package/dist-cjs/providers/exa.js.map +1 -0
- package/dist-cjs/providers/firecrawl.d.ts +10 -0
- package/dist-cjs/providers/firecrawl.js +60 -0
- package/dist-cjs/providers/firecrawl.js.map +1 -0
- package/dist-cjs/providers/index.d.ts +8 -0
- package/dist-cjs/providers/index.js +18 -0
- package/dist-cjs/providers/index.js.map +1 -0
- package/dist-cjs/providers/jina.d.ts +10 -0
- package/dist-cjs/providers/jina.js +54 -0
- package/dist-cjs/providers/jina.js.map +1 -0
- package/dist-cjs/providers/router.d.ts +21 -0
- package/dist-cjs/providers/router.js +101 -0
- package/dist-cjs/providers/router.js.map +1 -0
- package/dist-cjs/providers/search-provider.d.ts +35 -0
- package/dist-cjs/providers/search-provider.js +37 -0
- package/dist-cjs/providers/search-provider.js.map +1 -0
- package/dist-cjs/providers/tavily.d.ts +10 -0
- package/dist-cjs/providers/tavily.js +59 -0
- package/dist-cjs/providers/tavily.js.map +1 -0
- package/dist-cjs/quip/desktop-session.d.ts +69 -0
- package/dist-cjs/quip/desktop-session.js +354 -0
- package/dist-cjs/quip/desktop-session.js.map +1 -0
- package/dist-cjs/registry/index.d.ts +1 -0
- package/dist-cjs/registry/index.js +7 -0
- package/dist-cjs/registry/index.js.map +1 -0
- package/dist-cjs/registry/registry.d.ts +156 -0
- package/dist-cjs/registry/registry.js +762 -0
- package/dist-cjs/registry/registry.js.map +1 -0
- package/dist-cjs/runtime-socket-local-control-client.d.ts +10 -0
- package/dist-cjs/runtime-socket-local-control-client.js +368 -0
- package/dist-cjs/runtime-socket-local-control-client.js.map +1 -0
- package/dist-cjs/security/dns-normalization.d.ts +6 -0
- package/dist-cjs/security/dns-normalization.js +23 -0
- package/dist-cjs/security/dns-normalization.js.map +1 -0
- package/dist-cjs/security/dns-pinning.d.ts +27 -0
- package/dist-cjs/security/dns-pinning.js +161 -0
- package/dist-cjs/security/dns-pinning.js.map +1 -0
- package/dist-cjs/security/external-content.d.ts +40 -0
- package/dist-cjs/security/external-content.js +96 -0
- package/dist-cjs/security/external-content.js.map +1 -0
- package/dist-cjs/security/ssrf.d.ts +40 -0
- package/dist-cjs/security/ssrf.js +222 -0
- package/dist-cjs/security/ssrf.js.map +1 -0
- package/dist-cjs/slack/desktop-session.d.ts +69 -0
- package/dist-cjs/slack/desktop-session.js +367 -0
- package/dist-cjs/slack/desktop-session.js.map +1 -0
- package/dist-cjs/tool-factory.d.ts +46 -0
- package/dist-cjs/tool-factory.js +51 -0
- package/dist-cjs/tool-factory.js.map +1 -0
- package/dist-cjs/types.d.ts +1188 -0
- package/dist-cjs/types.js +9 -0
- package/dist-cjs/types.js.map +1 -0
- package/dist-cjs/utils/retry.d.ts +11 -0
- package/dist-cjs/utils/retry.js +170 -0
- package/dist-cjs/utils/retry.js.map +1 -0
- package/dist-cjs/utils/safe-parse-json.d.ts +26 -0
- package/dist-cjs/utils/safe-parse-json.js +165 -0
- package/dist-cjs/utils/safe-parse-json.js.map +1 -0
- package/dist-cjs/utils/url.d.ts +10 -0
- package/dist-cjs/utils/url.js +24 -0
- package/dist-cjs/utils/url.js.map +1 -0
- package/package.json +55 -0
- package/src/__tests__/web-fetch-download.test.ts +433 -0
- package/src/__tests__/web-tools.test.ts +619 -0
- package/src/ask-user-interaction.ts +33 -0
- package/src/cache/web-cache.ts +110 -0
- package/src/definitions/arion.ts +118 -0
- package/src/definitions/browser/browser.ts +502 -0
- package/src/definitions/browser/index.ts +5 -0
- package/src/definitions/browser/pw-downloads.ts +142 -0
- package/src/definitions/browser/pw-interactions.ts +282 -0
- package/src/definitions/browser/pw-responses.ts +98 -0
- package/src/definitions/browser/pw-session.ts +405 -0
- package/src/definitions/browser/pw-shared.ts +85 -0
- package/src/definitions/browser/pw-snapshot.ts +383 -0
- package/src/definitions/browser/pw-state.ts +101 -0
- package/src/definitions/browser/types.ts +203 -0
- package/src/definitions/core.ts +106 -0
- package/src/definitions/delegation.ts +567 -0
- package/src/definitions/deploy.ts +73 -0
- package/src/definitions/filesystem.ts +253 -0
- package/src/definitions/index.ts +25 -0
- package/src/definitions/memory.ts +150 -0
- package/src/definitions/messaging.ts +734 -0
- package/src/definitions/meta.ts +392 -0
- package/src/definitions/network.ts +179 -0
- package/src/definitions/outlook.ts +318 -0
- package/src/definitions/patch/apply-patch.ts +235 -0
- package/src/definitions/patch/fuzzy-match.ts +217 -0
- package/src/definitions/patch/index.ts +1 -0
- package/src/definitions/patch/patch-parser.ts +297 -0
- package/src/definitions/patch/sandbox-paths.ts +129 -0
- package/src/definitions/process/index.ts +5 -0
- package/src/definitions/process/process-registry.ts +303 -0
- package/src/definitions/process/process.ts +456 -0
- package/src/definitions/process/pty-keys.ts +298 -0
- package/src/definitions/process/session-slug.ts +147 -0
- package/src/definitions/quip.ts +225 -0
- package/src/definitions/session-history.ts +79 -0
- package/src/definitions/shell.ts +202 -0
- package/src/definitions/slack.ts +211 -0
- package/src/definitions/web.ts +119 -0
- package/src/executors/apply-patch.ts +1015 -0
- package/src/executors/arion.ts +199 -0
- package/src/executors/deploy.ts +1066 -0
- package/src/executors/filesystem.ts +1421 -0
- package/src/executors/index.ts +222 -0
- package/src/executors/learning-meta.ts +1367 -0
- package/src/executors/memory.ts +978 -0
- package/src/executors/meta.ts +293 -0
- package/src/executors/process-registry.ts +570 -0
- package/src/executors/pty-session-store.ts +43 -0
- package/src/executors/pty.ts +342 -0
- package/src/executors/restart.ts +168 -0
- package/src/executors/search-types.ts +98 -0
- package/src/executors/self-diagnose.ts +552 -0
- package/src/executors/session-history.ts +435 -0
- package/src/executors/shell-safety.ts +519 -0
- package/src/executors/shell.ts +1243 -0
- package/src/executors/utils.ts +40 -0
- package/src/executors/web.ts +786 -0
- package/src/extraction/content-extraction.ts +281 -0
- package/src/extraction/index.ts +5 -0
- package/src/headless-control-contract.ts +1149 -0
- package/src/index.ts +763 -0
- package/src/local-control-http-auth.ts +2 -0
- package/src/mcp/client.ts +218 -0
- package/src/mcp/connection.ts +568 -0
- package/src/mcp/index.ts +11 -0
- package/src/mcp/jsonrpc.ts +195 -0
- package/src/mcp/types.ts +199 -0
- package/src/network-control-adapter.ts +88 -0
- package/src/network-runtime/address-types.ts +218 -0
- package/src/network-runtime/db-owner-fencing.ts +91 -0
- package/src/network-runtime/delivery-receipts.ts +372 -0
- package/src/network-runtime/direct-endpoint-authority.ts +35 -0
- package/src/network-runtime/index.ts +316 -0
- package/src/network-runtime/local-control-contract.ts +778 -0
- package/src/network-runtime/node-store-contract.ts +46 -0
- package/src/network-runtime/pair-route-contract.ts +97 -0
- package/src/network-runtime/peer-capabilities.ts +48 -0
- package/src/network-runtime/peer-principal-ref.ts +20 -0
- package/src/network-runtime/peer-state-machine.ts +160 -0
- package/src/network-runtime/protocol-schemas.ts +265 -0
- package/src/network-runtime/runtime-bootstrap-contract.ts +83 -0
- package/src/outlook/desktop-session.ts +409 -0
- package/src/policy.ts +171 -0
- package/src/providers/brave.ts +80 -0
- package/src/providers/duckduckgo.ts +199 -0
- package/src/providers/exa.ts +85 -0
- package/src/providers/firecrawl.ts +77 -0
- package/src/providers/index.ts +8 -0
- package/src/providers/jina.ts +70 -0
- package/src/providers/router.ts +121 -0
- package/src/providers/search-provider.ts +74 -0
- package/src/providers/tavily.ts +74 -0
- package/src/quip/desktop-session.ts +435 -0
- package/src/registry/index.ts +1 -0
- package/src/registry/registry.ts +905 -0
- package/src/runtime-socket-local-control-client.ts +632 -0
- package/src/security/dns-normalization.ts +34 -0
- package/src/security/dns-pinning.ts +138 -0
- package/src/security/external-content.ts +129 -0
- package/src/security/ssrf.ts +207 -0
- package/src/slack/desktop-session.ts +493 -0
- package/src/tool-factory.ts +91 -0
- package/src/types.ts +1337 -0
- package/src/utils/retry.ts +163 -0
- package/src/utils/safe-parse-json.ts +176 -0
- package/src/utils/url.ts +20 -0
- package/tests/benchmarks/registry.bench.ts +57 -0
- package/tests/cache/web-cache.test.ts +147 -0
- package/tests/critical-integration.test.ts +1465 -0
- package/tests/definitions/apply-patch.test.ts +586 -0
- package/tests/definitions/browser.test.ts +495 -0
- package/tests/definitions/delegation-pause-resume.test.ts +758 -0
- package/tests/definitions/execution.test.ts +671 -0
- package/tests/definitions/messaging-inbox-scope.test.ts +229 -0
- package/tests/definitions/messaging.test.ts +1468 -0
- package/tests/definitions/outlook.test.ts +30 -0
- package/tests/definitions/process.test.ts +469 -0
- package/tests/definitions/slack.test.ts +28 -0
- package/tests/definitions/tool-inventory.test.ts +207 -0
- package/tests/e2e/delegation-quest-orchestration.e2e.test.ts +433 -0
- package/tests/e2e/memory-tool-discovery-contract.e2e.test.ts +81 -0
- package/tests/executors/apply-patch.test.ts +538 -0
- package/tests/executors/arion.test.ts +309 -0
- package/tests/executors/conversation-primitives.test.ts +250 -0
- package/tests/executors/deploy.test.ts +746 -0
- package/tests/executors/filesystem-tools.test.ts +357 -0
- package/tests/executors/filesystem.test.ts +959 -0
- package/tests/executors/memory-bugfixes.test.ts +257 -0
- package/tests/executors/memory-real-memoria.integration.test.ts +316 -0
- package/tests/executors/memory.test.ts +853 -0
- package/tests/executors/meta-tools.test.ts +411 -0
- package/tests/executors/meta.test.ts +683 -0
- package/tests/executors/path-containment.test.ts +51 -0
- package/tests/executors/process-registry.test.ts +505 -0
- package/tests/executors/pty.test.ts +664 -0
- package/tests/executors/quest-security.test.ts +249 -0
- package/tests/executors/read-file-media.test.ts +230 -0
- package/tests/executors/recall-knowledge-schema.test.ts +209 -0
- package/tests/executors/recall-tags.test.ts +278 -0
- package/tests/executors/remember-null-safety.contract.test.ts +41 -0
- package/tests/executors/restart.test.ts +67 -0
- package/tests/executors/search-unified.test.ts +381 -0
- package/tests/executors/session-history.test.ts +340 -0
- package/tests/executors/session-transcript.test.ts +561 -0
- package/tests/executors/shell-abort.test.ts +416 -0
- package/tests/executors/shell-env-blocklist.test.ts +648 -0
- package/tests/executors/shell-env-process.test.ts +245 -0
- package/tests/executors/shell-process-registry.test.ts +334 -0
- package/tests/executors/shell-tools.test.ts +393 -0
- package/tests/executors/shell.test.ts +690 -0
- package/tests/executors/web-abort-vs-timeout.test.ts +213 -0
- package/tests/executors/web-integration.test.ts +633 -0
- package/tests/executors/web-symlink.test.ts +18 -0
- package/tests/executors/web.test.ts +1400 -0
- package/tests/executors/write-stdin.test.ts +145 -0
- package/tests/extraction/content-extraction.test.ts +153 -0
- package/tests/guards/tools-default-test-lane.integration.test.ts +21 -0
- package/tests/guards/tools-package-test-commands.e2e.test.ts +43 -0
- package/tests/guards/tools-test-lane-manifest.contract.test.ts +76 -0
- package/tests/guards/tools-vitest-workspace-alias.contract.test.ts +63 -0
- package/tests/helpers/async-waits.ts +53 -0
- package/tests/integration/headless-control-contract.integration.test.ts +151 -0
- package/tests/integration/memory-tool-schema-parity.integration.test.ts +67 -0
- package/tests/integration/meta-tools-round-trip.integration.test.ts +506 -0
- package/tests/integration/quest-round-trip.test.ts +303 -0
- package/tests/integration/registry-executor-flow.test.ts +85 -0
- package/tests/integration.test.ts +177 -0
- package/tests/loading-tier.test.ts +126 -0
- package/tests/mcp/client-reconnect.test.ts +267 -0
- package/tests/mcp/connection.test.ts +846 -0
- package/tests/mcp/injectable-logger.test.ts +83 -0
- package/tests/mcp/jsonrpc.test.ts +109 -0
- package/tests/mcp/lifecycle.test.ts +879 -0
- package/tests/network-runtime/address-types.contract.test.ts +143 -0
- package/tests/network-runtime/continuity-bind-schema.contract.test.ts +203 -0
- package/tests/network-runtime/local-control-contract.test.ts +869 -0
- package/tests/network-runtime/local-control-invite-token.contract.test.ts +146 -0
- package/tests/network-runtime/node-store-contract.test.ts +11 -0
- package/tests/network-runtime/pair-protocol-nodeid.contract.test.ts +15 -0
- package/tests/network-runtime/peer-state-machine.contract.test.ts +148 -0
- package/tests/network-runtime/protocol-schemas.contract.test.ts +512 -0
- package/tests/network-runtime/relay-pending-nodeid.contract.test.ts +62 -0
- package/tests/network-runtime/runtime-bootstrap-contract.test.ts +227 -0
- package/tests/network-runtime/runtime-socket-local-control-client.test.ts +621 -0
- package/tests/network-runtime/wait-for-message-script.test.ts +288 -0
- package/tests/parallel.test.ts +71 -0
- package/tests/policy.test.ts +184 -0
- package/tests/print-default-test-lane.ts +14 -0
- package/tests/print-test-lane-manifest.ts +22 -0
- package/tests/providers/brave.test.ts +159 -0
- package/tests/providers/duckduckgo.test.ts +207 -0
- package/tests/providers/exa.test.ts +175 -0
- package/tests/providers/firecrawl.test.ts +168 -0
- package/tests/providers/jina.test.ts +144 -0
- package/tests/providers/router.test.ts +328 -0
- package/tests/providers/tavily.test.ts +165 -0
- package/tests/registry/discovery.test.ts +154 -0
- package/tests/registry/injectable-logger.test.ts +230 -0
- package/tests/registry/input-validation.test.ts +361 -0
- package/tests/registry/interface-completeness.test.ts +85 -0
- package/tests/registry/mcp-integration.test.ts +103 -0
- package/tests/registry/mcp-read-only-hint.test.ts +60 -0
- package/tests/registry/memoria-discovery.test.ts +390 -0
- package/tests/registry/nested-validation.test.ts +283 -0
- package/tests/registry/pseudo-tool-filtering.test.ts +258 -0
- package/tests/registry/registration-lifecycle.test.ts +133 -0
- package/tests/registry-validation.test.ts +424 -0
- package/tests/registry.test.ts +460 -0
- package/tests/security/dns-pinning.test.ts +162 -0
- package/tests/security/external-content.test.ts +144 -0
- package/tests/security/ssrf.test.ts +118 -0
- package/tests/shell-safety-integration.test.ts +32 -0
- package/tests/shell-safety.test.ts +365 -0
- package/tests/slack/desktop-session.test.ts +50 -0
- package/tests/test-lane-manifest.ts +436 -0
- package/tests/test-utils.ts +27 -0
- package/tests/tool-factory.test.ts +188 -0
- package/tests/utils/retry.test.ts +231 -0
- package/tests/utils/url.test.ts +63 -0
- package/tsconfig.cjs.json +16 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +55 -0
- package/vitest.e2e.config.ts +24 -0
- package/vitest.integration.config.ts +24 -0
- package/vitest.native.config.ts +24 -0
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aria/tools - Web tool executors
|
|
3
|
+
*
|
|
4
|
+
* Implementation of web operations for ARIA tool system.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { log } from "@aria/types";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import type { ToolContext, ToolResult } from "../types.js";
|
|
11
|
+
import { success, fail, getErrorMessage } from "./utils.js";
|
|
12
|
+
import { safeParseJson } from "../utils/safe-parse-json.js";
|
|
13
|
+
import { validateUrlStructure, followRedirects, discardResponseBody } from "../security/ssrf.js";
|
|
14
|
+
import { SearchProviderRouter } from "../providers/router.js";
|
|
15
|
+
import {
|
|
16
|
+
TavilySearchProvider,
|
|
17
|
+
DuckDuckGoSearchProvider,
|
|
18
|
+
BraveSearchProvider,
|
|
19
|
+
JinaSearchProvider,
|
|
20
|
+
ExaSearchProvider,
|
|
21
|
+
FirecrawlSearchProvider,
|
|
22
|
+
} from "../providers/index.js";
|
|
23
|
+
import type { SearchProviderEnv, SearchOptions } from "../providers/search-provider.js";
|
|
24
|
+
import { resolveSearchProviderEnv } from "../providers/search-provider.js";
|
|
25
|
+
import {
|
|
26
|
+
searchCache,
|
|
27
|
+
fetchCache,
|
|
28
|
+
browseCache,
|
|
29
|
+
type CachedFetchOutput,
|
|
30
|
+
type CachedBrowseOutput,
|
|
31
|
+
} from "../cache/web-cache.js";
|
|
32
|
+
import { fetchWithSsrf } from "../utils/retry.js";
|
|
33
|
+
import { wrapExternalContent } from "../security/external-content.js";
|
|
34
|
+
import { extractFromResponse } from "../extraction/content-extraction.js";
|
|
35
|
+
import { normalizeGitHubUrl, getUserAgent } from "../utils/url.js";
|
|
36
|
+
|
|
37
|
+
function buildSearchEnv(ctx: ToolContext): SearchProviderEnv {
|
|
38
|
+
const env = ctx.env ?? {};
|
|
39
|
+
return {
|
|
40
|
+
ARIA_SEARCH_PROVIDER: env.ARIA_SEARCH_PROVIDER ?? process.env.ARIA_SEARCH_PROVIDER,
|
|
41
|
+
BRAVE_API_KEY: env.BRAVE_API_KEY ?? process.env.BRAVE_API_KEY,
|
|
42
|
+
FIRECRAWL_API_KEY: env.FIRECRAWL_API_KEY ?? process.env.FIRECRAWL_API_KEY,
|
|
43
|
+
EXA_API_KEY: env.EXA_API_KEY ?? process.env.EXA_API_KEY,
|
|
44
|
+
TAVILY_API_KEY: env.TAVILY_API_KEY ?? process.env.TAVILY_API_KEY,
|
|
45
|
+
JINA_API_KEY: env.JINA_API_KEY ?? process.env.JINA_API_KEY,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function createSearchRouter(env: SearchProviderEnv): SearchProviderRouter {
|
|
50
|
+
return new SearchProviderRouter(
|
|
51
|
+
[
|
|
52
|
+
new BraveSearchProvider(env),
|
|
53
|
+
new TavilySearchProvider(env),
|
|
54
|
+
new JinaSearchProvider(env),
|
|
55
|
+
new ExaSearchProvider(env),
|
|
56
|
+
new FirecrawlSearchProvider(env),
|
|
57
|
+
new DuckDuckGoSearchProvider(),
|
|
58
|
+
],
|
|
59
|
+
env,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Default timeout for fetch requests in milliseconds */
|
|
64
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
65
|
+
|
|
66
|
+
/** Default maximum response size in bytes for fetch (1MB) */
|
|
67
|
+
const FETCH_MAX_SIZE_BYTES = 1 * 1024 * 1024;
|
|
68
|
+
|
|
69
|
+
/** Default maximum response size in bytes for browse (2MB) */
|
|
70
|
+
const BROWSE_MAX_SIZE_BYTES = 2 * 1024 * 1024;
|
|
71
|
+
|
|
72
|
+
const JsonFetchContentSchema = z.union([
|
|
73
|
+
z.record(z.string(), z.unknown()),
|
|
74
|
+
z.array(z.unknown()),
|
|
75
|
+
z.string(),
|
|
76
|
+
z.number(),
|
|
77
|
+
z.boolean(),
|
|
78
|
+
z.null(),
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Creates an AbortController with a timeout.
|
|
83
|
+
*/
|
|
84
|
+
function createTimeoutController(timeoutMs: number): {
|
|
85
|
+
controller: AbortController;
|
|
86
|
+
timeoutId: NodeJS.Timeout;
|
|
87
|
+
} {
|
|
88
|
+
const controller = new AbortController();
|
|
89
|
+
const timeoutId = setTimeout(() => {
|
|
90
|
+
if (!controller.signal.aborted) {
|
|
91
|
+
controller.abort();
|
|
92
|
+
}
|
|
93
|
+
}, timeoutMs);
|
|
94
|
+
return { controller, timeoutId };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Links a parent AbortSignal to a child AbortController, forwarding abort.
|
|
99
|
+
* Returns a cleanup function that MUST be called when the operation completes
|
|
100
|
+
* to prevent the listener from firing after the try/catch scope has exited.
|
|
101
|
+
*/
|
|
102
|
+
function linkAbortSignal(
|
|
103
|
+
parentSignal: AbortSignal | undefined,
|
|
104
|
+
childController: AbortController,
|
|
105
|
+
): () => void {
|
|
106
|
+
if (!parentSignal) return () => {};
|
|
107
|
+
|
|
108
|
+
const onAbort = () => {
|
|
109
|
+
if (!childController.signal.aborted) {
|
|
110
|
+
childController.abort();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
parentSignal.addEventListener("abort", onAbort, { once: true });
|
|
115
|
+
return () => {
|
|
116
|
+
parentSignal.removeEventListener("abort", onAbort);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
interface ReadResponseResult {
|
|
121
|
+
text: string;
|
|
122
|
+
truncated: boolean;
|
|
123
|
+
contentBytes: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Reads a response body with a streaming byte limit.
|
|
128
|
+
* Unlike checking Content-Length alone, this protects against chunked/streaming
|
|
129
|
+
* responses that lack a Content-Length header.
|
|
130
|
+
*
|
|
131
|
+
* When `truncate` is false (default), throws if the limit is exceeded.
|
|
132
|
+
* When `truncate` is true, returns whatever was read up to the limit.
|
|
133
|
+
*/
|
|
134
|
+
async function readResponseWithLimit(
|
|
135
|
+
response: Response,
|
|
136
|
+
maxBytes: number,
|
|
137
|
+
options?: { truncate?: boolean },
|
|
138
|
+
): Promise<ReadResponseResult> {
|
|
139
|
+
const body = response.body;
|
|
140
|
+
if (!body) {
|
|
141
|
+
return { text: "", truncated: false, contentBytes: 0 };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const truncateMode = options?.truncate ?? false;
|
|
145
|
+
const reader = body.getReader();
|
|
146
|
+
const decoder = new TextDecoder();
|
|
147
|
+
const chunks: string[] = [];
|
|
148
|
+
let totalBytes = 0;
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
for (;;) {
|
|
152
|
+
const { done, value } = await reader.read();
|
|
153
|
+
if (done) break;
|
|
154
|
+
|
|
155
|
+
const chunkBytes = value.byteLength;
|
|
156
|
+
if (totalBytes + chunkBytes > maxBytes) {
|
|
157
|
+
if (truncateMode) {
|
|
158
|
+
// Keep what we have so far (exclude the chunk that exceeded the limit)
|
|
159
|
+
reader.cancel();
|
|
160
|
+
chunks.push(decoder.decode());
|
|
161
|
+
return {
|
|
162
|
+
text: chunks.join(""),
|
|
163
|
+
truncated: true,
|
|
164
|
+
contentBytes: totalBytes,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
reader.cancel();
|
|
168
|
+
throw new Error(`Response body exceeds maximum size of ${maxBytes} bytes`);
|
|
169
|
+
}
|
|
170
|
+
totalBytes += chunkBytes;
|
|
171
|
+
chunks.push(decoder.decode(value, { stream: true }));
|
|
172
|
+
}
|
|
173
|
+
// Flush the decoder
|
|
174
|
+
chunks.push(decoder.decode());
|
|
175
|
+
return { text: chunks.join(""), truncated: false, contentBytes: totalBytes };
|
|
176
|
+
} catch (err) {
|
|
177
|
+
reader.cancel();
|
|
178
|
+
throw err;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ============================================================================
|
|
183
|
+
// Web Search
|
|
184
|
+
// ============================================================================
|
|
185
|
+
|
|
186
|
+
export interface WebSearchInput {
|
|
187
|
+
/** Search query */
|
|
188
|
+
query: string;
|
|
189
|
+
/** Maximum number of results */
|
|
190
|
+
limit?: number;
|
|
191
|
+
/** Search topic classification */
|
|
192
|
+
topic?: "general" | "news";
|
|
193
|
+
/** Restrict results to these domains */
|
|
194
|
+
domains?: string[];
|
|
195
|
+
/** Exclude results from these domains */
|
|
196
|
+
excludeDomains?: string[];
|
|
197
|
+
/** Restrict results by freshness window */
|
|
198
|
+
timeRange?: "day" | "week" | "month" | "year";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface WebSearchResult {
|
|
202
|
+
title: string;
|
|
203
|
+
url: string;
|
|
204
|
+
content: string;
|
|
205
|
+
score?: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface WebSearchOutput {
|
|
209
|
+
query: string;
|
|
210
|
+
results: WebSearchResult[];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function ensureWrappedExternalContent(
|
|
214
|
+
content: string,
|
|
215
|
+
source: Parameters<typeof wrapExternalContent>[1],
|
|
216
|
+
): string {
|
|
217
|
+
return wrapExternalContent(content, source).content;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function wrapWebSearchOutput(output: WebSearchOutput): WebSearchOutput {
|
|
221
|
+
return {
|
|
222
|
+
query: output.query,
|
|
223
|
+
results: output.results.map((result) => ({
|
|
224
|
+
...result,
|
|
225
|
+
content: ensureWrappedExternalContent(result.content, "web_search"),
|
|
226
|
+
})),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function hasAdvancedSearchOptions(input: WebSearchInput): boolean {
|
|
231
|
+
return (
|
|
232
|
+
input.limit !== undefined ||
|
|
233
|
+
input.topic !== undefined ||
|
|
234
|
+
(input.domains?.length ?? 0) > 0 ||
|
|
235
|
+
(input.excludeDomains?.length ?? 0) > 0 ||
|
|
236
|
+
input.timeRange !== undefined
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function buildSearchCachePayload(query: string, options: SearchOptions): string {
|
|
241
|
+
return JSON.stringify({ query, ...options });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function buildRouterSearchCacheKey(
|
|
245
|
+
env: SearchProviderEnv,
|
|
246
|
+
query: string,
|
|
247
|
+
options: SearchOptions,
|
|
248
|
+
): string {
|
|
249
|
+
const resolved = resolveSearchProviderEnv(env);
|
|
250
|
+
const providerOverride = resolved.ARIA_SEARCH_PROVIDER ?? "auto";
|
|
251
|
+
const providerAvailability = [
|
|
252
|
+
resolved.BRAVE_API_KEY ? "brave=1" : "brave=0",
|
|
253
|
+
resolved.TAVILY_API_KEY ? "tavily=1" : "tavily=0",
|
|
254
|
+
resolved.JINA_API_KEY ? "jina=1" : "jina=0",
|
|
255
|
+
resolved.EXA_API_KEY ? "exa=1" : "exa=0",
|
|
256
|
+
resolved.FIRECRAWL_API_KEY ? "firecrawl=1" : "firecrawl=0",
|
|
257
|
+
].join(",");
|
|
258
|
+
return `search:router:${providerOverride}:${providerAvailability}:${buildSearchCachePayload(query, options)}`;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function buildNativeSearchCacheKey(
|
|
262
|
+
providerName: string,
|
|
263
|
+
query: string,
|
|
264
|
+
options: SearchOptions,
|
|
265
|
+
): string {
|
|
266
|
+
return `search:native:${providerName}:${buildSearchCachePayload(query, options)}`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Searches the web using the SearchProviderRouter with automatic fallback.
|
|
271
|
+
* Providers are selected based on available API keys (Brave, Tavily, Jina, Exa,
|
|
272
|
+
* Firecrawl, DuckDuckGo). DuckDuckGo is always available as a last resort.
|
|
273
|
+
*
|
|
274
|
+
* Results are cached via LRU+TTL cache for 15 minutes.
|
|
275
|
+
*/
|
|
276
|
+
export async function executeWebSearch(
|
|
277
|
+
input: WebSearchInput,
|
|
278
|
+
ctx: ToolContext,
|
|
279
|
+
): Promise<ToolResult> {
|
|
280
|
+
const limit = input.limit ?? 10;
|
|
281
|
+
const searchOptions: SearchOptions = {
|
|
282
|
+
limit,
|
|
283
|
+
...(input.topic ? { topic: input.topic } : {}),
|
|
284
|
+
...(input.domains ? { domains: input.domains } : {}),
|
|
285
|
+
...(input.excludeDomains ? { excludeDomains: input.excludeDomains } : {}),
|
|
286
|
+
...(input.timeRange ? { timeRange: input.timeRange } : {}),
|
|
287
|
+
};
|
|
288
|
+
const searchEnv = buildSearchEnv(ctx);
|
|
289
|
+
|
|
290
|
+
const advancedOptionsProvided = hasAdvancedSearchOptions(input);
|
|
291
|
+
const nativeSearchAvailable = Boolean(
|
|
292
|
+
ctx.nativeSearchAdapter && ctx.providerContext?.capabilities?.nativeSearch,
|
|
293
|
+
);
|
|
294
|
+
const nativeProviderName = ctx.providerContext?.name ?? "unknown";
|
|
295
|
+
|
|
296
|
+
const routerCacheKey = buildRouterSearchCacheKey(searchEnv, input.query, searchOptions);
|
|
297
|
+
const nativeCacheKey =
|
|
298
|
+
nativeSearchAvailable && !advancedOptionsProvided
|
|
299
|
+
? buildNativeSearchCacheKey(nativeProviderName, input.query, searchOptions)
|
|
300
|
+
: undefined;
|
|
301
|
+
|
|
302
|
+
if (nativeCacheKey) {
|
|
303
|
+
const cachedNative = searchCache.get(nativeCacheKey);
|
|
304
|
+
if (cachedNative) {
|
|
305
|
+
return success(
|
|
306
|
+
`Found ${cachedNative.results.length} cached results for "${input.query}"`,
|
|
307
|
+
wrapWebSearchOutput(cachedNative),
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
const cachedRouter = searchCache.get(routerCacheKey);
|
|
312
|
+
if (cachedRouter) {
|
|
313
|
+
return success(
|
|
314
|
+
`Found ${cachedRouter.results.length} cached results for "${input.query}"`,
|
|
315
|
+
wrapWebSearchOutput(cachedRouter),
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (advancedOptionsProvided && nativeSearchAvailable) {
|
|
321
|
+
log.debug("[web_search] advanced options provided; bypassing native adapter");
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Native search routing: If provider supports native search and adapter is wired, use it
|
|
325
|
+
// Phase 1: Gemini isolated adapter (router-based callback pattern)
|
|
326
|
+
if (nativeSearchAvailable && ctx.nativeSearchAdapter && !advancedOptionsProvided) {
|
|
327
|
+
try {
|
|
328
|
+
const rawResults = await ctx.nativeSearchAdapter(input.query);
|
|
329
|
+
if (rawResults.length === 0) {
|
|
330
|
+
throw new Error("Native search returned no results");
|
|
331
|
+
}
|
|
332
|
+
const results: WebSearchResult[] = rawResults.map((r) => ({
|
|
333
|
+
title: r.title,
|
|
334
|
+
url: r.url,
|
|
335
|
+
content: r.content,
|
|
336
|
+
score: r.score,
|
|
337
|
+
}));
|
|
338
|
+
const output: WebSearchOutput = { query: input.query, results };
|
|
339
|
+
searchCache.set(nativeCacheKey!, output);
|
|
340
|
+
return success(
|
|
341
|
+
`Found ${results.length} results for "${input.query}" (native search)`,
|
|
342
|
+
wrapWebSearchOutput(output),
|
|
343
|
+
);
|
|
344
|
+
} catch (err) {
|
|
345
|
+
// Fall through to SearchProviderRouter on native search failure
|
|
346
|
+
log.debug(`[web_search] native adapter failed, falling back: ${getErrorMessage(err)}`);
|
|
347
|
+
const cachedRouterFallback = searchCache.get(routerCacheKey);
|
|
348
|
+
if (cachedRouterFallback) {
|
|
349
|
+
return success(
|
|
350
|
+
`Found ${cachedRouterFallback.results.length} cached results for "${input.query}"`,
|
|
351
|
+
wrapWebSearchOutput(cachedRouterFallback),
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const searchRouter = createSearchRouter(searchEnv);
|
|
357
|
+
|
|
358
|
+
try {
|
|
359
|
+
// Race search against context abort signal for cancellation support
|
|
360
|
+
let results: Awaited<ReturnType<typeof searchRouter.search>>;
|
|
361
|
+
if (ctx.abortSignal) {
|
|
362
|
+
const abortPromise = new Promise<never>((_resolve, reject) => {
|
|
363
|
+
if (ctx.abortSignal!.aborted) {
|
|
364
|
+
reject(new DOMException("The operation was aborted", "AbortError"));
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
ctx.abortSignal!.addEventListener(
|
|
368
|
+
"abort",
|
|
369
|
+
() => reject(new DOMException("The operation was aborted", "AbortError")),
|
|
370
|
+
{ once: true },
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
results = await Promise.race([searchRouter.search(input.query, searchOptions), abortPromise]);
|
|
374
|
+
} else {
|
|
375
|
+
results = await searchRouter.search(input.query, searchOptions);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Normalize results to WebSearchResult shape (cache raw; wrap at return-time)
|
|
379
|
+
const webResults: WebSearchResult[] = results.map((r) => ({
|
|
380
|
+
title: r.title,
|
|
381
|
+
url: r.url,
|
|
382
|
+
content: r.content,
|
|
383
|
+
score: r.score,
|
|
384
|
+
}));
|
|
385
|
+
|
|
386
|
+
const output: WebSearchOutput = { query: input.query, results: webResults };
|
|
387
|
+
searchCache.set(routerCacheKey, output);
|
|
388
|
+
|
|
389
|
+
return success(
|
|
390
|
+
`Found ${webResults.length} results for "${input.query}"`,
|
|
391
|
+
wrapWebSearchOutput(output),
|
|
392
|
+
);
|
|
393
|
+
} catch (err) {
|
|
394
|
+
if (ctx.abortSignal?.aborted) {
|
|
395
|
+
return fail("Web search cancelled");
|
|
396
|
+
}
|
|
397
|
+
return fail(`Web search failed: ${getErrorMessage(err)}`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// ============================================================================
|
|
402
|
+
// Web Fetch
|
|
403
|
+
// ============================================================================
|
|
404
|
+
|
|
405
|
+
export interface WebFetchInput {
|
|
406
|
+
/** URL to fetch */
|
|
407
|
+
url: string;
|
|
408
|
+
/** Response format: 'text', 'html', or 'json' */
|
|
409
|
+
format?: "text" | "html" | "json";
|
|
410
|
+
/** Custom headers to include in the request */
|
|
411
|
+
headers?: Record<string, string>;
|
|
412
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
413
|
+
timeoutMs?: number;
|
|
414
|
+
/** Maximum response size in bytes (default: 1MB) */
|
|
415
|
+
maxSizeBytes?: number;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export interface WebFetchOutput {
|
|
419
|
+
content: unknown;
|
|
420
|
+
status: number;
|
|
421
|
+
contentType?: string;
|
|
422
|
+
fromCache: boolean;
|
|
423
|
+
fetchedAt: string;
|
|
424
|
+
finalUrl: string;
|
|
425
|
+
contentBytes: number;
|
|
426
|
+
truncated: boolean;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function wrapWebFetchOutput(output: WebFetchOutput): WebFetchOutput {
|
|
430
|
+
if (typeof output.content !== "string") {
|
|
431
|
+
return output;
|
|
432
|
+
}
|
|
433
|
+
return {
|
|
434
|
+
...output,
|
|
435
|
+
content: ensureWrappedExternalContent(output.content, "web_fetch"),
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function markFetchOutputFromCache(cached: CachedFetchOutput): WebFetchOutput {
|
|
440
|
+
return {
|
|
441
|
+
...cached,
|
|
442
|
+
fromCache: true,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function normalizeRequestHeaders(
|
|
447
|
+
headers: Record<string, string> | undefined,
|
|
448
|
+
): Array<[string, string]> {
|
|
449
|
+
if (!headers) {
|
|
450
|
+
return [];
|
|
451
|
+
}
|
|
452
|
+
return Object.entries(headers)
|
|
453
|
+
.map(([name, value]) => [name.trim().toLowerCase(), value.trim()] as [string, string])
|
|
454
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function hashRequestHeaders(headers: Record<string, string> | undefined): string {
|
|
458
|
+
const normalizedHeaders = normalizeRequestHeaders(headers);
|
|
459
|
+
if (normalizedHeaders.length === 0) {
|
|
460
|
+
return "none";
|
|
461
|
+
}
|
|
462
|
+
return createHash("sha256").update(JSON.stringify(normalizedHeaders)).digest("hex");
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function createFetchCacheKey({
|
|
466
|
+
url,
|
|
467
|
+
format,
|
|
468
|
+
headers,
|
|
469
|
+
timeoutMs,
|
|
470
|
+
maxSizeBytes,
|
|
471
|
+
}: {
|
|
472
|
+
url: string;
|
|
473
|
+
format: "text" | "html" | "json";
|
|
474
|
+
headers: Record<string, string> | undefined;
|
|
475
|
+
timeoutMs: number;
|
|
476
|
+
maxSizeBytes: number;
|
|
477
|
+
}): string {
|
|
478
|
+
return `fetch:${url}:${format}:headers=${hashRequestHeaders(headers)}:maxSizeBytes=${maxSizeBytes}:timeoutMs=${timeoutMs}`;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Fetches content from a URL with retry resilience, caching, and security wrapping.
|
|
483
|
+
* Uses fetchWithRetry for automatic retry on transient failures (429, 5xx, ECONNRESET).
|
|
484
|
+
* Results are cached via LRU+TTL cache for 15 minutes.
|
|
485
|
+
*/
|
|
486
|
+
export async function executeWebFetch(input: WebFetchInput, ctx: ToolContext): Promise<ToolResult> {
|
|
487
|
+
// Normalize GitHub blob URLs to raw content URLs before fetching
|
|
488
|
+
const url = normalizeGitHubUrl(input.url);
|
|
489
|
+
|
|
490
|
+
// Validate URL structure. DNS/SSRF safety is enforced by fetchWithSsrf
|
|
491
|
+
// so validation and fetch share one trust boundary.
|
|
492
|
+
const urlError = validateUrlStructure(url);
|
|
493
|
+
if (urlError) {
|
|
494
|
+
return fail(urlError);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const format = input.format ?? "text";
|
|
498
|
+
const timeoutMs = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
499
|
+
const maxSizeBytes = input.maxSizeBytes ?? FETCH_MAX_SIZE_BYTES;
|
|
500
|
+
|
|
501
|
+
// Check cache first (use normalized URL + request variants to avoid collisions)
|
|
502
|
+
const cacheKey = createFetchCacheKey({
|
|
503
|
+
url,
|
|
504
|
+
format,
|
|
505
|
+
headers: input.headers,
|
|
506
|
+
timeoutMs,
|
|
507
|
+
maxSizeBytes,
|
|
508
|
+
});
|
|
509
|
+
const cached = fetchCache.get(cacheKey);
|
|
510
|
+
if (cached) {
|
|
511
|
+
return success(
|
|
512
|
+
`Fetched ${input.url} (cached)`,
|
|
513
|
+
wrapWebFetchOutput(markFetchOutputFromCache(cached)),
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const { controller, timeoutId } = createTimeoutController(timeoutMs);
|
|
518
|
+
|
|
519
|
+
// Forward context abort signal to our controller
|
|
520
|
+
const unlinkAbort = linkAbortSignal(ctx.abortSignal, controller);
|
|
521
|
+
|
|
522
|
+
try {
|
|
523
|
+
const fetchOptions: RequestInit = {
|
|
524
|
+
headers: input.headers ?? {},
|
|
525
|
+
signal: controller.signal,
|
|
526
|
+
redirect: "manual",
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// Use DNS-pinned SSRF fetch wrapper with transient retry support.
|
|
530
|
+
const initialResponse = await fetchWithSsrf(url, fetchOptions, {
|
|
531
|
+
maxAttempts: 2,
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// Follow redirects manually and keep each hop on the same DNS-pinned path.
|
|
535
|
+
const response = await followRedirects(initialResponse, fetchOptions, {
|
|
536
|
+
baseUrl: url,
|
|
537
|
+
fetchFn: (redirectUrl, redirectInit) =>
|
|
538
|
+
fetchWithSsrf(redirectUrl, redirectInit, { maxAttempts: 2 }),
|
|
539
|
+
validateRedirectUrl: validateUrlStructure,
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
clearTimeout(timeoutId);
|
|
543
|
+
|
|
544
|
+
if (!response.ok) {
|
|
545
|
+
await discardResponseBody(response);
|
|
546
|
+
unlinkAbort();
|
|
547
|
+
return fail(`HTTP error: ${response.status} ${response.statusText}`, {
|
|
548
|
+
status: response.status,
|
|
549
|
+
statusText: response.statusText,
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// Check Content-Length header for size limit
|
|
554
|
+
const contentLength = response.headers.get("Content-Length");
|
|
555
|
+
if (contentLength) {
|
|
556
|
+
const size = parseInt(contentLength, 10);
|
|
557
|
+
if (!isNaN(size) && size > maxSizeBytes) {
|
|
558
|
+
await discardResponseBody(response);
|
|
559
|
+
unlinkAbort();
|
|
560
|
+
return fail(`Response too large: ${size} bytes exceeds maximum of ${maxSizeBytes} bytes`);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
const contentType = response.headers.get("Content-Type") ?? undefined;
|
|
565
|
+
let content: unknown;
|
|
566
|
+
|
|
567
|
+
// Use streaming reader to enforce size limit even for chunked responses
|
|
568
|
+
let text: string;
|
|
569
|
+
let contentBytes = 0;
|
|
570
|
+
try {
|
|
571
|
+
const result = await readResponseWithLimit(response, maxSizeBytes);
|
|
572
|
+
text = result.text;
|
|
573
|
+
contentBytes = result.contentBytes;
|
|
574
|
+
if (result.truncated) {
|
|
575
|
+
unlinkAbort();
|
|
576
|
+
return fail(`Response body exceeds maximum size of ${maxSizeBytes} bytes`);
|
|
577
|
+
}
|
|
578
|
+
} catch (sizeErr) {
|
|
579
|
+
unlinkAbort();
|
|
580
|
+
return fail(getErrorMessage(sizeErr));
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (format === "json") {
|
|
584
|
+
const parsed = safeParseJson(text, JsonFetchContentSchema);
|
|
585
|
+
if (!parsed.ok) {
|
|
586
|
+
unlinkAbort();
|
|
587
|
+
return fail(`Failed to parse JSON response (${parsed.reason})`);
|
|
588
|
+
}
|
|
589
|
+
content = parsed.data;
|
|
590
|
+
} else {
|
|
591
|
+
content = text;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
const output: WebFetchOutput = {
|
|
595
|
+
content,
|
|
596
|
+
status: response.status,
|
|
597
|
+
contentType,
|
|
598
|
+
fromCache: false,
|
|
599
|
+
fetchedAt: new Date().toISOString(),
|
|
600
|
+
finalUrl: response.url || url,
|
|
601
|
+
contentBytes,
|
|
602
|
+
truncated: false,
|
|
603
|
+
};
|
|
604
|
+
fetchCache.set(cacheKey, output);
|
|
605
|
+
|
|
606
|
+
unlinkAbort();
|
|
607
|
+
return success(`Fetched ${input.url} (${response.status})`, wrapWebFetchOutput(output));
|
|
608
|
+
} catch (err) {
|
|
609
|
+
clearTimeout(timeoutId);
|
|
610
|
+
unlinkAbort();
|
|
611
|
+
if (
|
|
612
|
+
err instanceof Error &&
|
|
613
|
+
(err.name === "AbortError" || (err instanceof DOMException && err.name === "AbortError"))
|
|
614
|
+
) {
|
|
615
|
+
if (ctx.abortSignal?.aborted) {
|
|
616
|
+
return fail("Request cancelled");
|
|
617
|
+
}
|
|
618
|
+
return fail(`Request timed out after ${timeoutMs}ms`);
|
|
619
|
+
}
|
|
620
|
+
return fail(getErrorMessage(err));
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// ============================================================================
|
|
625
|
+
// Browse
|
|
626
|
+
// ============================================================================
|
|
627
|
+
|
|
628
|
+
/** Default timeout for browsing in milliseconds */
|
|
629
|
+
const BROWSE_TIMEOUT_MS = 30_000;
|
|
630
|
+
|
|
631
|
+
/** Maximum content length returned by browse (characters) — increased from 10K to 50K */
|
|
632
|
+
const BROWSE_MAX_CONTENT_LENGTH = 50_000;
|
|
633
|
+
|
|
634
|
+
export interface BrowseInput {
|
|
635
|
+
/** URL to browse */
|
|
636
|
+
url: string;
|
|
637
|
+
/** Timeout in milliseconds (default: 30000) */
|
|
638
|
+
timeoutMs?: number;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export interface BrowseOutput {
|
|
642
|
+
url: string;
|
|
643
|
+
title: string;
|
|
644
|
+
content: string;
|
|
645
|
+
fromCache: boolean;
|
|
646
|
+
fetchedAt: string;
|
|
647
|
+
finalUrl: string;
|
|
648
|
+
contentBytes: number;
|
|
649
|
+
truncated: boolean;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function wrapBrowseOutput(output: BrowseOutput): BrowseOutput {
|
|
653
|
+
return {
|
|
654
|
+
...output,
|
|
655
|
+
content: ensureWrappedExternalContent(output.content, "browse"),
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
function markBrowseOutputFromCache(cached: CachedBrowseOutput): BrowseOutput {
|
|
660
|
+
return {
|
|
661
|
+
...cached,
|
|
662
|
+
fromCache: true,
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Browses a URL by fetching its HTML content and extracting Markdown.
|
|
668
|
+
* Uses Readability.js + Turndown for article extraction with three-tier fallback.
|
|
669
|
+
* Supports GitHub URL normalization, retry on transient failures, LRU+TTL caching,
|
|
670
|
+
* and nonce-based external content wrapping.
|
|
671
|
+
*/
|
|
672
|
+
export async function executeBrowse(input: BrowseInput, ctx: ToolContext): Promise<ToolResult> {
|
|
673
|
+
// Validate URL
|
|
674
|
+
if (!input.url) {
|
|
675
|
+
return fail("URL is required for browse");
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// Normalize GitHub blob URLs to raw content URLs
|
|
679
|
+
const url = normalizeGitHubUrl(input.url);
|
|
680
|
+
|
|
681
|
+
// Check cache (using normalized URL as key)
|
|
682
|
+
const cached = browseCache.get(url);
|
|
683
|
+
if (cached) {
|
|
684
|
+
return success(
|
|
685
|
+
`Browsed ${input.url} (cached)`,
|
|
686
|
+
wrapBrowseOutput(markBrowseOutputFromCache(cached)),
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
const urlError = validateUrlStructure(url);
|
|
691
|
+
if (urlError) {
|
|
692
|
+
return fail(urlError);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const timeoutMs = input.timeoutMs ?? BROWSE_TIMEOUT_MS;
|
|
696
|
+
const { controller, timeoutId } = createTimeoutController(timeoutMs);
|
|
697
|
+
|
|
698
|
+
// Forward context abort signal to our controller
|
|
699
|
+
const unlinkAbort = linkAbortSignal(ctx.abortSignal, controller);
|
|
700
|
+
|
|
701
|
+
try {
|
|
702
|
+
const fetchOptions: RequestInit = {
|
|
703
|
+
headers: {
|
|
704
|
+
"User-Agent": getUserAgent(),
|
|
705
|
+
Accept: "text/html, application/xhtml+xml, */*",
|
|
706
|
+
},
|
|
707
|
+
signal: controller.signal,
|
|
708
|
+
redirect: "manual",
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// Use DNS-pinned SSRF fetch wrapper with transient retry support.
|
|
712
|
+
const initialResponse = await fetchWithSsrf(url, fetchOptions, {
|
|
713
|
+
maxAttempts: 2,
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
// Follow redirects manually and keep each hop on the same DNS-pinned path.
|
|
717
|
+
const response = await followRedirects(initialResponse, fetchOptions, {
|
|
718
|
+
baseUrl: url,
|
|
719
|
+
fetchFn: (redirectUrl, redirectInit) =>
|
|
720
|
+
fetchWithSsrf(redirectUrl, redirectInit, { maxAttempts: 2 }),
|
|
721
|
+
validateRedirectUrl: validateUrlStructure,
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
clearTimeout(timeoutId);
|
|
725
|
+
|
|
726
|
+
if (!response.ok) {
|
|
727
|
+
await discardResponseBody(response);
|
|
728
|
+
unlinkAbort();
|
|
729
|
+
return fail(`HTTP error fetching ${input.url}: ${response.status} ${response.statusText}`);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// Truncate large pages gracefully — content gets reduced to 50K chars by
|
|
733
|
+
// Readability+Turndown anyway, so the first 2MB of HTML is plenty.
|
|
734
|
+
const {
|
|
735
|
+
text: html,
|
|
736
|
+
truncated: responseTruncated,
|
|
737
|
+
contentBytes,
|
|
738
|
+
} = await readResponseWithLimit(response, BROWSE_MAX_SIZE_BYTES, {
|
|
739
|
+
truncate: true,
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
// Extract content using Content-Type-aware extraction pipeline.
|
|
743
|
+
const { title, content: extractedContent } = await extractFromResponse(
|
|
744
|
+
html,
|
|
745
|
+
url,
|
|
746
|
+
response.headers.get("Content-Type"),
|
|
747
|
+
);
|
|
748
|
+
|
|
749
|
+
// Truncate to 50K character limit
|
|
750
|
+
// extractContent() internally truncates to MAX_CONTENT_LENGTH (50K),
|
|
751
|
+
// so content that was originally longer arrives here at exactly 50K.
|
|
752
|
+
// Use >= to detect content that hit the internal limit.
|
|
753
|
+
const contentLimitReached = extractedContent.length >= BROWSE_MAX_CONTENT_LENGTH;
|
|
754
|
+
const truncated = contentLimitReached || responseTruncated;
|
|
755
|
+
const truncatedContent = contentLimitReached
|
|
756
|
+
? extractedContent.slice(0, BROWSE_MAX_CONTENT_LENGTH) + "\n\n[Content truncated]"
|
|
757
|
+
: responseTruncated
|
|
758
|
+
? extractedContent + "\n\n[Content truncated]"
|
|
759
|
+
: extractedContent;
|
|
760
|
+
|
|
761
|
+
const output: BrowseOutput = {
|
|
762
|
+
url: input.url,
|
|
763
|
+
title,
|
|
764
|
+
content: truncatedContent,
|
|
765
|
+
fromCache: false,
|
|
766
|
+
fetchedAt: new Date().toISOString(),
|
|
767
|
+
finalUrl: response.url || url,
|
|
768
|
+
contentBytes,
|
|
769
|
+
truncated,
|
|
770
|
+
};
|
|
771
|
+
browseCache.set(url, output);
|
|
772
|
+
|
|
773
|
+
unlinkAbort();
|
|
774
|
+
return success(`Browsed ${input.url}`, wrapBrowseOutput(output));
|
|
775
|
+
} catch (err) {
|
|
776
|
+
clearTimeout(timeoutId);
|
|
777
|
+
unlinkAbort();
|
|
778
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
779
|
+
if (ctx.abortSignal?.aborted) {
|
|
780
|
+
return fail("Browse cancelled");
|
|
781
|
+
}
|
|
782
|
+
return fail(`Browse timed out after ${timeoutMs}ms: ${input.url}`);
|
|
783
|
+
}
|
|
784
|
+
return fail(`Browse failed: ${getErrorMessage(err)}`);
|
|
785
|
+
}
|
|
786
|
+
}
|