@browserbasehq/orca 3.1.0-patch.0 → 3.1.0-patch.2

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.
Files changed (358) hide show
  1. package/dist/cjs/cli.js +183 -0
  2. package/dist/cjs/cli.js.map +7 -0
  3. package/dist/cjs/index.d.ts +1 -0
  4. package/dist/cjs/index.js +24956 -0
  5. package/dist/cjs/index.js.map +7 -0
  6. package/dist/cjs/lib/inference.d.ts +65 -0
  7. package/dist/cjs/lib/inferenceLogUtils.d.ts +12 -0
  8. package/dist/cjs/lib/logger.d.ts +69 -0
  9. package/dist/cjs/lib/modelUtils.d.ts +11 -0
  10. package/dist/cjs/lib/prompt.d.ts +14 -0
  11. package/dist/cjs/lib/utils.d.ts +68 -0
  12. package/dist/cjs/lib/v3/agent/AgentClient.d.ts +19 -0
  13. package/dist/cjs/lib/v3/agent/AgentProvider.d.ts +20 -0
  14. package/dist/cjs/lib/v3/agent/AnthropicCUAClient.d.ts +57 -0
  15. package/dist/cjs/lib/v3/agent/GoogleCUAClient.d.ts +74 -0
  16. package/dist/cjs/lib/v3/agent/MicrosoftCUAClient.d.ts +71 -0
  17. package/dist/cjs/lib/v3/agent/OpenAICUAClient.d.ts +69 -0
  18. package/dist/cjs/lib/v3/agent/prompts/agentSystemPrompt.d.ts +12 -0
  19. package/dist/cjs/lib/v3/agent/tools/act.d.ts +12 -0
  20. package/dist/cjs/lib/v3/agent/tools/ariaTree.d.ts +5 -0
  21. package/dist/cjs/lib/v3/agent/tools/click.d.ts +6 -0
  22. package/dist/cjs/lib/v3/agent/tools/clickAndHold.d.ts +14 -0
  23. package/dist/cjs/lib/v3/agent/tools/dragAndDrop.d.ts +7 -0
  24. package/dist/cjs/lib/v3/agent/tools/extract.d.ts +20 -0
  25. package/dist/cjs/lib/v3/agent/tools/fillFormVision.d.ts +12 -0
  26. package/dist/cjs/lib/v3/agent/tools/fillform.d.ts +12 -0
  27. package/dist/cjs/lib/v3/agent/tools/goto.d.ts +12 -0
  28. package/dist/cjs/lib/v3/agent/tools/index.d.ts +92 -0
  29. package/dist/cjs/lib/v3/agent/tools/keys.d.ts +24 -0
  30. package/dist/cjs/lib/v3/agent/tools/navback.d.ts +6 -0
  31. package/dist/cjs/lib/v3/agent/tools/screenshot.d.ts +6 -0
  32. package/dist/cjs/lib/v3/agent/tools/scroll.d.ts +19 -0
  33. package/dist/cjs/lib/v3/agent/tools/search.d.ts +15 -0
  34. package/dist/cjs/lib/v3/agent/tools/think.d.ts +6 -0
  35. package/dist/cjs/lib/v3/agent/tools/type.d.ts +7 -0
  36. package/dist/cjs/lib/v3/agent/tools/wait.d.ts +5 -0
  37. package/dist/cjs/lib/v3/agent/utils/actionMapping.d.ts +3 -0
  38. package/dist/cjs/lib/v3/agent/utils/coordinateNormalization.d.ts +13 -0
  39. package/dist/cjs/lib/v3/agent/utils/cuaKeyMapping.d.ts +10 -0
  40. package/dist/cjs/lib/v3/agent/utils/googleCustomToolHandler.d.ts +25 -0
  41. package/dist/cjs/lib/v3/agent/utils/handleDoneToolCall.d.ts +22 -0
  42. package/dist/cjs/lib/v3/agent/utils/imageCompression.d.ts +53 -0
  43. package/dist/cjs/lib/v3/agent/utils/messageProcessing.d.ts +12 -0
  44. package/dist/cjs/lib/v3/agent/utils/screenshotHandler.d.ts +10 -0
  45. package/dist/cjs/lib/v3/agent/utils/validateExperimentalFeatures.d.ts +26 -0
  46. package/dist/cjs/lib/v3/agent/utils/xpath.d.ts +11 -0
  47. package/dist/cjs/lib/v3/api.d.ts +86 -0
  48. package/dist/cjs/lib/v3/cache/ActCache.d.ts +23 -0
  49. package/dist/cjs/lib/v3/cache/AgentCache.d.ts +109 -0
  50. package/dist/cjs/lib/v3/cache/CacheStorage.d.ts +17 -0
  51. package/dist/cjs/lib/v3/cache/serverAgentCache.d.ts +7 -0
  52. package/dist/cjs/lib/v3/cache/utils.d.ts +15 -0
  53. package/dist/cjs/lib/v3/cli.d.ts +2 -0
  54. package/dist/cjs/lib/v3/dom/a11yScripts/index.d.ts +11 -0
  55. package/dist/cjs/lib/v3/dom/build/a11yScripts.generated.d.ts +16 -0
  56. package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.d.ts +52 -0
  57. package/dist/cjs/lib/v3/dom/build/reRenderScriptContent.d.ts +1 -0
  58. package/dist/cjs/lib/v3/dom/build/rerender-index.d.ts +0 -0
  59. package/dist/cjs/lib/v3/dom/build/rerender-index.js +1 -0
  60. package/dist/cjs/lib/v3/dom/build/screenshotScripts.generated.d.ts +4 -0
  61. package/dist/cjs/lib/v3/dom/build/scriptV3Content.d.ts +1 -0
  62. package/dist/cjs/lib/v3/dom/build/v3-index.d.ts +0 -0
  63. package/dist/cjs/lib/v3/dom/build/v3-index.js +1 -0
  64. package/dist/cjs/lib/v3/dom/genA11yScripts.d.ts +1 -0
  65. package/dist/cjs/lib/v3/dom/genDomScripts.d.ts +1 -0
  66. package/dist/cjs/lib/v3/dom/genLocatorScripts.d.ts +1 -0
  67. package/dist/cjs/lib/v3/dom/genScreenshotScripts.d.ts +1 -0
  68. package/dist/cjs/lib/v3/dom/index.d.ts +1 -0
  69. package/dist/cjs/lib/v3/dom/locatorScripts/counts.d.ts +15 -0
  70. package/dist/cjs/lib/v3/dom/locatorScripts/index.d.ts +4 -0
  71. package/dist/cjs/lib/v3/dom/locatorScripts/scripts.d.ts +37 -0
  72. package/dist/cjs/lib/v3/dom/locatorScripts/selectors.d.ts +4 -0
  73. package/dist/cjs/lib/v3/dom/locatorScripts/waitForSelector.d.ts +19 -0
  74. package/dist/cjs/lib/v3/dom/locatorScripts/xpathParser.d.ts +76 -0
  75. package/dist/cjs/lib/v3/dom/locatorScripts/xpathResolver.d.ts +9 -0
  76. package/dist/cjs/lib/v3/dom/piercer.entry.d.ts +1 -0
  77. package/dist/cjs/lib/v3/dom/piercer.runtime.d.ts +23 -0
  78. package/dist/cjs/lib/v3/dom/rerenderMissingShadows.entry.d.ts +1 -0
  79. package/dist/cjs/lib/v3/dom/rerenderMissingShadows.runtime.d.ts +1 -0
  80. package/dist/cjs/lib/v3/dom/screenshotScripts/index.d.ts +1 -0
  81. package/dist/cjs/lib/v3/dom/screenshotScripts/resolveMaskRect.d.ts +8 -0
  82. package/dist/cjs/lib/v3/external_clients/aisdk.d.ts +11 -0
  83. package/dist/cjs/lib/v3/external_clients/customOpenAI.d.ts +18 -0
  84. package/dist/cjs/lib/v3/flowLogger.d.ts +139 -0
  85. package/dist/cjs/lib/v3/handlers/actHandler.d.ts +21 -0
  86. package/dist/cjs/lib/v3/handlers/extractHandler.d.ts +31 -0
  87. package/dist/cjs/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +24 -0
  88. package/dist/cjs/lib/v3/handlers/handlerUtils/timeoutGuard.d.ts +2 -0
  89. package/dist/cjs/lib/v3/handlers/observeHandler.d.ts +17 -0
  90. package/dist/cjs/lib/v3/handlers/v3AgentHandler.d.ts +32 -0
  91. package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.d.ts +33 -0
  92. package/dist/cjs/lib/v3/index.d.ts +18 -0
  93. package/dist/cjs/lib/v3/launch/browserbase.d.ts +7 -0
  94. package/dist/cjs/lib/v3/launch/local.d.ts +15 -0
  95. package/dist/cjs/lib/v3/llm/AnthropicClient.d.ts +16 -0
  96. package/dist/cjs/lib/v3/llm/CerebrasClient.d.ts +17 -0
  97. package/dist/cjs/lib/v3/llm/GoogleClient.d.ts +19 -0
  98. package/dist/cjs/lib/v3/llm/GroqClient.d.ts +17 -0
  99. package/dist/cjs/lib/v3/llm/LLMClient.d.ts +121 -0
  100. package/dist/cjs/lib/v3/llm/LLMProvider.d.ts +13 -0
  101. package/dist/cjs/lib/v3/llm/OpenAIClient.d.ts +15 -0
  102. package/dist/cjs/lib/v3/llm/aisdk.d.ts +15 -0
  103. package/dist/cjs/lib/v3/logger.d.ts +9 -0
  104. package/dist/cjs/lib/v3/mcp/connection.d.ts +11 -0
  105. package/dist/cjs/lib/v3/mcp/utils.d.ts +3 -0
  106. package/dist/cjs/lib/v3/shutdown/cleanupLocal.d.ts +14 -0
  107. package/dist/cjs/lib/v3/shutdown/supervisor.d.ts +11 -0
  108. package/dist/cjs/lib/v3/shutdown/supervisorClient.d.ts +15 -0
  109. package/dist/cjs/lib/v3/tests/agent-abort-signal.spec.js +113 -0
  110. package/dist/cjs/lib/v3/tests/agent-abort-signal.spec.js.map +7 -0
  111. package/dist/cjs/lib/v3/tests/agent-cache-self-heal.spec.js +102 -0
  112. package/dist/cjs/lib/v3/tests/agent-cache-self-heal.spec.js.map +7 -0
  113. package/dist/cjs/lib/v3/tests/agent-callbacks.spec.js +374 -0
  114. package/dist/cjs/lib/v3/tests/agent-callbacks.spec.js.map +7 -0
  115. package/dist/cjs/lib/v3/tests/agent-experimental-validation.spec.js +354 -0
  116. package/dist/cjs/lib/v3/tests/agent-experimental-validation.spec.js.map +7 -0
  117. package/dist/cjs/lib/v3/tests/agent-hybrid-mode.spec.js +247 -0
  118. package/dist/cjs/lib/v3/tests/agent-hybrid-mode.spec.js.map +7 -0
  119. package/dist/cjs/lib/v3/tests/agent-message-continuation.spec.js +105 -0
  120. package/dist/cjs/lib/v3/tests/agent-message-continuation.spec.js.map +7 -0
  121. package/dist/cjs/lib/v3/tests/agent-streaming.spec.js +126 -0
  122. package/dist/cjs/lib/v3/tests/agent-streaming.spec.js.map +7 -0
  123. package/dist/cjs/lib/v3/tests/cdp-session-detached.spec.js +44 -0
  124. package/dist/cjs/lib/v3/tests/cdp-session-detached.spec.js.map +7 -0
  125. package/dist/cjs/lib/v3/tests/click-count.spec.js +147 -0
  126. package/dist/cjs/lib/v3/tests/click-count.spec.js.map +7 -0
  127. package/dist/cjs/lib/v3/tests/connect-to-existing-browser.spec.js +54 -0
  128. package/dist/cjs/lib/v3/tests/connect-to-existing-browser.spec.js.map +7 -0
  129. package/dist/cjs/lib/v3/tests/context-addInitScript.spec.js +176 -0
  130. package/dist/cjs/lib/v3/tests/context-addInitScript.spec.js.map +7 -0
  131. package/dist/cjs/lib/v3/tests/default-page-tracking.spec.js +53 -0
  132. package/dist/cjs/lib/v3/tests/default-page-tracking.spec.js.map +7 -0
  133. package/dist/cjs/lib/v3/tests/downloads.spec.js +80 -0
  134. package/dist/cjs/lib/v3/tests/downloads.spec.js.map +7 -0
  135. package/dist/cjs/lib/v3/tests/frame-get-location-and-click.spec.js +53 -0
  136. package/dist/cjs/lib/v3/tests/frame-get-location-and-click.spec.js.map +7 -0
  137. package/dist/cjs/lib/v3/tests/iframe-ctx-addInitScript.spec.js +493 -0
  138. package/dist/cjs/lib/v3/tests/iframe-ctx-addInitScript.spec.js.map +7 -0
  139. package/dist/cjs/lib/v3/tests/keep-alive.child.js +92 -0
  140. package/dist/cjs/lib/v3/tests/keep-alive.child.js.map +7 -0
  141. package/dist/cjs/lib/v3/tests/keep-alive.helpers.js +568 -0
  142. package/dist/cjs/lib/v3/tests/keep-alive.helpers.js.map +7 -0
  143. package/dist/cjs/lib/v3/tests/keep-alive.spec.js +15 -0
  144. package/dist/cjs/lib/v3/tests/keep-alive.spec.js.map +7 -0
  145. package/dist/cjs/lib/v3/tests/keyboard.spec.js +296 -0
  146. package/dist/cjs/lib/v3/tests/keyboard.spec.js.map +7 -0
  147. package/dist/cjs/lib/v3/tests/locator-backend-node-id.spec.js +159 -0
  148. package/dist/cjs/lib/v3/tests/locator-backend-node-id.spec.js.map +7 -0
  149. package/dist/cjs/lib/v3/tests/locator-content-methods.spec.js +191 -0
  150. package/dist/cjs/lib/v3/tests/locator-content-methods.spec.js.map +7 -0
  151. package/dist/cjs/lib/v3/tests/locator-count-iframe.spec.js +108 -0
  152. package/dist/cjs/lib/v3/tests/locator-count-iframe.spec.js.map +7 -0
  153. package/dist/cjs/lib/v3/tests/locator-count.spec.js +71 -0
  154. package/dist/cjs/lib/v3/tests/locator-count.spec.js.map +7 -0
  155. package/dist/cjs/lib/v3/tests/locator-fill.spec.js +118 -0
  156. package/dist/cjs/lib/v3/tests/locator-fill.spec.js.map +7 -0
  157. package/dist/cjs/lib/v3/tests/locator-input-methods.spec.js +136 -0
  158. package/dist/cjs/lib/v3/tests/locator-input-methods.spec.js.map +7 -0
  159. package/dist/cjs/lib/v3/tests/locator-nth.spec.js +157 -0
  160. package/dist/cjs/lib/v3/tests/locator-nth.spec.js.map +7 -0
  161. package/dist/cjs/lib/v3/tests/locator-select-option.spec.js +242 -0
  162. package/dist/cjs/lib/v3/tests/locator-select-option.spec.js.map +7 -0
  163. package/dist/cjs/lib/v3/tests/logger-initialization.spec.js +547 -0
  164. package/dist/cjs/lib/v3/tests/logger-initialization.spec.js.map +7 -0
  165. package/dist/cjs/lib/v3/tests/multi-instance-logger.spec.js +269 -0
  166. package/dist/cjs/lib/v3/tests/multi-instance-logger.spec.js.map +7 -0
  167. package/dist/cjs/lib/v3/tests/nested-div.spec.js +23 -0
  168. package/dist/cjs/lib/v3/tests/nested-div.spec.js.map +7 -0
  169. package/dist/cjs/lib/v3/tests/page-addInitScript.spec.js +90 -0
  170. package/dist/cjs/lib/v3/tests/page-addInitScript.spec.js.map +7 -0
  171. package/dist/cjs/lib/v3/tests/page-console.spec.js +56 -0
  172. package/dist/cjs/lib/v3/tests/page-console.spec.js.map +7 -0
  173. package/dist/cjs/lib/v3/tests/page-drag-and-drop.spec.js +418 -0
  174. package/dist/cjs/lib/v3/tests/page-drag-and-drop.spec.js.map +7 -0
  175. package/dist/cjs/lib/v3/tests/page-goto-response.spec.js +35 -0
  176. package/dist/cjs/lib/v3/tests/page-goto-response.spec.js.map +7 -0
  177. package/dist/cjs/lib/v3/tests/page-hover.spec.js +167 -0
  178. package/dist/cjs/lib/v3/tests/page-hover.spec.js.map +7 -0
  179. package/dist/cjs/lib/v3/tests/page-screenshot.spec.js +295 -0
  180. package/dist/cjs/lib/v3/tests/page-screenshot.spec.js.map +7 -0
  181. package/dist/cjs/lib/v3/tests/page-scroll.spec.js +182 -0
  182. package/dist/cjs/lib/v3/tests/page-scroll.spec.js.map +7 -0
  183. package/dist/cjs/lib/v3/tests/page-send-cdp.spec.js +46 -0
  184. package/dist/cjs/lib/v3/tests/page-send-cdp.spec.js.map +7 -0
  185. package/dist/cjs/lib/v3/tests/perform-understudy-method.spec.js +98 -0
  186. package/dist/cjs/lib/v3/tests/perform-understudy-method.spec.js.map +7 -0
  187. package/dist/cjs/lib/v3/tests/setinputfiles.spec.js +148 -0
  188. package/dist/cjs/lib/v3/tests/setinputfiles.spec.js.map +7 -0
  189. package/dist/cjs/lib/v3/tests/shadow-iframe-oopif.spec.js +156 -0
  190. package/dist/cjs/lib/v3/tests/shadow-iframe-oopif.spec.js.map +7 -0
  191. package/dist/cjs/lib/v3/tests/shadow-iframe-spif.spec.js +156 -0
  192. package/dist/cjs/lib/v3/tests/shadow-iframe-spif.spec.js.map +7 -0
  193. package/dist/cjs/lib/v3/tests/testUtils.js +54 -0
  194. package/dist/cjs/lib/v3/tests/testUtils.js.map +7 -0
  195. package/dist/cjs/lib/v3/tests/text-selector-innermost.spec.js +100 -0
  196. package/dist/cjs/lib/v3/tests/text-selector-innermost.spec.js.map +7 -0
  197. package/dist/cjs/lib/v3/tests/timeouts.spec.js +32 -0
  198. package/dist/cjs/lib/v3/tests/timeouts.spec.js.map +7 -0
  199. package/dist/cjs/lib/v3/tests/user-data-dir.spec.js +65 -0
  200. package/dist/cjs/lib/v3/tests/user-data-dir.spec.js.map +7 -0
  201. package/dist/cjs/lib/v3/tests/v3.config.js +36 -0
  202. package/dist/cjs/lib/v3/tests/v3.config.js.map +7 -0
  203. package/dist/cjs/lib/v3/tests/v3.dynamic.config.js +67 -0
  204. package/dist/cjs/lib/v3/tests/v3.dynamic.config.js.map +7 -0
  205. package/dist/cjs/lib/v3/tests/v3.playwright.config.js +61 -0
  206. package/dist/cjs/lib/v3/tests/v3.playwright.config.js.map +7 -0
  207. package/dist/cjs/lib/v3/tests/wait-for-selector.spec.js +593 -0
  208. package/dist/cjs/lib/v3/tests/wait-for-selector.spec.js.map +7 -0
  209. package/dist/cjs/lib/v3/tests/wait-for-timeout.spec.js +97 -0
  210. package/dist/cjs/lib/v3/tests/wait-for-timeout.spec.js.map +7 -0
  211. package/dist/cjs/lib/v3/tests/xpath-for-location-deep.spec.js +77 -0
  212. package/dist/cjs/lib/v3/tests/xpath-for-location-deep.spec.js.map +7 -0
  213. package/dist/cjs/lib/v3/timeoutConfig.d.ts +2 -0
  214. package/dist/cjs/lib/v3/types/private/agent.d.ts +6 -0
  215. package/dist/cjs/lib/v3/types/private/api.d.ts +11 -0
  216. package/dist/cjs/lib/v3/types/private/cache.d.ts +128 -0
  217. package/dist/cjs/lib/v3/types/private/evaluator.d.ts +40 -0
  218. package/dist/cjs/lib/v3/types/private/handlers.d.ts +38 -0
  219. package/dist/cjs/lib/v3/types/private/index.d.ts +7 -0
  220. package/dist/cjs/lib/v3/types/private/internal.d.ts +39 -0
  221. package/dist/cjs/lib/v3/types/private/locator.d.ts +9 -0
  222. package/dist/cjs/lib/v3/types/private/network.d.ts +34 -0
  223. package/dist/cjs/lib/v3/types/private/shutdown.d.ts +19 -0
  224. package/dist/cjs/lib/v3/types/private/shutdownErrors.d.ts +12 -0
  225. package/dist/cjs/lib/v3/types/private/snapshot.d.ts +117 -0
  226. package/dist/cjs/lib/v3/types/public/agent.d.ts +595 -0
  227. package/dist/cjs/lib/v3/types/public/api.d.ts +1211 -0
  228. package/dist/cjs/lib/v3/types/public/apiErrors.d.ts +18 -0
  229. package/dist/cjs/lib/v3/types/public/index.d.ts +12 -0
  230. package/dist/cjs/lib/v3/types/public/locator.d.ts +9 -0
  231. package/dist/cjs/lib/v3/types/public/logs.d.ts +23 -0
  232. package/dist/cjs/lib/v3/types/public/methods.d.ts +56 -0
  233. package/dist/cjs/lib/v3/types/public/metrics.d.ts +27 -0
  234. package/dist/cjs/lib/v3/types/public/model.d.ts +65 -0
  235. package/dist/cjs/lib/v3/types/public/options.d.ts +70 -0
  236. package/dist/cjs/lib/v3/types/public/page.d.ts +18 -0
  237. package/dist/cjs/lib/v3/types/public/screenshotTypes.d.ts +25 -0
  238. package/dist/cjs/lib/v3/types/public/sdkErrors.d.ts +152 -0
  239. package/dist/cjs/lib/v3/understudy/a11y/snapshot/a11yTree.d.ts +15 -0
  240. package/dist/cjs/lib/v3/understudy/a11y/snapshot/activeElement.d.ts +8 -0
  241. package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.d.ts +77 -0
  242. package/dist/cjs/lib/v3/understudy/a11y/snapshot/coordinateResolver.d.ts +7 -0
  243. package/dist/cjs/lib/v3/understudy/a11y/snapshot/domTree.d.ts +46 -0
  244. package/dist/cjs/lib/v3/understudy/a11y/snapshot/focusSelectors.d.ts +24 -0
  245. package/dist/cjs/lib/v3/understudy/a11y/snapshot/index.d.ts +4 -0
  246. package/dist/cjs/lib/v3/understudy/a11y/snapshot/sessions.d.ts +16 -0
  247. package/dist/cjs/lib/v3/understudy/a11y/snapshot/treeFormatUtils.d.ts +28 -0
  248. package/dist/cjs/lib/v3/understudy/a11y/snapshot/xpathUtils.d.ts +26 -0
  249. package/dist/cjs/lib/v3/understudy/a11yInvocation.d.ts +8 -0
  250. package/dist/cjs/lib/v3/understudy/cdp.d.ts +69 -0
  251. package/dist/cjs/lib/v3/understudy/consoleMessage.d.ts +22 -0
  252. package/dist/cjs/lib/v3/understudy/context.d.ts +132 -0
  253. package/dist/cjs/lib/v3/understudy/deepLocator.d.ts +87 -0
  254. package/dist/cjs/lib/v3/understudy/executionContextRegistry.d.ts +15 -0
  255. package/dist/cjs/lib/v3/understudy/fileUploadUtils.d.ts +13 -0
  256. package/dist/cjs/lib/v3/understudy/frame.d.ts +69 -0
  257. package/dist/cjs/lib/v3/understudy/frameLocator.d.ts +50 -0
  258. package/dist/cjs/lib/v3/understudy/frameRegistry.d.ts +101 -0
  259. package/dist/cjs/lib/v3/understudy/initScripts.d.ts +2 -0
  260. package/dist/cjs/lib/v3/understudy/lifecycleWatcher.d.ts +64 -0
  261. package/dist/cjs/lib/v3/understudy/locator.d.ts +194 -0
  262. package/dist/cjs/lib/v3/understudy/locatorInvocation.d.ts +8 -0
  263. package/dist/cjs/lib/v3/understudy/navigationResponseTracker.d.ts +84 -0
  264. package/dist/cjs/lib/v3/understudy/networkManager.d.ts +53 -0
  265. package/dist/cjs/lib/v3/understudy/page.d.ts +354 -0
  266. package/dist/cjs/lib/v3/understudy/piercer.d.ts +4 -0
  267. package/dist/cjs/lib/v3/understudy/response.d.ts +137 -0
  268. package/dist/cjs/lib/v3/understudy/screenshotUtils.d.ts +16 -0
  269. package/dist/cjs/lib/v3/understudy/selectorResolver.d.ts +38 -0
  270. package/dist/cjs/lib/v3/v3.d.ts +191 -0
  271. package/dist/cjs/lib/v3/zodCompat.d.ts +12 -0
  272. package/dist/cjs/lib/v3Evaluator.d.ts +19 -0
  273. package/dist/cjs/lib/version.d.ts +5 -0
  274. package/dist/cjs/package.json +3 -0
  275. package/dist/cjs/tests/browserbase-session-accessors.test.js +101 -0
  276. package/dist/cjs/tests/browserbase-session-accessors.test.js.map +7 -0
  277. package/dist/cjs/tests/cache-llm-resolution.test.js +187 -0
  278. package/dist/cjs/tests/cache-llm-resolution.test.js.map +7 -0
  279. package/dist/cjs/tests/helpers/mockCDPSession.js +50 -0
  280. package/dist/cjs/tests/helpers/mockCDPSession.js.map +7 -0
  281. package/dist/cjs/tests/llm-provider.test.js +57 -0
  282. package/dist/cjs/tests/llm-provider.test.js.map +7 -0
  283. package/dist/cjs/tests/model-deprecation.test.js +132 -0
  284. package/dist/cjs/tests/model-deprecation.test.js.map +7 -0
  285. package/dist/cjs/tests/page-snapshot.test.js +58 -0
  286. package/dist/cjs/tests/page-snapshot.test.js.map +7 -0
  287. package/dist/cjs/tests/public-api/export-surface.test.js +76 -0
  288. package/dist/cjs/tests/public-api/export-surface.test.js.map +7 -0
  289. package/dist/cjs/tests/public-api/llm-and-agents.test.js +150 -0
  290. package/dist/cjs/tests/public-api/llm-and-agents.test.js.map +7 -0
  291. package/dist/cjs/tests/public-api/public-error-types.test.js +104 -0
  292. package/dist/cjs/tests/public-api/public-error-types.test.js.map +7 -0
  293. package/dist/cjs/tests/public-api/public-types.test.js +74 -0
  294. package/dist/cjs/tests/public-api/public-types.test.js.map +7 -0
  295. package/dist/cjs/tests/public-api/runtime-utils.test.js +53 -0
  296. package/dist/cjs/tests/public-api/runtime-utils.test.js.map +7 -0
  297. package/dist/cjs/tests/public-api/schema-utils.test.js +100 -0
  298. package/dist/cjs/tests/public-api/schema-utils.test.js.map +7 -0
  299. package/dist/cjs/tests/public-api/timeout-error-types.test.js +103 -0
  300. package/dist/cjs/tests/public-api/timeout-error-types.test.js.map +7 -0
  301. package/dist/cjs/tests/public-api/tool-type-export.test.js +47 -0
  302. package/dist/cjs/tests/public-api/tool-type-export.test.js.map +7 -0
  303. package/dist/cjs/tests/public-api/v3-core.test.js +104 -0
  304. package/dist/cjs/tests/public-api/v3-core.test.js.map +7 -0
  305. package/dist/cjs/tests/safety-confirmation.test.js +134 -0
  306. package/dist/cjs/tests/safety-confirmation.test.js.map +7 -0
  307. package/dist/cjs/tests/snapshot-a11y-resolvers.test.js +370 -0
  308. package/dist/cjs/tests/snapshot-a11y-resolvers.test.js.map +7 -0
  309. package/dist/cjs/tests/snapshot-a11y-tree-utils.test.js +294 -0
  310. package/dist/cjs/tests/snapshot-a11y-tree-utils.test.js.map +7 -0
  311. package/dist/cjs/tests/snapshot-capture-orchestration.test.js +403 -0
  312. package/dist/cjs/tests/snapshot-capture-orchestration.test.js.map +7 -0
  313. package/dist/cjs/tests/snapshot-cbor.test.js +197 -0
  314. package/dist/cjs/tests/snapshot-cbor.test.js.map +7 -0
  315. package/dist/cjs/tests/snapshot-dom-session-builders.test.js +246 -0
  316. package/dist/cjs/tests/snapshot-dom-session-builders.test.js.map +7 -0
  317. package/dist/cjs/tests/snapshot-dom-tree-utils.test.js +104 -0
  318. package/dist/cjs/tests/snapshot-dom-tree-utils.test.js.map +7 -0
  319. package/dist/cjs/tests/snapshot-focus-selectors-utils.test.js +45 -0
  320. package/dist/cjs/tests/snapshot-focus-selectors-utils.test.js.map +7 -0
  321. package/dist/cjs/tests/snapshot-frame-merge.test.js +388 -0
  322. package/dist/cjs/tests/snapshot-frame-merge.test.js.map +7 -0
  323. package/dist/cjs/tests/snapshot-tree-format-utils.test.js +106 -0
  324. package/dist/cjs/tests/snapshot-tree-format-utils.test.js.map +7 -0
  325. package/dist/cjs/tests/snapshot-xpath-utils.test.js +74 -0
  326. package/dist/cjs/tests/snapshot-xpath-utils.test.js.map +7 -0
  327. package/dist/cjs/tests/timeout-handlers.test.js +864 -0
  328. package/dist/cjs/tests/timeout-handlers.test.js.map +7 -0
  329. package/dist/cjs/tests/xpath-parser.test.js +314 -0
  330. package/dist/cjs/tests/xpath-parser.test.js.map +7 -0
  331. package/dist/cjs/tests/xpath-resolver.test.js +70 -0
  332. package/dist/cjs/tests/xpath-resolver.test.js.map +7 -0
  333. package/dist/cjs/tests/zod-enum-compatibility.test.js +119 -0
  334. package/dist/cjs/tests/zod-enum-compatibility.test.js.map +7 -0
  335. package/dist/esm/index.d.ts +2 -2
  336. package/dist/esm/lib/v3/api.d.ts +16 -1
  337. package/dist/esm/lib/v3/api.js +41 -5
  338. package/dist/esm/lib/v3/api.js.map +1 -1
  339. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +0 -3
  340. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js +22 -20
  341. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -1
  342. package/dist/esm/lib/v3/llm/aisdk.js +5 -2
  343. package/dist/esm/lib/v3/llm/aisdk.js.map +1 -1
  344. package/dist/esm/lib/v3/types/public/api.d.ts +8 -0
  345. package/dist/esm/lib/v3/types/public/api.js +5 -3
  346. package/dist/esm/lib/v3/types/public/api.js.map +1 -1
  347. package/dist/esm/lib/v3/types/public/index.d.ts +1 -0
  348. package/dist/esm/lib/v3/types/public/index.js.map +1 -1
  349. package/dist/esm/lib/v3/types/public/sdkErrors.d.ts +3 -0
  350. package/dist/esm/lib/v3/types/public/sdkErrors.js +12 -6
  351. package/dist/esm/lib/v3/types/public/sdkErrors.js.map +1 -1
  352. package/dist/esm/tests/api-multiregion.test.js +73 -0
  353. package/dist/esm/tests/api-multiregion.test.js.map +7 -0
  354. package/dist/esm/tests/public-api/public-error-types.test.js +2 -1
  355. package/dist/esm/tests/public-api/public-error-types.test.js.map +2 -2
  356. package/dist/esm/tests/understudy-command-exception.test.js +55 -0
  357. package/dist/esm/tests/understudy-command-exception.test.js.map +7 -0
  358. package/package.json +1 -1
@@ -0,0 +1,354 @@
1
+ import { Protocol } from "devtools-protocol";
2
+ import type { CDPSessionLike } from "./cdp.js";
3
+ import { CdpConnection } from "./cdp.js";
4
+ import { Frame } from "./frame.js";
5
+ import { FrameLocator } from "./frameLocator.js";
6
+ import { LoadState, SnapshotResult, PageSnapshotOptions } from "../types/public/page.js";
7
+ import { Response } from "./response.js";
8
+ import { ConsoleListener } from "./consoleMessage.js";
9
+ import type { StagehandAPIClient } from "../api.js";
10
+ import { LocalBrowserLaunchOptions } from "../types/public/index.js";
11
+ import type { ScreenshotOptions } from "../types/public/screenshotTypes.js";
12
+ import { InitScriptSource } from "../types/private/index.js";
13
+ export declare class Page {
14
+ private readonly conn;
15
+ private readonly mainSession;
16
+ private readonly _targetId;
17
+ /** Every CDP child session this page owns (top-level + adopted OOPIF sessions). */
18
+ private readonly sessions;
19
+ /** Unified truth for frame topology + ownership. */
20
+ private readonly registry;
21
+ /** A convenience wrapper bound to the current main frame id (top-level session). */
22
+ private mainFrameWrapper;
23
+ /** Compact ordinal per frameId (used by snapshot encoding). */
24
+ private frameOrdinals;
25
+ private nextOrdinal;
26
+ /** cache Frames per frameId so everyone uses the same one */
27
+ private readonly frameCache;
28
+ private readonly browserIsRemote;
29
+ /** Stable id for Frames created by this Page (use top-level TargetId). */
30
+ private readonly pageId;
31
+ /** Cached current URL for synchronous page.url() */
32
+ private _currentUrl;
33
+ private navigationCommandSeq;
34
+ private latestNavigationCommandId;
35
+ private readonly networkManager;
36
+ /** Optional API client for routing page operations to the API */
37
+ private readonly apiClient;
38
+ private readonly consoleListeners;
39
+ private readonly consoleHandlers;
40
+ /** Document-start scripts installed across every session this page owns. */
41
+ private readonly initScripts;
42
+ private constructor();
43
+ private installInitScriptOnSession;
44
+ private applyInitScriptsToSession;
45
+ registerInitScript(source: string): Promise<void>;
46
+ seedInitScript(source: string): void;
47
+ private cursorEnabled;
48
+ private ensureCursorScript;
49
+ enableCursorOverlay(): Promise<void>;
50
+ private updateCursor;
51
+ addInitScript<Arg>(script: InitScriptSource<Arg>, arg?: Arg): Promise<void>;
52
+ /**
53
+ * Factory: create Page and seed registry with the shallow tree from Page.getFrameTree.
54
+ * Assumes Page domain is already enabled on the session passed in.
55
+ */
56
+ static create(conn: CdpConnection, session: CDPSessionLike, targetId: string, apiClient?: StagehandAPIClient | null, localBrowserLaunchOptions?: LocalBrowserLaunchOptions | null, browserIsRemote?: boolean): Promise<Page>;
57
+ /**
58
+ * Parent/child session emitted a `frameAttached`.
59
+ * Topology update + ownership stamped to **emitting session**.
60
+ */
61
+ onFrameAttached(frameId: string, parentId: string | null, session: CDPSessionLike): void;
62
+ /**
63
+ * Parent/child session emitted a `frameDetached`.
64
+ */
65
+ onFrameDetached(frameId: string, reason?: "remove" | "swap" | string): void;
66
+ /**
67
+ * Parent/child session emitted a `frameNavigated`.
68
+ * Topology + ownership update. Handles root swaps.
69
+ */
70
+ onFrameNavigated(frame: Protocol.Page.Frame, session: CDPSessionLike): void;
71
+ onNavigatedWithinDocument(frameId: string, url: string, session: CDPSessionLike): void;
72
+ /**
73
+ * An OOPIF child session whose **main** frame id equals the parent iframe’s frameId
74
+ * has been attached; adopt the session into this Page and seed ownership for its subtree.
75
+ */
76
+ adoptOopifSession(childSession: CDPSessionLike, childMainFrameId: string): void;
77
+ /** Detach an adopted child session and prune its subtree */
78
+ detachOopifSession(sessionId: string): void;
79
+ /** Return the owning CDP session for a frameId (falls back to main session) */
80
+ getSessionForFrame(frameId: string): CDPSessionLike;
81
+ /** Always returns a Frame bound to the owning session */
82
+ frameForId(frameId: string): Frame;
83
+ /** Expose a session by id (used by snapshot to resolve session id -> session) */
84
+ getSessionById(id: string): CDPSessionLike | undefined;
85
+ registerSessionForNetwork(session: CDPSessionLike): void;
86
+ unregisterSessionForNetwork(sessionId: string | undefined): void;
87
+ on(event: "console", listener: ConsoleListener): Page;
88
+ once(event: "console", listener: ConsoleListener): Page;
89
+ off(event: "console", listener: ConsoleListener): Page;
90
+ targetId(): string;
91
+ /**
92
+ * Send a CDP command through the main session.
93
+ * Allows external consumers to execute arbitrary Chrome DevTools Protocol commands.
94
+ *
95
+ * @param method - The CDP method name (e.g., "Page.enable", "Runtime.evaluate")
96
+ * @param params - Optional parameters for the CDP command
97
+ * @returns Promise resolving to the typed CDP response
98
+ *
99
+ * @example
100
+ * // Enable the Runtime domain
101
+ * await page.sendCDP("Runtime.enable");
102
+ *
103
+ * @example
104
+ * // Evaluate JavaScript with typed response
105
+ * const result = await page.sendCDP<Protocol.Runtime.EvaluateResponse>(
106
+ * "Runtime.evaluate",
107
+ * { expression: "1 + 1" }
108
+ * );
109
+ */
110
+ sendCDP<T = unknown>(method: string, params?: object): Promise<T>;
111
+ /** Seed the cached URL before navigation events converge. */
112
+ seedCurrentUrl(url: string | undefined | null): void;
113
+ mainFrameId(): string;
114
+ mainFrame(): Frame;
115
+ /**
116
+ * Close this top-level page (tab). Best-effort via Target.closeTarget.
117
+ */
118
+ close(): Promise<void>;
119
+ getFullFrameTree(): Protocol.Page.FrameTree;
120
+ asProtocolFrameTree(rootMainFrameId: string): Protocol.Page.FrameTree;
121
+ private ensureOrdinal;
122
+ /** Public getter for snapshot code / handlers. */
123
+ getOrdinal(frameId: string): number;
124
+ listAllFrameIds(): string[];
125
+ private ensureConsoleTaps;
126
+ private installConsoleTap;
127
+ private sessionKey;
128
+ private resolveSessionByKey;
129
+ private teardownConsoleTap;
130
+ private removeAllConsoleTaps;
131
+ private emitConsole;
132
+ /**
133
+ * Navigate the page; optionally wait for a lifecycle state.
134
+ * Waits on the **current** main frame and follows root swaps during navigation.
135
+ */
136
+ goto(url: string, options?: {
137
+ waitUntil?: LoadState;
138
+ timeoutMs?: number;
139
+ }): Promise<Response | null>;
140
+ /**
141
+ * Reload the page; optionally wait for a lifecycle state.
142
+ */
143
+ reload(options?: {
144
+ waitUntil?: LoadState;
145
+ timeoutMs?: number;
146
+ ignoreCache?: boolean;
147
+ }): Promise<Response | null>;
148
+ /**
149
+ * Navigate back in history if possible; optionally wait for a lifecycle state.
150
+ */
151
+ goBack(options?: {
152
+ waitUntil?: LoadState;
153
+ timeoutMs?: number;
154
+ }): Promise<Response | null>;
155
+ /**
156
+ * Navigate forward in history if possible; optionally wait for a lifecycle state.
157
+ */
158
+ goForward(options?: {
159
+ waitUntil?: LoadState;
160
+ timeoutMs?: number;
161
+ }): Promise<Response | null>;
162
+ /**
163
+ * Return the current page URL (synchronous, cached from navigation events).
164
+ */
165
+ url(): string;
166
+ private beginNavigationCommand;
167
+ isCurrentNavigationCommand(id: number): boolean;
168
+ /**
169
+ * Return the current page title.
170
+ * Prefers reading from the active document via Runtime.evaluate to reflect dynamic changes.
171
+ * Falls back to navigation history title if evaluation is unavailable.
172
+ */
173
+ title(): Promise<string>;
174
+ /**
175
+ * Capture a screenshot with Playwright-style options.
176
+ *
177
+ * @param options Optional screenshot configuration.
178
+ * @param options.animations Control CSS/Web animations during capture. Use
179
+ * "disabled" to fast-forward finite animations and pause infinite ones.
180
+ * @param options.caret Either hide the text caret (default) or leave it
181
+ * visible via "initial".
182
+ * @param options.clip Restrict capture to a specific rectangle (in CSS
183
+ * pixels). Cannot be combined with `fullPage`.
184
+ * @param options.fullPage Capture the full scrollable page instead of the
185
+ * current viewport.
186
+ * @param options.mask Array of locators that should be covered with an
187
+ * overlay while the screenshot is taken.
188
+ * @param options.maskColor CSS color used for the mask overlay (default
189
+ * `#FF00FF`).
190
+ * @param options.omitBackground Make the default page background transparent
191
+ * (PNG only).
192
+ * @param options.path File path to write the screenshot to. The file extension
193
+ * determines the image type when `type` is not explicitly provided.
194
+ * @param options.quality JPEG quality (0–100). Only applies when
195
+ * `type === "jpeg"`.
196
+ * @param options.scale Render scale: use "css" for one pixel per CSS pixel,
197
+ * otherwise the default "device" leverages the current device pixel ratio.
198
+ * @param options.style Additional CSS text injected into every frame before
199
+ * capture (removed afterwards).
200
+ * @param options.timeout Maximum capture duration in milliseconds before a
201
+ * timeout error is thrown.
202
+ * @param options.type Image format (`"png"` by default).
203
+ */
204
+ screenshot(options?: ScreenshotOptions): Promise<Buffer>;
205
+ /**
206
+ * Create a locator bound to the current main frame.
207
+ */
208
+ locator(selector: string): ReturnType<Frame["locator"]>;
209
+ /**
210
+ * Deep locator that supports cross-iframe traversal.
211
+ * - Recognizes '>>' hop notation to enter iframe contexts.
212
+ * - Supports deep XPath that includes iframe steps (e.g., '/html/body/iframe[2]//div').
213
+ * Returns a Locator scoped to the appropriate frame.
214
+ */
215
+ deepLocator(selector: string): import("./deepLocator.js").DeepLocatorDelegate;
216
+ /**
217
+ * Frame locator similar to Playwright: targets iframe elements and scopes
218
+ * subsequent locators to that frame. Supports chaining.
219
+ */
220
+ frameLocator(selector: string): FrameLocator;
221
+ /**
222
+ * List all frames belonging to this page as Frame objects bound to their owning sessions.
223
+ * The list is ordered by a stable ordinal assigned during the page lifetime.
224
+ */
225
+ frames(): Frame[];
226
+ /**
227
+ * Wait until the page reaches a lifecycle state on the current main frame.
228
+ * Mirrors Playwright's API signatures.
229
+ */
230
+ waitForLoadState(state: LoadState, timeoutMs?: number): Promise<void>;
231
+ /**
232
+ * Wait for a specified amount of time.
233
+ *
234
+ * @param ms The number of milliseconds to wait.
235
+ */
236
+ waitForTimeout(ms: number): Promise<void>;
237
+ /**
238
+ * Wait for an element matching the selector to appear in the DOM.
239
+ * Uses MutationObserver for efficiency
240
+ * Pierces shadow DOM by default.
241
+ * Supports iframe hop notation with '>>' (e.g., 'iframe#checkout >> .submit-btn').
242
+ *
243
+ * @param selector CSS selector to wait for (supports '>>' for iframe hops)
244
+ * @param options
245
+ * @param options.state Element state to wait for: 'attached' | 'detached' | 'visible' | 'hidden' (default: 'visible')
246
+ * @param options.timeout Maximum time to wait in milliseconds (default: 30000)
247
+ * @param options.pierceShadow Whether to search inside shadow DOM (default: true)
248
+ * @returns True when the condition is met
249
+ * @throws Error if timeout is reached before the condition is met
250
+ */
251
+ waitForSelector(selector: string, options?: {
252
+ state?: "attached" | "detached" | "visible" | "hidden";
253
+ timeout?: number;
254
+ pierceShadow?: boolean;
255
+ }): Promise<boolean>;
256
+ /**
257
+ * Evaluate a function or expression in the current main frame's main world.
258
+ * - If a string is provided, it is treated as a JS expression.
259
+ * - If a function is provided, it is stringified and invoked with the optional argument.
260
+ * - The return value should be JSON-serializable. Non-serializable objects will
261
+ * best-effort serialize via JSON.stringify inside the page context.
262
+ */
263
+ evaluate<R = unknown, Arg = unknown>(pageFunctionOrExpression: string | ((arg: Arg) => R | Promise<R>), arg?: Arg): Promise<R>;
264
+ /**
265
+ * Force the page viewport to an exact CSS size and device scale factor.
266
+ * Ensures screenshots match width x height pixels when deviceScaleFactor = 1.
267
+ */
268
+ setViewportSize(width: number, height: number, options?: {
269
+ deviceScaleFactor?: number;
270
+ }): Promise<void>;
271
+ /**
272
+ * Click at absolute page coordinates (CSS pixels).
273
+ * Dispatches mouseMoved → mousePressed → mouseReleased via CDP Input domain
274
+ * on the top-level page target's session. Coordinates are relative to the
275
+ * viewport origin (top-left). Does not scroll.
276
+ */
277
+ click(x: number, y: number, options?: {
278
+ button?: "left" | "right" | "middle";
279
+ clickCount?: number;
280
+ returnXpath?: boolean;
281
+ }): Promise<string>;
282
+ /**
283
+ * Hover at absolute page coordinates (CSS pixels).
284
+ * Dispatches mouseMoved via CDP Input domain on the top-level page target's
285
+ * session.
286
+ */
287
+ hover(x: number, y: number, options?: {
288
+ returnXpath?: boolean;
289
+ }): Promise<string>;
290
+ scroll(x: number, y: number, deltaX: number, deltaY: number, options?: {
291
+ returnXpath?: boolean;
292
+ }): Promise<string>;
293
+ /**
294
+ * Drag from (fromX, fromY) to (toX, toY) using mouse events.
295
+ * Sends mouseMoved → mousePressed → mouseMoved (steps) → mouseReleased.
296
+ */
297
+ dragAndDrop(fromX: number, fromY: number, toX: number, toY: number, options?: {
298
+ button?: "left" | "right" | "middle";
299
+ steps?: number;
300
+ delay?: number;
301
+ returnXpath?: boolean;
302
+ }): Promise<[string, string]>;
303
+ /**
304
+ * Type a string by dispatching keyDown/keyUp events per character.
305
+ * Focus must already be on the desired element. Uses CDP Input.dispatchKeyEvent
306
+ * and never falls back to Input.insertText. Optional delay applies between
307
+ * successive characters.
308
+ */
309
+ type(text: string, options?: {
310
+ delay?: number;
311
+ withMistakes?: boolean;
312
+ }): Promise<void>;
313
+ /**
314
+ * Press a single key or key combination (keyDown then keyUp).
315
+ * For printable characters, uses the text path on keyDown; for named keys, sets key/code/VK.
316
+ * Supports key combinations with modifiers like "Cmd+A", "Ctrl+C", "Shift+Tab", etc.
317
+ */
318
+ keyPress(key: string, options?: {
319
+ delay?: number;
320
+ }): Promise<void>;
321
+ snapshot(options?: PageSnapshotOptions): Promise<SnapshotResult>;
322
+ private _pressedModifiers;
323
+ /** Press a key down without releasing it */
324
+ private keyDown;
325
+ /** Release a pressed key */
326
+ private keyUp;
327
+ /** Normalize key names to match CDP expectations */
328
+ private normalizeModifierKey;
329
+ /**
330
+ * Get the map of named keys with their properties
331
+ */
332
+ private getNamedKeys;
333
+ /**
334
+ * Minimal description for printable keys (letters/digits/space) to provide code and VK.
335
+ * Used when non-Shift modifiers are pressed to avoid sending text while keeping accelerator info.
336
+ */
337
+ private describePrintableKey;
338
+ private isMacOS;
339
+ /**
340
+ * Return Chromium mac editing commands (without trailing ':') for a given code like 'KeyA'
341
+ * Only used on macOS to trigger system editing shortcuts (e.g., selectAll, copy, paste...).
342
+ */
343
+ private macCommandsFor;
344
+ /** Resolve the main-world execution context for the current main frame. */
345
+ private mainWorldExecutionContextId;
346
+ private isMainLoadStateReady;
347
+ /**
348
+ * Wait until the **current** main frame reaches a lifecycle state.
349
+ * - Fast path via `document.readyState`.
350
+ * - Event path listens at the session level and compares incoming `frameId`
351
+ * to `mainFrameId()` **at event time** to follow root swaps.
352
+ */
353
+ waitForMainLoadState(state: LoadState, timeoutMs?: number): Promise<void>;
354
+ }
@@ -0,0 +1,4 @@
1
+ import type { CDPSessionLike } from "./cdp.js";
2
+ export declare function installV3PiercerIntoSession(session: CDPSessionLike): Promise<boolean>;
3
+ /** (Optional) stream patch logs in your node console during bring-up */
4
+ export declare function tapPiercerConsole(session: CDPSessionLike, label: string): void;
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Response
3
+ * -----------------
4
+ *
5
+ * This module implements a Playwright-inspired response wrapper that exposes
6
+ * navigation metadata and helpers for retrieving HTTP response bodies. The
7
+ * abstraction is consumed by navigation routines (e.g. `Page.goto`) so callers
8
+ * can synchronously inspect status codes, lazily fetch body text, or await the
9
+ * network layer finishing the request. The implementation is built directly on
10
+ * Chrome DevTools Protocol primitives – it holds the originating `requestId`
11
+ * so it can request payloads via `Network.getResponseBody`, and it listens for
12
+ * `responseReceivedExtraInfo`, `loadingFinished`, and `loadingFailed` events to
13
+ * hydrate the richer header view and resolve callers waiting on completion.
14
+ */
15
+ import type { Protocol } from "devtools-protocol";
16
+ import type { SerializableResponse } from "../types/private/index.js";
17
+ import type { CDPSessionLike } from "./cdp.js";
18
+ import type { Frame } from "./frame.js";
19
+ import type { Page } from "./page.js";
20
+ type ServerAddr = {
21
+ ipAddress: string;
22
+ port: number;
23
+ };
24
+ export declare function isSerializableResponse(value: unknown): value is SerializableResponse;
25
+ /**
26
+ * Thin wrapper around CDP response metadata that mirrors the ergonomics of
27
+ * Playwright's `Response` class. The class intentionally keeps the same method
28
+ * names so upstream integrations can transition with minimal code changes.
29
+ */
30
+ export declare class Response {
31
+ private readonly page;
32
+ private readonly session;
33
+ private readonly requestId;
34
+ private readonly frameId?;
35
+ private readonly loaderId?;
36
+ private readonly response;
37
+ private readonly fromServiceWorkerFlag;
38
+ private readonly serverAddress?;
39
+ private headersObject;
40
+ private headersArrayCache;
41
+ private allHeadersCache;
42
+ private readonly headerValuesMap;
43
+ private finishedDeferred;
44
+ private finishedSettled;
45
+ private extraInfoHeaders;
46
+ private extraInfoHeadersText;
47
+ /**
48
+ * Build a response wrapper from the CDP notification associated with a
49
+ * navigation. The constructor captures the owning page/session so follow-up
50
+ * methods (body/text/json) can query CDP on-demand. The `response` payload is
51
+ * the raw `Protocol.Network.Response` object emitted by Chrome.
52
+ */
53
+ constructor(params: {
54
+ page: Page;
55
+ session: CDPSessionLike;
56
+ requestId: string;
57
+ frameId?: string;
58
+ loaderId?: string;
59
+ response: Protocol.Network.Response;
60
+ fromServiceWorker: boolean;
61
+ });
62
+ /** URL associated with the navigation request. */
63
+ url(): string;
64
+ /** HTTP status code reported by Chrome. */
65
+ status(): number;
66
+ /** Human-readable status text that accompanied the response. */
67
+ statusText(): string;
68
+ /** Convenience predicate that checks for 2xx statuses. */
69
+ ok(): boolean;
70
+ /** Returns the Stagehand frame object that initiated the navigation. */
71
+ frame(): Frame | null;
72
+ /** Indicates whether the response was serviced by a Service Worker. */
73
+ fromServiceWorker(): boolean;
74
+ /**
75
+ * Returns TLS security metadata when provided by the browser. In practice
76
+ * this includes certificate issuer, protocol, and validity interval.
77
+ */
78
+ securityDetails(): Promise<Protocol.Network.SecurityDetails | null>;
79
+ /** Returns the resolved server address for the navigation when available. */
80
+ serverAddr(): Promise<ServerAddr | null>;
81
+ /**
82
+ * Returns the response headers normalised to lowercase keys. Matches the
83
+ * behaviour of Playwright's `headers()` by eliding duplicate header entries.
84
+ */
85
+ headers(): Record<string, string>;
86
+ /**
87
+ * Returns all headers including those only surfaced through
88
+ * `responseReceivedExtraInfo` such as `set-cookie`. Values are reported as the
89
+ * browser sends them (no further splitting or concatenation).
90
+ */
91
+ allHeaders(): Promise<Record<string, string>>;
92
+ /** Returns a concatenated header string for the supplied header name. */
93
+ headerValue(name: string): Promise<string | null>;
94
+ /** Returns all values for a header (case-insensitive lookup). */
95
+ headerValues(name: string): Promise<string[]>;
96
+ /**
97
+ * Returns header entries preserving their original wire casing and ordering.
98
+ * Falls back to the CDP object when the raw header text is unavailable.
99
+ */
100
+ headersArray(): Promise<Array<{
101
+ name: string;
102
+ value: string;
103
+ }>>;
104
+ /**
105
+ * Requests the raw response body from Chrome DevTools Protocol. The method is
106
+ * intentionally lazy because not every caller needs the payload, and CDP only
107
+ * allows retrieving it once the response completes.
108
+ */
109
+ body(): Promise<Buffer>;
110
+ /** Decodes the response body as UTF-8 text. */
111
+ text(): Promise<string>;
112
+ /** Parses the response body as JSON and throws if parsing fails. */
113
+ json<T = unknown>(): Promise<T>;
114
+ /**
115
+ * Resolves once the underlying network request completes or fails. Mirrors
116
+ * Playwright's behaviour by resolving to `null` on success and to an `Error`
117
+ * instance when Chrome reports `Network.loadingFailed`.
118
+ */
119
+ finished(): Promise<null | Error>;
120
+ /**
121
+ * Internal helper invoked by the navigation tracker when CDP reports extra
122
+ * header information. This keeps the cached header views in sync with the
123
+ * richer metadata.
124
+ */
125
+ applyExtraInfo(event: Protocol.Network.ResponseReceivedExtraInfoEvent): void;
126
+ /**
127
+ * Internal helper for creating a Response object from a Serializable
128
+ * goto response from the Stagehand API
129
+ */
130
+ static fromSerializable(serialized: SerializableResponse, context: {
131
+ page: Page;
132
+ session: CDPSessionLike;
133
+ }): Response;
134
+ /** Marks the response as finished and resolves the `finished()` promise. */
135
+ markFinished(error: Error | null): void;
136
+ }
137
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { CDPSessionLike } from "./cdp.js";
2
+ import type { Frame } from "./frame.js";
3
+ import type { Locator } from "./locator.js";
4
+ import type { Page } from "./page.js";
5
+ import type { ScreenshotClip, ScreenshotScaleOption } from "../types/public/screenshotTypes.js";
6
+ export type ScreenshotCleanup = () => Promise<void> | void;
7
+ export declare function collectFramesForScreenshot(page: Page): Frame[];
8
+ export declare function normalizeScreenshotClip(clip: ScreenshotClip): ScreenshotClip;
9
+ export declare function computeScreenshotScale(page: Page, mode: ScreenshotScaleOption): Promise<number | undefined>;
10
+ export declare function setTransparentBackground(session: CDPSessionLike): Promise<ScreenshotCleanup>;
11
+ export declare function applyStyleToFrames(frames: Frame[], css: string, label: string): Promise<ScreenshotCleanup>;
12
+ export declare function disableAnimations(frames: Frame[]): Promise<ScreenshotCleanup>;
13
+ export declare function hideCaret(frames: Frame[]): Promise<ScreenshotCleanup>;
14
+ export declare function applyMaskOverlays(locators: Locator[], color: string): Promise<ScreenshotCleanup>;
15
+ export declare function runScreenshotCleanups(cleanups: ScreenshotCleanup[]): Promise<void>;
16
+ export declare function withScreenshotTimeout<T>(timeoutMs: number | undefined, task: () => Promise<T>): Promise<T>;
@@ -0,0 +1,38 @@
1
+ import type { Protocol } from "devtools-protocol";
2
+ import type { Frame } from "./frame.js";
3
+ export type SelectorQuery = {
4
+ kind: "css";
5
+ value: string;
6
+ } | {
7
+ kind: "text";
8
+ value: string;
9
+ } | {
10
+ kind: "xpath";
11
+ value: string;
12
+ };
13
+ export interface ResolvedNode {
14
+ objectId: Protocol.Runtime.RemoteObjectId;
15
+ nodeId: Protocol.DOM.NodeId | null;
16
+ }
17
+ export interface ResolveManyOptions {
18
+ limit?: number;
19
+ }
20
+ export declare class FrameSelectorResolver {
21
+ private readonly frame;
22
+ constructor(frame: Frame);
23
+ static parseSelector(raw: string): SelectorQuery;
24
+ resolveFirst(query: SelectorQuery): Promise<ResolvedNode | null>;
25
+ resolveAll(query: SelectorQuery, { limit }?: ResolveManyOptions): Promise<ResolvedNode[]>;
26
+ count(query: SelectorQuery): Promise<number>;
27
+ resolveAtIndex(query: SelectorQuery, index: number): Promise<ResolvedNode | null>;
28
+ private buildLocatorInvocation;
29
+ private resolveCss;
30
+ private resolveText;
31
+ private resolveXPath;
32
+ private countCss;
33
+ private countText;
34
+ private countXPath;
35
+ private resolveFromObjectId;
36
+ private evaluateCount;
37
+ private evaluateElement;
38
+ }