@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,7 @@
|
|
|
1
|
+
import type { V3 } from "../v3.js";
|
|
2
|
+
import type { AgentCacheTransferPayload } from "../types/private/index.js";
|
|
3
|
+
export interface ServerAgentCacheHandle {
|
|
4
|
+
complete(): AgentCacheTransferPayload | null;
|
|
5
|
+
discard(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function __internalCreateInMemoryAgentCacheHandle(stagehand: V3): ServerAgentCacheHandle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Logger } from "../types/public/index.js";
|
|
2
|
+
import { Page } from "../understudy/page.js";
|
|
3
|
+
export declare function cloneForCache<T>(value: T): T;
|
|
4
|
+
export declare function safeGetPageUrl(page: Page): Promise<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Waits for a cached action's selector to be attached to the DOM before executing.
|
|
7
|
+
* Logs a warning and proceeds if the wait times out (non-blocking).
|
|
8
|
+
*/
|
|
9
|
+
export declare function waitForCachedSelector(params: {
|
|
10
|
+
page: Page;
|
|
11
|
+
selector: string | undefined;
|
|
12
|
+
timeout: number | undefined;
|
|
13
|
+
logger: Logger;
|
|
14
|
+
context?: string;
|
|
15
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function getScrollOffsets(): {
|
|
2
|
+
sx: number;
|
|
3
|
+
sy: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function getBoundingRectLite(this: Element): {
|
|
6
|
+
left: number;
|
|
7
|
+
top: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function resolveDeepActiveElement(): Element | null;
|
|
10
|
+
export declare function nodeToAbsoluteXPath(this: Node | null | undefined): string;
|
|
11
|
+
export declare function documentHasFocusStrict(): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const a11yScriptBootstrap = "if (!globalThis.__stagehandA11yScripts) { var __stagehandA11yScriptsFactory=(()=>{var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var N=(o,t)=>{for(var n in t)i(o,n,{get:t[n],enumerable:!0})},h=(o,t,n,d)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let u of f(t))!p.call(o,u)&&u!==n&&i(o,u,{get:()=>t[u],enumerable:!(d=a(t,u))||d.enumerable});return o};var E=o=>h(i({},\"__esModule\",{value:!0}),o);var b={};N(b,{documentHasFocusStrict:()=>g,getBoundingRectLite:()=>w,getScrollOffsets:()=>y,nodeToAbsoluteXPath:()=>$,resolveDeepActiveElement:()=>T});function y(){try{let o=window.scrollX??window.pageXOffset??document.documentElement?.scrollLeft??0,t=window.scrollY??window.pageYOffset??document.documentElement?.scrollTop??0;return{sx:Number(o)||0,sy:Number(t)||0}}catch{return{sx:0,sy:0}}}function w(){try{let o=this.getBoundingClientRect();return{left:Number(o?.left??0)||0,top:Number(o?.top??0)||0}}catch{return{left:0,top:0}}}function T(){try{return(t=>{let n=t.activeElement??null;for(;n&&n.shadowRoot&&n.shadowRoot.activeElement;)n=n.shadowRoot.activeElement;return n??null})(document)}catch{return null}}function $(){return(t=>{try{let n=e=>{if(!e||!e.parentNode)return 1;let l=1,m=`${e.nodeType}:${(e.nodeName||\"\").toLowerCase()}`;for(let c=e.previousSibling;c;c=c.previousSibling)`${c.nodeType}:${(c.nodeName||\"\").toLowerCase()}`===m&&(l+=1);return l},d=e=>{if(!e||e.nodeType===Node.DOCUMENT_NODE)return\"\";if(e.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return\"//\";if(e.nodeType===Node.TEXT_NODE)return`text()[${n(e)}]`;if(e.nodeType===Node.COMMENT_NODE)return`comment()[${n(e)}]`;let l=(e.nodeName||\"\").toLowerCase();return`${l.includes(\":\")?`*[name()='${l}']`:l}[${n(e)}]`},u=[],s=t;for(;s;){if(s.nodeType===Node.DOCUMENT_FRAGMENT_NODE){u.push(\"//\"),s=s.host??null;continue}let e=d(s);e&&u.push(e),s=s.parentNode}u.reverse();let r=\"\";for(let e of u)e===\"//\"?r=r?r.endsWith(\"/\")?`${r}/`:`${r}//`:\"//\":r=r?r.endsWith(\"/\")?`${r}${e}`:`${r}/${e}`:`/${e}`;return r||\"/\"}catch{return\"/\"}})(this)}function g(){try{return document.hasFocus()===!0}catch{return!1}}return E(b);})();\n globalThis.__stagehandA11yScripts = __stagehandA11yScriptsFactory;\n}";
|
|
2
|
+
export declare const a11yScriptSources: {
|
|
3
|
+
readonly documentHasFocusStrict: "function h(){try{return document.hasFocus()===!0}catch{return!1}}";
|
|
4
|
+
readonly getBoundingRectLite: "function f(){try{let r=this.getBoundingClientRect();return{left:Number(r?.left??0)||0,top:Number(r?.top??0)||0}}catch{return{left:0,top:0}}}";
|
|
5
|
+
readonly getScrollOffsets: "function a(){try{let r=window.scrollX??window.pageXOffset??document.documentElement?.scrollLeft??0,s=window.scrollY??window.pageYOffset??document.documentElement?.scrollTop??0;return{sx:Number(r)||0,sy:Number(s)||0}}catch{return{sx:0,sy:0}}}";
|
|
6
|
+
readonly nodeToAbsoluteXPath: "function N(){return(s=>{try{let n=e=>{if(!e||!e.parentNode)return 1;let u=1,d=`${e.nodeType}:${(e.nodeName||\"\").toLowerCase()}`;for(let l=e.previousSibling;l;l=l.previousSibling)`${l.nodeType}:${(l.nodeName||\"\").toLowerCase()}`===d&&(u+=1);return u},i=e=>{if(!e||e.nodeType===Node.DOCUMENT_NODE)return\"\";if(e.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return\"//\";if(e.nodeType===Node.TEXT_NODE)return`text()[${n(e)}]`;if(e.nodeType===Node.COMMENT_NODE)return`comment()[${n(e)}]`;let u=(e.nodeName||\"\").toLowerCase();return`${u.includes(\":\")?`*[name()='${u}']`:u}[${n(e)}]`},c=[],o=s;for(;o;){if(o.nodeType===Node.DOCUMENT_FRAGMENT_NODE){c.push(\"//\"),o=o.host??null;continue}let e=i(o);e&&c.push(e),o=o.parentNode}c.reverse();let t=\"\";for(let e of c)e===\"//\"?t=t?t.endsWith(\"/\")?`${t}/`:`${t}//`:\"//\":t=t?t.endsWith(\"/\")?`${t}${e}`:`${t}/${e}`:`/${e}`;return t||\"/\"}catch{return\"/\"}})(this)}";
|
|
7
|
+
readonly resolveDeepActiveElement: "function p(){try{return(s=>{let n=s.activeElement??null;for(;n&&n.shadowRoot&&n.shadowRoot.activeElement;)n=n.shadowRoot.activeElement;return n??null})(document)}catch{return null}}";
|
|
8
|
+
};
|
|
9
|
+
export declare const a11yScriptGlobalRefs: {
|
|
10
|
+
readonly documentHasFocusStrict: "globalThis.__stagehandA11yScripts.documentHasFocusStrict";
|
|
11
|
+
readonly getBoundingRectLite: "globalThis.__stagehandA11yScripts.getBoundingRectLite";
|
|
12
|
+
readonly getScrollOffsets: "globalThis.__stagehandA11yScripts.getScrollOffsets";
|
|
13
|
+
readonly nodeToAbsoluteXPath: "globalThis.__stagehandA11yScripts.nodeToAbsoluteXPath";
|
|
14
|
+
readonly resolveDeepActiveElement: "globalThis.__stagehandA11yScripts.resolveDeepActiveElement";
|
|
15
|
+
};
|
|
16
|
+
export type A11yScriptName = keyof typeof a11yScriptSources;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const locatorScriptBootstrap = "if (!globalThis.__stagehandLocatorScripts) { var __stagehandLocatorScriptsFactory=(()=>{var M=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Z=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,o)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let r of U(t))!Q.call(e,r)&&r!==n&&M(e,r,{get:()=>t[r],enumerable:!(o=K(t,r))||o.enumerable});return e};var J=e=>j(M({},\"__esModule\",{value:!0}),e);var Oe={};Z(Oe,{assignFilePayloadsToInputElement:()=>te,countCssMatchesPierce:()=>Me,countCssMatchesPrimary:()=>Ce,countTextMatches:()=>Le,countXPathMatchesMainWorld:()=>Pe,dispatchDomClick:()=>ne,ensureFileInputElement:()=>ee,fillElementValue:()=>se,focusElement:()=>le,isElementChecked:()=>ce,isElementVisible:()=>ae,prepareElementForTyping:()=>v,readElementInnerHTML:()=>me,readElementInnerText:()=>fe,readElementInputValue:()=>ue,readElementTextContent:()=>de,resolveCssSelector:()=>ve,resolveCssSelectorPierce:()=>Te,resolveTextSelector:()=>Re,resolveXPathMainWorld:()=>Ne,scrollElementToPercent:()=>oe,selectElementOptions:()=>ie,waitForSelector:()=>_e});function ee(){try{return(this.tagName?.toLowerCase()??\"\")!==\"input\"?!1:String(this.type??\"\").toLowerCase()===\"file\"}catch{return!1}}function te(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\"input\"||(t.type??\"\").toLowerCase()!==\"file\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\"upload.bin\",s=r.mimeType||\"application/octet-stream\",i=typeof r.lastModified==\"number\"?r.lastModified:Date.now(),a=window.atob(r.base64??\"\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\"input\",{bubbles:!0})),t.dispatchEvent(new Event(\"change\",{bubbles:!0})),!0}catch{return!1}}function ne(e){let t=e??{};try{let n=new MouseEvent(\"click\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\"number\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}function oe(e){let t=n=>{if(typeof n==\"number\"&&Number.isFinite(n))return n;let o=String(n??\"\").trim();if(!o)return 0;let r=parseFloat(o.replace(\"%\",\"\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\"\";if(r===\"html\"||r===\"body\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\"smooth\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\"smooth\"}),!0}catch{return!1}}var H=new Set([\"color\",\"date\",\"datetime-local\",\"month\",\"range\",\"time\",\"week\"]),re=new Set([\"\",\"email\",\"number\",\"password\",\"search\",\"tel\",\"text\",\"url\"]);function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\"function\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\"function\")return e.select(),!0}catch{}try{let o=(e.value??\"\").length;if(typeof e.setSelectionRange==\"function\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}function se(e){let t=this;if(!t.isConnected)return{status:\"error\",reason:\"notconnected\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\"\";try{let l=s=>{let i;if(typeof o.InputEvent==\"function\")try{i=new o.InputEvent(\"input\",{bubbles:!0,composed:!0,data:s,inputType:\"insertText\"})}catch{i=new o.Event(\"input\",{bubbles:!0,composed:!0})}else i=new o.Event(\"input\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\"change\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\"\").toLowerCase();if(!re.has(s)&&!H.has(s))return{status:\"error\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\"number\"){let a=e.trim();if(a!==\"\"&&Number.isNaN(Number(a)))return{status:\"error\",reason:\"invalid-number-value\"};i=a}if(r=i,H.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\"value\")?.set;return typeof c==\"function\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\"error\",reason:\"malformed-value\"}:(l(a),{status:\"done\"})}return v.call(t),{status:\"needsinput\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\"needsinput\",value:e}):t instanceof o.HTMLSelectElement?{status:\"error\",reason:\"unsupported-element\"}:t.isContentEditable?(v.call(t),r=e,{status:\"needsinput\",value:e}):{status:\"error\",reason:\"unsupported-element\"}}catch(l){let s=\"exception\";if(l&&typeof l==\"object\"){let i=l.message;typeof i==\"string\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\"needsinput\",value:r,reason:s}}}function le(){try{typeof this.focus==\"function\"&&this.focus()}catch{}}function ie(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\"\").trim())),o=s=>{let i=(s.label||s.textContent||\"\").trim(),a=String(s.value??\"\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\"input\",{bubbles:!0}),l=new Event(\"change\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}function ae(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\"none\"||t.visibility===\"hidden\")return!1;let n=parseFloat(t.opacity??\"1\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}function ce(){try{let e=this;if((e.tagName||\"\").toLowerCase()===\"input\"){let o=e.type?.toLowerCase()??\"\";if(o===\"checkbox\"||o===\"radio\")return!!e.checked}let n=e.getAttribute?.(\"aria-checked\");return n!=null?n===\"true\":!1}catch{return!1}}function ue(){try{let e=this,t=(e.tagName||\"\").toLowerCase();return t===\"input\"||t===\"textarea\"||t===\"select\"?String(e.value??\"\"):e.isContentEditable?String(e.textContent??\"\"):\"\"}catch{return\"\"}}function de(){try{return String(this.textContent??\"\")}catch{return\"\"}}function me(){try{return String(this.innerHTML??\"\")}catch{return\"\"}}function fe(){try{let e=this,t=e.innerText;if(typeof t==\"string\"&&t.length>0)return t;let n=e.textContent;return typeof n==\"string\"?n:\"\"}catch{return\"\"}}function O(e){let t=String(e||\"\").trim().replace(/^xpath=/i,\"\");if(!t)return[];let n=[],o=0;for(;o<t.length;){let r=\"child\";t.startsWith(\"//\",o)?(r=\"desc\",o+=2):t[o]===\"/\"&&(r=\"child\",o+=1);let l=o,s=0,i=null;for(;o<t.length;){let c=t[o];if(i)c===i&&(i=null);else if(c===\"'\"||c==='\"')i=c;else if(c===\"[\")s++;else if(c===\"]\")s--;else if(c===\"/\"&&s===0)break;o+=1}let a=t.slice(l,o).trim();if(!a)continue;let{tag:d,predicates:f}=pe(a);n.push({axis:r,tag:d,predicates:f})}return n}function he(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==\"[\"){n++;continue}n++;let o=n,r=null;for(;n<e.length;){let l=e[n];if(r)l===r&&(r=null);else if(l===\"'\"||l==='\"')r=l;else if(l===\"]\")break;n++}t.push(e.slice(o,n).trim()),n++}return t}function pe(e){let t=e.indexOf(\"[\");if(t===-1)return{tag:e===\"\"?\"*\":e.toLowerCase(),predicates:[]};let n=e.slice(0,t).trim(),o=n===\"\"?\"*\":n.toLowerCase(),r=e.slice(t),l=[];for(let s of he(r)){let i=T(s);i&&l.push(i)}return{tag:o,predicates:l}}function T(e){let t=e.trim();if(!t)return null;let n=A(t,\"or\");if(n.length>1){let l=n.map(s=>T(s)).filter(Boolean);return l.length!==n.length?null:{type:\"or\",predicates:l}}let o=A(t,\"and\");if(o.length>1){let l=o.map(s=>T(s)).filter(Boolean);return l.length!==o.length?null:{type:\"and\",predicates:l}}let r=we(t,\"not\");if(r!=null){let l=T(r);return l?{type:\"not\",predicate:l}:null}return ge(t)}function ge(e){let t=/^(?:'([^']*)'|\"([^\"]*)\")$/,n=\"[a-zA-Z_][\\\\w.-]*\",o=`(?:'([^']*)'|\"([^\"]*)\")`;if(/^\\d+$/.test(e))return{type:\"index\",index:Math.max(1,Number(e))};let r=e.match(new RegExp(`^normalize-space\\\\(\\\\s*@(${n})\\\\s*\\\\)\\\\s*=\\\\s*${o}$`));if(r)return{type:\"attrEquals\",name:r[1],value:r[2]??r[3]??\"\",normalize:!0};let l=e.match(new RegExp(`^normalize-space\\\\(\\\\s*(?:text\\\\(\\\\)|\\\\.)\\\\s*\\\\)\\\\s*=\\\\s*${o}$`));if(l)return{type:\"textEquals\",value:l[1]??l[2]??\"\",normalize:!0};let s=e.match(new RegExp(`^@(${n})\\\\s*=\\\\s*${o}$`));if(s)return{type:\"attrEquals\",name:s[1],value:s[2]??s[3]??\"\"};let i=e.match(new RegExp(`^@(${n})$`));if(i)return{type:\"attrExists\",name:i[1]};let a=e.match(new RegExp(`^contains\\\\(\\\\s*@(${n})\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));if(a)return{type:\"attrContains\",name:a[1],value:a[2]??a[3]??\"\"};let d=e.match(new RegExp(`^starts-with\\\\(\\\\s*@(${n})\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));if(d)return{type:\"attrStartsWith\",name:d[1],value:d[2]??d[3]??\"\"};let f=e.match(new RegExp(`^(?:text\\\\(\\\\)|\\\\.)\\\\s*=\\\\s*${o}$`));if(f)return{type:\"textEquals\",value:f[1]??f[2]??\"\"};let c=e.match(new RegExp(`^contains\\\\(\\\\s*(?:text\\\\(\\\\)|\\\\.)\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));return c?{type:\"textContains\",value:c[1]??c[2]??\"\"}:(t.test(e),null)}function A(e,t){let n=[],o=0,r=0,l=null,s=0;for(;s<e.length;){let i=e[s];if(l){i===l&&(l=null),s+=1;continue}if(i===\"'\"||i==='\"'){l=i,s+=1;continue}if(i===\"(\"){r+=1,s+=1;continue}if(i===\")\"){r=Math.max(0,r-1),s+=1;continue}if(r===0&&Ee(e,s,t)){n.push(e.slice(o,s).trim()),s+=t.length,o=s;continue}s+=1}return n.push(e.slice(o).trim()),n.filter(i=>i.length>0)}function Ee(e,t,n){if(!e.startsWith(n,t))return!1;let o=t>0?e[t-1]:\" \";if(o===\"@\")return!1;let r=t+n.length<e.length?e[t+n.length]:\" \";return W(o)&&W(r)}function W(e){return!/[a-zA-Z0-9_.-]/.test(e)}function we(e,t){let n=`${t}(`;if(!e.startsWith(n)||!e.endsWith(\")\"))return null;let o=e.slice(n.length,-1);return ye(o)?o:null}function ye(e){let t=0,n=null;for(let o=0;o<e.length;o+=1){let r=e[o];if(n){r===n&&(n=null);continue}if(r===\"'\"||r==='\"'){n=r;continue}if(r===\"(\"?t+=1:r===\")\"&&(t-=1),t<0)return!1}return t===0}var be=e=>e.replace(/\\s+/g,\" \").trim();function _(e){return String(e.textContent??\"\")}function S(e,t){return t?be(e):e}function R(e,t){switch(t.type){case\"and\":return t.predicates.every(n=>R(e,n));case\"or\":return t.predicates.some(n=>R(e,n));case\"not\":return!R(e,t.predicate);case\"attrExists\":return e.getAttribute(t.name)!==null;case\"attrEquals\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize)===S(t.value,t.normalize)}case\"attrContains\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).includes(S(t.value,t.normalize))}case\"attrStartsWith\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).startsWith(S(t.value,t.normalize))}case\"textEquals\":return S(_(e),t.normalize)===S(t.value,t.normalize);case\"textContains\":return S(_(e),t.normalize).includes(S(t.value,t.normalize));case\"index\":return!0;default:return!0}}function q(e,t){let n=e;for(let o of t){if(!n.length)return[];if(o.type===\"index\"){let r=o.index-1;n=r>=0&&r<n.length?[n[r]]:[];continue}n=n.filter(r=>R(r,o))}return n}var P=e=>{let t=String(e??\"\").trim();return t?t.replace(/^xpath=/i,\"\").trim():\"\"};function I(e,t){return k(e,0,t)}function k(e,t,n){if(!Number.isFinite(t)||t<0)return null;let o=P(e);if(!o)return null;let r=Math.floor(t),l=n?.pierceShadow!==!1,s=l?z():null;if(!l)return X(o,r).value;if(!s?.hasShadow){let a=X(o,r);return a.error?N(o,s?.getClosedRoot)[r]??null:a.value}return N(o,s.getClosedRoot)[r]??null}function $(e,t){let n=P(e);if(!n)return 0;let o=t?.pierceShadow!==!1,r=o?z():null;if(!o)return F(n).count;if(!r?.hasShadow){let l=F(n);return l.error?N(n,r?.getClosedRoot).length:l.count}return N(n,r.getClosedRoot).length}function N(e,t){let n=P(e);if(!n)return[];let o=O(n);if(!o.length)return[];let r=t??null,l=[document];for(let s of o){let i=[],a=new Set;for(let d of l){if(!d)continue;let f=s.axis===\"child\"?L(d,r):Se(d,r);if(!f.length)continue;let c=f.filter(g=>xe(g,s)),p=q(c,s.predicates);for(let g of p)a.has(g)||(a.add(g),i.push(g))}if(!i.length)return[];l=i}return l}function xe(e,t){return t.tag===\"*\"?!0:e.localName===t.tag}function z(){let e=window.__stagehandV3__,t=e&&typeof e.getClosedRoot==\"function\"?o=>{try{return e.getClosedRoot(o)??null}catch{return null}}:null,n=!1;try{if(e&&typeof e.stats==\"function\"){let o=e.stats();n=(o?.open??0)>0||(o?.closed??0)>0}}catch{}if(!n)try{let o=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;o.nextNode();)if(o.currentNode.shadowRoot){n=!0;break}}catch{}return{getClosedRoot:t,hasShadow:n}}function L(e,t){let n=[];if(!e)return n;if(e instanceof Document)return e.documentElement&&n.push(e.documentElement),n;if(e instanceof ShadowRoot||e instanceof DocumentFragment)return n.push(...Array.from(e.children??[])),n;if(e instanceof Element){n.push(...Array.from(e.children??[]));let o=e.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),t){let r=t(e);r&&n.push(...Array.from(r.children??[]))}return n}return n}function Se(e,t){let n=[],o=new Set,r=[...L(e,t)].reverse();for(;r.length;){let l=r.pop();if(!l||o.has(l))continue;o.add(l),n.push(l);let s=L(l,t);for(let i=s.length-1;i>=0;i-=1)r.push(s[i])}return n}function X(e,t){try{return{value:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(t),error:!1}}catch{return{value:null,error:!0}}}function F(e){try{return{count:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength,error:!1}}catch{return{count:0,error:!0}}}var C=e=>{let t=Number(e??0);return!Number.isFinite(t)||t<0?0:Math.floor(t)},V=(e,t)=>{if(!e)return[];let n=new WeakSet,o=new Set,r=[],l=[document],s=i=>{if(!(!i||n.has(i)||r.length>=t)){n.add(i);try{let a=i.querySelectorAll(e);for(let d of a)if(!o.has(d)&&(o.add(d),r.push(d),r.length>=t))return}catch{}try{let d=(i instanceof Document?i:i.host?.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),f;for(;f=d.nextNode();){if(!(f instanceof Element))continue;let c=f.shadowRoot;c&&l.push(c)}}catch{}}};for(;l.length&&r.length<t;){let i=l.shift();i&&s(i)}return r};function ve(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t);return V(n,o+1)[o]??null}function Te(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\"function\")return V(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}function Re(e,t){let n=String(e??\"\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\"\";return l.has(h)},i=u=>{try{if(s(u))return\"\";let h=u.innerText;if(typeof h==\"string\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\"string\")return h.trim()}catch{}return\"\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\"function\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\"\",id:u.id??\"\",className:u.className??\"\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\"\",id:E.id??\"\",className:E.className??\"\",text:i(E)});let b=E.shadowRoot;b&&w(b);let D=f(E);D&&w(D)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}function Ne(e,t){let n=C(t);return k(e,n,{pierceShadow:!0})}function Ce(e){let t=String(e??\"\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\"function\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}function Me(e){let t=String(e??\"\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\"function\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\"function\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}function Le(e){let t=String(e??\"\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\"\";return o.has(u)},l=m=>{try{if(r(m))return\"\";let u=m.innerText;if(typeof u==\"string\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\"string\")return u.trim()}catch{}return\"\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\"function\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\"\",id:m.id??\"\",className:m.className??\"\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\"\",id:h.id??\"\",className:h.className??\"\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}function Pe(e){return $(e,{pierceShadow:!0})}var ke=e=>e.startsWith(\"xpath=\")||e.startsWith(\"/\"),De=e=>{try{let t=window.__stagehandV3__;if(t&&typeof t.getClosedRoot==\"function\")return t.getClosedRoot(e)??null}catch{}return null},Y=e=>e.shadowRoot?e.shadowRoot:De(e),He=(e,t,n)=>{try{let l=e.querySelector(t);if(l)return l}catch{}if(!n)return null;let o=new WeakSet,r=[e];for(;r.length>0;){let l=r.shift();if(!(!l||o.has(l))){o.add(l);try{let s=l.querySelector(t);if(s)return s}catch{}try{let i=(l instanceof Document?l:l.host?.ownerDocument??document).createTreeWalker(l,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();){if(!(a instanceof Element))continue;let d=Y(a);d&&!o.has(d)&&r.push(d)}}catch{}}}return null},Ae=(e,t)=>I(e,{pierceShadow:t}),B=(e,t)=>ke(e)?Ae(e,t):He(document,e,t),G=(e,t)=>{if(t===\"detached\")return e===null;if(t===\"attached\")return e!==null;if(e===null)return!1;if(t===\"hidden\")try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display===\"none\"||n.visibility===\"hidden\"||n.opacity===\"0\"||o.width===0||o.height===0}catch{return!1}try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display!==\"none\"&&n.visibility!==\"hidden\"&&n.opacity!==\"0\"&&o.width>0&&o.height>0}catch{return!1}},We=(e,t)=>{let n=new WeakSet,o=l=>{let s=Y(l);if(s&&!n.has(s)){n.add(s);let i=new MutationObserver(e);i.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),t.push(i);for(let a of Array.from(s.children))o(a)}for(let i of Array.from(l.children))o(i)},r=document.documentElement||document.body;r&&o(r)};function _e(e,t,n,o){let r=String(e??\"\").trim(),l=String(t??\"visible\")||\"visible\",s=typeof n==\"number\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=B(r,i);if(G(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\"DOMContentLoaded\",c),c=null)},m=()=>{if(p)return;let E=B(r,i);G(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\"DOMContentLoaded\",c),c=null,m(),h()},document.addEventListener(\"DOMContentLoaded\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),x.push(b),i&&We(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s)})}return J(Oe);})();\n globalThis.__stagehandLocatorScripts = __stagehandLocatorScriptsFactory;\n}";
|
|
2
|
+
export declare const locatorScriptSources: {
|
|
3
|
+
readonly assignFilePayloadsToInputElement: "function ce(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\"input\"||(t.type??\"\").toLowerCase()!==\"file\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\"upload.bin\",s=r.mimeType||\"application/octet-stream\",i=typeof r.lastModified==\"number\"?r.lastModified:Date.now(),a=window.atob(r.base64??\"\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\"input\",{bubbles:!0})),t.dispatchEvent(new Event(\"change\",{bubbles:!0})),!0}catch{return!1}}";
|
|
4
|
+
readonly countCssMatchesPierce: "function He(e){let t=String(e??\"\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\"function\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\"function\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}";
|
|
5
|
+
readonly countCssMatchesPrimary: "function De(e){let t=String(e??\"\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\"function\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}";
|
|
6
|
+
readonly countTextMatches: "function Ae(e){let t=String(e??\"\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\"\";return o.has(u)},l=m=>{try{if(r(m))return\"\";let u=m.innerText;if(typeof u==\"string\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\"string\")return u.trim()}catch{}return\"\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\"function\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\"\",id:m.id??\"\",className:m.className??\"\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\"\",id:h.id??\"\",className:h.className??\"\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}";
|
|
7
|
+
readonly countXPathMatchesMainWorld: "function We(e){return I(e,{pierceShadow:!0})}";
|
|
8
|
+
readonly dispatchDomClick: "function ue(e){let t=e??{};try{let n=new MouseEvent(\"click\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\"number\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}";
|
|
9
|
+
readonly ensureFileInputElement: "function ae(){try{return(this.tagName?.toLowerCase()??\"\")!==\"input\"?!1:String(this.type??\"\").toLowerCase()===\"file\"}catch{return!1}}";
|
|
10
|
+
readonly fillElementValue: "function me(e){let t=this;if(!t.isConnected)return{status:\"error\",reason:\"notconnected\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\"\";try{let l=s=>{let i;if(typeof o.InputEvent==\"function\")try{i=new o.InputEvent(\"input\",{bubbles:!0,composed:!0,data:s,inputType:\"insertText\"})}catch{i=new o.Event(\"input\",{bubbles:!0,composed:!0})}else i=new o.Event(\"input\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\"change\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\"\").toLowerCase();if(!Y.has(s)&&!D.has(s))return{status:\"error\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\"number\"){let a=e.trim();if(a!==\"\"&&Number.isNaN(Number(a)))return{status:\"error\",reason:\"invalid-number-value\"};i=a}if(r=i,D.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\"value\")?.set;return typeof c==\"function\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\"error\",reason:\"malformed-value\"}:(l(a),{status:\"done\"})}return v.call(t),{status:\"needsinput\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\"needsinput\",value:e}):t instanceof o.HTMLSelectElement?{status:\"error\",reason:\"unsupported-element\"}:t.isContentEditable?(v.call(t),r=e,{status:\"needsinput\",value:e}):{status:\"error\",reason:\"unsupported-element\"}}catch(l){let s=\"exception\";if(l&&typeof l==\"object\"){let i=l.message;typeof i==\"string\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\"needsinput\",value:r,reason:s}}}";
|
|
11
|
+
readonly focusElement: "function fe(){try{typeof this.focus==\"function\"&&this.focus()}catch{}}";
|
|
12
|
+
readonly isElementChecked: "function ge(){try{let e=this;if((e.tagName||\"\").toLowerCase()===\"input\"){let o=e.type?.toLowerCase()??\"\";if(o===\"checkbox\"||o===\"radio\")return!!e.checked}let n=e.getAttribute?.(\"aria-checked\");return n!=null?n===\"true\":!1}catch{return!1}}";
|
|
13
|
+
readonly isElementVisible: "function pe(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\"none\"||t.visibility===\"hidden\")return!1;let n=parseFloat(t.opacity??\"1\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}";
|
|
14
|
+
readonly prepareElementForTyping: "function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\"function\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\"function\")return e.select(),!0}catch{}try{let o=(e.value??\"\").length;if(typeof e.setSelectionRange==\"function\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}";
|
|
15
|
+
readonly readElementInnerHTML: "function ye(){try{return String(this.innerHTML??\"\")}catch{return\"\"}}";
|
|
16
|
+
readonly readElementInnerText: "function be(){try{let e=this,t=e.innerText;if(typeof t==\"string\"&&t.length>0)return t;let n=e.textContent;return typeof n==\"string\"?n:\"\"}catch{return\"\"}}";
|
|
17
|
+
readonly readElementInputValue: "function Ee(){try{let e=this,t=(e.tagName||\"\").toLowerCase();return t===\"input\"||t===\"textarea\"||t===\"select\"?String(e.value??\"\"):e.isContentEditable?String(e.textContent??\"\"):\"\"}catch{return\"\"}}";
|
|
18
|
+
readonly readElementTextContent: "function we(){try{return String(this.textContent??\"\")}catch{return\"\"}}";
|
|
19
|
+
readonly resolveCssSelector: "function Ne(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t);return z(n,o+1)[o]??null}";
|
|
20
|
+
readonly resolveCssSelectorPierce: "function Ce(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\"function\")return z(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}";
|
|
21
|
+
readonly resolveTextSelector: "function Me(e,t){let n=String(e??\"\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\"\";return l.has(h)},i=u=>{try{if(s(u))return\"\";let h=u.innerText;if(typeof h==\"string\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\"string\")return h.trim()}catch{}return\"\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\"function\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\"\",id:u.id??\"\",className:u.className??\"\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\"\",id:E.id??\"\",className:E.className??\"\",text:i(E)});let b=E.shadowRoot;b&&w(b);let k=f(E);k&&w(k)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}";
|
|
22
|
+
readonly resolveXPathMainWorld: "function Le(e,t){let n=C(t);return P(e,n,{pierceShadow:!0})}";
|
|
23
|
+
readonly scrollElementToPercent: "function de(e){let t=n=>{if(typeof n==\"number\"&&Number.isFinite(n))return n;let o=String(n??\"\").trim();if(!o)return 0;let r=parseFloat(o.replace(\"%\",\"\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\"\";if(r===\"html\"||r===\"body\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\"smooth\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\"smooth\"}),!0}catch{return!1}}";
|
|
24
|
+
readonly selectElementOptions: "function he(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\"\").trim())),o=s=>{let i=(s.label||s.textContent||\"\").trim(),a=String(s.value??\"\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\"input\",{bubbles:!0}),l=new Event(\"change\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}";
|
|
25
|
+
readonly waitForSelector: "function qe(e,t,n,o){let r=String(e??\"\").trim(),l=String(t??\"visible\")||\"visible\",s=typeof n==\"number\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=V(r,i);if(B(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\"DOMContentLoaded\",c),c=null)},m=()=>{if(p)return;let E=V(r,i);B(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\"DOMContentLoaded\",c),c=null,m(),h()},document.addEventListener(\"DOMContentLoaded\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),x.push(b),i&&ie(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s)})}";
|
|
26
|
+
};
|
|
27
|
+
export declare const locatorScriptGlobalRefs: {
|
|
28
|
+
readonly assignFilePayloadsToInputElement: "globalThis.__stagehandLocatorScripts.assignFilePayloadsToInputElement";
|
|
29
|
+
readonly countCssMatchesPierce: "globalThis.__stagehandLocatorScripts.countCssMatchesPierce";
|
|
30
|
+
readonly countCssMatchesPrimary: "globalThis.__stagehandLocatorScripts.countCssMatchesPrimary";
|
|
31
|
+
readonly countTextMatches: "globalThis.__stagehandLocatorScripts.countTextMatches";
|
|
32
|
+
readonly countXPathMatchesMainWorld: "globalThis.__stagehandLocatorScripts.countXPathMatchesMainWorld";
|
|
33
|
+
readonly dispatchDomClick: "globalThis.__stagehandLocatorScripts.dispatchDomClick";
|
|
34
|
+
readonly ensureFileInputElement: "globalThis.__stagehandLocatorScripts.ensureFileInputElement";
|
|
35
|
+
readonly fillElementValue: "globalThis.__stagehandLocatorScripts.fillElementValue";
|
|
36
|
+
readonly focusElement: "globalThis.__stagehandLocatorScripts.focusElement";
|
|
37
|
+
readonly isElementChecked: "globalThis.__stagehandLocatorScripts.isElementChecked";
|
|
38
|
+
readonly isElementVisible: "globalThis.__stagehandLocatorScripts.isElementVisible";
|
|
39
|
+
readonly prepareElementForTyping: "globalThis.__stagehandLocatorScripts.prepareElementForTyping";
|
|
40
|
+
readonly readElementInnerHTML: "globalThis.__stagehandLocatorScripts.readElementInnerHTML";
|
|
41
|
+
readonly readElementInnerText: "globalThis.__stagehandLocatorScripts.readElementInnerText";
|
|
42
|
+
readonly readElementInputValue: "globalThis.__stagehandLocatorScripts.readElementInputValue";
|
|
43
|
+
readonly readElementTextContent: "globalThis.__stagehandLocatorScripts.readElementTextContent";
|
|
44
|
+
readonly resolveCssSelector: "globalThis.__stagehandLocatorScripts.resolveCssSelector";
|
|
45
|
+
readonly resolveCssSelectorPierce: "globalThis.__stagehandLocatorScripts.resolveCssSelectorPierce";
|
|
46
|
+
readonly resolveTextSelector: "globalThis.__stagehandLocatorScripts.resolveTextSelector";
|
|
47
|
+
readonly resolveXPathMainWorld: "globalThis.__stagehandLocatorScripts.resolveXPathMainWorld";
|
|
48
|
+
readonly scrollElementToPercent: "globalThis.__stagehandLocatorScripts.scrollElementToPercent";
|
|
49
|
+
readonly selectElementOptions: "globalThis.__stagehandLocatorScripts.selectElementOptions";
|
|
50
|
+
readonly waitForSelector: "globalThis.__stagehandLocatorScripts.waitForSelector";
|
|
51
|
+
};
|
|
52
|
+
export type LocatorScriptName = keyof typeof locatorScriptSources;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const reRenderScriptContent = "(()=>{function s(){try{let o=window.__stagehandV3__;if(!o||typeof o.getClosedRoot!=\"function\")return;let t=[],r=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let e=r.currentNode,n=e.tagName?.toLowerCase()??\"\";if(!n.includes(\"-\")||typeof customElements?.get!=\"function\"||!customElements.get(n))continue;let c=!!e.shadowRoot,i=!!o.getClosedRoot(e);c||i||t.push(e)}for(let e of t)try{let n=e.cloneNode(!0);e.replaceWith(n)}catch{}o.stats&&t.length&&console.info(\"[v3-piercer] rerender\",{count:t.length})}catch(o){console.info(\"[v3-piercer] rerender error\",{message:String(o??\"\")})}}s();})();\n";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{function s(){try{let o=window.__stagehandV3__;if(!o||typeof o.getClosedRoot!="function")return;let t=[],r=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let e=r.currentNode,n=e.tagName?.toLowerCase()??"";if(!n.includes("-")||typeof customElements?.get!="function"||!customElements.get(n))continue;let c=!!e.shadowRoot,i=!!o.getClosedRoot(e);c||i||t.push(e)}for(let e of t)try{let n=e.cloneNode(!0);e.replaceWith(n)}catch{}o.stats&&t.length&&console.info("[v3-piercer] rerender",{count:t.length})}catch(o){console.info("[v3-piercer] rerender error",{message:String(o??"")})}}s();})();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const screenshotScriptSources: {
|
|
2
|
+
readonly resolveMaskRect: "function h(r){function u(t,e){try{return t&&typeof t.closest==\"function\"?t.closest(e):null}catch{return null}}function s(t,e){try{return!!t&&typeof t.matches==\"function\"&&t.matches(e)}catch{return!1}}function c(t){let e=u(t,\"dialog[open]\");if(e)return e;let l=u(t,\"[popover]\");return l&&s(l,\":popover-open\")?l:null}if(!this||typeof this.getBoundingClientRect!=\"function\")return null;let n=this.getBoundingClientRect();if(!n)return null;let i=window.getComputedStyle(this);if(!i||i.visibility===\"hidden\"||i.display===\"none\"||n.width<=0||n.height<=0)return null;let o=c(this);if(o){let t=o.getBoundingClientRect();if(!t)return null;let e=null;if(r)try{let l=o.getAttribute(\"data-stagehand-mask-root\");l&&l.startsWith(r)?e=l:(e=r+\"_root_\"+Math.random().toString(36).slice(2),o.setAttribute(\"data-stagehand-mask-root\",e))}catch{e=null}return{x:n.left-t.left-(o.clientLeft||0)+(o.scrollLeft||0),y:n.top-t.top-(o.clientTop||0)+(o.scrollTop||0),width:n.width,height:n.height,rootToken:e}}return{x:n.left+window.scrollX,y:n.top+window.scrollY,width:n.width,height:n.height,rootToken:null}}";
|
|
3
|
+
};
|
|
4
|
+
export type ScreenshotScriptName = keyof typeof screenshotScriptSources;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const v3ScriptContent = "(()=>{function s(c={}){let r=e=>{let{hostToRoot:o}=e;window.__stagehandV3__={getClosedRoot:a=>o.get(a),stats:()=>({installed:!0,url:location.href,isTop:window.top===window,open:e.openCount,closed:e.closedCount})}},n=Element.prototype.attachShadow;if(n.__v3Patched&&n.__v3State){n.__v3State.debug=!0,r(n.__v3State);return}let t={hostToRoot:new WeakMap,openCount:0,closedCount:0,debug:!0},l=n,d=function(e){let o=e?.mode??\"open\",a=l.call(this,e);try{t.hostToRoot.set(this,a),o===\"closed\"?t.closedCount++:t.openCount++,t.debug&&console.info(\"[v3-piercer] attachShadow\",{tag:this.tagName?.toLowerCase()??\"\",mode:o,url:location.href})}catch{}return a};if(d.__v3Patched=!0,d.__v3State=t,Object.defineProperty(Element.prototype,\"attachShadow\",{configurable:!0,writable:!0,value:d}),c.tagExisting)try{let e=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let o=e.currentNode;o.shadowRoot&&(t.hostToRoot.set(o,o.shadowRoot),t.openCount++)}}catch{}window.__stagehandV3Injected=!0,r(t),t.debug&&console.info(\"[v3-piercer] installed\",{url:location.href,isTop:window.top===window,readyState:document.readyState})}s({debug:!0,tagExisting:!1});})();\n";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{function s(c={}){let r=e=>{let{hostToRoot:o}=e;window.__stagehandV3__={getClosedRoot:a=>o.get(a),stats:()=>({installed:!0,url:location.href,isTop:window.top===window,open:e.openCount,closed:e.closedCount})}},n=Element.prototype.attachShadow;if(n.__v3Patched&&n.__v3State){n.__v3State.debug=!0,r(n.__v3State);return}let t={hostToRoot:new WeakMap,openCount:0,closedCount:0,debug:!0},l=n,d=function(e){let o=e?.mode??"open",a=l.call(this,e);try{t.hostToRoot.set(this,a),o==="closed"?t.closedCount++:t.openCount++,t.debug&&console.info("[v3-piercer] attachShadow",{tag:this.tagName?.toLowerCase()??"",mode:o,url:location.href})}catch{}return a};if(d.__v3Patched=!0,d.__v3State=t,Object.defineProperty(Element.prototype,"attachShadow",{configurable:!0,writable:!0,value:d}),c.tagExisting)try{let e=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let o=e.currentNode;o.shadowRoot&&(t.hostToRoot.set(o,o.shadowRoot),t.openCount++)}}catch{}window.__stagehandV3Injected=!0,r(t),t.debug&&console.info("[v3-piercer] installed",{url:location.href,isTop:window.top===window,readyState:document.readyState})}s({debug:!0,tagExisting:!1});})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./piercer.runtime.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TextMatchSample {
|
|
2
|
+
tag: string;
|
|
3
|
+
id: string;
|
|
4
|
+
class: string;
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TextMatchResult {
|
|
8
|
+
count: number;
|
|
9
|
+
sample: TextMatchSample[];
|
|
10
|
+
error: null;
|
|
11
|
+
}
|
|
12
|
+
export declare function countCssMatchesPrimary(selectorRaw: string): number;
|
|
13
|
+
export declare function countCssMatchesPierce(selectorRaw: string): number;
|
|
14
|
+
export declare function countTextMatches(rawNeedle: string): TextMatchResult;
|
|
15
|
+
export declare function countXPathMatchesMainWorld(rawXp: string): number;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface ClickEventOptions {
|
|
2
|
+
bubbles?: boolean;
|
|
3
|
+
cancelable?: boolean;
|
|
4
|
+
composed?: boolean;
|
|
5
|
+
detail?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function ensureFileInputElement(this: Element): boolean;
|
|
8
|
+
export interface SerializedFilePayload {
|
|
9
|
+
name: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
base64: string;
|
|
12
|
+
lastModified?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Attach File objects created from serialized payloads to an <input type="file">. */
|
|
15
|
+
export declare function assignFilePayloadsToInputElement(this: Element, payloads: SerializedFilePayload[]): boolean;
|
|
16
|
+
export declare function dispatchDomClick(this: Element, options?: ClickEventOptions): void;
|
|
17
|
+
export declare function scrollElementToPercent(this: Element, percent: number | string): boolean;
|
|
18
|
+
export type FillElementResult = {
|
|
19
|
+
status: "done";
|
|
20
|
+
} | {
|
|
21
|
+
status: "needsinput";
|
|
22
|
+
value: string;
|
|
23
|
+
reason?: string;
|
|
24
|
+
} | {
|
|
25
|
+
status: "error";
|
|
26
|
+
reason: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function prepareElementForTyping(this: Element): boolean;
|
|
29
|
+
export declare function fillElementValue(this: Element, rawValue: string): FillElementResult;
|
|
30
|
+
export declare function focusElement(this: Element): void;
|
|
31
|
+
export declare function selectElementOptions(this: Element, rawValues: string | string[]): string[];
|
|
32
|
+
export declare function isElementVisible(this: Element): boolean;
|
|
33
|
+
export declare function isElementChecked(this: Element): boolean;
|
|
34
|
+
export declare function readElementInputValue(this: Element): string;
|
|
35
|
+
export declare function readElementTextContent(this: Element): string;
|
|
36
|
+
export declare function readElementInnerHTML(this: Element): string;
|
|
37
|
+
export declare function readElementInnerText(this: Element): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function resolveCssSelector(selectorRaw: string, targetIndexRaw?: number): Element | null;
|
|
2
|
+
export declare function resolveCssSelectorPierce(selectorRaw: string, targetIndexRaw?: number): Element | null;
|
|
3
|
+
export declare function resolveTextSelector(rawNeedle: string, targetIndexRaw?: number): Element | null;
|
|
4
|
+
export declare function resolveXPathMainWorld(rawXp: string, targetIndexRaw?: number): Element | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* waitForSelector - Waits for an element matching a selector to reach a specific state.
|
|
3
|
+
* Supports both CSS selectors and XPath expressions.
|
|
4
|
+
* Uses MutationObserver for efficiency and integrates with the V3 piercer for closed shadow roots.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: This function runs inside the page context. Keep it dependency-free
|
|
7
|
+
* and resilient to exceptions.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Wait for an element matching the selector to reach the specified state.
|
|
11
|
+
* Supports both CSS selectors and XPath expressions (prefix with "xpath=" or start with "/").
|
|
12
|
+
*
|
|
13
|
+
* @param selectorRaw - CSS selector or XPath expression to wait for
|
|
14
|
+
* @param stateRaw - Element state: 'attached' | 'detached' | 'visible' | 'hidden'
|
|
15
|
+
* @param timeoutRaw - Maximum time to wait in milliseconds
|
|
16
|
+
* @param pierceShadowRaw - Whether to search inside shadow DOM
|
|
17
|
+
* @returns Promise that resolves to true when condition is met, or rejects on timeout
|
|
18
|
+
*/
|
|
19
|
+
export declare function waitForSelector(selectorRaw: string, stateRaw?: string, timeoutRaw?: number, pierceShadowRaw?: boolean): Promise<boolean>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export type XPathPredicate = {
|
|
2
|
+
type: "index";
|
|
3
|
+
index: number;
|
|
4
|
+
} | {
|
|
5
|
+
type: "attrEquals";
|
|
6
|
+
name: string;
|
|
7
|
+
value: string;
|
|
8
|
+
normalize?: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
type: "attrExists";
|
|
11
|
+
name: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "attrContains";
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
normalize?: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
type: "attrStartsWith";
|
|
19
|
+
name: string;
|
|
20
|
+
value: string;
|
|
21
|
+
normalize?: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
type: "textEquals";
|
|
24
|
+
value: string;
|
|
25
|
+
normalize?: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
type: "textContains";
|
|
28
|
+
value: string;
|
|
29
|
+
normalize?: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
type: "and";
|
|
32
|
+
predicates: XPathPredicate[];
|
|
33
|
+
} | {
|
|
34
|
+
type: "or";
|
|
35
|
+
predicates: XPathPredicate[];
|
|
36
|
+
} | {
|
|
37
|
+
type: "not";
|
|
38
|
+
predicate: XPathPredicate;
|
|
39
|
+
};
|
|
40
|
+
export interface XPathStep {
|
|
41
|
+
axis: "child" | "desc";
|
|
42
|
+
tag: string;
|
|
43
|
+
predicates: XPathPredicate[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parse an XPath expression into a list of traversal steps.
|
|
47
|
+
*
|
|
48
|
+
* This is a subset parser designed for composed DOM traversal (including
|
|
49
|
+
* shadow roots). It intentionally does not implement the full XPath spec.
|
|
50
|
+
*
|
|
51
|
+
* Supported:
|
|
52
|
+
* - Child (`/`) and descendant (`//`) axes
|
|
53
|
+
* - Tag names and wildcard (`*`)
|
|
54
|
+
* - Positional indices (`[n]`)
|
|
55
|
+
* - Attribute equality predicates (`[@attr='value']`, `[@attr="value"]`)
|
|
56
|
+
* - Attribute existence (`[@attr]`)
|
|
57
|
+
* - Attribute contains/starts-with (`contains(@attr,'v')`, `starts-with(@attr,'v')`)
|
|
58
|
+
* - Text equality/contains (`[text()='v']`, `[contains(text(),'v')]`, `[.='v']`)
|
|
59
|
+
* - normalize-space on text/attributes (`[normalize-space(text())='v']`)
|
|
60
|
+
* - Basic boolean predicates (`and`, `or`, `not(...)`)
|
|
61
|
+
* - Multiple predicates per step (`[@class='foo'][2]`)
|
|
62
|
+
* - Optional `xpath=` prefix
|
|
63
|
+
*
|
|
64
|
+
* Not supported:
|
|
65
|
+
* - Position functions (`[position() > n]`, `[last()]`)
|
|
66
|
+
* - Axes beyond child/descendant (`ancestor::`, `parent::`, `self::`,
|
|
67
|
+
* `preceding-sibling::`, `following-sibling::`)
|
|
68
|
+
* - Union operator (`|`)
|
|
69
|
+
* - Grouped expressions (`(//div)[n]`)
|
|
70
|
+
*
|
|
71
|
+
* Unsupported predicates are silently ignored — the step still matches
|
|
72
|
+
* by tag name, but the unrecognized predicate has no filtering effect.
|
|
73
|
+
*/
|
|
74
|
+
export declare function parseXPathSteps(input: string): XPathStep[];
|
|
75
|
+
export declare function evaluatePredicate(element: Element, predicate: XPathPredicate): boolean;
|
|
76
|
+
export declare function applyPredicates(elements: Element[], predicates: XPathPredicate[]): Element[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type ClosedRootGetter = (host: Element) => ShadowRoot | null;
|
|
2
|
+
export type XPathResolveOptions = {
|
|
3
|
+
pierceShadow?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function resolveXPathFirst(rawXp: string, options?: XPathResolveOptions): Element | null;
|
|
6
|
+
export declare function resolveXPathAtIndex(rawXp: string, index: number, options?: XPathResolveOptions): Element | null;
|
|
7
|
+
export declare function countXPathMatches(rawXp: string, options?: XPathResolveOptions): number;
|
|
8
|
+
export declare function resolveXPathComposedMatches(rawXp: string, getClosedRoot?: ClosedRootGetter | null): Element[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface V3ShadowPatchOptions {
|
|
2
|
+
debug?: boolean;
|
|
3
|
+
tagExisting?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface StagehandV3Backdoor {
|
|
6
|
+
/** Closed shadow-root accessors */
|
|
7
|
+
getClosedRoot(host: Element): ShadowRoot | undefined;
|
|
8
|
+
/** Stats + quick health check */
|
|
9
|
+
stats(): {
|
|
10
|
+
installed: true;
|
|
11
|
+
url: string;
|
|
12
|
+
isTop: boolean;
|
|
13
|
+
open: number;
|
|
14
|
+
closed: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
__stagehandV3Injected?: boolean;
|
|
20
|
+
__stagehandV3__?: StagehandV3Backdoor;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare function installV3ShadowPiercer(opts?: V3ShadowPatchOptions): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function rerenderMissingShadowHosts(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolveMaskRect } from "./resolveMaskRect.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LanguageModelV2 } from "@ai-sdk/provider";
|
|
2
|
+
import { CreateChatCompletionOptions, LLMClient } from "../llm/LLMClient.js";
|
|
3
|
+
import { ChatCompletion } from "openai/resources";
|
|
4
|
+
export declare class AISdkClient extends LLMClient {
|
|
5
|
+
type: "aisdk";
|
|
6
|
+
private model;
|
|
7
|
+
constructor({ model }: {
|
|
8
|
+
model: LanguageModelV2;
|
|
9
|
+
});
|
|
10
|
+
createChatCompletion<T = ChatCompletion>({ options, }: CreateChatCompletionOptions): Promise<T>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Welcome to the Stagehand custom OpenAI client!
|
|
3
|
+
*
|
|
4
|
+
* This is a client for models that are compatible with the OpenAI API, like Ollama, Gemini, etc.
|
|
5
|
+
* You can just pass in an OpenAI instance to the client and it will work.
|
|
6
|
+
*/
|
|
7
|
+
import { CreateChatCompletionOptions, LLMClient } from "../llm/LLMClient.js";
|
|
8
|
+
import OpenAI from "openai";
|
|
9
|
+
import type { ChatCompletion } from "openai/resources/chat/completions";
|
|
10
|
+
export declare class CustomOpenAIClient extends LLMClient {
|
|
11
|
+
type: "openai";
|
|
12
|
+
private client;
|
|
13
|
+
constructor({ modelName, client }: {
|
|
14
|
+
modelName: string;
|
|
15
|
+
client: OpenAI;
|
|
16
|
+
});
|
|
17
|
+
createChatCompletion<T = ChatCompletion>({ options, retries, logger, }: CreateChatCompletionOptions): Promise<T>;
|
|
18
|
+
}
|