@browserbasehq/orca 3.1.0-patch.0 → 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/lib/modelUtils.d.ts +0 -3
- package/dist/esm/lib/modelUtils.js +2 -7
- package/dist/esm/lib/modelUtils.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/act.d.ts +1 -2
- package/dist/esm/lib/v3/agent/tools/act.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/extract.d.ts +1 -2
- package/dist/esm/lib/v3/agent/tools/extract.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/fillform.d.ts +1 -2
- package/dist/esm/lib/v3/agent/tools/fillform.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/index.d.ts +2 -2
- package/dist/esm/lib/v3/agent/tools/index.js.map +1 -1
- 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/build/rerender-index.d.ts +0 -0
- package/dist/esm/lib/v3/dom/build/rerender-index.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.map +1 -0
- package/dist/esm/lib/v3/handlers/v3AgentHandler.d.ts +2 -2
- package/dist/esm/lib/v3/handlers/v3AgentHandler.js.map +1 -1
- package/dist/esm/lib/v3/index.d.ts +1 -0
- package/dist/esm/lib/v3/index.js +1 -0
- package/dist/esm/lib/v3/index.js.map +1 -1
- package/dist/esm/lib/v3/shutdown/supervisor.d.ts +7 -5
- package/dist/esm/lib/v3/shutdown/supervisor.js +62 -52
- package/dist/esm/lib/v3/shutdown/supervisor.js.map +1 -1
- package/dist/esm/lib/v3/shutdown/supervisorClient.js +48 -52
- package/dist/esm/lib/v3/shutdown/supervisorClient.js.map +1 -1
- package/dist/esm/lib/v3/tests/click-count.spec.js +47 -12
- package/dist/esm/lib/v3/tests/click-count.spec.js.map +2 -2
- package/dist/esm/lib/v3/tests/iframe-ctx-addInitScript.spec.js +67 -21
- package/dist/esm/lib/v3/tests/iframe-ctx-addInitScript.spec.js.map +2 -2
- package/dist/esm/lib/v3/tests/v3.playwright.config.js +3 -60
- package/dist/esm/lib/v3/tests/v3.playwright.config.js.map +2 -2
- package/dist/esm/lib/v3/types/private/shutdown.d.ts +1 -13
- package/dist/esm/lib/v3/types/private/shutdown.js.map +1 -1
- package/dist/esm/lib/v3/understudy/context.js +10 -1
- package/dist/esm/lib/v3/understudy/context.js.map +1 -1
- package/dist/esm/lib/v3/understudy/locator.js +2 -2
- package/dist/esm/lib/v3/understudy/locator.js.map +1 -1
- package/dist/esm/lib/v3/understudy/page.js +2 -1
- package/dist/esm/lib/v3/understudy/page.js.map +1 -1
- package/dist/esm/lib/v3/v3.js +10 -13
- package/dist/esm/lib/v3/v3.js.map +1 -1
- package/dist/esm/tests/public-api/export-surface.test.js +1 -0
- package/dist/esm/tests/public-api/export-surface.test.js.map +2 -2
- package/package.json +13 -9
- package/dist/esm/lib/v3/tests/envReporter.js +0 -57
- package/dist/esm/lib/v3/tests/envReporter.js.map +0 -7
- package/dist/esm/tests/agent-execution-model.test.js +0 -139
- package/dist/esm/tests/agent-execution-model.test.js.map +0 -7
- package/dist/esm/tests/model-utils.test.js +0 -43
- package/dist/esm/tests/model-utils.test.js.map +0 -7
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { ToolSet, ModelMessage, wrapLanguageModel, StreamTextResult, StepResult, PrepareStepFunction, GenerateTextOnStepFinishCallback, StreamTextOnStepFinishCallback, StreamTextOnErrorCallback, StreamTextOnChunkCallback, StreamTextOnFinishCallback } from "ai";
|
|
3
|
+
import { LogLine } from "./logs.js";
|
|
4
|
+
import { ClientOptions } from "./model.js";
|
|
5
|
+
import { StagehandZodObject } from "../../zodCompat.js";
|
|
6
|
+
export type { ModelMessage } from "ai";
|
|
7
|
+
export type { Tool } from "ai";
|
|
8
|
+
import { Page as PlaywrightPage } from "playwright-core";
|
|
9
|
+
import { Page as PuppeteerPage } from "puppeteer-core";
|
|
10
|
+
import { Page as PatchrightPage } from "patchright-core";
|
|
11
|
+
import { Page } from "../../understudy/page.js";
|
|
12
|
+
export interface AgentContext {
|
|
13
|
+
options: AgentExecuteOptionsBase;
|
|
14
|
+
maxSteps: number;
|
|
15
|
+
systemPrompt: string;
|
|
16
|
+
allTools: ToolSet;
|
|
17
|
+
messages: ModelMessage[];
|
|
18
|
+
wrappedModel: ReturnType<typeof wrapLanguageModel>;
|
|
19
|
+
initialPageUrl: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentState {
|
|
22
|
+
collectedReasoning: string[];
|
|
23
|
+
actions: AgentAction[];
|
|
24
|
+
finalMessage: string;
|
|
25
|
+
completed: boolean;
|
|
26
|
+
currentPageUrl: string;
|
|
27
|
+
}
|
|
28
|
+
export interface AgentAction {
|
|
29
|
+
type: string;
|
|
30
|
+
reasoning?: string;
|
|
31
|
+
taskCompleted?: boolean;
|
|
32
|
+
action?: string;
|
|
33
|
+
timeMs?: number;
|
|
34
|
+
pageText?: string;
|
|
35
|
+
pageUrl?: string;
|
|
36
|
+
instruction?: string;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
export interface AgentResult {
|
|
40
|
+
success: boolean;
|
|
41
|
+
message: string;
|
|
42
|
+
actions: AgentAction[];
|
|
43
|
+
completed: boolean;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
usage?: {
|
|
46
|
+
input_tokens: number;
|
|
47
|
+
output_tokens: number;
|
|
48
|
+
reasoning_tokens?: number;
|
|
49
|
+
cached_input_tokens?: number;
|
|
50
|
+
inference_time_ms: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The conversation messages from this execution.
|
|
54
|
+
* Pass these to a subsequent execute() call via the `messages` option to continue the conversation.
|
|
55
|
+
* @experimental
|
|
56
|
+
*/
|
|
57
|
+
messages?: ModelMessage[];
|
|
58
|
+
/**
|
|
59
|
+
* Custom output data extracted based on the `output` schema provided in execute options.
|
|
60
|
+
* Only populated if an `output` schema was provided.
|
|
61
|
+
* @experimental
|
|
62
|
+
*/
|
|
63
|
+
output?: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
export type AgentStreamResult = StreamTextResult<ToolSet, never> & {
|
|
66
|
+
result: Promise<AgentResult>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Base callbacks shared between execute (non-streaming) and streaming modes.
|
|
70
|
+
*/
|
|
71
|
+
export interface AgentCallbacks {
|
|
72
|
+
/**
|
|
73
|
+
* Optional function called before each step to modify settings.
|
|
74
|
+
* You can change the model, tool choices, active tools, system prompt,
|
|
75
|
+
* and input messages for each step.
|
|
76
|
+
*/
|
|
77
|
+
prepareStep?: PrepareStepFunction<ToolSet>;
|
|
78
|
+
/**
|
|
79
|
+
* Callback called when each step (LLM call) is finished.
|
|
80
|
+
* This is called for intermediate steps as well as the final step.
|
|
81
|
+
*/
|
|
82
|
+
onStepFinish?: GenerateTextOnStepFinishCallback<ToolSet> | StreamTextOnStepFinishCallback<ToolSet>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Error message type for streaming-only callbacks used in non-streaming mode.
|
|
86
|
+
* This provides a clear error message when users try to use streaming callbacks without stream: true.
|
|
87
|
+
*/
|
|
88
|
+
type StreamingCallbackNotAvailable = "This callback requires 'stream: true' in AgentConfig. Set stream: true to use streaming callbacks like onChunk, onFinish, onError, and onAbort.";
|
|
89
|
+
/**
|
|
90
|
+
* Error message for safety confirmation callback misuse.
|
|
91
|
+
* Safety confirmations are only available for non-streaming CUA agent executions.
|
|
92
|
+
*/
|
|
93
|
+
type SafetyConfirmationCallbackNotAvailable = "Safety confirmation callbacks are only available via non-streaming AgentExecuteOptions.callbacks when using mode: 'cua'.";
|
|
94
|
+
/**
|
|
95
|
+
* Callbacks specific to the non-streaming execute method.
|
|
96
|
+
*/
|
|
97
|
+
export interface AgentExecuteCallbacks extends AgentCallbacks {
|
|
98
|
+
/**
|
|
99
|
+
* Callback called when each step (LLM call) is finished.
|
|
100
|
+
*/
|
|
101
|
+
onStepFinish?: GenerateTextOnStepFinishCallback<ToolSet>;
|
|
102
|
+
/**
|
|
103
|
+
* Callback for handling safety confirmation requests from CUA providers.
|
|
104
|
+
* Only available when running an agent configured with mode: "cua".
|
|
105
|
+
*/
|
|
106
|
+
onSafetyConfirmation?: SafetyConfirmationHandler;
|
|
107
|
+
/**
|
|
108
|
+
* NOT AVAILABLE in non-streaming mode.
|
|
109
|
+
* This callback requires `stream: true` in AgentConfig.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* // Enable streaming to use onChunk:
|
|
114
|
+
* const agent = stagehand.agent({ stream: true });
|
|
115
|
+
* await agent.execute({
|
|
116
|
+
* instruction: "...",
|
|
117
|
+
* callbacks: { onChunk: async (chunk) => console.log(chunk) }
|
|
118
|
+
* });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
onChunk?: StreamingCallbackNotAvailable;
|
|
122
|
+
/**
|
|
123
|
+
* NOT AVAILABLE in non-streaming mode.
|
|
124
|
+
* This callback requires `stream: true` in AgentConfig.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* // Enable streaming to use onFinish:
|
|
129
|
+
* const agent = stagehand.agent({ stream: true });
|
|
130
|
+
* await agent.execute({
|
|
131
|
+
* instruction: "...",
|
|
132
|
+
* callbacks: { onFinish: (event) => console.log("Done!", event) }
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
onFinish?: StreamingCallbackNotAvailable;
|
|
137
|
+
/**
|
|
138
|
+
* NOT AVAILABLE in non-streaming mode.
|
|
139
|
+
* This callback requires `stream: true` in AgentConfig.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* // Enable streaming to use onError:
|
|
144
|
+
* const agent = stagehand.agent({ stream: true });
|
|
145
|
+
* await agent.execute({
|
|
146
|
+
* instruction: "...",
|
|
147
|
+
* callbacks: { onError: ({ error }) => console.error(error) }
|
|
148
|
+
* });
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
onError?: StreamingCallbackNotAvailable;
|
|
152
|
+
/**
|
|
153
|
+
* NOT AVAILABLE in non-streaming mode.
|
|
154
|
+
* This callback requires `stream: true` in AgentConfig.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // Enable streaming to use onAbort:
|
|
159
|
+
* const agent = stagehand.agent({ stream: true });
|
|
160
|
+
* await agent.execute({
|
|
161
|
+
* instruction: "...",
|
|
162
|
+
* callbacks: { onAbort: (event) => console.log("Aborted", event.steps) }
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
onAbort?: StreamingCallbackNotAvailable;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Callbacks specific to the streaming mode.
|
|
170
|
+
*/
|
|
171
|
+
export interface AgentStreamCallbacks extends AgentCallbacks {
|
|
172
|
+
/**
|
|
173
|
+
* Callback called when each step (LLM call) is finished during streaming.
|
|
174
|
+
*/
|
|
175
|
+
onStepFinish?: StreamTextOnStepFinishCallback<ToolSet>;
|
|
176
|
+
/**
|
|
177
|
+
* Callback called when an error occurs during streaming.
|
|
178
|
+
* Use this to log errors or handle error states.
|
|
179
|
+
*/
|
|
180
|
+
onError?: StreamTextOnErrorCallback;
|
|
181
|
+
/**
|
|
182
|
+
* Callback called for each chunk of the stream.
|
|
183
|
+
* Stream processing will pause until the callback promise resolves.
|
|
184
|
+
*/
|
|
185
|
+
onChunk?: StreamTextOnChunkCallback<ToolSet>;
|
|
186
|
+
/**
|
|
187
|
+
* Callback called when the stream finishes.
|
|
188
|
+
*/
|
|
189
|
+
onFinish?: StreamTextOnFinishCallback<ToolSet>;
|
|
190
|
+
/**
|
|
191
|
+
* Callback called when the stream is aborted.
|
|
192
|
+
*/
|
|
193
|
+
onAbort?: (event: {
|
|
194
|
+
steps: Array<StepResult<ToolSet>>;
|
|
195
|
+
}) => PromiseLike<void> | void;
|
|
196
|
+
/**
|
|
197
|
+
* NOT AVAILABLE in streaming mode.
|
|
198
|
+
* Safety confirmations currently require non-streaming execute() on CUA agents.
|
|
199
|
+
*/
|
|
200
|
+
onSafetyConfirmation?: SafetyConfirmationCallbackNotAvailable;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Base options for agent execution (without callbacks).
|
|
204
|
+
*/
|
|
205
|
+
export interface AgentExecuteOptionsBase {
|
|
206
|
+
instruction: string;
|
|
207
|
+
maxSteps?: number;
|
|
208
|
+
page?: PlaywrightPage | PuppeteerPage | PatchrightPage | Page;
|
|
209
|
+
highlightCursor?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Previous conversation messages to continue from.
|
|
212
|
+
* Pass the `messages` from a previous AgentResult to continue that conversation.
|
|
213
|
+
* @experimental
|
|
214
|
+
*/
|
|
215
|
+
messages?: ModelMessage[];
|
|
216
|
+
/**
|
|
217
|
+
* An AbortSignal that can be used to cancel the agent execution.
|
|
218
|
+
* When aborted, the agent will stop and return a partial result.
|
|
219
|
+
* @experimental
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const controller = new AbortController();
|
|
224
|
+
* setTimeout(() => controller.abort(), 30000); // 30 second timeout
|
|
225
|
+
*
|
|
226
|
+
* const result = await agent.execute({
|
|
227
|
+
* instruction: "...",
|
|
228
|
+
* signal: controller.signal
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
signal?: AbortSignal;
|
|
233
|
+
/**
|
|
234
|
+
* Tools to exclude from this execution.
|
|
235
|
+
* Pass an array of tool names to prevent the agent from using those tools.
|
|
236
|
+
*
|
|
237
|
+
* **Note:** Not supported in CUA mode (`mode: "cua"`).
|
|
238
|
+
*
|
|
239
|
+
* **Available tools by mode:**
|
|
240
|
+
*
|
|
241
|
+
* **DOM mode (default):**
|
|
242
|
+
* - `act` - Perform semantic actions (click, type, etc.)
|
|
243
|
+
* - `fillForm` - Fill form fields using DOM selectors
|
|
244
|
+
* - `ariaTree` - Get accessibility tree of the page
|
|
245
|
+
* - `extract` - Extract structured data from page
|
|
246
|
+
* - `goto` - Navigate to a URL
|
|
247
|
+
* - `scroll` - Scroll using semantic directions (up/down/left/right)
|
|
248
|
+
* - `keys` - Press keyboard keys
|
|
249
|
+
* - `navback` - Navigate back in history
|
|
250
|
+
* - `screenshot` - Take a screenshot
|
|
251
|
+
* - `think` - Agent reasoning/planning step
|
|
252
|
+
* - `wait` - Wait for time or condition
|
|
253
|
+
* - `done` - Mark task as complete
|
|
254
|
+
* - `search` - Web search (requires BRAVE_API_KEY)
|
|
255
|
+
*
|
|
256
|
+
* **Hybrid mode:**
|
|
257
|
+
* - `click` - Click at specific coordinates
|
|
258
|
+
* - `type` - Type text at coordinates
|
|
259
|
+
* - `dragAndDrop` - Drag from one point to another
|
|
260
|
+
* - `clickAndHold` - Click and hold at coordinates
|
|
261
|
+
* - `fillFormVision` - Fill forms using vision/coordinates
|
|
262
|
+
* - `act` - Perform semantic actions
|
|
263
|
+
* - `ariaTree` - Get accessibility tree
|
|
264
|
+
* - `extract` - Extract data from page
|
|
265
|
+
* - `goto` - Navigate to URL
|
|
266
|
+
* - `scroll` - Scroll using coordinates
|
|
267
|
+
* - `keys` - Press keyboard keys
|
|
268
|
+
* - `navback` - Navigate back
|
|
269
|
+
* - `screenshot` - Take screenshot
|
|
270
|
+
* - `think` - Agent reasoning step
|
|
271
|
+
* - `wait` - Wait for time/condition
|
|
272
|
+
* - `done` - Mark task complete
|
|
273
|
+
* - `search` - Web search (requires BRAVE_API_KEY)
|
|
274
|
+
*
|
|
275
|
+
* @experimental
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* // Exclude screenshot and extract tools
|
|
279
|
+
* const result = await agent.execute({
|
|
280
|
+
* instruction: "Click the submit button",
|
|
281
|
+
* excludeTools: ["screenshot", "extract"]
|
|
282
|
+
* });
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
excludeTools?: string[];
|
|
286
|
+
/**
|
|
287
|
+
* A Zod schema defining custom output data to return when the task completes.
|
|
288
|
+
* The agent will populate this data in the final done tool call.
|
|
289
|
+
*
|
|
290
|
+
* @experimental
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* const result = await agent.execute({
|
|
294
|
+
* instruction: "Find the cheapest flight from NYC to LA",
|
|
295
|
+
* output: z.object({
|
|
296
|
+
* price: z.string().describe("The price of the flight"),
|
|
297
|
+
* airline: z.string().describe("The airline name"),
|
|
298
|
+
* departureTime: z.string().describe("Departure time"),
|
|
299
|
+
* }),
|
|
300
|
+
* });
|
|
301
|
+
*
|
|
302
|
+
* console.log(result.output); // { price: "$199", airline: "Delta", departureTime: "8:00 AM" }
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
output?: StagehandZodObject;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Options for non-streaming agent execution.
|
|
309
|
+
* Only accepts AgentExecuteCallbacks (no streaming-specific callbacks like onChunk, onFinish).
|
|
310
|
+
*/
|
|
311
|
+
export interface AgentExecuteOptions extends AgentExecuteOptionsBase {
|
|
312
|
+
/**
|
|
313
|
+
* Callbacks for non-streaming agent execution.
|
|
314
|
+
* For streaming callbacks (onChunk, onFinish, onError, onAbort), use stream: true in AgentConfig.
|
|
315
|
+
*/
|
|
316
|
+
callbacks?: AgentExecuteCallbacks;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Options for streaming agent execution.
|
|
320
|
+
* Accepts AgentStreamCallbacks including onChunk, onFinish, onError, and onAbort.
|
|
321
|
+
*/
|
|
322
|
+
export interface AgentStreamExecuteOptions extends AgentExecuteOptionsBase {
|
|
323
|
+
/**
|
|
324
|
+
* Callbacks for streaming agent execution.
|
|
325
|
+
* Includes streaming-specific callbacks: onChunk, onFinish, onError, onAbort.
|
|
326
|
+
*/
|
|
327
|
+
callbacks?: AgentStreamCallbacks;
|
|
328
|
+
}
|
|
329
|
+
export type AgentType = "openai" | "anthropic" | "google" | "microsoft";
|
|
330
|
+
export declare const AVAILABLE_CUA_MODELS: readonly ["openai/computer-use-preview", "openai/computer-use-preview-2025-03-11", "anthropic/claude-3-7-sonnet-latest", "anthropic/claude-opus-4-5-20251101", "anthropic/claude-opus-4-6", "anthropic/claude-haiku-4-5-20251001", "anthropic/claude-sonnet-4-20250514", "anthropic/claude-sonnet-4-5-20250929", "google/gemini-2.5-computer-use-preview-10-2025", "google/gemini-3-flash-preview", "google/gemini-3-pro-preview", "microsoft/fara-7b"];
|
|
331
|
+
export type AvailableCuaModel = (typeof AVAILABLE_CUA_MODELS)[number];
|
|
332
|
+
export interface AgentExecutionOptions<TOptions extends AgentExecuteOptions = AgentExecuteOptions> {
|
|
333
|
+
options: TOptions;
|
|
334
|
+
logger: (message: LogLine) => void;
|
|
335
|
+
retries?: number;
|
|
336
|
+
}
|
|
337
|
+
export interface AgentHandlerOptions {
|
|
338
|
+
modelName: string;
|
|
339
|
+
clientOptions?: ClientOptions;
|
|
340
|
+
userProvidedInstructions?: string;
|
|
341
|
+
experimental?: boolean;
|
|
342
|
+
}
|
|
343
|
+
export interface ActionExecutionResult {
|
|
344
|
+
success: boolean;
|
|
345
|
+
error?: string;
|
|
346
|
+
data?: unknown;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Represents a safety check that requires user confirmation before proceeding.
|
|
350
|
+
* These are issued by CUA providers (OpenAI, Google) when the agent attempts
|
|
351
|
+
* potentially risky actions.
|
|
352
|
+
*/
|
|
353
|
+
export interface SafetyCheck {
|
|
354
|
+
/** Unique identifier for this safety check */
|
|
355
|
+
id: string;
|
|
356
|
+
/** Code identifying the type of safety concern */
|
|
357
|
+
code: string;
|
|
358
|
+
/** Human-readable description of the safety concern */
|
|
359
|
+
message: string;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Response from the user for a safety confirmation request.
|
|
363
|
+
*/
|
|
364
|
+
export interface SafetyConfirmationResponse {
|
|
365
|
+
/** Whether the user acknowledged/approved the safety checks */
|
|
366
|
+
acknowledged: boolean;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Callback for handling safety confirmation requests.
|
|
370
|
+
* Called when the CUA provider issues safety checks that require user confirmation.
|
|
371
|
+
* The callback should return a promise that resolves when the user has made a decision.
|
|
372
|
+
*
|
|
373
|
+
* @param safetyChecks - Array of safety checks requiring confirmation
|
|
374
|
+
* @returns Promise resolving to the user's response
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* const agent = stagehand.agent({
|
|
379
|
+
* mode: "cua",
|
|
380
|
+
* });
|
|
381
|
+
* await agent.execute({
|
|
382
|
+
* instruction: "...",
|
|
383
|
+
* callbacks: {
|
|
384
|
+
* onSafetyConfirmation: async (checks) => {
|
|
385
|
+
* console.log("Safety checks:", checks);
|
|
386
|
+
* const userApproved = await showConfirmationDialog(checks);
|
|
387
|
+
* return { acknowledged: userApproved };
|
|
388
|
+
* },
|
|
389
|
+
* },
|
|
390
|
+
* });
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
export type SafetyConfirmationHandler = (safetyChecks: SafetyCheck[]) => Promise<SafetyConfirmationResponse>;
|
|
394
|
+
export interface ToolUseItem extends ResponseItem {
|
|
395
|
+
type: "tool_use";
|
|
396
|
+
id: string;
|
|
397
|
+
name: string;
|
|
398
|
+
input: Record<string, unknown>;
|
|
399
|
+
}
|
|
400
|
+
export interface AnthropicMessage {
|
|
401
|
+
role: string;
|
|
402
|
+
content: string | Array<AnthropicContentBlock>;
|
|
403
|
+
}
|
|
404
|
+
export interface AnthropicContentBlock {
|
|
405
|
+
type: string;
|
|
406
|
+
[key: string]: unknown;
|
|
407
|
+
}
|
|
408
|
+
export interface AnthropicTextBlock extends AnthropicContentBlock {
|
|
409
|
+
type: "text";
|
|
410
|
+
text: string;
|
|
411
|
+
}
|
|
412
|
+
export interface AnthropicToolResult {
|
|
413
|
+
type: "tool_result";
|
|
414
|
+
tool_use_id: string;
|
|
415
|
+
content: string | Array<AnthropicContentBlock>;
|
|
416
|
+
}
|
|
417
|
+
export interface ResponseItem {
|
|
418
|
+
type: string;
|
|
419
|
+
id: string;
|
|
420
|
+
[key: string]: unknown;
|
|
421
|
+
}
|
|
422
|
+
export interface ComputerCallItem extends ResponseItem {
|
|
423
|
+
type: "computer_call";
|
|
424
|
+
call_id: string;
|
|
425
|
+
action: {
|
|
426
|
+
type: string;
|
|
427
|
+
[key: string]: unknown;
|
|
428
|
+
};
|
|
429
|
+
pending_safety_checks?: Array<{
|
|
430
|
+
id: string;
|
|
431
|
+
code: string;
|
|
432
|
+
message: string;
|
|
433
|
+
}>;
|
|
434
|
+
}
|
|
435
|
+
export interface FunctionCallItem extends ResponseItem {
|
|
436
|
+
type: "function_call";
|
|
437
|
+
call_id: string;
|
|
438
|
+
name: string;
|
|
439
|
+
arguments: string;
|
|
440
|
+
}
|
|
441
|
+
export type ResponseInputItem = {
|
|
442
|
+
role: string;
|
|
443
|
+
content: string;
|
|
444
|
+
} | {
|
|
445
|
+
type: "computer_call_output";
|
|
446
|
+
call_id: string;
|
|
447
|
+
output: {
|
|
448
|
+
type: "input_image";
|
|
449
|
+
image_url: string;
|
|
450
|
+
current_url?: string;
|
|
451
|
+
error?: string;
|
|
452
|
+
[key: string]: unknown;
|
|
453
|
+
} | string;
|
|
454
|
+
acknowledged_safety_checks?: Array<{
|
|
455
|
+
id: string;
|
|
456
|
+
code: string;
|
|
457
|
+
message: string;
|
|
458
|
+
}>;
|
|
459
|
+
} | {
|
|
460
|
+
type: "function_call_output";
|
|
461
|
+
call_id: string;
|
|
462
|
+
output: string;
|
|
463
|
+
};
|
|
464
|
+
export interface AgentInstance {
|
|
465
|
+
execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
|
|
466
|
+
}
|
|
467
|
+
export type AgentProviderType = AgentType;
|
|
468
|
+
export type AgentModelConfig<TModelName extends string = string> = {
|
|
469
|
+
modelName: TModelName;
|
|
470
|
+
} & Record<string, unknown>;
|
|
471
|
+
/**
|
|
472
|
+
* Agent tool mode determines which set of tools are available to the agent.
|
|
473
|
+
* - 'dom': Uses DOM-based tools (act, fillForm) - better for structured page interactions
|
|
474
|
+
* - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, etc.) - better for visual/screenshot-based interactions
|
|
475
|
+
* - 'cua': Uses Computer Use Agent (CUA) providers like Anthropic Claude or Google Gemini for screenshot-based automation
|
|
476
|
+
*/
|
|
477
|
+
export type AgentToolMode = "dom" | "hybrid" | "cua";
|
|
478
|
+
export type AgentConfig = {
|
|
479
|
+
/**
|
|
480
|
+
* Custom system prompt to provide to the agent. Overrides the default system prompt.
|
|
481
|
+
*/
|
|
482
|
+
systemPrompt?: string;
|
|
483
|
+
/**
|
|
484
|
+
* MCP integrations - Array of Client objects
|
|
485
|
+
*/
|
|
486
|
+
integrations?: (Client | string)[];
|
|
487
|
+
/**
|
|
488
|
+
* Tools passed to the agent client
|
|
489
|
+
*/
|
|
490
|
+
tools?: ToolSet;
|
|
491
|
+
/**
|
|
492
|
+
* @deprecated Use `mode: "cua"` instead. This option will be removed in a future version.
|
|
493
|
+
* Enables Computer Use Agent (CUA) mode.
|
|
494
|
+
*/
|
|
495
|
+
cua?: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* The model to use for agent functionality
|
|
498
|
+
*/
|
|
499
|
+
model?: string | AgentModelConfig<string>;
|
|
500
|
+
/**
|
|
501
|
+
* The model to use for tool execution (observe/act calls within agent tools).
|
|
502
|
+
* If not specified, inherits from the main model configuration.
|
|
503
|
+
* Format: "provider/model" (e.g., "openai/gpt-4o-mini", "google/gemini-2.0-flash-exp")
|
|
504
|
+
*/
|
|
505
|
+
executionModel?: string | AgentModelConfig<string>;
|
|
506
|
+
/**
|
|
507
|
+
* Enable streaming mode for the agent.
|
|
508
|
+
* When true, execute() returns AgentStreamResult with textStream for incremental output.
|
|
509
|
+
* When false (default), execute() returns AgentResult after completion.
|
|
510
|
+
*/
|
|
511
|
+
stream?: boolean;
|
|
512
|
+
/**
|
|
513
|
+
* Tool mode for the agent. Determines which set of tools are available.
|
|
514
|
+
* - 'dom' (default): Uses DOM-based tools (act, fillForm) for structured interactions
|
|
515
|
+
* - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, clickAndHold, fillFormVision)
|
|
516
|
+
* for visual/screenshot-based interactions
|
|
517
|
+
* - 'cua': Uses Computer Use Agent (CUA) providers for screenshot-based automation
|
|
518
|
+
*/
|
|
519
|
+
mode?: AgentToolMode;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* Agent instance returned when stream: true is set in AgentConfig.
|
|
523
|
+
* execute() returns a streaming result that can be consumed incrementally.
|
|
524
|
+
* Accepts AgentStreamExecuteOptions with streaming-specific callbacks.
|
|
525
|
+
*/
|
|
526
|
+
export interface StreamingAgentInstance {
|
|
527
|
+
execute: (instructionOrOptions: string | AgentStreamExecuteOptions) => Promise<AgentStreamResult>;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Agent instance returned when stream is false or not set in AgentConfig.
|
|
531
|
+
* execute() returns a result after the agent completes.
|
|
532
|
+
* Accepts AgentExecuteOptions with non-streaming callbacks only.
|
|
533
|
+
*/
|
|
534
|
+
export interface NonStreamingAgentInstance {
|
|
535
|
+
execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Content item type for toModelOutput return values.
|
|
539
|
+
* Used in tool definitions to return text and/or media to the model.
|
|
540
|
+
*/
|
|
541
|
+
export type ModelOutputContentItem = {
|
|
542
|
+
type: "text";
|
|
543
|
+
text: string;
|
|
544
|
+
} | {
|
|
545
|
+
type: "media";
|
|
546
|
+
mediaType: string;
|
|
547
|
+
data: string;
|
|
548
|
+
};
|
|
549
|
+
export interface ClickToolResult {
|
|
550
|
+
success: boolean;
|
|
551
|
+
describe?: string;
|
|
552
|
+
coordinates?: number[];
|
|
553
|
+
error?: string;
|
|
554
|
+
screenshotBase64?: string;
|
|
555
|
+
}
|
|
556
|
+
export interface TypeToolResult {
|
|
557
|
+
success: boolean;
|
|
558
|
+
describe?: string;
|
|
559
|
+
text?: string;
|
|
560
|
+
error?: string;
|
|
561
|
+
screenshotBase64?: string;
|
|
562
|
+
}
|
|
563
|
+
export interface DragAndDropToolResult {
|
|
564
|
+
success: boolean;
|
|
565
|
+
describe?: string;
|
|
566
|
+
error?: string;
|
|
567
|
+
screenshotBase64?: string;
|
|
568
|
+
}
|
|
569
|
+
export interface FillFormField {
|
|
570
|
+
action: string;
|
|
571
|
+
value: string;
|
|
572
|
+
coordinates: {
|
|
573
|
+
x: number;
|
|
574
|
+
y: number;
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
export interface FillFormVisionToolResult {
|
|
578
|
+
success: boolean;
|
|
579
|
+
playwrightArguments?: FillFormField[];
|
|
580
|
+
error?: string;
|
|
581
|
+
screenshotBase64?: string;
|
|
582
|
+
}
|
|
583
|
+
export interface ScrollToolResult {
|
|
584
|
+
success: boolean;
|
|
585
|
+
message: string;
|
|
586
|
+
scrolledPixels: number;
|
|
587
|
+
}
|
|
588
|
+
export interface ScrollVisionToolResult extends ScrollToolResult {
|
|
589
|
+
screenshotBase64?: string;
|
|
590
|
+
}
|
|
591
|
+
export interface WaitToolResult {
|
|
592
|
+
success: boolean;
|
|
593
|
+
waited: number;
|
|
594
|
+
screenshotBase64?: string;
|
|
595
|
+
}
|