@browserbasehq/orca 3.0.9-alpha-4 → 3.1.0-patch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli.js +183 -0
- package/dist/cjs/cli.js.map +7 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +24956 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/lib/inference.d.ts +65 -0
- package/dist/cjs/lib/inferenceLogUtils.d.ts +12 -0
- package/dist/cjs/lib/logger.d.ts +69 -0
- package/dist/cjs/lib/modelUtils.d.ts +11 -0
- package/dist/cjs/lib/prompt.d.ts +14 -0
- package/dist/cjs/lib/utils.d.ts +68 -0
- package/dist/cjs/lib/v3/agent/AgentClient.d.ts +19 -0
- package/dist/cjs/lib/v3/agent/AgentProvider.d.ts +20 -0
- package/dist/cjs/lib/v3/agent/AnthropicCUAClient.d.ts +57 -0
- package/dist/cjs/lib/v3/agent/GoogleCUAClient.d.ts +74 -0
- package/dist/cjs/lib/v3/agent/MicrosoftCUAClient.d.ts +71 -0
- package/dist/cjs/lib/v3/agent/OpenAICUAClient.d.ts +69 -0
- package/dist/cjs/lib/v3/agent/prompts/agentSystemPrompt.d.ts +12 -0
- package/dist/cjs/lib/v3/agent/tools/act.d.ts +12 -0
- package/dist/cjs/lib/v3/agent/tools/ariaTree.d.ts +5 -0
- package/dist/cjs/lib/v3/agent/tools/click.d.ts +6 -0
- package/dist/cjs/lib/v3/agent/tools/clickAndHold.d.ts +14 -0
- package/dist/cjs/lib/v3/agent/tools/dragAndDrop.d.ts +7 -0
- package/dist/cjs/lib/v3/agent/tools/extract.d.ts +20 -0
- package/dist/cjs/lib/v3/agent/tools/fillFormVision.d.ts +12 -0
- package/dist/cjs/lib/v3/agent/tools/fillform.d.ts +12 -0
- package/dist/cjs/lib/v3/agent/tools/goto.d.ts +12 -0
- package/dist/cjs/lib/v3/agent/tools/index.d.ts +92 -0
- package/dist/cjs/lib/v3/agent/tools/keys.d.ts +24 -0
- package/dist/cjs/lib/v3/agent/tools/navback.d.ts +6 -0
- package/dist/cjs/lib/v3/agent/tools/screenshot.d.ts +6 -0
- package/dist/cjs/lib/v3/agent/tools/scroll.d.ts +19 -0
- package/dist/cjs/lib/v3/agent/tools/search.d.ts +15 -0
- package/dist/cjs/lib/v3/agent/tools/think.d.ts +6 -0
- package/dist/cjs/lib/v3/agent/tools/type.d.ts +7 -0
- package/dist/cjs/lib/v3/agent/tools/wait.d.ts +5 -0
- package/dist/cjs/lib/v3/agent/utils/actionMapping.d.ts +3 -0
- package/dist/cjs/lib/v3/agent/utils/coordinateNormalization.d.ts +13 -0
- package/dist/cjs/lib/v3/agent/utils/cuaKeyMapping.d.ts +10 -0
- package/dist/cjs/lib/v3/agent/utils/googleCustomToolHandler.d.ts +25 -0
- package/dist/cjs/lib/v3/agent/utils/handleDoneToolCall.d.ts +22 -0
- package/dist/cjs/lib/v3/agent/utils/imageCompression.d.ts +53 -0
- package/dist/cjs/lib/v3/agent/utils/messageProcessing.d.ts +12 -0
- package/dist/cjs/lib/v3/agent/utils/screenshotHandler.d.ts +10 -0
- package/dist/cjs/lib/v3/agent/utils/validateExperimentalFeatures.d.ts +26 -0
- package/dist/cjs/lib/v3/agent/utils/xpath.d.ts +11 -0
- package/dist/cjs/lib/v3/api.d.ts +86 -0
- package/dist/cjs/lib/v3/cache/ActCache.d.ts +23 -0
- package/dist/cjs/lib/v3/cache/AgentCache.d.ts +109 -0
- package/dist/cjs/lib/v3/cache/CacheStorage.d.ts +17 -0
- package/dist/cjs/lib/v3/cache/serverAgentCache.d.ts +7 -0
- package/dist/cjs/lib/v3/cache/utils.d.ts +15 -0
- package/dist/cjs/lib/v3/cli.d.ts +2 -0
- package/dist/cjs/lib/v3/dom/a11yScripts/index.d.ts +11 -0
- package/dist/cjs/lib/v3/dom/build/a11yScripts.generated.d.ts +16 -0
- package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.d.ts +52 -0
- package/dist/cjs/lib/v3/dom/build/reRenderScriptContent.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/build/rerender-index.d.ts +0 -0
- package/dist/cjs/lib/v3/dom/build/rerender-index.js +1 -0
- package/dist/cjs/lib/v3/dom/build/screenshotScripts.generated.d.ts +4 -0
- package/dist/cjs/lib/v3/dom/build/scriptV3Content.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/build/v3-index.d.ts +0 -0
- package/dist/cjs/lib/v3/dom/build/v3-index.js +1 -0
- package/dist/cjs/lib/v3/dom/genA11yScripts.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/genDomScripts.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/genLocatorScripts.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/genScreenshotScripts.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/index.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/locatorScripts/counts.d.ts +15 -0
- package/dist/cjs/lib/v3/dom/locatorScripts/index.d.ts +4 -0
- package/dist/cjs/lib/v3/dom/locatorScripts/scripts.d.ts +37 -0
- package/dist/cjs/lib/v3/dom/locatorScripts/selectors.d.ts +4 -0
- package/dist/cjs/lib/v3/dom/locatorScripts/waitForSelector.d.ts +19 -0
- package/dist/cjs/lib/v3/dom/locatorScripts/xpathParser.d.ts +76 -0
- package/dist/cjs/lib/v3/dom/locatorScripts/xpathResolver.d.ts +9 -0
- package/dist/cjs/lib/v3/dom/piercer.entry.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/piercer.runtime.d.ts +23 -0
- package/dist/cjs/lib/v3/dom/rerenderMissingShadows.entry.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/rerenderMissingShadows.runtime.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/screenshotScripts/index.d.ts +1 -0
- package/dist/cjs/lib/v3/dom/screenshotScripts/resolveMaskRect.d.ts +8 -0
- package/dist/cjs/lib/v3/external_clients/aisdk.d.ts +11 -0
- package/dist/cjs/lib/v3/external_clients/customOpenAI.d.ts +18 -0
- package/dist/cjs/lib/v3/flowLogger.d.ts +139 -0
- package/dist/cjs/lib/v3/handlers/actHandler.d.ts +21 -0
- package/dist/cjs/lib/v3/handlers/extractHandler.d.ts +31 -0
- package/dist/cjs/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +24 -0
- package/dist/cjs/lib/v3/handlers/handlerUtils/timeoutGuard.d.ts +2 -0
- package/dist/cjs/lib/v3/handlers/observeHandler.d.ts +17 -0
- package/dist/cjs/lib/v3/handlers/v3AgentHandler.d.ts +32 -0
- package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.d.ts +33 -0
- package/dist/cjs/lib/v3/index.d.ts +18 -0
- package/dist/cjs/lib/v3/launch/browserbase.d.ts +7 -0
- package/dist/cjs/lib/v3/launch/local.d.ts +15 -0
- package/dist/cjs/lib/v3/llm/AnthropicClient.d.ts +16 -0
- package/dist/cjs/lib/v3/llm/CerebrasClient.d.ts +17 -0
- package/dist/cjs/lib/v3/llm/GoogleClient.d.ts +19 -0
- package/dist/cjs/lib/v3/llm/GroqClient.d.ts +17 -0
- package/dist/cjs/lib/v3/llm/LLMClient.d.ts +121 -0
- package/dist/cjs/lib/v3/llm/LLMProvider.d.ts +13 -0
- package/dist/cjs/lib/v3/llm/OpenAIClient.d.ts +15 -0
- package/dist/cjs/lib/v3/llm/aisdk.d.ts +15 -0
- package/dist/cjs/lib/v3/logger.d.ts +9 -0
- package/dist/cjs/lib/v3/mcp/connection.d.ts +11 -0
- package/dist/cjs/lib/v3/mcp/utils.d.ts +3 -0
- package/dist/cjs/lib/v3/shutdown/cleanupLocal.d.ts +14 -0
- package/dist/cjs/lib/v3/shutdown/supervisor.d.ts +11 -0
- package/dist/cjs/lib/v3/shutdown/supervisorClient.d.ts +15 -0
- package/dist/cjs/lib/v3/tests/agent-abort-signal.spec.js +113 -0
- package/dist/cjs/lib/v3/tests/agent-abort-signal.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/agent-cache-self-heal.spec.js +102 -0
- package/dist/cjs/lib/v3/tests/agent-cache-self-heal.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/agent-callbacks.spec.js +374 -0
- package/dist/cjs/lib/v3/tests/agent-callbacks.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/agent-experimental-validation.spec.js +354 -0
- package/dist/cjs/lib/v3/tests/agent-experimental-validation.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/agent-hybrid-mode.spec.js +247 -0
- package/dist/cjs/lib/v3/tests/agent-hybrid-mode.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/agent-message-continuation.spec.js +105 -0
- package/dist/cjs/lib/v3/tests/agent-message-continuation.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/agent-streaming.spec.js +126 -0
- package/dist/cjs/lib/v3/tests/agent-streaming.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/cdp-session-detached.spec.js +44 -0
- package/dist/cjs/lib/v3/tests/cdp-session-detached.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/click-count.spec.js +147 -0
- package/dist/cjs/lib/v3/tests/click-count.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/connect-to-existing-browser.spec.js +54 -0
- package/dist/cjs/lib/v3/tests/connect-to-existing-browser.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/context-addInitScript.spec.js +176 -0
- package/dist/cjs/lib/v3/tests/context-addInitScript.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/default-page-tracking.spec.js +53 -0
- package/dist/cjs/lib/v3/tests/default-page-tracking.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/downloads.spec.js +80 -0
- package/dist/cjs/lib/v3/tests/downloads.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/frame-get-location-and-click.spec.js +53 -0
- package/dist/cjs/lib/v3/tests/frame-get-location-and-click.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/iframe-ctx-addInitScript.spec.js +493 -0
- package/dist/cjs/lib/v3/tests/iframe-ctx-addInitScript.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/keep-alive.child.js +92 -0
- package/dist/cjs/lib/v3/tests/keep-alive.child.js.map +7 -0
- package/dist/cjs/lib/v3/tests/keep-alive.helpers.js +568 -0
- package/dist/cjs/lib/v3/tests/keep-alive.helpers.js.map +7 -0
- package/dist/cjs/lib/v3/tests/keep-alive.spec.js +15 -0
- package/dist/cjs/lib/v3/tests/keep-alive.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/keyboard.spec.js +296 -0
- package/dist/cjs/lib/v3/tests/keyboard.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/locator-backend-node-id.spec.js +159 -0
- package/dist/cjs/lib/v3/tests/locator-backend-node-id.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/locator-content-methods.spec.js +191 -0
- package/dist/cjs/lib/v3/tests/locator-content-methods.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/locator-count-iframe.spec.js +108 -0
- package/dist/cjs/lib/v3/tests/locator-count-iframe.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/locator-count.spec.js +71 -0
- package/dist/cjs/lib/v3/tests/locator-count.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/locator-fill.spec.js +118 -0
- package/dist/cjs/lib/v3/tests/locator-fill.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/locator-input-methods.spec.js +136 -0
- package/dist/cjs/lib/v3/tests/locator-input-methods.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/locator-nth.spec.js +157 -0
- package/dist/cjs/lib/v3/tests/locator-nth.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/locator-select-option.spec.js +242 -0
- package/dist/cjs/lib/v3/tests/locator-select-option.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/logger-initialization.spec.js +547 -0
- package/dist/cjs/lib/v3/tests/logger-initialization.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/multi-instance-logger.spec.js +269 -0
- package/dist/cjs/lib/v3/tests/multi-instance-logger.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/nested-div.spec.js +23 -0
- package/dist/cjs/lib/v3/tests/nested-div.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/page-addInitScript.spec.js +90 -0
- package/dist/cjs/lib/v3/tests/page-addInitScript.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/page-console.spec.js +56 -0
- package/dist/cjs/lib/v3/tests/page-console.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/page-drag-and-drop.spec.js +418 -0
- package/dist/cjs/lib/v3/tests/page-drag-and-drop.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/page-goto-response.spec.js +35 -0
- package/dist/cjs/lib/v3/tests/page-goto-response.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/page-hover.spec.js +167 -0
- package/dist/cjs/lib/v3/tests/page-hover.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/page-screenshot.spec.js +295 -0
- package/dist/cjs/lib/v3/tests/page-screenshot.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/page-scroll.spec.js +182 -0
- package/dist/cjs/lib/v3/tests/page-scroll.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/page-send-cdp.spec.js +46 -0
- package/dist/cjs/lib/v3/tests/page-send-cdp.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/perform-understudy-method.spec.js +98 -0
- package/dist/cjs/lib/v3/tests/perform-understudy-method.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/setinputfiles.spec.js +148 -0
- package/dist/cjs/lib/v3/tests/setinputfiles.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/shadow-iframe-oopif.spec.js +156 -0
- package/dist/cjs/lib/v3/tests/shadow-iframe-oopif.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/shadow-iframe-spif.spec.js +156 -0
- package/dist/cjs/lib/v3/tests/shadow-iframe-spif.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/testUtils.js +54 -0
- package/dist/cjs/lib/v3/tests/testUtils.js.map +7 -0
- package/dist/cjs/lib/v3/tests/text-selector-innermost.spec.js +100 -0
- package/dist/cjs/lib/v3/tests/text-selector-innermost.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/timeouts.spec.js +32 -0
- package/dist/cjs/lib/v3/tests/timeouts.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/user-data-dir.spec.js +65 -0
- package/dist/cjs/lib/v3/tests/user-data-dir.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/v3.config.js +36 -0
- package/dist/cjs/lib/v3/tests/v3.config.js.map +7 -0
- package/dist/cjs/lib/v3/tests/v3.dynamic.config.js +67 -0
- package/dist/cjs/lib/v3/tests/v3.dynamic.config.js.map +7 -0
- package/dist/cjs/lib/v3/tests/v3.playwright.config.js +61 -0
- package/dist/cjs/lib/v3/tests/v3.playwright.config.js.map +7 -0
- package/dist/cjs/lib/v3/tests/wait-for-selector.spec.js +593 -0
- package/dist/cjs/lib/v3/tests/wait-for-selector.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/wait-for-timeout.spec.js +97 -0
- package/dist/cjs/lib/v3/tests/wait-for-timeout.spec.js.map +7 -0
- package/dist/cjs/lib/v3/tests/xpath-for-location-deep.spec.js +77 -0
- package/dist/cjs/lib/v3/tests/xpath-for-location-deep.spec.js.map +7 -0
- package/dist/cjs/lib/v3/timeoutConfig.d.ts +2 -0
- package/dist/cjs/lib/v3/types/private/agent.d.ts +6 -0
- package/dist/cjs/lib/v3/types/private/api.d.ts +11 -0
- package/dist/cjs/lib/v3/types/private/cache.d.ts +128 -0
- package/dist/cjs/lib/v3/types/private/evaluator.d.ts +40 -0
- package/dist/cjs/lib/v3/types/private/handlers.d.ts +38 -0
- package/dist/cjs/lib/v3/types/private/index.d.ts +7 -0
- package/dist/cjs/lib/v3/types/private/internal.d.ts +39 -0
- package/dist/cjs/lib/v3/types/private/locator.d.ts +9 -0
- package/dist/cjs/lib/v3/types/private/network.d.ts +34 -0
- package/dist/cjs/lib/v3/types/private/shutdown.d.ts +19 -0
- package/dist/cjs/lib/v3/types/private/shutdownErrors.d.ts +12 -0
- package/dist/cjs/lib/v3/types/private/snapshot.d.ts +117 -0
- package/dist/cjs/lib/v3/types/public/agent.d.ts +595 -0
- package/dist/cjs/lib/v3/types/public/api.d.ts +1211 -0
- package/dist/cjs/lib/v3/types/public/apiErrors.d.ts +18 -0
- package/dist/cjs/lib/v3/types/public/index.d.ts +12 -0
- package/dist/cjs/lib/v3/types/public/locator.d.ts +9 -0
- package/dist/cjs/lib/v3/types/public/logs.d.ts +23 -0
- package/dist/cjs/lib/v3/types/public/methods.d.ts +56 -0
- package/dist/cjs/lib/v3/types/public/metrics.d.ts +27 -0
- package/dist/cjs/lib/v3/types/public/model.d.ts +65 -0
- package/dist/cjs/lib/v3/types/public/options.d.ts +70 -0
- package/dist/cjs/lib/v3/types/public/page.d.ts +18 -0
- package/dist/cjs/lib/v3/types/public/screenshotTypes.d.ts +25 -0
- package/dist/cjs/lib/v3/types/public/sdkErrors.d.ts +152 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/a11yTree.d.ts +15 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/activeElement.d.ts +8 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.d.ts +77 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/coordinateResolver.d.ts +7 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/domTree.d.ts +46 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/focusSelectors.d.ts +24 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/index.d.ts +4 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/sessions.d.ts +16 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/treeFormatUtils.d.ts +28 -0
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/xpathUtils.d.ts +26 -0
- package/dist/cjs/lib/v3/understudy/a11yInvocation.d.ts +8 -0
- package/dist/cjs/lib/v3/understudy/cdp.d.ts +69 -0
- package/dist/cjs/lib/v3/understudy/consoleMessage.d.ts +22 -0
- package/dist/cjs/lib/v3/understudy/context.d.ts +132 -0
- package/dist/cjs/lib/v3/understudy/deepLocator.d.ts +87 -0
- package/dist/cjs/lib/v3/understudy/executionContextRegistry.d.ts +15 -0
- package/dist/cjs/lib/v3/understudy/fileUploadUtils.d.ts +13 -0
- package/dist/cjs/lib/v3/understudy/frame.d.ts +69 -0
- package/dist/cjs/lib/v3/understudy/frameLocator.d.ts +50 -0
- package/dist/cjs/lib/v3/understudy/frameRegistry.d.ts +101 -0
- package/dist/cjs/lib/v3/understudy/initScripts.d.ts +2 -0
- package/dist/cjs/lib/v3/understudy/lifecycleWatcher.d.ts +64 -0
- package/dist/cjs/lib/v3/understudy/locator.d.ts +194 -0
- package/dist/cjs/lib/v3/understudy/locatorInvocation.d.ts +8 -0
- package/dist/cjs/lib/v3/understudy/navigationResponseTracker.d.ts +84 -0
- package/dist/cjs/lib/v3/understudy/networkManager.d.ts +53 -0
- package/dist/cjs/lib/v3/understudy/page.d.ts +354 -0
- package/dist/cjs/lib/v3/understudy/piercer.d.ts +4 -0
- package/dist/cjs/lib/v3/understudy/response.d.ts +137 -0
- package/dist/cjs/lib/v3/understudy/screenshotUtils.d.ts +16 -0
- package/dist/cjs/lib/v3/understudy/selectorResolver.d.ts +38 -0
- package/dist/cjs/lib/v3/v3.d.ts +191 -0
- package/dist/cjs/lib/v3/zodCompat.d.ts +12 -0
- package/dist/cjs/lib/v3Evaluator.d.ts +19 -0
- package/dist/cjs/lib/version.d.ts +5 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/tests/browserbase-session-accessors.test.js +101 -0
- package/dist/cjs/tests/browserbase-session-accessors.test.js.map +7 -0
- package/dist/cjs/tests/cache-llm-resolution.test.js +187 -0
- package/dist/cjs/tests/cache-llm-resolution.test.js.map +7 -0
- package/dist/cjs/tests/helpers/mockCDPSession.js +50 -0
- package/dist/cjs/tests/helpers/mockCDPSession.js.map +7 -0
- package/dist/cjs/tests/llm-provider.test.js +57 -0
- package/dist/cjs/tests/llm-provider.test.js.map +7 -0
- package/dist/cjs/tests/model-deprecation.test.js +132 -0
- package/dist/cjs/tests/model-deprecation.test.js.map +7 -0
- package/dist/cjs/tests/page-snapshot.test.js +58 -0
- package/dist/cjs/tests/page-snapshot.test.js.map +7 -0
- package/dist/cjs/tests/public-api/export-surface.test.js +76 -0
- package/dist/cjs/tests/public-api/export-surface.test.js.map +7 -0
- package/dist/cjs/tests/public-api/llm-and-agents.test.js +150 -0
- package/dist/cjs/tests/public-api/llm-and-agents.test.js.map +7 -0
- package/dist/cjs/tests/public-api/public-error-types.test.js +104 -0
- package/dist/cjs/tests/public-api/public-error-types.test.js.map +7 -0
- package/dist/cjs/tests/public-api/public-types.test.js +74 -0
- package/dist/cjs/tests/public-api/public-types.test.js.map +7 -0
- package/dist/cjs/tests/public-api/runtime-utils.test.js +53 -0
- package/dist/cjs/tests/public-api/runtime-utils.test.js.map +7 -0
- package/dist/cjs/tests/public-api/schema-utils.test.js +100 -0
- package/dist/cjs/tests/public-api/schema-utils.test.js.map +7 -0
- package/dist/cjs/tests/public-api/timeout-error-types.test.js +103 -0
- package/dist/cjs/tests/public-api/timeout-error-types.test.js.map +7 -0
- package/dist/cjs/tests/public-api/tool-type-export.test.js +47 -0
- package/dist/cjs/tests/public-api/tool-type-export.test.js.map +7 -0
- package/dist/cjs/tests/public-api/v3-core.test.js +104 -0
- package/dist/cjs/tests/public-api/v3-core.test.js.map +7 -0
- package/dist/cjs/tests/safety-confirmation.test.js +134 -0
- package/dist/cjs/tests/safety-confirmation.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-a11y-resolvers.test.js +370 -0
- package/dist/cjs/tests/snapshot-a11y-resolvers.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-a11y-tree-utils.test.js +294 -0
- package/dist/cjs/tests/snapshot-a11y-tree-utils.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-capture-orchestration.test.js +403 -0
- package/dist/cjs/tests/snapshot-capture-orchestration.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-cbor.test.js +197 -0
- package/dist/cjs/tests/snapshot-cbor.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-dom-session-builders.test.js +246 -0
- package/dist/cjs/tests/snapshot-dom-session-builders.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-dom-tree-utils.test.js +104 -0
- package/dist/cjs/tests/snapshot-dom-tree-utils.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-focus-selectors-utils.test.js +45 -0
- package/dist/cjs/tests/snapshot-focus-selectors-utils.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-frame-merge.test.js +388 -0
- package/dist/cjs/tests/snapshot-frame-merge.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-tree-format-utils.test.js +106 -0
- package/dist/cjs/tests/snapshot-tree-format-utils.test.js.map +7 -0
- package/dist/cjs/tests/snapshot-xpath-utils.test.js +74 -0
- package/dist/cjs/tests/snapshot-xpath-utils.test.js.map +7 -0
- package/dist/cjs/tests/timeout-handlers.test.js +864 -0
- package/dist/cjs/tests/timeout-handlers.test.js.map +7 -0
- package/dist/cjs/tests/xpath-parser.test.js +314 -0
- package/dist/cjs/tests/xpath-parser.test.js.map +7 -0
- package/dist/cjs/tests/xpath-resolver.test.js +70 -0
- package/dist/cjs/tests/xpath-resolver.test.js.map +7 -0
- package/dist/cjs/tests/zod-enum-compatibility.test.js +119 -0
- package/dist/cjs/tests/zod-enum-compatibility.test.js.map +7 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/lib/inference.d.ts +65 -0
- package/dist/esm/lib/inference.js +333 -0
- package/dist/esm/lib/inference.js.map +1 -0
- package/dist/esm/lib/inferenceLogUtils.d.ts +12 -0
- package/dist/esm/lib/inferenceLogUtils.js +92 -0
- package/dist/esm/lib/inferenceLogUtils.js.map +1 -0
- package/dist/esm/lib/logger.d.ts +69 -0
- package/dist/esm/lib/logger.js +323 -0
- package/dist/esm/lib/logger.js.map +1 -0
- package/dist/esm/lib/modelUtils.d.ts +11 -0
- package/dist/esm/lib/modelUtils.js +43 -0
- package/dist/esm/lib/modelUtils.js.map +1 -0
- package/dist/esm/lib/prompt.d.ts +14 -0
- package/dist/esm/lib/prompt.js +230 -0
- package/dist/esm/lib/prompt.js.map +1 -0
- package/dist/esm/lib/utils.d.ts +68 -0
- package/dist/esm/lib/utils.js +654 -0
- package/dist/esm/lib/utils.js.map +1 -0
- package/dist/esm/lib/v3/agent/AgentClient.d.ts +19 -0
- package/dist/esm/lib/v3/agent/AgentClient.js +17 -0
- package/dist/esm/lib/v3/agent/AgentClient.js.map +1 -0
- package/dist/esm/lib/v3/agent/AgentProvider.d.ts +20 -0
- package/dist/esm/lib/v3/agent/AgentProvider.js +77 -0
- package/dist/esm/lib/v3/agent/AgentProvider.js.map +1 -0
- package/dist/esm/lib/v3/agent/AnthropicCUAClient.d.ts +57 -0
- package/dist/esm/lib/v3/agent/AnthropicCUAClient.js +822 -0
- package/dist/esm/lib/v3/agent/AnthropicCUAClient.js.map +1 -0
- package/dist/esm/lib/v3/agent/GoogleCUAClient.d.ts +74 -0
- package/dist/esm/lib/v3/agent/GoogleCUAClient.js +799 -0
- package/dist/esm/lib/v3/agent/GoogleCUAClient.js.map +1 -0
- package/dist/esm/lib/v3/agent/MicrosoftCUAClient.d.ts +71 -0
- package/dist/esm/lib/v3/agent/MicrosoftCUAClient.js +770 -0
- package/dist/esm/lib/v3/agent/MicrosoftCUAClient.js.map +1 -0
- package/dist/esm/lib/v3/agent/OpenAICUAClient.d.ts +69 -0
- package/dist/esm/lib/v3/agent/OpenAICUAClient.js +615 -0
- package/dist/esm/lib/v3/agent/OpenAICUAClient.js.map +1 -0
- package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.d.ts +12 -0
- package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.js +186 -0
- package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/act.d.ts +12 -0
- package/dist/esm/lib/v3/agent/tools/act.js +49 -0
- package/dist/esm/lib/v3/agent/tools/act.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/ariaTree.d.ts +5 -0
- package/dist/esm/lib/v3/agent/tools/ariaTree.js +31 -0
- package/dist/esm/lib/v3/agent/tools/ariaTree.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/click.d.ts +6 -0
- package/dist/esm/lib/v3/agent/tools/click.js +104 -0
- package/dist/esm/lib/v3/agent/tools/click.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/clickAndHold.d.ts +14 -0
- package/dist/esm/lib/v3/agent/tools/clickAndHold.js +68 -0
- package/dist/esm/lib/v3/agent/tools/clickAndHold.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/dragAndDrop.d.ts +7 -0
- package/dist/esm/lib/v3/agent/tools/dragAndDrop.js +105 -0
- package/dist/esm/lib/v3/agent/tools/dragAndDrop.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/extract.d.ts +20 -0
- package/dist/esm/lib/v3/agent/tools/extract.js +93 -0
- package/dist/esm/lib/v3/agent/tools/extract.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/fillFormVision.d.ts +12 -0
- package/dist/esm/lib/v3/agent/tools/fillFormVision.js +143 -0
- package/dist/esm/lib/v3/agent/tools/fillFormVision.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/fillform.d.ts +12 -0
- package/dist/esm/lib/v3/agent/tools/fillform.js +56 -0
- package/dist/esm/lib/v3/agent/tools/fillform.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/goto.d.ts +12 -0
- package/dist/esm/lib/v3/agent/tools/goto.js +31 -0
- package/dist/esm/lib/v3/agent/tools/goto.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/index.d.ts +92 -0
- package/dist/esm/lib/v3/agent/tools/index.js +74 -0
- package/dist/esm/lib/v3/agent/tools/index.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/keys.d.ts +24 -0
- package/dist/esm/lib/v3/agent/tools/keys.js +60 -0
- package/dist/esm/lib/v3/agent/tools/keys.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/navback.d.ts +6 -0
- package/dist/esm/lib/v3/agent/tools/navback.js +23 -0
- package/dist/esm/lib/v3/agent/tools/navback.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/screenshot.d.ts +6 -0
- package/dist/esm/lib/v3/agent/tools/screenshot.js +26 -0
- package/dist/esm/lib/v3/agent/tools/screenshot.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/scroll.d.ts +19 -0
- package/dist/esm/lib/v3/agent/tools/scroll.js +142 -0
- package/dist/esm/lib/v3/agent/tools/scroll.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/search.d.ts +15 -0
- package/dist/esm/lib/v3/agent/tools/search.js +73 -0
- package/dist/esm/lib/v3/agent/tools/search.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/think.d.ts +6 -0
- package/dist/esm/lib/v3/agent/tools/think.js +24 -0
- package/dist/esm/lib/v3/agent/tools/think.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/type.d.ts +7 -0
- package/dist/esm/lib/v3/agent/tools/type.js +106 -0
- package/dist/esm/lib/v3/agent/tools/type.js.map +1 -0
- package/dist/esm/lib/v3/agent/tools/wait.d.ts +5 -0
- package/dist/esm/lib/v3/agent/tools/wait.js +53 -0
- package/dist/esm/lib/v3/agent/tools/wait.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/actionMapping.d.ts +3 -0
- package/dist/esm/lib/v3/agent/utils/actionMapping.js +100 -0
- package/dist/esm/lib/v3/agent/utils/actionMapping.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/coordinateNormalization.d.ts +13 -0
- package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js +28 -0
- package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.d.ts +10 -0
- package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.js +62 -0
- package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.d.ts +25 -0
- package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.js +145 -0
- package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.d.ts +22 -0
- package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js +101 -0
- package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/imageCompression.d.ts +53 -0
- package/dist/esm/lib/v3/agent/utils/imageCompression.js +204 -0
- package/dist/esm/lib/v3/agent/utils/imageCompression.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/messageProcessing.d.ts +12 -0
- package/dist/esm/lib/v3/agent/utils/messageProcessing.js +164 -0
- package/dist/esm/lib/v3/agent/utils/messageProcessing.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/screenshotHandler.d.ts +10 -0
- package/dist/esm/lib/v3/agent/utils/screenshotHandler.js +26 -0
- package/dist/esm/lib/v3/agent/utils/screenshotHandler.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.d.ts +26 -0
- package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.js +79 -0
- package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.js.map +1 -0
- package/dist/esm/lib/v3/agent/utils/xpath.d.ts +11 -0
- package/dist/esm/lib/v3/agent/utils/xpath.js +19 -0
- package/dist/esm/lib/v3/agent/utils/xpath.js.map +1 -0
- package/dist/esm/lib/v3/api.d.ts +86 -0
- package/dist/esm/lib/v3/api.js +484 -0
- package/dist/esm/lib/v3/api.js.map +1 -0
- package/dist/esm/lib/v3/cache/ActCache.d.ts +23 -0
- package/dist/esm/lib/v3/cache/ActCache.js +292 -0
- package/dist/esm/lib/v3/cache/ActCache.js.map +1 -0
- package/dist/esm/lib/v3/cache/AgentCache.d.ts +109 -0
- package/dist/esm/lib/v3/cache/AgentCache.js +640 -0
- package/dist/esm/lib/v3/cache/AgentCache.js.map +1 -0
- package/dist/esm/lib/v3/cache/CacheStorage.d.ts +17 -0
- package/dist/esm/lib/v3/cache/CacheStorage.js +98 -0
- package/dist/esm/lib/v3/cache/CacheStorage.js.map +1 -0
- package/dist/esm/lib/v3/cache/serverAgentCache.d.ts +7 -0
- package/dist/esm/lib/v3/cache/serverAgentCache.js +49 -0
- package/dist/esm/lib/v3/cache/serverAgentCache.js.map +1 -0
- package/dist/esm/lib/v3/cache/utils.d.ts +15 -0
- package/dist/esm/lib/v3/cache/utils.js +39 -0
- package/dist/esm/lib/v3/cache/utils.js.map +1 -0
- package/dist/esm/lib/v3/cli.d.ts +2 -0
- package/dist/esm/lib/v3/cli.js +10 -0
- package/dist/esm/lib/v3/cli.js.map +1 -0
- package/dist/esm/lib/v3/dom/a11yScripts/index.d.ts +11 -0
- package/dist/esm/lib/v3/dom/a11yScripts/index.js +117 -0
- package/dist/esm/lib/v3/dom/a11yScripts/index.js.map +1 -0
- package/dist/esm/lib/v3/dom/build/a11yScripts.generated.d.ts +16 -0
- package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js +20 -0
- package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js.map +1 -0
- package/dist/esm/lib/v3/dom/build/locatorScripts.generated.d.ts +52 -0
- package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js +56 -0
- package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js.map +1 -0
- package/dist/esm/lib/v3/dom/build/reRenderScriptContent.d.ts +1 -0
- package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js +2 -0
- package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js.map +1 -0
- package/dist/esm/lib/v3/dom/build/rerender-index.d.ts +0 -0
- package/dist/esm/lib/v3/dom/build/rerender-index.js +1 -0
- package/dist/esm/lib/v3/dom/build/rerender-index.js.map +1 -0
- package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.d.ts +4 -0
- package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js +8 -0
- package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js.map +1 -0
- package/dist/esm/lib/v3/dom/build/scriptV3Content.d.ts +1 -0
- package/dist/esm/lib/v3/dom/build/scriptV3Content.js +2 -0
- package/dist/esm/lib/v3/dom/build/scriptV3Content.js.map +1 -0
- package/dist/esm/lib/v3/dom/build/v3-index.d.ts +0 -0
- package/dist/esm/lib/v3/dom/build/v3-index.js +1 -0
- package/dist/esm/lib/v3/dom/build/v3-index.js.map +1 -0
- package/dist/esm/lib/v3/dom/genA11yScripts.d.ts +1 -0
- package/dist/esm/lib/v3/dom/genA11yScripts.js +54 -0
- package/dist/esm/lib/v3/dom/genA11yScripts.js.map +1 -0
- package/dist/esm/lib/v3/dom/genDomScripts.d.ts +1 -0
- package/dist/esm/lib/v3/dom/genDomScripts.js +38 -0
- package/dist/esm/lib/v3/dom/genDomScripts.js.map +1 -0
- package/dist/esm/lib/v3/dom/genLocatorScripts.d.ts +1 -0
- package/dist/esm/lib/v3/dom/genLocatorScripts.js +51 -0
- package/dist/esm/lib/v3/dom/genLocatorScripts.js.map +1 -0
- package/dist/esm/lib/v3/dom/genScreenshotScripts.d.ts +1 -0
- package/dist/esm/lib/v3/dom/genScreenshotScripts.js +37 -0
- package/dist/esm/lib/v3/dom/genScreenshotScripts.js.map +1 -0
- package/dist/esm/lib/v3/dom/index.d.ts +1 -0
- package/dist/esm/lib/v3/dom/index.js +2 -0
- package/dist/esm/lib/v3/dom/index.js.map +1 -0
- package/dist/esm/lib/v3/dom/locatorScripts/counts.d.ts +15 -0
- package/dist/esm/lib/v3/dom/locatorScripts/counts.js +272 -0
- package/dist/esm/lib/v3/dom/locatorScripts/counts.js.map +1 -0
- package/dist/esm/lib/v3/dom/locatorScripts/index.d.ts +4 -0
- package/dist/esm/lib/v3/dom/locatorScripts/index.js +5 -0
- package/dist/esm/lib/v3/dom/locatorScripts/index.js.map +1 -0
- package/dist/esm/lib/v3/dom/locatorScripts/scripts.d.ts +37 -0
- package/dist/esm/lib/v3/dom/locatorScripts/scripts.js +458 -0
- package/dist/esm/lib/v3/dom/locatorScripts/scripts.js.map +1 -0
- package/dist/esm/lib/v3/dom/locatorScripts/selectors.d.ts +4 -0
- package/dist/esm/lib/v3/dom/locatorScripts/selectors.js +283 -0
- package/dist/esm/lib/v3/dom/locatorScripts/selectors.js.map +1 -0
- package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.d.ts +19 -0
- package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.js +283 -0
- package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.js.map +1 -0
- package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.d.ts +76 -0
- package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.js +376 -0
- package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.js.map +1 -0
- package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.d.ts +9 -0
- package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.js +196 -0
- package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.js.map +1 -0
- package/dist/esm/lib/v3/dom/piercer.entry.d.ts +1 -0
- package/dist/esm/lib/v3/dom/piercer.entry.js +3 -0
- package/dist/esm/lib/v3/dom/piercer.entry.js.map +1 -0
- package/dist/esm/lib/v3/dom/piercer.runtime.d.ts +23 -0
- package/dist/esm/lib/v3/dom/piercer.runtime.js +90 -0
- package/dist/esm/lib/v3/dom/piercer.runtime.js.map +1 -0
- package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.d.ts +1 -0
- package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.js +3 -0
- package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.js.map +1 -0
- package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.d.ts +1 -0
- package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.js +40 -0
- package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.js.map +1 -0
- package/dist/esm/lib/v3/dom/screenshotScripts/index.d.ts +1 -0
- package/dist/esm/lib/v3/dom/screenshotScripts/index.js +2 -0
- package/dist/esm/lib/v3/dom/screenshotScripts/index.js.map +1 -0
- package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.d.ts +8 -0
- package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.js +82 -0
- package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.js.map +1 -0
- package/dist/esm/lib/v3/external_clients/aisdk.d.ts +11 -0
- package/dist/esm/lib/v3/external_clients/aisdk.js +103 -0
- package/dist/esm/lib/v3/external_clients/aisdk.js.map +1 -0
- package/dist/esm/lib/v3/external_clients/customOpenAI.d.ts +18 -0
- package/dist/esm/lib/v3/external_clients/customOpenAI.js +220 -0
- package/dist/esm/lib/v3/external_clients/customOpenAI.js.map +1 -0
- package/dist/esm/lib/v3/flowLogger.d.ts +139 -0
- package/dist/esm/lib/v3/flowLogger.js +868 -0
- package/dist/esm/lib/v3/flowLogger.js.map +1 -0
- package/dist/esm/lib/v3/handlers/actHandler.d.ts +21 -0
- package/dist/esm/lib/v3/handlers/actHandler.js +340 -0
- package/dist/esm/lib/v3/handlers/actHandler.js.map +1 -0
- package/dist/esm/lib/v3/handlers/extractHandler.d.ts +31 -0
- package/dist/esm/lib/v3/handlers/extractHandler.js +139 -0
- package/dist/esm/lib/v3/handlers/extractHandler.js.map +1 -0
- package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +24 -0
- package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js +623 -0
- package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -0
- package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.d.ts +2 -0
- package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.js +14 -0
- package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.js.map +1 -0
- package/dist/esm/lib/v3/handlers/observeHandler.d.ts +17 -0
- package/dist/esm/lib/v3/handlers/observeHandler.js +156 -0
- package/dist/esm/lib/v3/handlers/observeHandler.js.map +1 -0
- package/dist/esm/lib/v3/handlers/v3AgentHandler.d.ts +32 -0
- package/dist/esm/lib/v3/handlers/v3AgentHandler.js +461 -0
- package/dist/esm/lib/v3/handlers/v3AgentHandler.js.map +1 -0
- package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.d.ts +33 -0
- package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js +528 -0
- package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -0
- package/dist/esm/lib/v3/index.d.ts +18 -0
- package/dist/esm/lib/v3/index.js +14 -0
- package/dist/esm/lib/v3/index.js.map +1 -0
- package/dist/esm/lib/v3/launch/browserbase.d.ts +7 -0
- package/dist/esm/lib/v3/launch/browserbase.js +46 -0
- package/dist/esm/lib/v3/launch/browserbase.js.map +1 -0
- package/dist/esm/lib/v3/launch/local.d.ts +15 -0
- package/dist/esm/lib/v3/launch/local.js +98 -0
- package/dist/esm/lib/v3/launch/local.js.map +1 -0
- package/dist/esm/lib/v3/llm/AnthropicClient.d.ts +16 -0
- package/dist/esm/lib/v3/llm/AnthropicClient.js +239 -0
- package/dist/esm/lib/v3/llm/AnthropicClient.js.map +1 -0
- package/dist/esm/lib/v3/llm/CerebrasClient.d.ts +17 -0
- package/dist/esm/lib/v3/llm/CerebrasClient.js +235 -0
- package/dist/esm/lib/v3/llm/CerebrasClient.js.map +1 -0
- package/dist/esm/lib/v3/llm/GoogleClient.d.ts +19 -0
- package/dist/esm/lib/v3/llm/GoogleClient.js +369 -0
- package/dist/esm/lib/v3/llm/GoogleClient.js.map +1 -0
- package/dist/esm/lib/v3/llm/GroqClient.d.ts +17 -0
- package/dist/esm/lib/v3/llm/GroqClient.js +236 -0
- package/dist/esm/lib/v3/llm/GroqClient.js.map +1 -0
- package/dist/esm/lib/v3/llm/LLMClient.d.ts +121 -0
- package/dist/esm/lib/v3/llm/LLMClient.js +23 -0
- package/dist/esm/lib/v3/llm/LLMClient.js.map +1 -0
- package/dist/esm/lib/v3/llm/LLMProvider.d.ts +13 -0
- package/dist/esm/lib/v3/llm/LLMProvider.js +194 -0
- package/dist/esm/lib/v3/llm/LLMProvider.js.map +1 -0
- package/dist/esm/lib/v3/llm/OpenAIClient.d.ts +15 -0
- package/dist/esm/lib/v3/llm/OpenAIClient.js +329 -0
- package/dist/esm/lib/v3/llm/OpenAIClient.js.map +1 -0
- package/dist/esm/lib/v3/llm/aisdk.d.ts +15 -0
- package/dist/esm/lib/v3/llm/aisdk.js +348 -0
- package/dist/esm/lib/v3/llm/aisdk.js.map +1 -0
- package/dist/esm/lib/v3/logger.d.ts +9 -0
- package/dist/esm/lib/v3/logger.js +96 -0
- package/dist/esm/lib/v3/logger.js.map +1 -0
- package/dist/esm/lib/v3/mcp/connection.d.ts +11 -0
- package/dist/esm/lib/v3/mcp/connection.js +49 -0
- package/dist/esm/lib/v3/mcp/connection.js.map +1 -0
- package/dist/esm/lib/v3/mcp/utils.d.ts +3 -0
- package/dist/esm/lib/v3/mcp/utils.js +36 -0
- package/dist/esm/lib/v3/mcp/utils.js.map +1 -0
- package/dist/esm/lib/v3/shutdown/cleanupLocal.d.ts +14 -0
- package/dist/esm/lib/v3/shutdown/cleanupLocal.js +30 -0
- package/dist/esm/lib/v3/shutdown/cleanupLocal.js.map +1 -0
- package/dist/esm/lib/v3/shutdown/supervisor.d.ts +11 -0
- package/dist/esm/lib/v3/shutdown/supervisor.js +166 -0
- package/dist/esm/lib/v3/shutdown/supervisor.js.map +1 -0
- package/dist/esm/lib/v3/shutdown/supervisorClient.d.ts +15 -0
- package/dist/esm/lib/v3/shutdown/supervisorClient.js +93 -0
- package/dist/esm/lib/v3/shutdown/supervisorClient.js.map +1 -0
- package/dist/esm/lib/v3/tests/agent-abort-signal.spec.js +113 -0
- package/dist/esm/lib/v3/tests/agent-abort-signal.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/agent-cache-self-heal.spec.js +80 -0
- package/dist/esm/lib/v3/tests/agent-cache-self-heal.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/agent-callbacks.spec.js +374 -0
- package/dist/esm/lib/v3/tests/agent-callbacks.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/agent-experimental-validation.spec.js +357 -0
- package/dist/esm/lib/v3/tests/agent-experimental-validation.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/agent-hybrid-mode.spec.js +247 -0
- package/dist/esm/lib/v3/tests/agent-hybrid-mode.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/agent-message-continuation.spec.js +105 -0
- package/dist/esm/lib/v3/tests/agent-message-continuation.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/agent-streaming.spec.js +126 -0
- package/dist/esm/lib/v3/tests/agent-streaming.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/cdp-session-detached.spec.js +44 -0
- package/dist/esm/lib/v3/tests/cdp-session-detached.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/click-count.spec.js +147 -0
- package/dist/esm/lib/v3/tests/click-count.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/connect-to-existing-browser.spec.js +54 -0
- package/dist/esm/lib/v3/tests/connect-to-existing-browser.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/context-addInitScript.spec.js +176 -0
- package/dist/esm/lib/v3/tests/context-addInitScript.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/default-page-tracking.spec.js +53 -0
- package/dist/esm/lib/v3/tests/default-page-tracking.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/downloads.spec.js +58 -0
- package/dist/esm/lib/v3/tests/downloads.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/frame-get-location-and-click.spec.js +53 -0
- package/dist/esm/lib/v3/tests/frame-get-location-and-click.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/iframe-ctx-addInitScript.spec.js +493 -0
- package/dist/esm/lib/v3/tests/iframe-ctx-addInitScript.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/keep-alive.child.js +92 -0
- package/dist/esm/lib/v3/tests/keep-alive.child.js.map +7 -0
- package/dist/esm/lib/v3/tests/keep-alive.helpers.js +532 -0
- package/dist/esm/lib/v3/tests/keep-alive.helpers.js.map +7 -0
- package/dist/esm/lib/v3/tests/keep-alive.spec.js +19 -0
- package/dist/esm/lib/v3/tests/keep-alive.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/keyboard.spec.js +296 -0
- package/dist/esm/lib/v3/tests/keyboard.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/locator-backend-node-id.spec.js +159 -0
- package/dist/esm/lib/v3/tests/locator-backend-node-id.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/locator-content-methods.spec.js +191 -0
- package/dist/esm/lib/v3/tests/locator-content-methods.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/locator-count-iframe.spec.js +108 -0
- package/dist/esm/lib/v3/tests/locator-count-iframe.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/locator-count.spec.js +71 -0
- package/dist/esm/lib/v3/tests/locator-count.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/locator-fill.spec.js +118 -0
- package/dist/esm/lib/v3/tests/locator-fill.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/locator-input-methods.spec.js +136 -0
- package/dist/esm/lib/v3/tests/locator-input-methods.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/locator-nth.spec.js +157 -0
- package/dist/esm/lib/v3/tests/locator-nth.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/locator-select-option.spec.js +242 -0
- package/dist/esm/lib/v3/tests/locator-select-option.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/logger-initialization.spec.js +552 -0
- package/dist/esm/lib/v3/tests/logger-initialization.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/multi-instance-logger.spec.js +269 -0
- package/dist/esm/lib/v3/tests/multi-instance-logger.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/nested-div.spec.js +23 -0
- package/dist/esm/lib/v3/tests/nested-div.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/page-addInitScript.spec.js +90 -0
- package/dist/esm/lib/v3/tests/page-addInitScript.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/page-console.spec.js +56 -0
- package/dist/esm/lib/v3/tests/page-console.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/page-drag-and-drop.spec.js +418 -0
- package/dist/esm/lib/v3/tests/page-drag-and-drop.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/page-goto-response.spec.js +35 -0
- package/dist/esm/lib/v3/tests/page-goto-response.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/page-hover.spec.js +167 -0
- package/dist/esm/lib/v3/tests/page-hover.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/page-screenshot.spec.js +273 -0
- package/dist/esm/lib/v3/tests/page-screenshot.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/page-scroll.spec.js +182 -0
- package/dist/esm/lib/v3/tests/page-scroll.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/page-send-cdp.spec.js +46 -0
- package/dist/esm/lib/v3/tests/page-send-cdp.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/perform-understudy-method.spec.js +98 -0
- package/dist/esm/lib/v3/tests/perform-understudy-method.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/setinputfiles.spec.js +126 -0
- package/dist/esm/lib/v3/tests/setinputfiles.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/shadow-iframe-oopif.spec.js +134 -0
- package/dist/esm/lib/v3/tests/shadow-iframe-oopif.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/shadow-iframe-spif.spec.js +134 -0
- package/dist/esm/lib/v3/tests/shadow-iframe-spif.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/testUtils.js +31 -0
- package/dist/esm/lib/v3/tests/testUtils.js.map +7 -0
- package/dist/esm/lib/v3/tests/text-selector-innermost.spec.js +100 -0
- package/dist/esm/lib/v3/tests/text-selector-innermost.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/timeouts.spec.js +32 -0
- package/dist/esm/lib/v3/tests/timeouts.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/user-data-dir.spec.js +43 -0
- package/dist/esm/lib/v3/tests/user-data-dir.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/v3.config.js +15 -0
- package/dist/esm/lib/v3/tests/v3.config.js.map +7 -0
- package/dist/esm/lib/v3/tests/v3.dynamic.config.js +43 -0
- package/dist/esm/lib/v3/tests/v3.dynamic.config.js.map +7 -0
- package/dist/esm/lib/v3/tests/v3.playwright.config.js +41 -0
- package/dist/esm/lib/v3/tests/v3.playwright.config.js.map +7 -0
- package/dist/esm/lib/v3/tests/wait-for-selector.spec.js +593 -0
- package/dist/esm/lib/v3/tests/wait-for-selector.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/wait-for-timeout.spec.js +97 -0
- package/dist/esm/lib/v3/tests/wait-for-timeout.spec.js.map +7 -0
- package/dist/esm/lib/v3/tests/xpath-for-location-deep.spec.js +77 -0
- package/dist/esm/lib/v3/tests/xpath-for-location-deep.spec.js.map +7 -0
- package/dist/esm/lib/v3/timeoutConfig.d.ts +2 -0
- package/dist/esm/lib/v3/timeoutConfig.js +27 -0
- package/dist/esm/lib/v3/timeoutConfig.js.map +1 -0
- package/dist/esm/lib/v3/types/private/agent.d.ts +6 -0
- package/dist/esm/lib/v3/types/private/agent.js +2 -0
- package/dist/esm/lib/v3/types/private/agent.js.map +1 -0
- package/dist/esm/lib/v3/types/private/api.d.ts +11 -0
- package/dist/esm/lib/v3/types/private/api.js +2 -0
- package/dist/esm/lib/v3/types/private/api.js.map +1 -0
- package/dist/esm/lib/v3/types/private/cache.d.ts +128 -0
- package/dist/esm/lib/v3/types/private/cache.js +2 -0
- package/dist/esm/lib/v3/types/private/cache.js.map +1 -0
- package/dist/esm/lib/v3/types/private/evaluator.d.ts +40 -0
- package/dist/esm/lib/v3/types/private/evaluator.js +2 -0
- package/dist/esm/lib/v3/types/private/evaluator.js.map +1 -0
- package/dist/esm/lib/v3/types/private/handlers.d.ts +38 -0
- package/dist/esm/lib/v3/types/private/handlers.js +16 -0
- package/dist/esm/lib/v3/types/private/handlers.js.map +1 -0
- package/dist/esm/lib/v3/types/private/index.d.ts +7 -0
- package/dist/esm/lib/v3/types/private/index.js +8 -0
- package/dist/esm/lib/v3/types/private/index.js.map +1 -0
- package/dist/esm/lib/v3/types/private/internal.d.ts +39 -0
- package/dist/esm/lib/v3/types/private/internal.js +2 -0
- package/dist/esm/lib/v3/types/private/internal.js.map +1 -0
- package/dist/esm/lib/v3/types/private/locator.d.ts +9 -0
- package/dist/esm/lib/v3/types/private/locator.js +2 -0
- package/dist/esm/lib/v3/types/private/locator.js.map +1 -0
- package/dist/esm/lib/v3/types/private/network.d.ts +34 -0
- package/dist/esm/lib/v3/types/private/network.js +3 -0
- package/dist/esm/lib/v3/types/private/network.js.map +1 -0
- package/dist/esm/lib/v3/types/private/shutdown.d.ts +19 -0
- package/dist/esm/lib/v3/types/private/shutdown.js +5 -0
- package/dist/esm/lib/v3/types/private/shutdown.js.map +1 -0
- package/dist/esm/lib/v3/types/private/shutdownErrors.d.ts +12 -0
- package/dist/esm/lib/v3/types/private/shutdownErrors.js +22 -0
- package/dist/esm/lib/v3/types/private/shutdownErrors.js.map +1 -0
- package/dist/esm/lib/v3/types/private/snapshot.d.ts +117 -0
- package/dist/esm/lib/v3/types/private/snapshot.js +2 -0
- package/dist/esm/lib/v3/types/private/snapshot.js.map +1 -0
- package/dist/esm/lib/v3/types/public/agent.d.ts +595 -0
- package/dist/esm/lib/v3/types/public/agent.js +15 -0
- package/dist/esm/lib/v3/types/public/agent.js.map +1 -0
- package/dist/esm/lib/v3/types/public/api.d.ts +1211 -0
- package/dist/esm/lib/v3/types/public/api.js +915 -0
- package/dist/esm/lib/v3/types/public/api.js.map +1 -0
- package/dist/esm/lib/v3/types/public/apiErrors.d.ts +18 -0
- package/dist/esm/lib/v3/types/public/apiErrors.js +32 -0
- package/dist/esm/lib/v3/types/public/apiErrors.js.map +1 -0
- package/dist/esm/lib/v3/types/public/index.d.ts +12 -0
- package/dist/esm/lib/v3/types/public/index.js +14 -0
- package/dist/esm/lib/v3/types/public/index.js.map +1 -0
- package/dist/esm/lib/v3/types/public/locator.d.ts +9 -0
- package/dist/esm/lib/v3/types/public/locator.js +2 -0
- package/dist/esm/lib/v3/types/public/locator.js.map +1 -0
- package/dist/esm/lib/v3/types/public/logs.d.ts +23 -0
- package/dist/esm/lib/v3/types/public/logs.js +13 -0
- package/dist/esm/lib/v3/types/public/logs.js.map +1 -0
- package/dist/esm/lib/v3/types/public/methods.d.ts +56 -0
- package/dist/esm/lib/v3/types/public/methods.js +15 -0
- package/dist/esm/lib/v3/types/public/methods.js.map +1 -0
- package/dist/esm/lib/v3/types/public/metrics.d.ts +27 -0
- package/dist/esm/lib/v3/types/public/metrics.js +2 -0
- package/dist/esm/lib/v3/types/public/metrics.js.map +1 -0
- package/dist/esm/lib/v3/types/public/model.d.ts +65 -0
- package/dist/esm/lib/v3/types/public/model.js +2 -0
- package/dist/esm/lib/v3/types/public/model.js.map +1 -0
- package/dist/esm/lib/v3/types/public/options.d.ts +70 -0
- package/dist/esm/lib/v3/types/public/options.js +4 -0
- package/dist/esm/lib/v3/types/public/options.js.map +1 -0
- package/dist/esm/lib/v3/types/public/page.d.ts +18 -0
- package/dist/esm/lib/v3/types/public/page.js +3 -0
- package/dist/esm/lib/v3/types/public/page.js.map +1 -0
- package/dist/esm/lib/v3/types/public/screenshotTypes.d.ts +25 -0
- package/dist/esm/lib/v3/types/public/screenshotTypes.js +2 -0
- package/dist/esm/lib/v3/types/public/screenshotTypes.js.map +1 -0
- package/dist/esm/lib/v3/types/public/sdkErrors.d.ts +152 -0
- package/dist/esm/lib/v3/types/public/sdkErrors.js +305 -0
- package/dist/esm/lib/v3/types/public/sdkErrors.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.d.ts +15 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js +196 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.d.ts +8 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.js +121 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.d.ts +77 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js +336 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.d.ts +7 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js +129 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.d.ts +46 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.js +274 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.d.ts +24 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.js +216 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/index.d.ts +4 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/index.js +5 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/index.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.d.ts +16 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.js +22 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.d.ts +28 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js +135 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.d.ts +26 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.js +102 -0
- package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.js.map +1 -0
- package/dist/esm/lib/v3/understudy/a11yInvocation.d.ts +8 -0
- package/dist/esm/lib/v3/understudy/a11yInvocation.js +12 -0
- package/dist/esm/lib/v3/understudy/a11yInvocation.js.map +1 -0
- package/dist/esm/lib/v3/understudy/cdp.d.ts +69 -0
- package/dist/esm/lib/v3/understudy/cdp.js +251 -0
- package/dist/esm/lib/v3/understudy/cdp.js.map +1 -0
- package/dist/esm/lib/v3/understudy/consoleMessage.d.ts +22 -0
- package/dist/esm/lib/v3/understudy/consoleMessage.js +66 -0
- package/dist/esm/lib/v3/understudy/consoleMessage.js.map +1 -0
- package/dist/esm/lib/v3/understudy/context.d.ts +132 -0
- package/dist/esm/lib/v3/understudy/context.js +696 -0
- package/dist/esm/lib/v3/understudy/context.js.map +1 -0
- package/dist/esm/lib/v3/understudy/deepLocator.d.ts +87 -0
- package/dist/esm/lib/v3/understudy/deepLocator.js +218 -0
- package/dist/esm/lib/v3/understudy/deepLocator.js.map +1 -0
- package/dist/esm/lib/v3/understudy/executionContextRegistry.d.ts +15 -0
- package/dist/esm/lib/v3/understudy/executionContextRegistry.js +83 -0
- package/dist/esm/lib/v3/understudy/executionContextRegistry.js.map +1 -0
- package/dist/esm/lib/v3/understudy/fileUploadUtils.d.ts +13 -0
- package/dist/esm/lib/v3/understudy/fileUploadUtils.js +81 -0
- package/dist/esm/lib/v3/understudy/fileUploadUtils.js.map +1 -0
- package/dist/esm/lib/v3/understudy/frame.d.ts +69 -0
- package/dist/esm/lib/v3/understudy/frame.js +211 -0
- package/dist/esm/lib/v3/understudy/frame.js.map +1 -0
- package/dist/esm/lib/v3/understudy/frameLocator.d.ts +50 -0
- package/dist/esm/lib/v3/understudy/frameLocator.js +255 -0
- package/dist/esm/lib/v3/understudy/frameLocator.js.map +1 -0
- package/dist/esm/lib/v3/understudy/frameRegistry.d.ts +101 -0
- package/dist/esm/lib/v3/understudy/frameRegistry.js +298 -0
- package/dist/esm/lib/v3/understudy/frameRegistry.js.map +1 -0
- package/dist/esm/lib/v3/understudy/initScripts.d.ts +2 -0
- package/dist/esm/lib/v3/understudy/initScripts.js +33 -0
- package/dist/esm/lib/v3/understudy/initScripts.js.map +1 -0
- package/dist/esm/lib/v3/understudy/lifecycleWatcher.d.ts +64 -0
- package/dist/esm/lib/v3/understudy/lifecycleWatcher.js +245 -0
- package/dist/esm/lib/v3/understudy/lifecycleWatcher.js.map +1 -0
- package/dist/esm/lib/v3/understudy/locator.d.ts +194 -0
- package/dist/esm/lib/v3/understudy/locator.js +753 -0
- package/dist/esm/lib/v3/understudy/locator.js.map +1 -0
- package/dist/esm/lib/v3/understudy/locatorInvocation.d.ts +8 -0
- package/dist/esm/lib/v3/understudy/locatorInvocation.js +12 -0
- package/dist/esm/lib/v3/understudy/locatorInvocation.js.map +1 -0
- package/dist/esm/lib/v3/understudy/navigationResponseTracker.d.ts +84 -0
- package/dist/esm/lib/v3/understudy/navigationResponseTracker.js +224 -0
- package/dist/esm/lib/v3/understudy/navigationResponseTracker.js.map +1 -0
- package/dist/esm/lib/v3/understudy/networkManager.d.ts +53 -0
- package/dist/esm/lib/v3/understudy/networkManager.js +306 -0
- package/dist/esm/lib/v3/understudy/networkManager.js.map +1 -0
- package/dist/esm/lib/v3/understudy/page.d.ts +354 -0
- package/dist/esm/lib/v3/understudy/page.js +1942 -0
- package/dist/esm/lib/v3/understudy/page.js.map +1 -0
- package/dist/esm/lib/v3/understudy/piercer.d.ts +4 -0
- package/dist/esm/lib/v3/understudy/piercer.js +61 -0
- package/dist/esm/lib/v3/understudy/piercer.js.map +1 -0
- package/dist/esm/lib/v3/understudy/response.d.ts +137 -0
- package/dist/esm/lib/v3/understudy/response.js +330 -0
- package/dist/esm/lib/v3/understudy/response.js.map +1 -0
- package/dist/esm/lib/v3/understudy/screenshotUtils.d.ts +16 -0
- package/dist/esm/lib/v3/understudy/screenshotUtils.js +352 -0
- package/dist/esm/lib/v3/understudy/screenshotUtils.js.map +1 -0
- package/dist/esm/lib/v3/understudy/selectorResolver.d.ts +38 -0
- package/dist/esm/lib/v3/understudy/selectorResolver.js +296 -0
- package/dist/esm/lib/v3/understudy/selectorResolver.js.map +1 -0
- package/dist/esm/lib/v3/v3.d.ts +191 -0
- package/dist/esm/lib/v3/v3.js +1569 -0
- package/dist/esm/lib/v3/v3.js.map +1 -0
- package/dist/esm/lib/v3/zodCompat.d.ts +12 -0
- package/dist/esm/lib/v3/zodCompat.js +17 -0
- package/dist/esm/lib/v3/zodCompat.js.map +1 -0
- package/dist/esm/lib/v3Evaluator.d.ts +19 -0
- package/dist/esm/lib/v3Evaluator.js +210 -0
- package/dist/esm/lib/v3Evaluator.js.map +1 -0
- package/dist/esm/lib/version.d.ts +5 -0
- package/dist/esm/lib/version.js +6 -0
- package/dist/esm/lib/version.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/tests/browserbase-session-accessors.test.js +101 -0
- package/dist/esm/tests/browserbase-session-accessors.test.js.map +7 -0
- package/dist/esm/tests/cache-llm-resolution.test.js +187 -0
- package/dist/esm/tests/cache-llm-resolution.test.js.map +7 -0
- package/dist/esm/tests/helpers/mockCDPSession.js +27 -0
- package/dist/esm/tests/helpers/mockCDPSession.js.map +7 -0
- package/dist/esm/tests/llm-provider.test.js +57 -0
- package/dist/esm/tests/llm-provider.test.js.map +7 -0
- package/dist/esm/tests/model-deprecation.test.js +135 -0
- package/dist/esm/tests/model-deprecation.test.js.map +7 -0
- package/dist/esm/tests/page-snapshot.test.js +36 -0
- package/dist/esm/tests/page-snapshot.test.js.map +7 -0
- package/dist/esm/tests/public-api/export-surface.test.js +54 -0
- package/dist/esm/tests/public-api/export-surface.test.js.map +7 -0
- package/dist/esm/tests/public-api/llm-and-agents.test.js +128 -0
- package/dist/esm/tests/public-api/llm-and-agents.test.js.map +7 -0
- package/dist/esm/tests/public-api/public-error-types.test.js +71 -0
- package/dist/esm/tests/public-api/public-error-types.test.js.map +7 -0
- package/dist/esm/tests/public-api/public-types.test.js +74 -0
- package/dist/esm/tests/public-api/public-types.test.js.map +7 -0
- package/dist/esm/tests/public-api/runtime-utils.test.js +31 -0
- package/dist/esm/tests/public-api/runtime-utils.test.js.map +7 -0
- package/dist/esm/tests/public-api/schema-utils.test.js +78 -0
- package/dist/esm/tests/public-api/schema-utils.test.js.map +7 -0
- package/dist/esm/tests/public-api/timeout-error-types.test.js +81 -0
- package/dist/esm/tests/public-api/timeout-error-types.test.js.map +7 -0
- package/dist/esm/tests/public-api/tool-type-export.test.js +25 -0
- package/dist/esm/tests/public-api/tool-type-export.test.js.map +7 -0
- package/dist/esm/tests/public-api/v3-core.test.js +82 -0
- package/dist/esm/tests/public-api/v3-core.test.js.map +7 -0
- package/dist/esm/tests/safety-confirmation.test.js +134 -0
- package/dist/esm/tests/safety-confirmation.test.js.map +7 -0
- package/dist/esm/tests/snapshot-a11y-resolvers.test.js +348 -0
- package/dist/esm/tests/snapshot-a11y-resolvers.test.js.map +7 -0
- package/dist/esm/tests/snapshot-a11y-tree-utils.test.js +300 -0
- package/dist/esm/tests/snapshot-a11y-tree-utils.test.js.map +7 -0
- package/dist/esm/tests/snapshot-capture-orchestration.test.js +381 -0
- package/dist/esm/tests/snapshot-capture-orchestration.test.js.map +7 -0
- package/dist/esm/tests/snapshot-cbor.test.js +197 -0
- package/dist/esm/tests/snapshot-cbor.test.js.map +7 -0
- package/dist/esm/tests/snapshot-dom-session-builders.test.js +251 -0
- package/dist/esm/tests/snapshot-dom-session-builders.test.js.map +7 -0
- package/dist/esm/tests/snapshot-dom-tree-utils.test.js +109 -0
- package/dist/esm/tests/snapshot-dom-tree-utils.test.js.map +7 -0
- package/dist/esm/tests/snapshot-focus-selectors-utils.test.js +49 -0
- package/dist/esm/tests/snapshot-focus-selectors-utils.test.js.map +7 -0
- package/dist/esm/tests/snapshot-frame-merge.test.js +391 -0
- package/dist/esm/tests/snapshot-frame-merge.test.js.map +7 -0
- package/dist/esm/tests/snapshot-tree-format-utils.test.js +113 -0
- package/dist/esm/tests/snapshot-tree-format-utils.test.js.map +7 -0
- package/dist/esm/tests/snapshot-xpath-utils.test.js +79 -0
- package/dist/esm/tests/snapshot-xpath-utils.test.js.map +7 -0
- package/dist/esm/tests/timeout-handlers.test.js +850 -0
- package/dist/esm/tests/timeout-handlers.test.js.map +7 -0
- package/dist/esm/tests/xpath-parser.test.js +317 -0
- package/dist/esm/tests/xpath-parser.test.js.map +7 -0
- package/dist/esm/tests/xpath-resolver.test.js +73 -0
- package/dist/esm/tests/xpath-resolver.test.js.map +7 -0
- package/dist/esm/tests/zod-enum-compatibility.test.js +97 -0
- package/dist/esm/tests/zod-enum-compatibility.test.js.map +7 -0
- package/package.json +41 -24
- package/dist/index.d.ts +0 -4363
- package/dist/index.js +0 -76530
|
@@ -0,0 +1,1569 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { EventEmitter } from "events";
|
|
36
|
+
import fs from "fs";
|
|
37
|
+
import os from "os";
|
|
38
|
+
import path from "path";
|
|
39
|
+
import process from "process";
|
|
40
|
+
import { v7 as uuidv7 } from "uuid";
|
|
41
|
+
import { toJsonSchema, } from "./zodCompat.js";
|
|
42
|
+
import { loadApiKeyFromEnv } from "../utils.js";
|
|
43
|
+
import { StagehandLogger } from "../logger.js";
|
|
44
|
+
import { ActCache } from "./cache/ActCache.js";
|
|
45
|
+
import { AgentCache } from "./cache/AgentCache.js";
|
|
46
|
+
import { CacheStorage } from "./cache/CacheStorage.js";
|
|
47
|
+
import { ActHandler } from "./handlers/actHandler.js";
|
|
48
|
+
import { ExtractHandler } from "./handlers/extractHandler.js";
|
|
49
|
+
import { ObserveHandler } from "./handlers/observeHandler.js";
|
|
50
|
+
import { V3AgentHandler } from "./handlers/v3AgentHandler.js";
|
|
51
|
+
import { V3CuaAgentHandler } from "./handlers/v3CuaAgentHandler.js";
|
|
52
|
+
import { createBrowserbaseSession } from "./launch/browserbase.js";
|
|
53
|
+
import { launchLocalChrome } from "./launch/local.js";
|
|
54
|
+
import { LLMProvider } from "./llm/LLMProvider.js";
|
|
55
|
+
import { bindInstanceLogger, unbindInstanceLogger, withInstanceLogContext, } from "./logger.js";
|
|
56
|
+
import { cleanupLocalBrowser } from "./shutdown/cleanupLocal.js";
|
|
57
|
+
import { startShutdownSupervisor } from "./shutdown/supervisorClient.js";
|
|
58
|
+
import { resolveTools } from "./mcp/utils.js";
|
|
59
|
+
import { AVAILABLE_CUA_MODELS, defaultExtractSchema, V3FunctionName, CuaModelRequiredError, StagehandInvalidArgumentError, StagehandNotInitializedError, MissingEnvironmentVariableError, StagehandInitError, } from "./types/public/index.js";
|
|
60
|
+
import { V3Context } from "./understudy/context.js";
|
|
61
|
+
import { resolveModel } from "../modelUtils.js";
|
|
62
|
+
import { StagehandAPIClient } from "./api.js";
|
|
63
|
+
import { validateExperimentalFeatures } from "./agent/utils/validateExperimentalFeatures.js";
|
|
64
|
+
import { SessionFileLogger, logStagehandStep } from "./flowLogger.js";
|
|
65
|
+
import { createTimeoutGuard } from "./handlers/handlerUtils/timeoutGuard.js";
|
|
66
|
+
import { ActTimeoutError } from "./types/public/sdkErrors.js";
|
|
67
|
+
const DEFAULT_MODEL_NAME = "openai/gpt-4.1-mini";
|
|
68
|
+
const DEFAULT_VIEWPORT = { width: 1288, height: 711 };
|
|
69
|
+
function resolveModelConfiguration(model) {
|
|
70
|
+
if (!model) {
|
|
71
|
+
return { modelName: DEFAULT_MODEL_NAME };
|
|
72
|
+
}
|
|
73
|
+
if (typeof model === "string") {
|
|
74
|
+
return { modelName: model };
|
|
75
|
+
}
|
|
76
|
+
if (model && typeof model === "object") {
|
|
77
|
+
const { modelName, ...clientOptions } = model;
|
|
78
|
+
if (!modelName) {
|
|
79
|
+
throw new StagehandInvalidArgumentError("model.modelName is required when providing client options.");
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
modelName,
|
|
83
|
+
clientOptions: clientOptions,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return { modelName: DEFAULT_MODEL_NAME };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* V3
|
|
90
|
+
*
|
|
91
|
+
* Purpose:
|
|
92
|
+
* A high-level orchestrator for Stagehand V3. Abstracts away whether the browser
|
|
93
|
+
* runs **locally via Chrome** or remotely on **Browserbase**, and exposes simple
|
|
94
|
+
* entrypoints (`act`, `extract`, `observe`) that delegate to the corresponding
|
|
95
|
+
* handler classes.
|
|
96
|
+
*
|
|
97
|
+
* Responsibilities:
|
|
98
|
+
* - Bootstraps Chrome or Browserbase, ensures a working CDP WebSocket, and builds a `V3Context`.
|
|
99
|
+
* - Manages lifecycle: init, context access, cleanup.
|
|
100
|
+
* - Bridges external page objects (Playwright/Puppeteer) into internal frameIds for handlers.
|
|
101
|
+
* - Provides a stable API surface for downstream code regardless of runtime environment.
|
|
102
|
+
*/
|
|
103
|
+
let V3 = (() => {
|
|
104
|
+
let _instanceExtraInitializers = [];
|
|
105
|
+
let _act_decorators;
|
|
106
|
+
let _extract_decorators;
|
|
107
|
+
let _observe_decorators;
|
|
108
|
+
return class V3 {
|
|
109
|
+
static {
|
|
110
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
111
|
+
_act_decorators = [logStagehandStep("Stagehand.act", "ACT")];
|
|
112
|
+
_extract_decorators = [logStagehandStep("Stagehand.extract", "EXTRACT")];
|
|
113
|
+
_observe_decorators = [logStagehandStep("Stagehand.observe", "OBSERVE")];
|
|
114
|
+
__esDecorate(this, null, _act_decorators, { kind: "method", name: "act", static: false, private: false, access: { has: obj => "act" in obj, get: obj => obj.act }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
115
|
+
__esDecorate(this, null, _extract_decorators, { kind: "method", name: "extract", static: false, private: false, access: { has: obj => "extract" in obj, get: obj => obj.extract }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
116
|
+
__esDecorate(this, null, _observe_decorators, { kind: "method", name: "observe", static: false, private: false, access: { has: obj => "observe" in obj, get: obj => obj.observe }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
117
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
118
|
+
}
|
|
119
|
+
opts = __runInitializers(this, _instanceExtraInitializers);
|
|
120
|
+
state = { kind: "UNINITIALIZED" };
|
|
121
|
+
actHandler = null;
|
|
122
|
+
extractHandler = null;
|
|
123
|
+
observeHandler = null;
|
|
124
|
+
ctx = null;
|
|
125
|
+
llmClient;
|
|
126
|
+
/**
|
|
127
|
+
* Event bus for internal communication.
|
|
128
|
+
* Emits events like 'screenshot' when screenshots are captured during agent execution.
|
|
129
|
+
*/
|
|
130
|
+
bus = new EventEmitter();
|
|
131
|
+
modelName;
|
|
132
|
+
modelClientOptions;
|
|
133
|
+
llmProvider;
|
|
134
|
+
overrideLlmClients = new Map();
|
|
135
|
+
domSettleTimeoutMs;
|
|
136
|
+
_isClosing = false;
|
|
137
|
+
browserbaseSessionId;
|
|
138
|
+
browserbaseSessionUrl;
|
|
139
|
+
browserbaseDebugUrl;
|
|
140
|
+
get browserbaseSessionID() {
|
|
141
|
+
return this.browserbaseSessionId;
|
|
142
|
+
}
|
|
143
|
+
get browserbaseSessionURL() {
|
|
144
|
+
return this.browserbaseSessionUrl;
|
|
145
|
+
}
|
|
146
|
+
get browserbaseDebugURL() {
|
|
147
|
+
return this.browserbaseDebugUrl;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Returns true if the browser is running on Browserbase.
|
|
151
|
+
*/
|
|
152
|
+
get isBrowserbase() {
|
|
153
|
+
return this.state.kind === "BROWSERBASE";
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Returns true if advancedStealth is enabled in Browserbase settings.
|
|
157
|
+
*/
|
|
158
|
+
get isAdvancedStealth() {
|
|
159
|
+
return (this.opts.browserbaseSessionCreateParams?.browserSettings
|
|
160
|
+
?.advancedStealth === true);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns the configured viewport dimensions from launch options.
|
|
164
|
+
* Falls back to default 1288x711 if not configured.
|
|
165
|
+
*/
|
|
166
|
+
get configuredViewport() {
|
|
167
|
+
const defaultWidth = 1288;
|
|
168
|
+
const defaultHeight = 711;
|
|
169
|
+
if (this.opts.env === "BROWSERBASE") {
|
|
170
|
+
const vp = this.opts.browserbaseSessionCreateParams?.browserSettings?.viewport;
|
|
171
|
+
return {
|
|
172
|
+
width: vp?.width ?? defaultWidth,
|
|
173
|
+
height: vp?.height ?? defaultHeight,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// LOCAL env
|
|
177
|
+
const vp = this.opts.localBrowserLaunchOptions?.viewport;
|
|
178
|
+
return {
|
|
179
|
+
width: vp?.width ?? defaultWidth,
|
|
180
|
+
height: vp?.height ?? defaultHeight,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
_onCdpClosed = (why) => {
|
|
184
|
+
if (this.state.kind === "BROWSERBASE") {
|
|
185
|
+
void this._logBrowserbaseSessionStatus();
|
|
186
|
+
}
|
|
187
|
+
// Single place to react to the transport closing
|
|
188
|
+
this._immediateShutdown(`CDP transport closed: ${why}`).catch(() => { });
|
|
189
|
+
};
|
|
190
|
+
experimental = false;
|
|
191
|
+
logInferenceToFile = false;
|
|
192
|
+
disableAPI = false;
|
|
193
|
+
externalLogger;
|
|
194
|
+
verbose = 1;
|
|
195
|
+
stagehandLogger;
|
|
196
|
+
_history = [];
|
|
197
|
+
instanceId;
|
|
198
|
+
static _processGuardsInstalled = false;
|
|
199
|
+
static _instances = new Set();
|
|
200
|
+
cacheStorage;
|
|
201
|
+
actCache;
|
|
202
|
+
agentCache;
|
|
203
|
+
apiClient = null;
|
|
204
|
+
keepAlive;
|
|
205
|
+
shutdownSupervisor = null;
|
|
206
|
+
stagehandMetrics = {
|
|
207
|
+
actPromptTokens: 0,
|
|
208
|
+
actCompletionTokens: 0,
|
|
209
|
+
actReasoningTokens: 0,
|
|
210
|
+
actCachedInputTokens: 0,
|
|
211
|
+
actInferenceTimeMs: 0,
|
|
212
|
+
extractPromptTokens: 0,
|
|
213
|
+
extractCompletionTokens: 0,
|
|
214
|
+
extractReasoningTokens: 0,
|
|
215
|
+
extractCachedInputTokens: 0,
|
|
216
|
+
extractInferenceTimeMs: 0,
|
|
217
|
+
observePromptTokens: 0,
|
|
218
|
+
observeCompletionTokens: 0,
|
|
219
|
+
observeReasoningTokens: 0,
|
|
220
|
+
observeCachedInputTokens: 0,
|
|
221
|
+
observeInferenceTimeMs: 0,
|
|
222
|
+
agentPromptTokens: 0,
|
|
223
|
+
agentCompletionTokens: 0,
|
|
224
|
+
agentReasoningTokens: 0,
|
|
225
|
+
agentCachedInputTokens: 0,
|
|
226
|
+
agentInferenceTimeMs: 0,
|
|
227
|
+
totalPromptTokens: 0,
|
|
228
|
+
totalCompletionTokens: 0,
|
|
229
|
+
totalReasoningTokens: 0,
|
|
230
|
+
totalCachedInputTokens: 0,
|
|
231
|
+
totalInferenceTimeMs: 0,
|
|
232
|
+
};
|
|
233
|
+
constructor(opts) {
|
|
234
|
+
this.externalLogger = opts.logger;
|
|
235
|
+
this.verbose = opts.verbose ?? 1;
|
|
236
|
+
this.instanceId = uuidv7();
|
|
237
|
+
this.keepAlive =
|
|
238
|
+
opts.keepAlive ?? opts.browserbaseSessionCreateParams?.keepAlive;
|
|
239
|
+
// Create per-instance StagehandLogger (handles usePino, verbose, externalLogger)
|
|
240
|
+
// This gives each V3 instance independent logger configuration
|
|
241
|
+
// while still sharing the underlying Pino worker thread via StagehandLogger.sharedPinoLogger
|
|
242
|
+
const loggerOptions = {
|
|
243
|
+
pretty: true,
|
|
244
|
+
level: "info", // Most permissive - filtering happens at instance level
|
|
245
|
+
};
|
|
246
|
+
if (opts.disablePino !== undefined) {
|
|
247
|
+
loggerOptions.usePino = !opts.disablePino;
|
|
248
|
+
}
|
|
249
|
+
this.stagehandLogger = new StagehandLogger(loggerOptions, opts.logger);
|
|
250
|
+
this.stagehandLogger.setVerbosity(this.verbose);
|
|
251
|
+
// Also bind to AsyncLocalStorage for v3Logger() calls from handlers
|
|
252
|
+
// This maintains backward compatibility with code that uses v3Logger() directly
|
|
253
|
+
try {
|
|
254
|
+
if (this.externalLogger) {
|
|
255
|
+
// Use external logger directly when provided
|
|
256
|
+
bindInstanceLogger(this.instanceId, this.externalLogger);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// Fall back to stagehandLogger when no external logger
|
|
260
|
+
bindInstanceLogger(this.instanceId, (line) => {
|
|
261
|
+
this.stagehandLogger.log(line);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// ignore
|
|
267
|
+
}
|
|
268
|
+
const { modelName, clientOptions } = resolveModelConfiguration(opts.model);
|
|
269
|
+
this.modelName = modelName;
|
|
270
|
+
this.experimental = opts.experimental ?? false;
|
|
271
|
+
this.logInferenceToFile = opts.logInferenceToFile ?? false;
|
|
272
|
+
this.llmProvider = new LLMProvider(this.logger);
|
|
273
|
+
this.domSettleTimeoutMs = opts.domSettleTimeout;
|
|
274
|
+
this.disableAPI = opts.disableAPI ?? false;
|
|
275
|
+
const baseClientOptions = clientOptions
|
|
276
|
+
? { ...clientOptions }
|
|
277
|
+
: {};
|
|
278
|
+
if (opts.llmClient) {
|
|
279
|
+
this.llmClient = opts.llmClient;
|
|
280
|
+
this.modelClientOptions = baseClientOptions;
|
|
281
|
+
this.disableAPI = true;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
// Ensure API key is set
|
|
285
|
+
let apiKey = baseClientOptions.apiKey;
|
|
286
|
+
if (!apiKey) {
|
|
287
|
+
try {
|
|
288
|
+
apiKey = loadApiKeyFromEnv(this.modelName.split("/")[0], // "openai", "anthropic", etc
|
|
289
|
+
this.logger);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
this.logger({
|
|
293
|
+
category: "init",
|
|
294
|
+
message: `Error loading API key for model ${this.modelName}: ${error}. Continuing without LLM client.`,
|
|
295
|
+
level: 0,
|
|
296
|
+
});
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
this.modelClientOptions = {
|
|
301
|
+
...baseClientOptions,
|
|
302
|
+
apiKey,
|
|
303
|
+
};
|
|
304
|
+
// Get the default client for this model
|
|
305
|
+
this.llmClient = this.llmProvider.getClient(this.modelName, this.modelClientOptions, { experimental: this.experimental, disableAPI: this.disableAPI });
|
|
306
|
+
}
|
|
307
|
+
this.cacheStorage = CacheStorage.create(opts.cacheDir, this.logger, {
|
|
308
|
+
label: "cache directory",
|
|
309
|
+
});
|
|
310
|
+
this.actCache = new ActCache({
|
|
311
|
+
storage: this.cacheStorage,
|
|
312
|
+
logger: this.logger,
|
|
313
|
+
getActHandler: () => this.actHandler,
|
|
314
|
+
getDefaultLlmClient: () => this.resolveLlmClient(),
|
|
315
|
+
domSettleTimeoutMs: this.domSettleTimeoutMs,
|
|
316
|
+
});
|
|
317
|
+
this.agentCache = new AgentCache({
|
|
318
|
+
storage: this.cacheStorage,
|
|
319
|
+
logger: this.logger,
|
|
320
|
+
getActHandler: () => this.actHandler,
|
|
321
|
+
getContext: () => this.ctx,
|
|
322
|
+
getDefaultLlmClient: () => this.resolveLlmClient(),
|
|
323
|
+
getBaseModelName: () => this.modelName,
|
|
324
|
+
getSystemPrompt: () => opts.systemPrompt,
|
|
325
|
+
domSettleTimeoutMs: this.domSettleTimeoutMs,
|
|
326
|
+
act: this.act.bind(this),
|
|
327
|
+
});
|
|
328
|
+
this.opts = opts;
|
|
329
|
+
// Initialize session file logger
|
|
330
|
+
SessionFileLogger.init(this.instanceId, opts);
|
|
331
|
+
// Track instance for global process guard handling
|
|
332
|
+
V3._instances.add(this);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Async property for metrics so callers can `await v3.metrics`.
|
|
336
|
+
* When using API mode, fetches metrics from the API. Otherwise returns local metrics.
|
|
337
|
+
*/
|
|
338
|
+
get metrics() {
|
|
339
|
+
if (this.apiClient) {
|
|
340
|
+
// Fetch metrics from the API
|
|
341
|
+
return this.apiClient.getReplayMetrics().catch((error) => {
|
|
342
|
+
this.logger({
|
|
343
|
+
category: "metrics",
|
|
344
|
+
message: `Failed to fetch metrics from API: ${error}`,
|
|
345
|
+
level: 0,
|
|
346
|
+
});
|
|
347
|
+
// Fall back to local metrics on error
|
|
348
|
+
return this.stagehandMetrics;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
// Return local metrics wrapped in a Promise for consistency
|
|
352
|
+
return Promise.resolve(this.stagehandMetrics);
|
|
353
|
+
}
|
|
354
|
+
resolveLlmClient(model) {
|
|
355
|
+
if (!model) {
|
|
356
|
+
return this.llmClient;
|
|
357
|
+
}
|
|
358
|
+
let modelName;
|
|
359
|
+
let clientOptions;
|
|
360
|
+
if (typeof model === "string") {
|
|
361
|
+
modelName = model;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
const { modelName: overrideModelName, ...rest } = model;
|
|
365
|
+
modelName = overrideModelName;
|
|
366
|
+
clientOptions = rest;
|
|
367
|
+
}
|
|
368
|
+
if (modelName === this.modelName &&
|
|
369
|
+
(!clientOptions || Object.keys(clientOptions).length === 0)) {
|
|
370
|
+
return this.llmClient;
|
|
371
|
+
}
|
|
372
|
+
const overrideProvider = String(modelName).split("/")[0];
|
|
373
|
+
const baseProvider = String(this.modelName).split("/")[0];
|
|
374
|
+
const mergedOptions = {
|
|
375
|
+
...(overrideProvider === baseProvider ? this.modelClientOptions : {}),
|
|
376
|
+
...(clientOptions ?? {}),
|
|
377
|
+
};
|
|
378
|
+
const providerKey = overrideProvider;
|
|
379
|
+
if (!mergedOptions.apiKey) {
|
|
380
|
+
const apiKey = loadApiKeyFromEnv(providerKey, this.logger);
|
|
381
|
+
if (apiKey) {
|
|
382
|
+
mergedOptions.apiKey = apiKey;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const cacheKey = JSON.stringify({
|
|
386
|
+
modelName,
|
|
387
|
+
clientOptions: mergedOptions,
|
|
388
|
+
});
|
|
389
|
+
const cached = this.overrideLlmClients.get(cacheKey);
|
|
390
|
+
if (cached) {
|
|
391
|
+
return cached;
|
|
392
|
+
}
|
|
393
|
+
const client = this.llmProvider.getClient(modelName, mergedOptions, { experimental: this.experimental, disableAPI: this.disableAPI });
|
|
394
|
+
this.overrideLlmClients.set(cacheKey, client);
|
|
395
|
+
return client;
|
|
396
|
+
}
|
|
397
|
+
beginAgentReplayRecording() {
|
|
398
|
+
this.agentCache.beginRecording();
|
|
399
|
+
}
|
|
400
|
+
endAgentReplayRecording() {
|
|
401
|
+
return this.agentCache.endRecording();
|
|
402
|
+
}
|
|
403
|
+
discardAgentReplayRecording() {
|
|
404
|
+
this.agentCache.discardRecording();
|
|
405
|
+
}
|
|
406
|
+
isAgentReplayRecording() {
|
|
407
|
+
return this.agentCache.isRecording();
|
|
408
|
+
}
|
|
409
|
+
isAgentReplayActive() {
|
|
410
|
+
return this.agentCache.isReplayActive();
|
|
411
|
+
}
|
|
412
|
+
recordAgentReplayStep(step) {
|
|
413
|
+
this.agentCache.recordStep(step);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Async property for history so callers can `await v3.history`.
|
|
417
|
+
* Returns a frozen copy to avoid external mutation.
|
|
418
|
+
*/
|
|
419
|
+
get history() {
|
|
420
|
+
return Promise.resolve(Object.freeze([...this._history]));
|
|
421
|
+
}
|
|
422
|
+
addToHistory(method, parameters, result) {
|
|
423
|
+
this._history.push({
|
|
424
|
+
method,
|
|
425
|
+
parameters,
|
|
426
|
+
result: result ?? null,
|
|
427
|
+
timestamp: new Date().toISOString(),
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
updateMetrics(functionName, promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs) {
|
|
431
|
+
switch (functionName) {
|
|
432
|
+
case V3FunctionName.ACT:
|
|
433
|
+
this.stagehandMetrics.actPromptTokens += promptTokens;
|
|
434
|
+
this.stagehandMetrics.actCompletionTokens += completionTokens;
|
|
435
|
+
this.stagehandMetrics.actReasoningTokens += reasoningTokens;
|
|
436
|
+
this.stagehandMetrics.actCachedInputTokens += cachedInputTokens;
|
|
437
|
+
this.stagehandMetrics.actInferenceTimeMs += inferenceTimeMs;
|
|
438
|
+
break;
|
|
439
|
+
case V3FunctionName.EXTRACT:
|
|
440
|
+
this.stagehandMetrics.extractPromptTokens += promptTokens;
|
|
441
|
+
this.stagehandMetrics.extractCompletionTokens += completionTokens;
|
|
442
|
+
this.stagehandMetrics.extractReasoningTokens += reasoningTokens;
|
|
443
|
+
this.stagehandMetrics.extractCachedInputTokens += cachedInputTokens;
|
|
444
|
+
this.stagehandMetrics.extractInferenceTimeMs += inferenceTimeMs;
|
|
445
|
+
break;
|
|
446
|
+
case V3FunctionName.OBSERVE:
|
|
447
|
+
this.stagehandMetrics.observePromptTokens += promptTokens;
|
|
448
|
+
this.stagehandMetrics.observeCompletionTokens += completionTokens;
|
|
449
|
+
this.stagehandMetrics.observeReasoningTokens += reasoningTokens;
|
|
450
|
+
this.stagehandMetrics.observeCachedInputTokens += cachedInputTokens;
|
|
451
|
+
this.stagehandMetrics.observeInferenceTimeMs += inferenceTimeMs;
|
|
452
|
+
break;
|
|
453
|
+
case V3FunctionName.AGENT:
|
|
454
|
+
this.stagehandMetrics.agentPromptTokens += promptTokens;
|
|
455
|
+
this.stagehandMetrics.agentCompletionTokens += completionTokens;
|
|
456
|
+
this.stagehandMetrics.agentReasoningTokens += reasoningTokens;
|
|
457
|
+
this.stagehandMetrics.agentCachedInputTokens += cachedInputTokens;
|
|
458
|
+
this.stagehandMetrics.agentInferenceTimeMs += inferenceTimeMs;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
this.updateTotalMetrics(promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs);
|
|
462
|
+
}
|
|
463
|
+
updateTotalMetrics(promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs) {
|
|
464
|
+
this.stagehandMetrics.totalPromptTokens += promptTokens;
|
|
465
|
+
this.stagehandMetrics.totalCompletionTokens += completionTokens;
|
|
466
|
+
this.stagehandMetrics.totalReasoningTokens += reasoningTokens;
|
|
467
|
+
this.stagehandMetrics.totalCachedInputTokens += cachedInputTokens;
|
|
468
|
+
this.stagehandMetrics.totalInferenceTimeMs += inferenceTimeMs;
|
|
469
|
+
}
|
|
470
|
+
async _immediateShutdown(reason) {
|
|
471
|
+
try {
|
|
472
|
+
this.logger({
|
|
473
|
+
category: "v3",
|
|
474
|
+
message: `initiating shutdown → ${reason}`,
|
|
475
|
+
level: 0,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
catch {
|
|
479
|
+
//
|
|
480
|
+
}
|
|
481
|
+
try {
|
|
482
|
+
this.logger({
|
|
483
|
+
category: "v3",
|
|
484
|
+
message: `closing resources → ${reason}`,
|
|
485
|
+
level: 0,
|
|
486
|
+
});
|
|
487
|
+
await this.close({ force: true });
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
// swallow — already shutting down
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/** Spawn a crash-only supervisor that cleans up when this process dies. */
|
|
494
|
+
startShutdownSupervisor(config) {
|
|
495
|
+
if (this.shutdownSupervisor)
|
|
496
|
+
return this.shutdownSupervisor;
|
|
497
|
+
this.shutdownSupervisor = startShutdownSupervisor(config, {
|
|
498
|
+
onError: (error, context) => {
|
|
499
|
+
try {
|
|
500
|
+
this.logger({
|
|
501
|
+
category: "v3",
|
|
502
|
+
message: "Shutdown supervisor unavailable; crash cleanup disabled. " +
|
|
503
|
+
"If this process exits unexpectedly, local Chrome or Browserbase " +
|
|
504
|
+
"sessions may remain running even with keepAlive=false.",
|
|
505
|
+
level: 0,
|
|
506
|
+
auxiliary: {
|
|
507
|
+
context: { value: context, type: "string" },
|
|
508
|
+
error: { value: error.message, type: "string" },
|
|
509
|
+
},
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
catch {
|
|
513
|
+
// ignore logging failures
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
return this.shutdownSupervisor;
|
|
518
|
+
}
|
|
519
|
+
/** Stop the supervisor during a normal shutdown. */
|
|
520
|
+
stopShutdownSupervisor() {
|
|
521
|
+
if (!this.shutdownSupervisor)
|
|
522
|
+
return;
|
|
523
|
+
try {
|
|
524
|
+
this.shutdownSupervisor.stop();
|
|
525
|
+
}
|
|
526
|
+
catch {
|
|
527
|
+
// best-effort
|
|
528
|
+
}
|
|
529
|
+
this.shutdownSupervisor = null;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Entrypoint: initializes handlers, launches Chrome or Browserbase,
|
|
533
|
+
* and sets up a CDP context.
|
|
534
|
+
*/
|
|
535
|
+
async init() {
|
|
536
|
+
try {
|
|
537
|
+
return await withInstanceLogContext(this.instanceId, async () => {
|
|
538
|
+
this.actHandler = new ActHandler(this.llmClient, this.modelName, this.modelClientOptions, (model) => this.resolveLlmClient(model), this.opts.systemPrompt ?? "", this.logInferenceToFile, this.opts.selfHeal ?? true, (functionName, promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs) => this.updateMetrics(functionName, promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs), this.domSettleTimeoutMs);
|
|
539
|
+
this.extractHandler = new ExtractHandler(this.llmClient, this.modelName, this.modelClientOptions, (model) => this.resolveLlmClient(model), this.opts.systemPrompt ?? "", this.logInferenceToFile, this.experimental, (functionName, promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs) => this.updateMetrics(functionName, promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs));
|
|
540
|
+
this.observeHandler = new ObserveHandler(this.llmClient, this.modelName, this.modelClientOptions, (model) => this.resolveLlmClient(model), this.opts.systemPrompt ?? "", this.logInferenceToFile, this.experimental, (functionName, promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs) => this.updateMetrics(functionName, promptTokens, completionTokens, reasoningTokens, cachedInputTokens, inferenceTimeMs));
|
|
541
|
+
if (this.opts.env === "LOCAL") {
|
|
542
|
+
// chrome-launcher conditionally adds --headless when the environment variable
|
|
543
|
+
// HEADLESS is set, without parsing its value.
|
|
544
|
+
// if it is not equal to true, then we delete it from the process
|
|
545
|
+
const envHeadless = process.env.HEADLESS;
|
|
546
|
+
if (envHeadless !== undefined) {
|
|
547
|
+
const normalized = envHeadless.trim().toLowerCase();
|
|
548
|
+
if (normalized !== "true") {
|
|
549
|
+
delete process.env.HEADLESS;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
const lbo = this.opts.localBrowserLaunchOptions ?? {};
|
|
553
|
+
// If a CDP URL is provided, attach instead of launching.
|
|
554
|
+
if (lbo.cdpUrl) {
|
|
555
|
+
this.logger({
|
|
556
|
+
category: "init",
|
|
557
|
+
message: "Connecting to local browser",
|
|
558
|
+
level: 1,
|
|
559
|
+
});
|
|
560
|
+
this.ctx = await V3Context.create(lbo.cdpUrl, {
|
|
561
|
+
env: "LOCAL",
|
|
562
|
+
});
|
|
563
|
+
const logCtx = SessionFileLogger.getContext();
|
|
564
|
+
this.ctx.conn.cdpLogger = (info) => SessionFileLogger.logCdpCallEvent(info, logCtx);
|
|
565
|
+
this.ctx.conn.cdpEventLogger = (info) => SessionFileLogger.logCdpMessageEvent(info, logCtx);
|
|
566
|
+
this.ctx.conn.onTransportClosed(this._onCdpClosed);
|
|
567
|
+
this.state = {
|
|
568
|
+
kind: "LOCAL",
|
|
569
|
+
// no LaunchedChrome when attaching externally; create a stub kill
|
|
570
|
+
chrome: {
|
|
571
|
+
kill: async () => { },
|
|
572
|
+
},
|
|
573
|
+
ws: lbo.cdpUrl,
|
|
574
|
+
};
|
|
575
|
+
this.resetBrowserbaseSessionMetadata();
|
|
576
|
+
// Post-connect settings (downloads and viewport) if provided
|
|
577
|
+
await this._applyPostConnectLocalOptions(lbo);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
this.logger({
|
|
581
|
+
category: "init",
|
|
582
|
+
message: "Launching local browser",
|
|
583
|
+
level: 1,
|
|
584
|
+
});
|
|
585
|
+
// Determine or create user data dir
|
|
586
|
+
let userDataDir = lbo.userDataDir;
|
|
587
|
+
let createdTemp = false;
|
|
588
|
+
if (!userDataDir) {
|
|
589
|
+
const base = path.join(os.tmpdir(), "stagehand-v3");
|
|
590
|
+
fs.mkdirSync(base, { recursive: true });
|
|
591
|
+
userDataDir = fs.mkdtempSync(path.join(base, "profile-"));
|
|
592
|
+
createdTemp = true;
|
|
593
|
+
}
|
|
594
|
+
// Build chrome flags
|
|
595
|
+
const defaults = [
|
|
596
|
+
"--remote-allow-origins=*",
|
|
597
|
+
"--no-first-run",
|
|
598
|
+
"--no-default-browser-check",
|
|
599
|
+
"--disable-dev-shm-usage",
|
|
600
|
+
"--site-per-process",
|
|
601
|
+
];
|
|
602
|
+
let chromeFlags = [];
|
|
603
|
+
const ignore = lbo.ignoreDefaultArgs;
|
|
604
|
+
if (ignore === true) {
|
|
605
|
+
// drop defaults
|
|
606
|
+
chromeFlags = [];
|
|
607
|
+
}
|
|
608
|
+
else if (Array.isArray(ignore)) {
|
|
609
|
+
chromeFlags = defaults.filter((f) => !ignore.some((ex) => f.includes(ex)));
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
chromeFlags = [...defaults];
|
|
613
|
+
}
|
|
614
|
+
// headless handled by launchLocalChrome
|
|
615
|
+
if (lbo.devtools)
|
|
616
|
+
chromeFlags.push("--auto-open-devtools-for-tabs");
|
|
617
|
+
if (lbo.locale)
|
|
618
|
+
chromeFlags.push(`--lang=${lbo.locale}`);
|
|
619
|
+
if (!lbo.viewport) {
|
|
620
|
+
lbo.viewport = DEFAULT_VIEWPORT;
|
|
621
|
+
}
|
|
622
|
+
if (lbo.viewport?.width && lbo.viewport?.height) {
|
|
623
|
+
chromeFlags.push(`--window-size=${lbo.viewport.width},${lbo.viewport.height + 87}`);
|
|
624
|
+
}
|
|
625
|
+
if (typeof lbo.deviceScaleFactor === "number") {
|
|
626
|
+
chromeFlags.push(`--force-device-scale-factor=${Math.max(0.1, lbo.deviceScaleFactor)}`);
|
|
627
|
+
}
|
|
628
|
+
if (lbo.hasTouch)
|
|
629
|
+
chromeFlags.push("--touch-events=enabled");
|
|
630
|
+
if (lbo.ignoreHTTPSErrors)
|
|
631
|
+
chromeFlags.push("--ignore-certificate-errors");
|
|
632
|
+
if (lbo.proxy?.server)
|
|
633
|
+
chromeFlags.push(`--proxy-server=${lbo.proxy.server}`);
|
|
634
|
+
if (lbo.proxy?.bypass)
|
|
635
|
+
chromeFlags.push(`--proxy-bypass-list=${lbo.proxy.bypass}`);
|
|
636
|
+
// add user-supplied args last
|
|
637
|
+
if (Array.isArray(lbo.args))
|
|
638
|
+
chromeFlags.push(...lbo.args);
|
|
639
|
+
const keepAlive = this.keepAlive === true;
|
|
640
|
+
const { ws, chrome } = await launchLocalChrome({
|
|
641
|
+
chromePath: lbo.executablePath,
|
|
642
|
+
chromeFlags,
|
|
643
|
+
port: lbo.port,
|
|
644
|
+
headless: lbo.headless,
|
|
645
|
+
userDataDir,
|
|
646
|
+
connectTimeoutMs: lbo.connectTimeoutMs,
|
|
647
|
+
handleSIGINT: !keepAlive,
|
|
648
|
+
});
|
|
649
|
+
if (keepAlive) {
|
|
650
|
+
try {
|
|
651
|
+
chrome.process?.unref?.();
|
|
652
|
+
}
|
|
653
|
+
catch {
|
|
654
|
+
// best-effort: avoid keeping the event loop alive
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
this.ctx = await V3Context.create(ws, {
|
|
658
|
+
env: "LOCAL",
|
|
659
|
+
localBrowserLaunchOptions: lbo,
|
|
660
|
+
});
|
|
661
|
+
const logCtx = SessionFileLogger.getContext();
|
|
662
|
+
this.ctx.conn.cdpLogger = (info) => SessionFileLogger.logCdpCallEvent(info, logCtx);
|
|
663
|
+
this.ctx.conn.cdpEventLogger = (info) => SessionFileLogger.logCdpMessageEvent(info, logCtx);
|
|
664
|
+
this.ctx.conn.onTransportClosed(this._onCdpClosed);
|
|
665
|
+
this.state = {
|
|
666
|
+
kind: "LOCAL",
|
|
667
|
+
chrome,
|
|
668
|
+
ws,
|
|
669
|
+
userDataDir,
|
|
670
|
+
createdTempProfile: createdTemp,
|
|
671
|
+
preserveUserDataDir: !!lbo.preserveUserDataDir,
|
|
672
|
+
};
|
|
673
|
+
this.resetBrowserbaseSessionMetadata();
|
|
674
|
+
const chromePid = chrome.process?.pid ?? chrome.pid;
|
|
675
|
+
if (!keepAlive && chromePid) {
|
|
676
|
+
this.startShutdownSupervisor({
|
|
677
|
+
kind: "LOCAL",
|
|
678
|
+
pid: chromePid,
|
|
679
|
+
userDataDir,
|
|
680
|
+
createdTempProfile: createdTemp,
|
|
681
|
+
preserveUserDataDir: !!lbo.preserveUserDataDir,
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
// Post-connect settings (downloads and viewport) if provided
|
|
685
|
+
await this._applyPostConnectLocalOptions(lbo);
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
if (this.opts.env === "BROWSERBASE") {
|
|
689
|
+
const { apiKey, projectId } = this.requireBrowserbaseCreds();
|
|
690
|
+
if (!apiKey || !projectId) {
|
|
691
|
+
throw new MissingEnvironmentVariableError("BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID", "Browserbase environment");
|
|
692
|
+
}
|
|
693
|
+
this.logger({
|
|
694
|
+
category: "init",
|
|
695
|
+
message: "Starting browserbase session",
|
|
696
|
+
level: 1,
|
|
697
|
+
});
|
|
698
|
+
const baseSessionParams = this.opts.browserbaseSessionCreateParams ?? {};
|
|
699
|
+
const resolvedKeepAlive = this.keepAlive;
|
|
700
|
+
const keepAlive = this.keepAlive === true;
|
|
701
|
+
const effectiveSessionParams = resolvedKeepAlive !== undefined
|
|
702
|
+
? { ...baseSessionParams, keepAlive: resolvedKeepAlive }
|
|
703
|
+
: baseSessionParams;
|
|
704
|
+
if (!this.disableAPI && !this.experimental) {
|
|
705
|
+
this.apiClient = new StagehandAPIClient({
|
|
706
|
+
apiKey,
|
|
707
|
+
projectId,
|
|
708
|
+
logger: this.logger,
|
|
709
|
+
});
|
|
710
|
+
const createSessionPayload = {
|
|
711
|
+
projectId: effectiveSessionParams.projectId ?? projectId,
|
|
712
|
+
...effectiveSessionParams,
|
|
713
|
+
browserSettings: {
|
|
714
|
+
...(effectiveSessionParams.browserSettings ?? {}),
|
|
715
|
+
viewport: effectiveSessionParams.browserSettings?.viewport ?? {
|
|
716
|
+
width: 1288,
|
|
717
|
+
height: 711,
|
|
718
|
+
},
|
|
719
|
+
},
|
|
720
|
+
userMetadata: {
|
|
721
|
+
...(effectiveSessionParams.userMetadata ?? {}),
|
|
722
|
+
stagehand: "true",
|
|
723
|
+
},
|
|
724
|
+
};
|
|
725
|
+
const { sessionId, available } = await this.apiClient.init({
|
|
726
|
+
modelName: this.modelName,
|
|
727
|
+
modelApiKey: this.modelClientOptions.apiKey,
|
|
728
|
+
domSettleTimeoutMs: this.domSettleTimeoutMs,
|
|
729
|
+
verbose: this.verbose,
|
|
730
|
+
systemPrompt: this.opts.systemPrompt,
|
|
731
|
+
selfHeal: this.opts.selfHeal,
|
|
732
|
+
browserbaseSessionCreateParams: createSessionPayload,
|
|
733
|
+
browserbaseSessionID: this.opts.browserbaseSessionID,
|
|
734
|
+
});
|
|
735
|
+
if (!available) {
|
|
736
|
+
this.apiClient = null;
|
|
737
|
+
}
|
|
738
|
+
this.opts.browserbaseSessionID = sessionId;
|
|
739
|
+
}
|
|
740
|
+
const { ws, sessionId, bb } = await createBrowserbaseSession(apiKey, projectId, effectiveSessionParams, this.opts.browserbaseSessionID);
|
|
741
|
+
this.ctx = await V3Context.create(ws, {
|
|
742
|
+
env: "BROWSERBASE",
|
|
743
|
+
apiClient: this.apiClient,
|
|
744
|
+
});
|
|
745
|
+
const logCtx = SessionFileLogger.getContext();
|
|
746
|
+
this.ctx.conn.cdpLogger = (info) => SessionFileLogger.logCdpCallEvent(info, logCtx);
|
|
747
|
+
this.ctx.conn.cdpEventLogger = (info) => SessionFileLogger.logCdpMessageEvent(info, logCtx);
|
|
748
|
+
this.ctx.conn.onTransportClosed(this._onCdpClosed);
|
|
749
|
+
this.state = { kind: "BROWSERBASE", sessionId, ws, bb };
|
|
750
|
+
this.browserbaseSessionId = sessionId;
|
|
751
|
+
if (!keepAlive && !this.disableAPI) {
|
|
752
|
+
this.startShutdownSupervisor({
|
|
753
|
+
kind: "STAGEHAND_API",
|
|
754
|
+
sessionId,
|
|
755
|
+
apiKey,
|
|
756
|
+
projectId,
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
await this._ensureBrowserbaseDownloadsEnabled();
|
|
760
|
+
const resumed = !!this.opts.browserbaseSessionID;
|
|
761
|
+
let debugUrl;
|
|
762
|
+
try {
|
|
763
|
+
const dbg = (await bb.sessions.debug(sessionId));
|
|
764
|
+
debugUrl = dbg?.debuggerUrl;
|
|
765
|
+
}
|
|
766
|
+
catch {
|
|
767
|
+
// Ignore debug fetch failures; continue with sessionUrl only
|
|
768
|
+
}
|
|
769
|
+
const sessionUrl = `https://www.browserbase.com/sessions/${sessionId}`;
|
|
770
|
+
this.browserbaseSessionUrl = sessionUrl;
|
|
771
|
+
this.browserbaseDebugUrl = debugUrl;
|
|
772
|
+
try {
|
|
773
|
+
this.logger({
|
|
774
|
+
category: "init",
|
|
775
|
+
message: resumed
|
|
776
|
+
? this.apiClient
|
|
777
|
+
? "Browserbase session started"
|
|
778
|
+
: "Browserbase session resumed"
|
|
779
|
+
: "Browserbase session started",
|
|
780
|
+
level: 1,
|
|
781
|
+
auxiliary: {
|
|
782
|
+
sessionUrl: { value: sessionUrl, type: "string" },
|
|
783
|
+
...(debugUrl && {
|
|
784
|
+
debugUrl: { value: debugUrl, type: "string" },
|
|
785
|
+
}),
|
|
786
|
+
sessionId: { value: sessionId, type: "string" },
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
catch {
|
|
791
|
+
// best-effort logging — ignore failures
|
|
792
|
+
}
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
const neverEnv = this.opts.env;
|
|
796
|
+
throw new StagehandInitError(`Unsupported env: ${neverEnv}`);
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
catch (error) {
|
|
800
|
+
// Cleanup instanceLoggers map on init failure to prevent memory leak
|
|
801
|
+
if (this.externalLogger) {
|
|
802
|
+
try {
|
|
803
|
+
unbindInstanceLogger(this.instanceId);
|
|
804
|
+
}
|
|
805
|
+
catch {
|
|
806
|
+
// ignore cleanup errors
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
throw error;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
/** Apply post-connect local browser options that require CDP. */
|
|
813
|
+
async _applyPostConnectLocalOptions(lbo) {
|
|
814
|
+
try {
|
|
815
|
+
// Downloads behavior
|
|
816
|
+
if (lbo.downloadsPath || lbo.acceptDownloads !== undefined) {
|
|
817
|
+
const behavior = lbo.acceptDownloads === false ? "deny" : "allow";
|
|
818
|
+
await this.ctx?.conn
|
|
819
|
+
.send("Browser.setDownloadBehavior", {
|
|
820
|
+
behavior,
|
|
821
|
+
downloadPath: lbo.downloadsPath,
|
|
822
|
+
eventsEnabled: true,
|
|
823
|
+
})
|
|
824
|
+
.catch(() => { });
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
catch {
|
|
828
|
+
// best-effort only
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
async _ensureBrowserbaseDownloadsEnabled() {
|
|
832
|
+
const conn = this.ctx?.conn;
|
|
833
|
+
if (!conn)
|
|
834
|
+
return;
|
|
835
|
+
try {
|
|
836
|
+
await conn.send("Browser.setDownloadBehavior", {
|
|
837
|
+
behavior: "allow",
|
|
838
|
+
downloadPath: "downloads",
|
|
839
|
+
eventsEnabled: true,
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
catch {
|
|
843
|
+
// best-effort only
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
resetBrowserbaseSessionMetadata() {
|
|
847
|
+
this.browserbaseSessionId = undefined;
|
|
848
|
+
this.browserbaseSessionUrl = undefined;
|
|
849
|
+
this.browserbaseDebugUrl = undefined;
|
|
850
|
+
}
|
|
851
|
+
async act(input, options) {
|
|
852
|
+
return await withInstanceLogContext(this.instanceId, async () => {
|
|
853
|
+
if (!this.actHandler)
|
|
854
|
+
throw new StagehandNotInitializedError("act()");
|
|
855
|
+
let actResult;
|
|
856
|
+
if (isObserveResult(input)) {
|
|
857
|
+
// Resolve page: use provided page if any, otherwise default active page
|
|
858
|
+
const v3Page = await this.resolvePage(options?.page);
|
|
859
|
+
// Use selector as provided to support XPath, CSS, and other engines
|
|
860
|
+
const selector = input.selector;
|
|
861
|
+
if (this.apiClient) {
|
|
862
|
+
actResult = await this.apiClient.act({
|
|
863
|
+
input,
|
|
864
|
+
options,
|
|
865
|
+
frameId: v3Page.mainFrameId(),
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
else {
|
|
869
|
+
const effectiveTimeoutMs = typeof options?.timeout === "number" && options.timeout > 0
|
|
870
|
+
? options.timeout
|
|
871
|
+
: undefined;
|
|
872
|
+
const ensureTimeRemaining = createTimeoutGuard(effectiveTimeoutMs, (ms) => new ActTimeoutError(ms));
|
|
873
|
+
actResult = await this.actHandler.takeDeterministicAction({ ...input, selector }, v3Page, this.domSettleTimeoutMs, this.resolveLlmClient(options?.model), ensureTimeRemaining, options?.variables);
|
|
874
|
+
}
|
|
875
|
+
// history: record ObserveResult-based act call
|
|
876
|
+
this.addToHistory("act", {
|
|
877
|
+
observeResult: input,
|
|
878
|
+
}, actResult);
|
|
879
|
+
return actResult;
|
|
880
|
+
}
|
|
881
|
+
// instruction path
|
|
882
|
+
if (typeof input !== "string" || !input.trim()) {
|
|
883
|
+
throw new StagehandInvalidArgumentError("act(): instruction string is required unless passing an Action");
|
|
884
|
+
}
|
|
885
|
+
// Resolve page from options or default
|
|
886
|
+
const page = await this.resolvePage(options?.page);
|
|
887
|
+
const actCacheLlmClient = options?.model
|
|
888
|
+
? this.resolveLlmClient(options.model)
|
|
889
|
+
: undefined;
|
|
890
|
+
let actCacheContext = null;
|
|
891
|
+
const canUseCache = typeof input === "string" &&
|
|
892
|
+
!this.isAgentReplayRecording() &&
|
|
893
|
+
this.actCache.enabled;
|
|
894
|
+
if (canUseCache) {
|
|
895
|
+
actCacheContext = await this.actCache.prepareContext(input, page, options?.variables);
|
|
896
|
+
if (actCacheContext) {
|
|
897
|
+
const cachedResult = await this.actCache.tryReplay(actCacheContext, page, options?.timeout, actCacheLlmClient);
|
|
898
|
+
if (cachedResult) {
|
|
899
|
+
this.addToHistory("act", {
|
|
900
|
+
instruction: input,
|
|
901
|
+
variables: options?.variables,
|
|
902
|
+
timeout: options?.timeout,
|
|
903
|
+
cacheHit: true,
|
|
904
|
+
}, cachedResult);
|
|
905
|
+
return cachedResult;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
const handlerParams = {
|
|
910
|
+
instruction: input,
|
|
911
|
+
page,
|
|
912
|
+
variables: options?.variables,
|
|
913
|
+
timeout: options?.timeout,
|
|
914
|
+
model: options?.model,
|
|
915
|
+
};
|
|
916
|
+
if (this.apiClient) {
|
|
917
|
+
const frameId = page.mainFrameId();
|
|
918
|
+
actResult = await this.apiClient.act({ input, options, frameId });
|
|
919
|
+
}
|
|
920
|
+
else {
|
|
921
|
+
actResult = await this.actHandler.act(handlerParams);
|
|
922
|
+
}
|
|
923
|
+
// history: record instruction-based act call (omit page object)
|
|
924
|
+
this.addToHistory("act", {
|
|
925
|
+
instruction: input,
|
|
926
|
+
variables: options?.variables,
|
|
927
|
+
timeout: options?.timeout,
|
|
928
|
+
}, actResult);
|
|
929
|
+
if (actCacheContext &&
|
|
930
|
+
actResult.success &&
|
|
931
|
+
Array.isArray(actResult.actions) &&
|
|
932
|
+
actResult.actions.length > 0) {
|
|
933
|
+
await this.actCache.store(actCacheContext, actResult);
|
|
934
|
+
}
|
|
935
|
+
return actResult;
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
async extract(a, b, c) {
|
|
939
|
+
return await withInstanceLogContext(this.instanceId, async () => {
|
|
940
|
+
if (!this.extractHandler) {
|
|
941
|
+
throw new StagehandNotInitializedError("extract()");
|
|
942
|
+
}
|
|
943
|
+
// Normalize args
|
|
944
|
+
let instruction;
|
|
945
|
+
let schema;
|
|
946
|
+
let options;
|
|
947
|
+
if (typeof a === "string") {
|
|
948
|
+
instruction = a;
|
|
949
|
+
const isZodSchema = (val) => !!val &&
|
|
950
|
+
typeof val === "object" &&
|
|
951
|
+
"parse" in val &&
|
|
952
|
+
"safeParse" in val;
|
|
953
|
+
if (isZodSchema(b)) {
|
|
954
|
+
schema = b;
|
|
955
|
+
options = c;
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
options = b;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
// a is options or undefined
|
|
963
|
+
options = a || undefined;
|
|
964
|
+
}
|
|
965
|
+
if (!instruction && schema) {
|
|
966
|
+
throw new StagehandInvalidArgumentError("extract(): schema provided without instruction");
|
|
967
|
+
}
|
|
968
|
+
// If instruction without schema → defaultExtractSchema
|
|
969
|
+
const effectiveSchema = instruction && !schema ? defaultExtractSchema : schema;
|
|
970
|
+
// Resolve page from options or use active page
|
|
971
|
+
const page = await this.resolvePage(options?.page);
|
|
972
|
+
const handlerParams = {
|
|
973
|
+
instruction,
|
|
974
|
+
schema: effectiveSchema,
|
|
975
|
+
model: options?.model,
|
|
976
|
+
timeout: options?.timeout,
|
|
977
|
+
selector: options?.selector,
|
|
978
|
+
page,
|
|
979
|
+
};
|
|
980
|
+
let result;
|
|
981
|
+
if (this.apiClient) {
|
|
982
|
+
const frameId = page.mainFrameId();
|
|
983
|
+
result = await this.apiClient.extract({
|
|
984
|
+
instruction: handlerParams.instruction,
|
|
985
|
+
schema: handlerParams.schema,
|
|
986
|
+
options,
|
|
987
|
+
frameId,
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
991
|
+
result =
|
|
992
|
+
await this.extractHandler.extract(handlerParams);
|
|
993
|
+
}
|
|
994
|
+
const historySchemaDescriptor = effectiveSchema
|
|
995
|
+
? toJsonSchema(effectiveSchema)
|
|
996
|
+
: undefined;
|
|
997
|
+
this.addToHistory("extract", {
|
|
998
|
+
instruction,
|
|
999
|
+
selector: options?.selector,
|
|
1000
|
+
timeout: options?.timeout,
|
|
1001
|
+
schema: historySchemaDescriptor,
|
|
1002
|
+
}, result);
|
|
1003
|
+
return result;
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
async observe(a, b) {
|
|
1007
|
+
return await withInstanceLogContext(this.instanceId, async () => {
|
|
1008
|
+
if (!this.observeHandler) {
|
|
1009
|
+
throw new StagehandNotInitializedError("observe()");
|
|
1010
|
+
}
|
|
1011
|
+
// Normalize args
|
|
1012
|
+
let instruction;
|
|
1013
|
+
let options;
|
|
1014
|
+
if (typeof a === "string") {
|
|
1015
|
+
instruction = a;
|
|
1016
|
+
options = b;
|
|
1017
|
+
}
|
|
1018
|
+
else {
|
|
1019
|
+
options = a;
|
|
1020
|
+
}
|
|
1021
|
+
// Resolve to our internal Page type
|
|
1022
|
+
const page = await this.resolvePage(options?.page);
|
|
1023
|
+
const handlerParams = {
|
|
1024
|
+
instruction,
|
|
1025
|
+
model: options?.model,
|
|
1026
|
+
timeout: options?.timeout,
|
|
1027
|
+
selector: options?.selector,
|
|
1028
|
+
page: page,
|
|
1029
|
+
};
|
|
1030
|
+
let results;
|
|
1031
|
+
if (this.apiClient) {
|
|
1032
|
+
const frameId = page.mainFrameId();
|
|
1033
|
+
results = await this.apiClient.observe({
|
|
1034
|
+
instruction,
|
|
1035
|
+
options,
|
|
1036
|
+
frameId,
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
else {
|
|
1040
|
+
results = await this.observeHandler.observe(handlerParams);
|
|
1041
|
+
}
|
|
1042
|
+
// history: record observe call (omit page object)
|
|
1043
|
+
this.addToHistory("observe", {
|
|
1044
|
+
instruction,
|
|
1045
|
+
timeout: options?.timeout,
|
|
1046
|
+
}, results);
|
|
1047
|
+
return results;
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
/** Return the browser-level CDP WebSocket endpoint. */
|
|
1051
|
+
connectURL() {
|
|
1052
|
+
if (this.state.kind === "UNINITIALIZED") {
|
|
1053
|
+
throw new StagehandNotInitializedError("connectURL()");
|
|
1054
|
+
}
|
|
1055
|
+
return this.state.ws;
|
|
1056
|
+
}
|
|
1057
|
+
/** Expose the current CDP-backed context. */
|
|
1058
|
+
get context() {
|
|
1059
|
+
return this.ctx;
|
|
1060
|
+
}
|
|
1061
|
+
/** Best-effort cleanup of context and launched resources. */
|
|
1062
|
+
async close(opts) {
|
|
1063
|
+
// If we're already closing and this isn't a forced close, no-op.
|
|
1064
|
+
if (this._isClosing && !opts?.force)
|
|
1065
|
+
return;
|
|
1066
|
+
this._isClosing = true;
|
|
1067
|
+
const keepAlive = this.keepAlive === true;
|
|
1068
|
+
// End Browserbase session via API when keepAlive is not enabled
|
|
1069
|
+
if (!keepAlive && this.apiClient) {
|
|
1070
|
+
try {
|
|
1071
|
+
await this.apiClient.end();
|
|
1072
|
+
}
|
|
1073
|
+
catch {
|
|
1074
|
+
// best-effort cleanup
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
try {
|
|
1078
|
+
// Close session file logger
|
|
1079
|
+
try {
|
|
1080
|
+
await SessionFileLogger.close();
|
|
1081
|
+
}
|
|
1082
|
+
catch {
|
|
1083
|
+
// ignore
|
|
1084
|
+
}
|
|
1085
|
+
// Unhook CDP transport close handler
|
|
1086
|
+
try {
|
|
1087
|
+
if (this.ctx?.conn && this._onCdpClosed) {
|
|
1088
|
+
this.ctx.conn.offTransportClosed?.(this._onCdpClosed);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
catch {
|
|
1092
|
+
// ignore
|
|
1093
|
+
}
|
|
1094
|
+
// Close CDP context
|
|
1095
|
+
try {
|
|
1096
|
+
await this.ctx?.close();
|
|
1097
|
+
}
|
|
1098
|
+
catch {
|
|
1099
|
+
// ignore
|
|
1100
|
+
}
|
|
1101
|
+
// Kill local Chrome and clean up temp profile when keepAlive is not enabled
|
|
1102
|
+
if (!keepAlive && this.state.kind === "LOCAL") {
|
|
1103
|
+
const localState = this.state;
|
|
1104
|
+
await cleanupLocalBrowser({
|
|
1105
|
+
killChrome: () => localState.chrome.kill(),
|
|
1106
|
+
userDataDir: localState.userDataDir,
|
|
1107
|
+
createdTempProfile: localState.createdTempProfile,
|
|
1108
|
+
preserveUserDataDir: localState.preserveUserDataDir,
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
finally {
|
|
1113
|
+
this.stopShutdownSupervisor();
|
|
1114
|
+
// Reset internal state
|
|
1115
|
+
this.state = { kind: "UNINITIALIZED" };
|
|
1116
|
+
this.ctx = null;
|
|
1117
|
+
this._isClosing = false;
|
|
1118
|
+
this.resetBrowserbaseSessionMetadata();
|
|
1119
|
+
try {
|
|
1120
|
+
unbindInstanceLogger(this.instanceId);
|
|
1121
|
+
}
|
|
1122
|
+
catch {
|
|
1123
|
+
// ignore
|
|
1124
|
+
}
|
|
1125
|
+
try {
|
|
1126
|
+
this.bus.removeAllListeners();
|
|
1127
|
+
}
|
|
1128
|
+
catch {
|
|
1129
|
+
// ignore
|
|
1130
|
+
}
|
|
1131
|
+
this._history = [];
|
|
1132
|
+
this.actHandler = null;
|
|
1133
|
+
this.extractHandler = null;
|
|
1134
|
+
this.observeHandler = null;
|
|
1135
|
+
V3._instances.delete(this);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
/** Guard: ensure Browserbase credentials exist in options. */
|
|
1139
|
+
requireBrowserbaseCreds() {
|
|
1140
|
+
let { apiKey, projectId } = this.opts;
|
|
1141
|
+
// Fall back to environment variables if not explicitly provided
|
|
1142
|
+
if (!apiKey)
|
|
1143
|
+
apiKey = process.env.BROWSERBASE_API_KEY ?? process.env.BB_API_KEY;
|
|
1144
|
+
if (!projectId)
|
|
1145
|
+
projectId =
|
|
1146
|
+
process.env.BROWSERBASE_PROJECT_ID ?? process.env.BB_PROJECT_ID;
|
|
1147
|
+
if (!apiKey || !projectId) {
|
|
1148
|
+
const missing = [];
|
|
1149
|
+
if (!apiKey)
|
|
1150
|
+
missing.push("BROWSERBASE_API_KEY");
|
|
1151
|
+
if (!projectId)
|
|
1152
|
+
missing.push("BROWSERBASE_PROJECT_ID");
|
|
1153
|
+
throw new MissingEnvironmentVariableError(missing.join(", "), "Browserbase");
|
|
1154
|
+
}
|
|
1155
|
+
// Cache resolved values back into opts for consistency
|
|
1156
|
+
this.opts.apiKey = apiKey;
|
|
1157
|
+
this.opts.projectId = projectId;
|
|
1158
|
+
// Informational log
|
|
1159
|
+
this.logger({
|
|
1160
|
+
category: "init",
|
|
1161
|
+
message: "Using Browserbase credentials",
|
|
1162
|
+
level: 1,
|
|
1163
|
+
});
|
|
1164
|
+
return { apiKey, projectId };
|
|
1165
|
+
}
|
|
1166
|
+
get logger() {
|
|
1167
|
+
// Delegate to per-instance StagehandLogger
|
|
1168
|
+
// StagehandLogger handles: verbosity filtering, usePino selection, external logger routing
|
|
1169
|
+
// This provides per-instance configuration while maintaining shared Pino optimization
|
|
1170
|
+
return (logLine) => {
|
|
1171
|
+
const line = { ...logLine, level: logLine.level ?? 1 };
|
|
1172
|
+
this.stagehandLogger.log(line);
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Normalize a Playwright/Puppeteer page object into its top frame id,
|
|
1177
|
+
* so handlers can resolve it to a `Page` within our V3Context.
|
|
1178
|
+
*/
|
|
1179
|
+
async resolveTopFrameId(page) {
|
|
1180
|
+
if (this.isPlaywrightPage(page)) {
|
|
1181
|
+
const cdp = await page.context().newCDPSession(page);
|
|
1182
|
+
const { frameTree } = await cdp.send("Page.getFrameTree");
|
|
1183
|
+
return frameTree.frame.id;
|
|
1184
|
+
}
|
|
1185
|
+
if (this.isPatchrightPage(page)) {
|
|
1186
|
+
const cdp = await page.context().newCDPSession(page);
|
|
1187
|
+
const { frameTree } = await cdp.send("Page.getFrameTree");
|
|
1188
|
+
return frameTree.frame.id;
|
|
1189
|
+
}
|
|
1190
|
+
if (this.isPuppeteerPage(page)) {
|
|
1191
|
+
const cdp = await page.createCDPSession();
|
|
1192
|
+
const { frameTree } = await cdp.send("Page.getFrameTree");
|
|
1193
|
+
this.logger({
|
|
1194
|
+
category: "v3",
|
|
1195
|
+
message: "Puppeteer frame id",
|
|
1196
|
+
level: 2,
|
|
1197
|
+
auxiliary: { frameId: { value: frameTree.frame.id, type: "string" } },
|
|
1198
|
+
});
|
|
1199
|
+
return frameTree.frame.id;
|
|
1200
|
+
}
|
|
1201
|
+
throw new StagehandInvalidArgumentError("Unsupported page object passed to V3.act()");
|
|
1202
|
+
}
|
|
1203
|
+
isPlaywrightPage(p) {
|
|
1204
|
+
return (typeof p === "object" &&
|
|
1205
|
+
p !== null &&
|
|
1206
|
+
typeof p.context === "function");
|
|
1207
|
+
}
|
|
1208
|
+
isPatchrightPage(p) {
|
|
1209
|
+
return (typeof p === "object" &&
|
|
1210
|
+
p !== null &&
|
|
1211
|
+
typeof p.context === "function");
|
|
1212
|
+
}
|
|
1213
|
+
isPuppeteerPage(p) {
|
|
1214
|
+
return (typeof p === "object" &&
|
|
1215
|
+
p !== null &&
|
|
1216
|
+
typeof p.target === "function");
|
|
1217
|
+
}
|
|
1218
|
+
/** Resolve an external page reference or fall back to the active V3 page. */
|
|
1219
|
+
async resolvePage(page) {
|
|
1220
|
+
if (page) {
|
|
1221
|
+
return await this.normalizeToV3Page(page);
|
|
1222
|
+
}
|
|
1223
|
+
const ctx = this.ctx;
|
|
1224
|
+
if (!ctx) {
|
|
1225
|
+
throw new StagehandNotInitializedError("resolvePage()");
|
|
1226
|
+
}
|
|
1227
|
+
return await ctx.awaitActivePage();
|
|
1228
|
+
}
|
|
1229
|
+
async normalizeToV3Page(input) {
|
|
1230
|
+
if (input instanceof (await import("./understudy/page.js")).Page) {
|
|
1231
|
+
return input;
|
|
1232
|
+
}
|
|
1233
|
+
if (this.isPlaywrightPage(input)) {
|
|
1234
|
+
const frameId = await this.resolveTopFrameId(input);
|
|
1235
|
+
const page = this.ctx.resolvePageByMainFrameId(frameId);
|
|
1236
|
+
if (!page)
|
|
1237
|
+
throw new StagehandInitError("Failed to resolve V3 Page from Playwright page.");
|
|
1238
|
+
return page;
|
|
1239
|
+
}
|
|
1240
|
+
if (this.isPatchrightPage(input)) {
|
|
1241
|
+
const frameId = await this.resolveTopFrameId(input);
|
|
1242
|
+
const page = this.ctx.resolvePageByMainFrameId(frameId);
|
|
1243
|
+
if (!page)
|
|
1244
|
+
throw new StagehandInitError("Failed to resolve V3 Page from Patchright page.");
|
|
1245
|
+
return page;
|
|
1246
|
+
}
|
|
1247
|
+
if (this.isPuppeteerPage(input)) {
|
|
1248
|
+
const frameId = await this.resolveTopFrameId(input);
|
|
1249
|
+
const page = this.ctx.resolvePageByMainFrameId(frameId);
|
|
1250
|
+
if (!page)
|
|
1251
|
+
throw new StagehandInitError("Failed to resolve V3 Page from Puppeteer page.");
|
|
1252
|
+
return page;
|
|
1253
|
+
}
|
|
1254
|
+
throw new StagehandInvalidArgumentError("Unsupported page object.");
|
|
1255
|
+
}
|
|
1256
|
+
async _logBrowserbaseSessionStatus() {
|
|
1257
|
+
if (this.state.kind !== "BROWSERBASE") {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
try {
|
|
1261
|
+
const snapshot = (await this.state.bb.sessions.retrieve(this.state.sessionId));
|
|
1262
|
+
if (!snapshot?.status)
|
|
1263
|
+
return;
|
|
1264
|
+
const sessionId = snapshot.id ?? this.state.sessionId;
|
|
1265
|
+
const message = snapshot.status === "TIMED_OUT"
|
|
1266
|
+
? `Browserbase session timed out (sessionId: ${sessionId})`
|
|
1267
|
+
: `Browserbase session status: ${snapshot.status}`;
|
|
1268
|
+
this.logger({
|
|
1269
|
+
category: "v3",
|
|
1270
|
+
message,
|
|
1271
|
+
level: 0,
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
catch {
|
|
1275
|
+
// Ignore failures; nothing to log
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Prepares shared context for agent execution (both execute and stream).
|
|
1280
|
+
* Extracts duplicated setup logic into a single helper.
|
|
1281
|
+
*/
|
|
1282
|
+
async prepareAgentExecution(options, instructionOrOptions, agentConfigSignature) {
|
|
1283
|
+
// Note: experimental validation is done at the call site before this method
|
|
1284
|
+
// Warn if mode is not explicitly set (defaults to "dom")
|
|
1285
|
+
if (options?.mode === undefined) {
|
|
1286
|
+
this.logger({
|
|
1287
|
+
category: "agent",
|
|
1288
|
+
message: "Using agent in default DOM mode (legacy). Agent will default to 'hybrid' on an upcoming release for improved performance.\n → https://docs.stagehand.dev/v3/basics/agent\n",
|
|
1289
|
+
level: 0,
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
const tools = options?.integrations
|
|
1293
|
+
? await resolveTools(options.integrations, options.tools)
|
|
1294
|
+
: (options?.tools ?? {});
|
|
1295
|
+
const agentLlmClient = options?.model
|
|
1296
|
+
? this.resolveLlmClient(options.model)
|
|
1297
|
+
: this.llmClient;
|
|
1298
|
+
const handler = new V3AgentHandler(this, this.logger, agentLlmClient, typeof options?.executionModel === "string"
|
|
1299
|
+
? options.executionModel
|
|
1300
|
+
: options?.executionModel?.modelName, options?.systemPrompt, tools, options?.mode);
|
|
1301
|
+
const resolvedOptions = typeof instructionOrOptions === "string"
|
|
1302
|
+
? { instruction: instructionOrOptions }
|
|
1303
|
+
: instructionOrOptions;
|
|
1304
|
+
const callbacksWithSafety = resolvedOptions.callbacks;
|
|
1305
|
+
if (callbacksWithSafety?.onSafetyConfirmation) {
|
|
1306
|
+
throw new StagehandInvalidArgumentError('onSafetyConfirmation callback is only supported when using mode: "cua" agents.');
|
|
1307
|
+
}
|
|
1308
|
+
if (resolvedOptions.page) {
|
|
1309
|
+
const normalizedPage = await this.normalizeToV3Page(resolvedOptions.page);
|
|
1310
|
+
this.ctx.setActivePage(normalizedPage);
|
|
1311
|
+
}
|
|
1312
|
+
const instruction = resolvedOptions.instruction.trim();
|
|
1313
|
+
const sanitizedOptions = this.agentCache.sanitizeExecuteOptions(resolvedOptions);
|
|
1314
|
+
const cacheContext = this.agentCache.shouldAttemptCache(instruction)
|
|
1315
|
+
? await this.agentCache.prepareContext({
|
|
1316
|
+
instruction,
|
|
1317
|
+
options: sanitizedOptions,
|
|
1318
|
+
configSignature: agentConfigSignature,
|
|
1319
|
+
page: await this.ctx.awaitActivePage(),
|
|
1320
|
+
})
|
|
1321
|
+
: null;
|
|
1322
|
+
return {
|
|
1323
|
+
handler,
|
|
1324
|
+
resolvedOptions,
|
|
1325
|
+
instruction,
|
|
1326
|
+
cacheContext,
|
|
1327
|
+
llmClient: agentLlmClient,
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
agent(options) {
|
|
1331
|
+
// Determine if CUA mode is enabled (via mode: "cua" or deprecated cua: true)
|
|
1332
|
+
const isCuaMode = options?.mode !== undefined
|
|
1333
|
+
? options.mode === "cua"
|
|
1334
|
+
: options?.cua === true;
|
|
1335
|
+
// Emit deprecation warning for cua: true
|
|
1336
|
+
if (options?.cua === true) {
|
|
1337
|
+
this.logger({
|
|
1338
|
+
category: "agent",
|
|
1339
|
+
message: '[DEPRECATED] The "cua: true" option is deprecated. Use "mode: \'cua\'" instead. This option will be removed in a future version.',
|
|
1340
|
+
level: 0,
|
|
1341
|
+
});
|
|
1342
|
+
console.warn('[Stagehand] DEPRECATED: The "cua: true" option is deprecated. Use "mode: \'cua\'" instead.');
|
|
1343
|
+
}
|
|
1344
|
+
this.logger({
|
|
1345
|
+
category: "agent",
|
|
1346
|
+
message: "Creating v3 agent instance",
|
|
1347
|
+
level: 1,
|
|
1348
|
+
auxiliary: {
|
|
1349
|
+
cua: { value: isCuaMode ? "true" : "false", type: "boolean" },
|
|
1350
|
+
mode: { value: options?.mode ?? "dom", type: "string" },
|
|
1351
|
+
model: options?.model
|
|
1352
|
+
? typeof options?.model === "string"
|
|
1353
|
+
? { value: options.model, type: "string" }
|
|
1354
|
+
: { value: options.model.modelName, type: "string" }
|
|
1355
|
+
: { value: this.llmClient.modelName, type: "string" },
|
|
1356
|
+
systemPrompt: { value: options?.systemPrompt ?? "", type: "string" },
|
|
1357
|
+
tools: { value: JSON.stringify(options?.tools ?? {}), type: "object" },
|
|
1358
|
+
...(options?.integrations && {
|
|
1359
|
+
integrations: {
|
|
1360
|
+
value: JSON.stringify(options.integrations),
|
|
1361
|
+
type: "object",
|
|
1362
|
+
},
|
|
1363
|
+
}),
|
|
1364
|
+
},
|
|
1365
|
+
});
|
|
1366
|
+
// If CUA mode is enabled (via mode: "cua" or deprecated cua: true), use the computer-use agent path
|
|
1367
|
+
if (isCuaMode) {
|
|
1368
|
+
// Validate agent config at creation time (includes CUA+streaming conflict check)
|
|
1369
|
+
validateExperimentalFeatures({
|
|
1370
|
+
isExperimental: this.experimental,
|
|
1371
|
+
agentConfig: options,
|
|
1372
|
+
});
|
|
1373
|
+
const modelToUse = options?.model || {
|
|
1374
|
+
modelName: this.modelName,
|
|
1375
|
+
...this.modelClientOptions,
|
|
1376
|
+
};
|
|
1377
|
+
const { modelName, isCua, clientOptions } = resolveModel(modelToUse);
|
|
1378
|
+
if (!isCua) {
|
|
1379
|
+
throw new CuaModelRequiredError(AVAILABLE_CUA_MODELS);
|
|
1380
|
+
}
|
|
1381
|
+
const agentConfigSignature = this.agentCache.buildConfigSignature(options);
|
|
1382
|
+
return {
|
|
1383
|
+
execute: async (instructionOrOptions) => withInstanceLogContext(this.instanceId, async () => {
|
|
1384
|
+
validateExperimentalFeatures({
|
|
1385
|
+
isExperimental: this.experimental,
|
|
1386
|
+
agentConfig: options,
|
|
1387
|
+
executeOptions: typeof instructionOrOptions === "object"
|
|
1388
|
+
? instructionOrOptions
|
|
1389
|
+
: null,
|
|
1390
|
+
});
|
|
1391
|
+
SessionFileLogger.logAgentTaskStarted({
|
|
1392
|
+
invocation: "Agent.execute",
|
|
1393
|
+
args: [instructionOrOptions],
|
|
1394
|
+
});
|
|
1395
|
+
const tools = options?.integrations
|
|
1396
|
+
? await resolveTools(options.integrations, options.tools)
|
|
1397
|
+
: (options?.tools ?? {});
|
|
1398
|
+
const handler = new V3CuaAgentHandler(this, this.logger, {
|
|
1399
|
+
modelName,
|
|
1400
|
+
clientOptions,
|
|
1401
|
+
userProvidedInstructions: options.systemPrompt ??
|
|
1402
|
+
`You are a helpful assistant that can use a web browser.\nDo not ask follow up questions, the user will trust your judgement.`,
|
|
1403
|
+
}, tools);
|
|
1404
|
+
const resolvedOptions = typeof instructionOrOptions === "string"
|
|
1405
|
+
? { instruction: instructionOrOptions }
|
|
1406
|
+
: instructionOrOptions;
|
|
1407
|
+
if (resolvedOptions.page) {
|
|
1408
|
+
const normalizedPage = await this.normalizeToV3Page(resolvedOptions.page);
|
|
1409
|
+
this.ctx.setActivePage(normalizedPage);
|
|
1410
|
+
}
|
|
1411
|
+
const instruction = resolvedOptions.instruction.trim();
|
|
1412
|
+
const sanitizedOptions = this.agentCache.sanitizeExecuteOptions(resolvedOptions);
|
|
1413
|
+
let cacheContext = null;
|
|
1414
|
+
if (this.agentCache.shouldAttemptCache(instruction)) {
|
|
1415
|
+
const startPage = await this.ctx.awaitActivePage();
|
|
1416
|
+
cacheContext = await this.agentCache.prepareContext({
|
|
1417
|
+
instruction,
|
|
1418
|
+
options: sanitizedOptions,
|
|
1419
|
+
configSignature: agentConfigSignature,
|
|
1420
|
+
page: startPage,
|
|
1421
|
+
});
|
|
1422
|
+
if (cacheContext) {
|
|
1423
|
+
const replayed = await this.agentCache.tryReplay(cacheContext);
|
|
1424
|
+
if (replayed) {
|
|
1425
|
+
SessionFileLogger.logAgentTaskCompleted({ cacheHit: true });
|
|
1426
|
+
return replayed;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
let agentSteps = [];
|
|
1431
|
+
const shouldRecordLocally = !!cacheContext && (!this.apiClient || this.experimental);
|
|
1432
|
+
if (shouldRecordLocally) {
|
|
1433
|
+
this.beginAgentReplayRecording();
|
|
1434
|
+
}
|
|
1435
|
+
let result;
|
|
1436
|
+
try {
|
|
1437
|
+
if (this.apiClient && !this.experimental) {
|
|
1438
|
+
const page = await this.ctx.awaitActivePage();
|
|
1439
|
+
result = await this.apiClient.agentExecute(options, resolvedOptions, page.mainFrameId(), !!cacheContext);
|
|
1440
|
+
if (cacheContext) {
|
|
1441
|
+
const transferredEntry = this.apiClient.consumeLatestAgentCacheEntry();
|
|
1442
|
+
await this.agentCache.storeTransferredEntry(transferredEntry);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
else {
|
|
1446
|
+
result = await handler.execute(instructionOrOptions);
|
|
1447
|
+
}
|
|
1448
|
+
if (shouldRecordLocally) {
|
|
1449
|
+
agentSteps = this.endAgentReplayRecording();
|
|
1450
|
+
}
|
|
1451
|
+
if (shouldRecordLocally &&
|
|
1452
|
+
cacheContext &&
|
|
1453
|
+
result.success &&
|
|
1454
|
+
agentSteps.length > 0) {
|
|
1455
|
+
await this.agentCache.store(cacheContext, agentSteps, result);
|
|
1456
|
+
}
|
|
1457
|
+
return result;
|
|
1458
|
+
}
|
|
1459
|
+
catch (err) {
|
|
1460
|
+
if (shouldRecordLocally)
|
|
1461
|
+
this.discardAgentReplayRecording();
|
|
1462
|
+
throw err;
|
|
1463
|
+
}
|
|
1464
|
+
finally {
|
|
1465
|
+
if (shouldRecordLocally) {
|
|
1466
|
+
this.discardAgentReplayRecording();
|
|
1467
|
+
}
|
|
1468
|
+
SessionFileLogger.logAgentTaskCompleted();
|
|
1469
|
+
}
|
|
1470
|
+
}),
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
// Default: AISDK tools-based agent
|
|
1474
|
+
const agentConfigSignature = this.agentCache.buildConfigSignature(options);
|
|
1475
|
+
const isStreaming = options?.stream ?? false;
|
|
1476
|
+
return {
|
|
1477
|
+
execute: async (instructionOrOptions) => withInstanceLogContext(this.instanceId, async () => {
|
|
1478
|
+
validateExperimentalFeatures({
|
|
1479
|
+
isExperimental: this.experimental,
|
|
1480
|
+
agentConfig: options,
|
|
1481
|
+
executeOptions: typeof instructionOrOptions === "object"
|
|
1482
|
+
? instructionOrOptions
|
|
1483
|
+
: null,
|
|
1484
|
+
isStreaming,
|
|
1485
|
+
});
|
|
1486
|
+
SessionFileLogger.logAgentTaskStarted({
|
|
1487
|
+
invocation: "Agent.execute",
|
|
1488
|
+
args: [instructionOrOptions],
|
|
1489
|
+
});
|
|
1490
|
+
// Streaming mode
|
|
1491
|
+
if (isStreaming) {
|
|
1492
|
+
const { handler, resolvedOptions, cacheContext, llmClient } = await this.prepareAgentExecution(options, instructionOrOptions, agentConfigSignature);
|
|
1493
|
+
if (cacheContext) {
|
|
1494
|
+
const replayed = await this.agentCache.tryReplayAsStream(cacheContext, llmClient);
|
|
1495
|
+
if (replayed) {
|
|
1496
|
+
SessionFileLogger.logAgentTaskCompleted({ cacheHit: true });
|
|
1497
|
+
return replayed;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
const streamResult = await handler.stream(resolvedOptions);
|
|
1501
|
+
if (cacheContext) {
|
|
1502
|
+
const wrappedStream = this.agentCache.wrapStreamForCaching(cacheContext, streamResult, () => this.beginAgentReplayRecording(), () => this.endAgentReplayRecording(), () => this.discardAgentReplayRecording());
|
|
1503
|
+
// Log completion when stream is returned (stream completes asynchronously)
|
|
1504
|
+
SessionFileLogger.logAgentTaskCompleted();
|
|
1505
|
+
return wrappedStream;
|
|
1506
|
+
}
|
|
1507
|
+
// Log completion when stream is returned (stream completes asynchronously)
|
|
1508
|
+
SessionFileLogger.logAgentTaskCompleted();
|
|
1509
|
+
return streamResult;
|
|
1510
|
+
}
|
|
1511
|
+
// Non-streaming mode (default)
|
|
1512
|
+
const { handler, resolvedOptions, cacheContext, llmClient } = await this.prepareAgentExecution(options, instructionOrOptions, agentConfigSignature);
|
|
1513
|
+
if (cacheContext) {
|
|
1514
|
+
const replayed = await this.agentCache.tryReplay(cacheContext, llmClient);
|
|
1515
|
+
if (replayed) {
|
|
1516
|
+
SessionFileLogger.logAgentTaskCompleted({ cacheHit: true });
|
|
1517
|
+
return replayed;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
let agentSteps = [];
|
|
1521
|
+
const shouldRecordLocally = !!cacheContext && (!this.apiClient || this.experimental);
|
|
1522
|
+
if (shouldRecordLocally) {
|
|
1523
|
+
this.beginAgentReplayRecording();
|
|
1524
|
+
}
|
|
1525
|
+
let result;
|
|
1526
|
+
try {
|
|
1527
|
+
if (this.apiClient && !this.experimental) {
|
|
1528
|
+
const page = await this.ctx.awaitActivePage();
|
|
1529
|
+
result = await this.apiClient.agentExecute(options ?? {}, resolvedOptions, page.mainFrameId(), !!cacheContext);
|
|
1530
|
+
if (cacheContext) {
|
|
1531
|
+
const transferredEntry = this.apiClient.consumeLatestAgentCacheEntry();
|
|
1532
|
+
await this.agentCache.storeTransferredEntry(transferredEntry);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
else {
|
|
1536
|
+
result = await handler.execute(resolvedOptions);
|
|
1537
|
+
}
|
|
1538
|
+
if (shouldRecordLocally) {
|
|
1539
|
+
agentSteps = this.endAgentReplayRecording();
|
|
1540
|
+
}
|
|
1541
|
+
if (shouldRecordLocally &&
|
|
1542
|
+
cacheContext &&
|
|
1543
|
+
result.success &&
|
|
1544
|
+
agentSteps.length > 0) {
|
|
1545
|
+
await this.agentCache.store(cacheContext, agentSteps, result);
|
|
1546
|
+
}
|
|
1547
|
+
return result;
|
|
1548
|
+
}
|
|
1549
|
+
catch (err) {
|
|
1550
|
+
if (shouldRecordLocally)
|
|
1551
|
+
this.discardAgentReplayRecording();
|
|
1552
|
+
throw err;
|
|
1553
|
+
}
|
|
1554
|
+
finally {
|
|
1555
|
+
if (shouldRecordLocally) {
|
|
1556
|
+
this.discardAgentReplayRecording();
|
|
1557
|
+
}
|
|
1558
|
+
SessionFileLogger.logAgentTaskCompleted();
|
|
1559
|
+
}
|
|
1560
|
+
}),
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
})();
|
|
1565
|
+
export { V3 };
|
|
1566
|
+
function isObserveResult(v) {
|
|
1567
|
+
return (!!v && typeof v === "object" && "selector" in v);
|
|
1568
|
+
}
|
|
1569
|
+
//# sourceMappingURL=v3.js.map
|