@browserbasehq/orca 3.0.9-alpha-4 → 3.1.0-patch.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (655) hide show
  1. package/dist/esm/index.d.ts +3 -0
  2. package/dist/esm/index.js +3 -0
  3. package/dist/esm/lib/inference.d.ts +65 -0
  4. package/dist/esm/lib/inference.js +333 -0
  5. package/dist/esm/lib/inference.js.map +1 -0
  6. package/dist/esm/lib/inferenceLogUtils.d.ts +12 -0
  7. package/dist/esm/lib/inferenceLogUtils.js +92 -0
  8. package/dist/esm/lib/inferenceLogUtils.js.map +1 -0
  9. package/dist/esm/lib/logger.d.ts +69 -0
  10. package/dist/esm/lib/logger.js +323 -0
  11. package/dist/esm/lib/logger.js.map +1 -0
  12. package/dist/esm/lib/modelUtils.d.ts +14 -0
  13. package/dist/esm/lib/modelUtils.js +48 -0
  14. package/dist/esm/lib/modelUtils.js.map +1 -0
  15. package/dist/esm/lib/prompt.d.ts +14 -0
  16. package/dist/esm/lib/prompt.js +230 -0
  17. package/dist/esm/lib/prompt.js.map +1 -0
  18. package/dist/esm/lib/utils.d.ts +68 -0
  19. package/dist/esm/lib/utils.js +654 -0
  20. package/dist/esm/lib/utils.js.map +1 -0
  21. package/dist/esm/lib/v3/agent/AgentClient.d.ts +19 -0
  22. package/dist/esm/lib/v3/agent/AgentClient.js +17 -0
  23. package/dist/esm/lib/v3/agent/AgentClient.js.map +1 -0
  24. package/dist/esm/lib/v3/agent/AgentProvider.d.ts +20 -0
  25. package/dist/esm/lib/v3/agent/AgentProvider.js +77 -0
  26. package/dist/esm/lib/v3/agent/AgentProvider.js.map +1 -0
  27. package/dist/esm/lib/v3/agent/AnthropicCUAClient.d.ts +57 -0
  28. package/dist/esm/lib/v3/agent/AnthropicCUAClient.js +822 -0
  29. package/dist/esm/lib/v3/agent/AnthropicCUAClient.js.map +1 -0
  30. package/dist/esm/lib/v3/agent/GoogleCUAClient.d.ts +74 -0
  31. package/dist/esm/lib/v3/agent/GoogleCUAClient.js +799 -0
  32. package/dist/esm/lib/v3/agent/GoogleCUAClient.js.map +1 -0
  33. package/dist/esm/lib/v3/agent/MicrosoftCUAClient.d.ts +71 -0
  34. package/dist/esm/lib/v3/agent/MicrosoftCUAClient.js +770 -0
  35. package/dist/esm/lib/v3/agent/MicrosoftCUAClient.js.map +1 -0
  36. package/dist/esm/lib/v3/agent/OpenAICUAClient.d.ts +69 -0
  37. package/dist/esm/lib/v3/agent/OpenAICUAClient.js +615 -0
  38. package/dist/esm/lib/v3/agent/OpenAICUAClient.js.map +1 -0
  39. package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.d.ts +12 -0
  40. package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.js +186 -0
  41. package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.js.map +1 -0
  42. package/dist/esm/lib/v3/agent/tools/act.d.ts +13 -0
  43. package/dist/esm/lib/v3/agent/tools/act.js +49 -0
  44. package/dist/esm/lib/v3/agent/tools/act.js.map +1 -0
  45. package/dist/esm/lib/v3/agent/tools/ariaTree.d.ts +5 -0
  46. package/dist/esm/lib/v3/agent/tools/ariaTree.js +31 -0
  47. package/dist/esm/lib/v3/agent/tools/ariaTree.js.map +1 -0
  48. package/dist/esm/lib/v3/agent/tools/click.d.ts +6 -0
  49. package/dist/esm/lib/v3/agent/tools/click.js +104 -0
  50. package/dist/esm/lib/v3/agent/tools/click.js.map +1 -0
  51. package/dist/esm/lib/v3/agent/tools/clickAndHold.d.ts +14 -0
  52. package/dist/esm/lib/v3/agent/tools/clickAndHold.js +68 -0
  53. package/dist/esm/lib/v3/agent/tools/clickAndHold.js.map +1 -0
  54. package/dist/esm/lib/v3/agent/tools/dragAndDrop.d.ts +7 -0
  55. package/dist/esm/lib/v3/agent/tools/dragAndDrop.js +105 -0
  56. package/dist/esm/lib/v3/agent/tools/dragAndDrop.js.map +1 -0
  57. package/dist/esm/lib/v3/agent/tools/extract.d.ts +21 -0
  58. package/dist/esm/lib/v3/agent/tools/extract.js +93 -0
  59. package/dist/esm/lib/v3/agent/tools/extract.js.map +1 -0
  60. package/dist/esm/lib/v3/agent/tools/fillFormVision.d.ts +12 -0
  61. package/dist/esm/lib/v3/agent/tools/fillFormVision.js +143 -0
  62. package/dist/esm/lib/v3/agent/tools/fillFormVision.js.map +1 -0
  63. package/dist/esm/lib/v3/agent/tools/fillform.d.ts +13 -0
  64. package/dist/esm/lib/v3/agent/tools/fillform.js +56 -0
  65. package/dist/esm/lib/v3/agent/tools/fillform.js.map +1 -0
  66. package/dist/esm/lib/v3/agent/tools/goto.d.ts +12 -0
  67. package/dist/esm/lib/v3/agent/tools/goto.js +31 -0
  68. package/dist/esm/lib/v3/agent/tools/goto.js.map +1 -0
  69. package/dist/esm/lib/v3/agent/tools/index.d.ts +92 -0
  70. package/dist/esm/lib/v3/agent/tools/index.js +74 -0
  71. package/dist/esm/lib/v3/agent/tools/index.js.map +1 -0
  72. package/dist/esm/lib/v3/agent/tools/keys.d.ts +24 -0
  73. package/dist/esm/lib/v3/agent/tools/keys.js +60 -0
  74. package/dist/esm/lib/v3/agent/tools/keys.js.map +1 -0
  75. package/dist/esm/lib/v3/agent/tools/navback.d.ts +6 -0
  76. package/dist/esm/lib/v3/agent/tools/navback.js +23 -0
  77. package/dist/esm/lib/v3/agent/tools/navback.js.map +1 -0
  78. package/dist/esm/lib/v3/agent/tools/screenshot.d.ts +6 -0
  79. package/dist/esm/lib/v3/agent/tools/screenshot.js +26 -0
  80. package/dist/esm/lib/v3/agent/tools/screenshot.js.map +1 -0
  81. package/dist/esm/lib/v3/agent/tools/scroll.d.ts +19 -0
  82. package/dist/esm/lib/v3/agent/tools/scroll.js +142 -0
  83. package/dist/esm/lib/v3/agent/tools/scroll.js.map +1 -0
  84. package/dist/esm/lib/v3/agent/tools/search.d.ts +15 -0
  85. package/dist/esm/lib/v3/agent/tools/search.js +73 -0
  86. package/dist/esm/lib/v3/agent/tools/search.js.map +1 -0
  87. package/dist/esm/lib/v3/agent/tools/think.d.ts +6 -0
  88. package/dist/esm/lib/v3/agent/tools/think.js +24 -0
  89. package/dist/esm/lib/v3/agent/tools/think.js.map +1 -0
  90. package/dist/esm/lib/v3/agent/tools/type.d.ts +7 -0
  91. package/dist/esm/lib/v3/agent/tools/type.js +106 -0
  92. package/dist/esm/lib/v3/agent/tools/type.js.map +1 -0
  93. package/dist/esm/lib/v3/agent/tools/wait.d.ts +5 -0
  94. package/dist/esm/lib/v3/agent/tools/wait.js +53 -0
  95. package/dist/esm/lib/v3/agent/tools/wait.js.map +1 -0
  96. package/dist/esm/lib/v3/agent/utils/actionMapping.d.ts +3 -0
  97. package/dist/esm/lib/v3/agent/utils/actionMapping.js +100 -0
  98. package/dist/esm/lib/v3/agent/utils/actionMapping.js.map +1 -0
  99. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.d.ts +13 -0
  100. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js +28 -0
  101. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js.map +1 -0
  102. package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.d.ts +10 -0
  103. package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.js +62 -0
  104. package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.js.map +1 -0
  105. package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.d.ts +25 -0
  106. package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.js +145 -0
  107. package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.js.map +1 -0
  108. package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.d.ts +22 -0
  109. package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js +101 -0
  110. package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js.map +1 -0
  111. package/dist/esm/lib/v3/agent/utils/imageCompression.d.ts +53 -0
  112. package/dist/esm/lib/v3/agent/utils/imageCompression.js +204 -0
  113. package/dist/esm/lib/v3/agent/utils/imageCompression.js.map +1 -0
  114. package/dist/esm/lib/v3/agent/utils/messageProcessing.d.ts +12 -0
  115. package/dist/esm/lib/v3/agent/utils/messageProcessing.js +164 -0
  116. package/dist/esm/lib/v3/agent/utils/messageProcessing.js.map +1 -0
  117. package/dist/esm/lib/v3/agent/utils/screenshotHandler.d.ts +10 -0
  118. package/dist/esm/lib/v3/agent/utils/screenshotHandler.js +26 -0
  119. package/dist/esm/lib/v3/agent/utils/screenshotHandler.js.map +1 -0
  120. package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.d.ts +26 -0
  121. package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.js +79 -0
  122. package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.js.map +1 -0
  123. package/dist/esm/lib/v3/agent/utils/xpath.d.ts +11 -0
  124. package/dist/esm/lib/v3/agent/utils/xpath.js +19 -0
  125. package/dist/esm/lib/v3/agent/utils/xpath.js.map +1 -0
  126. package/dist/esm/lib/v3/api.d.ts +86 -0
  127. package/dist/esm/lib/v3/api.js +484 -0
  128. package/dist/esm/lib/v3/api.js.map +1 -0
  129. package/dist/esm/lib/v3/cache/ActCache.d.ts +23 -0
  130. package/dist/esm/lib/v3/cache/ActCache.js +292 -0
  131. package/dist/esm/lib/v3/cache/ActCache.js.map +1 -0
  132. package/dist/esm/lib/v3/cache/AgentCache.d.ts +109 -0
  133. package/dist/esm/lib/v3/cache/AgentCache.js +640 -0
  134. package/dist/esm/lib/v3/cache/AgentCache.js.map +1 -0
  135. package/dist/esm/lib/v3/cache/CacheStorage.d.ts +17 -0
  136. package/dist/esm/lib/v3/cache/CacheStorage.js +98 -0
  137. package/dist/esm/lib/v3/cache/CacheStorage.js.map +1 -0
  138. package/dist/esm/lib/v3/cache/serverAgentCache.d.ts +7 -0
  139. package/dist/esm/lib/v3/cache/serverAgentCache.js +49 -0
  140. package/dist/esm/lib/v3/cache/serverAgentCache.js.map +1 -0
  141. package/dist/esm/lib/v3/cache/utils.d.ts +15 -0
  142. package/dist/esm/lib/v3/cache/utils.js +39 -0
  143. package/dist/esm/lib/v3/cache/utils.js.map +1 -0
  144. package/dist/esm/lib/v3/dom/a11yScripts/index.d.ts +11 -0
  145. package/dist/esm/lib/v3/dom/a11yScripts/index.js +117 -0
  146. package/dist/esm/lib/v3/dom/a11yScripts/index.js.map +1 -0
  147. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.d.ts +16 -0
  148. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js +20 -0
  149. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js.map +1 -0
  150. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.d.ts +52 -0
  151. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js +56 -0
  152. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js.map +1 -0
  153. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.d.ts +1 -0
  154. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js +2 -0
  155. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js.map +1 -0
  156. package/dist/esm/lib/v3/dom/build/rerender-index.js +1 -0
  157. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.d.ts +4 -0
  158. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js +8 -0
  159. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js.map +1 -0
  160. package/dist/esm/lib/v3/dom/build/scriptV3Content.d.ts +1 -0
  161. package/dist/esm/lib/v3/dom/build/scriptV3Content.js +2 -0
  162. package/dist/esm/lib/v3/dom/build/scriptV3Content.js.map +1 -0
  163. package/dist/esm/lib/v3/dom/build/v3-index.js +1 -0
  164. package/dist/esm/lib/v3/dom/genA11yScripts.d.ts +1 -0
  165. package/dist/esm/lib/v3/dom/genA11yScripts.js +54 -0
  166. package/dist/esm/lib/v3/dom/genA11yScripts.js.map +1 -0
  167. package/dist/esm/lib/v3/dom/genDomScripts.d.ts +1 -0
  168. package/dist/esm/lib/v3/dom/genDomScripts.js +38 -0
  169. package/dist/esm/lib/v3/dom/genDomScripts.js.map +1 -0
  170. package/dist/esm/lib/v3/dom/genLocatorScripts.d.ts +1 -0
  171. package/dist/esm/lib/v3/dom/genLocatorScripts.js +51 -0
  172. package/dist/esm/lib/v3/dom/genLocatorScripts.js.map +1 -0
  173. package/dist/esm/lib/v3/dom/genScreenshotScripts.d.ts +1 -0
  174. package/dist/esm/lib/v3/dom/genScreenshotScripts.js +37 -0
  175. package/dist/esm/lib/v3/dom/genScreenshotScripts.js.map +1 -0
  176. package/dist/esm/lib/v3/dom/index.d.ts +1 -0
  177. package/dist/esm/lib/v3/dom/index.js +2 -0
  178. package/dist/esm/lib/v3/dom/index.js.map +1 -0
  179. package/dist/esm/lib/v3/dom/locatorScripts/counts.d.ts +15 -0
  180. package/dist/esm/lib/v3/dom/locatorScripts/counts.js +272 -0
  181. package/dist/esm/lib/v3/dom/locatorScripts/counts.js.map +1 -0
  182. package/dist/esm/lib/v3/dom/locatorScripts/index.d.ts +4 -0
  183. package/dist/esm/lib/v3/dom/locatorScripts/index.js +5 -0
  184. package/dist/esm/lib/v3/dom/locatorScripts/index.js.map +1 -0
  185. package/dist/esm/lib/v3/dom/locatorScripts/scripts.d.ts +37 -0
  186. package/dist/esm/lib/v3/dom/locatorScripts/scripts.js +458 -0
  187. package/dist/esm/lib/v3/dom/locatorScripts/scripts.js.map +1 -0
  188. package/dist/esm/lib/v3/dom/locatorScripts/selectors.d.ts +4 -0
  189. package/dist/esm/lib/v3/dom/locatorScripts/selectors.js +283 -0
  190. package/dist/esm/lib/v3/dom/locatorScripts/selectors.js.map +1 -0
  191. package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.d.ts +19 -0
  192. package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.js +283 -0
  193. package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.js.map +1 -0
  194. package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.d.ts +76 -0
  195. package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.js +376 -0
  196. package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.js.map +1 -0
  197. package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.d.ts +9 -0
  198. package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.js +196 -0
  199. package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.js.map +1 -0
  200. package/dist/esm/lib/v3/dom/piercer.entry.d.ts +1 -0
  201. package/dist/esm/lib/v3/dom/piercer.entry.js +3 -0
  202. package/dist/esm/lib/v3/dom/piercer.entry.js.map +1 -0
  203. package/dist/esm/lib/v3/dom/piercer.runtime.d.ts +23 -0
  204. package/dist/esm/lib/v3/dom/piercer.runtime.js +90 -0
  205. package/dist/esm/lib/v3/dom/piercer.runtime.js.map +1 -0
  206. package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.d.ts +1 -0
  207. package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.js +3 -0
  208. package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.js.map +1 -0
  209. package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.d.ts +1 -0
  210. package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.js +40 -0
  211. package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.js.map +1 -0
  212. package/dist/esm/lib/v3/dom/screenshotScripts/index.d.ts +1 -0
  213. package/dist/esm/lib/v3/dom/screenshotScripts/index.js +2 -0
  214. package/dist/esm/lib/v3/dom/screenshotScripts/index.js.map +1 -0
  215. package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.d.ts +8 -0
  216. package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.js +82 -0
  217. package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.js.map +1 -0
  218. package/dist/esm/lib/v3/external_clients/aisdk.d.ts +11 -0
  219. package/dist/esm/lib/v3/external_clients/aisdk.js +103 -0
  220. package/dist/esm/lib/v3/external_clients/aisdk.js.map +1 -0
  221. package/dist/esm/lib/v3/external_clients/customOpenAI.d.ts +18 -0
  222. package/dist/esm/lib/v3/external_clients/customOpenAI.js +220 -0
  223. package/dist/esm/lib/v3/external_clients/customOpenAI.js.map +1 -0
  224. package/dist/esm/lib/v3/flowLogger.d.ts +139 -0
  225. package/dist/esm/lib/v3/flowLogger.js +868 -0
  226. package/dist/esm/lib/v3/flowLogger.js.map +1 -0
  227. package/dist/esm/lib/v3/handlers/actHandler.d.ts +21 -0
  228. package/dist/esm/lib/v3/handlers/actHandler.js +340 -0
  229. package/dist/esm/lib/v3/handlers/actHandler.js.map +1 -0
  230. package/dist/esm/lib/v3/handlers/extractHandler.d.ts +31 -0
  231. package/dist/esm/lib/v3/handlers/extractHandler.js +139 -0
  232. package/dist/esm/lib/v3/handlers/extractHandler.js.map +1 -0
  233. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +24 -0
  234. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js +623 -0
  235. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -0
  236. package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.d.ts +2 -0
  237. package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.js +14 -0
  238. package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.js.map +1 -0
  239. package/dist/esm/lib/v3/handlers/observeHandler.d.ts +17 -0
  240. package/dist/esm/lib/v3/handlers/observeHandler.js +156 -0
  241. package/dist/esm/lib/v3/handlers/observeHandler.js.map +1 -0
  242. package/dist/esm/lib/v3/handlers/v3AgentHandler.d.ts +32 -0
  243. package/dist/esm/lib/v3/handlers/v3AgentHandler.js +461 -0
  244. package/dist/esm/lib/v3/handlers/v3AgentHandler.js.map +1 -0
  245. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.d.ts +33 -0
  246. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js +528 -0
  247. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -0
  248. package/dist/esm/lib/v3/index.d.ts +17 -0
  249. package/dist/esm/lib/v3/index.js +13 -0
  250. package/dist/esm/lib/v3/index.js.map +1 -0
  251. package/dist/esm/lib/v3/launch/browserbase.d.ts +7 -0
  252. package/dist/esm/lib/v3/launch/browserbase.js +46 -0
  253. package/dist/esm/lib/v3/launch/browserbase.js.map +1 -0
  254. package/dist/esm/lib/v3/launch/local.d.ts +15 -0
  255. package/dist/esm/lib/v3/launch/local.js +98 -0
  256. package/dist/esm/lib/v3/launch/local.js.map +1 -0
  257. package/dist/esm/lib/v3/llm/AnthropicClient.d.ts +16 -0
  258. package/dist/esm/lib/v3/llm/AnthropicClient.js +239 -0
  259. package/dist/esm/lib/v3/llm/AnthropicClient.js.map +1 -0
  260. package/dist/esm/lib/v3/llm/CerebrasClient.d.ts +17 -0
  261. package/dist/esm/lib/v3/llm/CerebrasClient.js +235 -0
  262. package/dist/esm/lib/v3/llm/CerebrasClient.js.map +1 -0
  263. package/dist/esm/lib/v3/llm/GoogleClient.d.ts +19 -0
  264. package/dist/esm/lib/v3/llm/GoogleClient.js +369 -0
  265. package/dist/esm/lib/v3/llm/GoogleClient.js.map +1 -0
  266. package/dist/esm/lib/v3/llm/GroqClient.d.ts +17 -0
  267. package/dist/esm/lib/v3/llm/GroqClient.js +236 -0
  268. package/dist/esm/lib/v3/llm/GroqClient.js.map +1 -0
  269. package/dist/esm/lib/v3/llm/LLMClient.d.ts +121 -0
  270. package/dist/esm/lib/v3/llm/LLMClient.js +23 -0
  271. package/dist/esm/lib/v3/llm/LLMClient.js.map +1 -0
  272. package/dist/esm/lib/v3/llm/LLMProvider.d.ts +13 -0
  273. package/dist/esm/lib/v3/llm/LLMProvider.js +194 -0
  274. package/dist/esm/lib/v3/llm/LLMProvider.js.map +1 -0
  275. package/dist/esm/lib/v3/llm/OpenAIClient.d.ts +15 -0
  276. package/dist/esm/lib/v3/llm/OpenAIClient.js +329 -0
  277. package/dist/esm/lib/v3/llm/OpenAIClient.js.map +1 -0
  278. package/dist/esm/lib/v3/llm/aisdk.d.ts +15 -0
  279. package/dist/esm/lib/v3/llm/aisdk.js +348 -0
  280. package/dist/esm/lib/v3/llm/aisdk.js.map +1 -0
  281. package/dist/esm/lib/v3/logger.d.ts +9 -0
  282. package/dist/esm/lib/v3/logger.js +96 -0
  283. package/dist/esm/lib/v3/logger.js.map +1 -0
  284. package/dist/esm/lib/v3/mcp/connection.d.ts +11 -0
  285. package/dist/esm/lib/v3/mcp/connection.js +49 -0
  286. package/dist/esm/lib/v3/mcp/connection.js.map +1 -0
  287. package/dist/esm/lib/v3/mcp/utils.d.ts +3 -0
  288. package/dist/esm/lib/v3/mcp/utils.js +36 -0
  289. package/dist/esm/lib/v3/mcp/utils.js.map +1 -0
  290. package/dist/esm/lib/v3/shutdown/cleanupLocal.d.ts +14 -0
  291. package/dist/esm/lib/v3/shutdown/cleanupLocal.js +30 -0
  292. package/dist/esm/lib/v3/shutdown/cleanupLocal.js.map +1 -0
  293. package/dist/esm/lib/v3/shutdown/supervisor.d.ts +9 -0
  294. package/dist/esm/lib/v3/shutdown/supervisor.js +156 -0
  295. package/dist/esm/lib/v3/shutdown/supervisor.js.map +1 -0
  296. package/dist/esm/lib/v3/shutdown/supervisorClient.d.ts +15 -0
  297. package/dist/esm/lib/v3/shutdown/supervisorClient.js +97 -0
  298. package/dist/esm/lib/v3/shutdown/supervisorClient.js.map +1 -0
  299. package/dist/esm/lib/v3/tests/agent-abort-signal.spec.js +113 -0
  300. package/dist/esm/lib/v3/tests/agent-abort-signal.spec.js.map +7 -0
  301. package/dist/esm/lib/v3/tests/agent-cache-self-heal.spec.js +80 -0
  302. package/dist/esm/lib/v3/tests/agent-cache-self-heal.spec.js.map +7 -0
  303. package/dist/esm/lib/v3/tests/agent-callbacks.spec.js +374 -0
  304. package/dist/esm/lib/v3/tests/agent-callbacks.spec.js.map +7 -0
  305. package/dist/esm/lib/v3/tests/agent-experimental-validation.spec.js +357 -0
  306. package/dist/esm/lib/v3/tests/agent-experimental-validation.spec.js.map +7 -0
  307. package/dist/esm/lib/v3/tests/agent-hybrid-mode.spec.js +247 -0
  308. package/dist/esm/lib/v3/tests/agent-hybrid-mode.spec.js.map +7 -0
  309. package/dist/esm/lib/v3/tests/agent-message-continuation.spec.js +105 -0
  310. package/dist/esm/lib/v3/tests/agent-message-continuation.spec.js.map +7 -0
  311. package/dist/esm/lib/v3/tests/agent-streaming.spec.js +126 -0
  312. package/dist/esm/lib/v3/tests/agent-streaming.spec.js.map +7 -0
  313. package/dist/esm/lib/v3/tests/cdp-session-detached.spec.js +44 -0
  314. package/dist/esm/lib/v3/tests/cdp-session-detached.spec.js.map +7 -0
  315. package/dist/esm/lib/v3/tests/click-count.spec.js +112 -0
  316. package/dist/esm/lib/v3/tests/click-count.spec.js.map +7 -0
  317. package/dist/esm/lib/v3/tests/connect-to-existing-browser.spec.js +54 -0
  318. package/dist/esm/lib/v3/tests/connect-to-existing-browser.spec.js.map +7 -0
  319. package/dist/esm/lib/v3/tests/context-addInitScript.spec.js +176 -0
  320. package/dist/esm/lib/v3/tests/context-addInitScript.spec.js.map +7 -0
  321. package/dist/esm/lib/v3/tests/default-page-tracking.spec.js +53 -0
  322. package/dist/esm/lib/v3/tests/default-page-tracking.spec.js.map +7 -0
  323. package/dist/esm/lib/v3/tests/downloads.spec.js +58 -0
  324. package/dist/esm/lib/v3/tests/downloads.spec.js.map +7 -0
  325. package/dist/esm/lib/v3/tests/envReporter.js +57 -0
  326. package/dist/esm/lib/v3/tests/envReporter.js.map +7 -0
  327. package/dist/esm/lib/v3/tests/frame-get-location-and-click.spec.js +53 -0
  328. package/dist/esm/lib/v3/tests/frame-get-location-and-click.spec.js.map +7 -0
  329. package/dist/esm/lib/v3/tests/iframe-ctx-addInitScript.spec.js +447 -0
  330. package/dist/esm/lib/v3/tests/iframe-ctx-addInitScript.spec.js.map +7 -0
  331. package/dist/esm/lib/v3/tests/keep-alive.child.js +92 -0
  332. package/dist/esm/lib/v3/tests/keep-alive.child.js.map +7 -0
  333. package/dist/esm/lib/v3/tests/keep-alive.helpers.js +532 -0
  334. package/dist/esm/lib/v3/tests/keep-alive.helpers.js.map +7 -0
  335. package/dist/esm/lib/v3/tests/keep-alive.spec.js +19 -0
  336. package/dist/esm/lib/v3/tests/keep-alive.spec.js.map +7 -0
  337. package/dist/esm/lib/v3/tests/keyboard.spec.js +296 -0
  338. package/dist/esm/lib/v3/tests/keyboard.spec.js.map +7 -0
  339. package/dist/esm/lib/v3/tests/locator-backend-node-id.spec.js +159 -0
  340. package/dist/esm/lib/v3/tests/locator-backend-node-id.spec.js.map +7 -0
  341. package/dist/esm/lib/v3/tests/locator-content-methods.spec.js +191 -0
  342. package/dist/esm/lib/v3/tests/locator-content-methods.spec.js.map +7 -0
  343. package/dist/esm/lib/v3/tests/locator-count-iframe.spec.js +108 -0
  344. package/dist/esm/lib/v3/tests/locator-count-iframe.spec.js.map +7 -0
  345. package/dist/esm/lib/v3/tests/locator-count.spec.js +71 -0
  346. package/dist/esm/lib/v3/tests/locator-count.spec.js.map +7 -0
  347. package/dist/esm/lib/v3/tests/locator-fill.spec.js +118 -0
  348. package/dist/esm/lib/v3/tests/locator-fill.spec.js.map +7 -0
  349. package/dist/esm/lib/v3/tests/locator-input-methods.spec.js +136 -0
  350. package/dist/esm/lib/v3/tests/locator-input-methods.spec.js.map +7 -0
  351. package/dist/esm/lib/v3/tests/locator-nth.spec.js +157 -0
  352. package/dist/esm/lib/v3/tests/locator-nth.spec.js.map +7 -0
  353. package/dist/esm/lib/v3/tests/locator-select-option.spec.js +242 -0
  354. package/dist/esm/lib/v3/tests/locator-select-option.spec.js.map +7 -0
  355. package/dist/esm/lib/v3/tests/logger-initialization.spec.js +552 -0
  356. package/dist/esm/lib/v3/tests/logger-initialization.spec.js.map +7 -0
  357. package/dist/esm/lib/v3/tests/multi-instance-logger.spec.js +269 -0
  358. package/dist/esm/lib/v3/tests/multi-instance-logger.spec.js.map +7 -0
  359. package/dist/esm/lib/v3/tests/nested-div.spec.js +23 -0
  360. package/dist/esm/lib/v3/tests/nested-div.spec.js.map +7 -0
  361. package/dist/esm/lib/v3/tests/page-addInitScript.spec.js +90 -0
  362. package/dist/esm/lib/v3/tests/page-addInitScript.spec.js.map +7 -0
  363. package/dist/esm/lib/v3/tests/page-console.spec.js +56 -0
  364. package/dist/esm/lib/v3/tests/page-console.spec.js.map +7 -0
  365. package/dist/esm/lib/v3/tests/page-drag-and-drop.spec.js +418 -0
  366. package/dist/esm/lib/v3/tests/page-drag-and-drop.spec.js.map +7 -0
  367. package/dist/esm/lib/v3/tests/page-goto-response.spec.js +35 -0
  368. package/dist/esm/lib/v3/tests/page-goto-response.spec.js.map +7 -0
  369. package/dist/esm/lib/v3/tests/page-hover.spec.js +167 -0
  370. package/dist/esm/lib/v3/tests/page-hover.spec.js.map +7 -0
  371. package/dist/esm/lib/v3/tests/page-screenshot.spec.js +273 -0
  372. package/dist/esm/lib/v3/tests/page-screenshot.spec.js.map +7 -0
  373. package/dist/esm/lib/v3/tests/page-scroll.spec.js +182 -0
  374. package/dist/esm/lib/v3/tests/page-scroll.spec.js.map +7 -0
  375. package/dist/esm/lib/v3/tests/page-send-cdp.spec.js +46 -0
  376. package/dist/esm/lib/v3/tests/page-send-cdp.spec.js.map +7 -0
  377. package/dist/esm/lib/v3/tests/perform-understudy-method.spec.js +98 -0
  378. package/dist/esm/lib/v3/tests/perform-understudy-method.spec.js.map +7 -0
  379. package/dist/esm/lib/v3/tests/setinputfiles.spec.js +126 -0
  380. package/dist/esm/lib/v3/tests/setinputfiles.spec.js.map +7 -0
  381. package/dist/esm/lib/v3/tests/shadow-iframe-oopif.spec.js +134 -0
  382. package/dist/esm/lib/v3/tests/shadow-iframe-oopif.spec.js.map +7 -0
  383. package/dist/esm/lib/v3/tests/shadow-iframe-spif.spec.js +134 -0
  384. package/dist/esm/lib/v3/tests/shadow-iframe-spif.spec.js.map +7 -0
  385. package/dist/esm/lib/v3/tests/testUtils.js +31 -0
  386. package/dist/esm/lib/v3/tests/testUtils.js.map +7 -0
  387. package/dist/esm/lib/v3/tests/text-selector-innermost.spec.js +100 -0
  388. package/dist/esm/lib/v3/tests/text-selector-innermost.spec.js.map +7 -0
  389. package/dist/esm/lib/v3/tests/timeouts.spec.js +32 -0
  390. package/dist/esm/lib/v3/tests/timeouts.spec.js.map +7 -0
  391. package/dist/esm/lib/v3/tests/user-data-dir.spec.js +43 -0
  392. package/dist/esm/lib/v3/tests/user-data-dir.spec.js.map +7 -0
  393. package/dist/esm/lib/v3/tests/v3.config.js +15 -0
  394. package/dist/esm/lib/v3/tests/v3.config.js.map +7 -0
  395. package/dist/esm/lib/v3/tests/v3.dynamic.config.js +43 -0
  396. package/dist/esm/lib/v3/tests/v3.dynamic.config.js.map +7 -0
  397. package/dist/esm/lib/v3/tests/v3.playwright.config.js +98 -0
  398. package/dist/esm/lib/v3/tests/v3.playwright.config.js.map +7 -0
  399. package/dist/esm/lib/v3/tests/wait-for-selector.spec.js +593 -0
  400. package/dist/esm/lib/v3/tests/wait-for-selector.spec.js.map +7 -0
  401. package/dist/esm/lib/v3/tests/wait-for-timeout.spec.js +97 -0
  402. package/dist/esm/lib/v3/tests/wait-for-timeout.spec.js.map +7 -0
  403. package/dist/esm/lib/v3/tests/xpath-for-location-deep.spec.js +77 -0
  404. package/dist/esm/lib/v3/tests/xpath-for-location-deep.spec.js.map +7 -0
  405. package/dist/esm/lib/v3/timeoutConfig.d.ts +2 -0
  406. package/dist/esm/lib/v3/timeoutConfig.js +27 -0
  407. package/dist/esm/lib/v3/timeoutConfig.js.map +1 -0
  408. package/dist/esm/lib/v3/types/private/agent.d.ts +6 -0
  409. package/dist/esm/lib/v3/types/private/agent.js +2 -0
  410. package/dist/esm/lib/v3/types/private/agent.js.map +1 -0
  411. package/dist/esm/lib/v3/types/private/api.d.ts +11 -0
  412. package/dist/esm/lib/v3/types/private/api.js +2 -0
  413. package/dist/esm/lib/v3/types/private/api.js.map +1 -0
  414. package/dist/esm/lib/v3/types/private/cache.d.ts +128 -0
  415. package/dist/esm/lib/v3/types/private/cache.js +2 -0
  416. package/dist/esm/lib/v3/types/private/cache.js.map +1 -0
  417. package/dist/esm/lib/v3/types/private/evaluator.d.ts +40 -0
  418. package/dist/esm/lib/v3/types/private/evaluator.js +2 -0
  419. package/dist/esm/lib/v3/types/private/evaluator.js.map +1 -0
  420. package/dist/esm/lib/v3/types/private/handlers.d.ts +38 -0
  421. package/dist/esm/lib/v3/types/private/handlers.js +16 -0
  422. package/dist/esm/lib/v3/types/private/handlers.js.map +1 -0
  423. package/dist/esm/lib/v3/types/private/index.d.ts +7 -0
  424. package/dist/esm/lib/v3/types/private/index.js +8 -0
  425. package/dist/esm/lib/v3/types/private/index.js.map +1 -0
  426. package/dist/esm/lib/v3/types/private/internal.d.ts +39 -0
  427. package/dist/esm/lib/v3/types/private/internal.js +2 -0
  428. package/dist/esm/lib/v3/types/private/internal.js.map +1 -0
  429. package/dist/esm/lib/v3/types/private/locator.d.ts +9 -0
  430. package/dist/esm/lib/v3/types/private/locator.js +2 -0
  431. package/dist/esm/lib/v3/types/private/locator.js.map +1 -0
  432. package/dist/esm/lib/v3/types/private/network.d.ts +34 -0
  433. package/dist/esm/lib/v3/types/private/network.js +3 -0
  434. package/dist/esm/lib/v3/types/private/network.js.map +1 -0
  435. package/dist/esm/lib/v3/types/private/shutdown.d.ts +31 -0
  436. package/dist/esm/lib/v3/types/private/shutdown.js +5 -0
  437. package/dist/esm/lib/v3/types/private/shutdown.js.map +1 -0
  438. package/dist/esm/lib/v3/types/private/shutdownErrors.d.ts +12 -0
  439. package/dist/esm/lib/v3/types/private/shutdownErrors.js +22 -0
  440. package/dist/esm/lib/v3/types/private/shutdownErrors.js.map +1 -0
  441. package/dist/esm/lib/v3/types/private/snapshot.d.ts +117 -0
  442. package/dist/esm/lib/v3/types/private/snapshot.js +2 -0
  443. package/dist/esm/lib/v3/types/private/snapshot.js.map +1 -0
  444. package/dist/esm/lib/v3/types/public/agent.d.ts +595 -0
  445. package/dist/esm/lib/v3/types/public/agent.js +15 -0
  446. package/dist/esm/lib/v3/types/public/agent.js.map +1 -0
  447. package/dist/esm/lib/v3/types/public/api.d.ts +1211 -0
  448. package/dist/esm/lib/v3/types/public/api.js +915 -0
  449. package/dist/esm/lib/v3/types/public/api.js.map +1 -0
  450. package/dist/esm/lib/v3/types/public/apiErrors.d.ts +18 -0
  451. package/dist/esm/lib/v3/types/public/apiErrors.js +32 -0
  452. package/dist/esm/lib/v3/types/public/apiErrors.js.map +1 -0
  453. package/dist/esm/lib/v3/types/public/index.d.ts +12 -0
  454. package/dist/esm/lib/v3/types/public/index.js +14 -0
  455. package/dist/esm/lib/v3/types/public/index.js.map +1 -0
  456. package/dist/esm/lib/v3/types/public/locator.d.ts +9 -0
  457. package/dist/esm/lib/v3/types/public/locator.js +2 -0
  458. package/dist/esm/lib/v3/types/public/locator.js.map +1 -0
  459. package/dist/esm/lib/v3/types/public/logs.d.ts +23 -0
  460. package/dist/esm/lib/v3/types/public/logs.js +13 -0
  461. package/dist/esm/lib/v3/types/public/logs.js.map +1 -0
  462. package/dist/esm/lib/v3/types/public/methods.d.ts +56 -0
  463. package/dist/esm/lib/v3/types/public/methods.js +15 -0
  464. package/dist/esm/lib/v3/types/public/methods.js.map +1 -0
  465. package/dist/esm/lib/v3/types/public/metrics.d.ts +27 -0
  466. package/dist/esm/lib/v3/types/public/metrics.js +2 -0
  467. package/dist/esm/lib/v3/types/public/metrics.js.map +1 -0
  468. package/dist/esm/lib/v3/types/public/model.d.ts +65 -0
  469. package/dist/esm/lib/v3/types/public/model.js +2 -0
  470. package/dist/esm/lib/v3/types/public/model.js.map +1 -0
  471. package/dist/esm/lib/v3/types/public/options.d.ts +70 -0
  472. package/dist/esm/lib/v3/types/public/options.js +4 -0
  473. package/dist/esm/lib/v3/types/public/options.js.map +1 -0
  474. package/dist/esm/lib/v3/types/public/page.d.ts +18 -0
  475. package/dist/esm/lib/v3/types/public/page.js +3 -0
  476. package/dist/esm/lib/v3/types/public/page.js.map +1 -0
  477. package/dist/esm/lib/v3/types/public/screenshotTypes.d.ts +25 -0
  478. package/dist/esm/lib/v3/types/public/screenshotTypes.js +2 -0
  479. package/dist/esm/lib/v3/types/public/screenshotTypes.js.map +1 -0
  480. package/dist/esm/lib/v3/types/public/sdkErrors.d.ts +152 -0
  481. package/dist/esm/lib/v3/types/public/sdkErrors.js +305 -0
  482. package/dist/esm/lib/v3/types/public/sdkErrors.js.map +1 -0
  483. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.d.ts +15 -0
  484. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js +196 -0
  485. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js.map +1 -0
  486. package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.d.ts +8 -0
  487. package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.js +121 -0
  488. package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.js.map +1 -0
  489. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.d.ts +77 -0
  490. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js +336 -0
  491. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -0
  492. package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.d.ts +7 -0
  493. package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js +129 -0
  494. package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js.map +1 -0
  495. package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.d.ts +46 -0
  496. package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.js +274 -0
  497. package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.js.map +1 -0
  498. package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.d.ts +24 -0
  499. package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.js +216 -0
  500. package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.js.map +1 -0
  501. package/dist/esm/lib/v3/understudy/a11y/snapshot/index.d.ts +4 -0
  502. package/dist/esm/lib/v3/understudy/a11y/snapshot/index.js +5 -0
  503. package/dist/esm/lib/v3/understudy/a11y/snapshot/index.js.map +1 -0
  504. package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.d.ts +16 -0
  505. package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.js +22 -0
  506. package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.js.map +1 -0
  507. package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.d.ts +28 -0
  508. package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js +135 -0
  509. package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js.map +1 -0
  510. package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.d.ts +26 -0
  511. package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.js +102 -0
  512. package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.js.map +1 -0
  513. package/dist/esm/lib/v3/understudy/a11yInvocation.d.ts +8 -0
  514. package/dist/esm/lib/v3/understudy/a11yInvocation.js +12 -0
  515. package/dist/esm/lib/v3/understudy/a11yInvocation.js.map +1 -0
  516. package/dist/esm/lib/v3/understudy/cdp.d.ts +69 -0
  517. package/dist/esm/lib/v3/understudy/cdp.js +251 -0
  518. package/dist/esm/lib/v3/understudy/cdp.js.map +1 -0
  519. package/dist/esm/lib/v3/understudy/consoleMessage.d.ts +22 -0
  520. package/dist/esm/lib/v3/understudy/consoleMessage.js +66 -0
  521. package/dist/esm/lib/v3/understudy/consoleMessage.js.map +1 -0
  522. package/dist/esm/lib/v3/understudy/context.d.ts +132 -0
  523. package/dist/esm/lib/v3/understudy/context.js +687 -0
  524. package/dist/esm/lib/v3/understudy/context.js.map +1 -0
  525. package/dist/esm/lib/v3/understudy/deepLocator.d.ts +87 -0
  526. package/dist/esm/lib/v3/understudy/deepLocator.js +218 -0
  527. package/dist/esm/lib/v3/understudy/deepLocator.js.map +1 -0
  528. package/dist/esm/lib/v3/understudy/executionContextRegistry.d.ts +15 -0
  529. package/dist/esm/lib/v3/understudy/executionContextRegistry.js +83 -0
  530. package/dist/esm/lib/v3/understudy/executionContextRegistry.js.map +1 -0
  531. package/dist/esm/lib/v3/understudy/fileUploadUtils.d.ts +13 -0
  532. package/dist/esm/lib/v3/understudy/fileUploadUtils.js +81 -0
  533. package/dist/esm/lib/v3/understudy/fileUploadUtils.js.map +1 -0
  534. package/dist/esm/lib/v3/understudy/frame.d.ts +69 -0
  535. package/dist/esm/lib/v3/understudy/frame.js +211 -0
  536. package/dist/esm/lib/v3/understudy/frame.js.map +1 -0
  537. package/dist/esm/lib/v3/understudy/frameLocator.d.ts +50 -0
  538. package/dist/esm/lib/v3/understudy/frameLocator.js +255 -0
  539. package/dist/esm/lib/v3/understudy/frameLocator.js.map +1 -0
  540. package/dist/esm/lib/v3/understudy/frameRegistry.d.ts +101 -0
  541. package/dist/esm/lib/v3/understudy/frameRegistry.js +298 -0
  542. package/dist/esm/lib/v3/understudy/frameRegistry.js.map +1 -0
  543. package/dist/esm/lib/v3/understudy/initScripts.d.ts +2 -0
  544. package/dist/esm/lib/v3/understudy/initScripts.js +33 -0
  545. package/dist/esm/lib/v3/understudy/initScripts.js.map +1 -0
  546. package/dist/esm/lib/v3/understudy/lifecycleWatcher.d.ts +64 -0
  547. package/dist/esm/lib/v3/understudy/lifecycleWatcher.js +245 -0
  548. package/dist/esm/lib/v3/understudy/lifecycleWatcher.js.map +1 -0
  549. package/dist/esm/lib/v3/understudy/locator.d.ts +194 -0
  550. package/dist/esm/lib/v3/understudy/locator.js +753 -0
  551. package/dist/esm/lib/v3/understudy/locator.js.map +1 -0
  552. package/dist/esm/lib/v3/understudy/locatorInvocation.d.ts +8 -0
  553. package/dist/esm/lib/v3/understudy/locatorInvocation.js +12 -0
  554. package/dist/esm/lib/v3/understudy/locatorInvocation.js.map +1 -0
  555. package/dist/esm/lib/v3/understudy/navigationResponseTracker.d.ts +84 -0
  556. package/dist/esm/lib/v3/understudy/navigationResponseTracker.js +224 -0
  557. package/dist/esm/lib/v3/understudy/navigationResponseTracker.js.map +1 -0
  558. package/dist/esm/lib/v3/understudy/networkManager.d.ts +53 -0
  559. package/dist/esm/lib/v3/understudy/networkManager.js +306 -0
  560. package/dist/esm/lib/v3/understudy/networkManager.js.map +1 -0
  561. package/dist/esm/lib/v3/understudy/page.d.ts +354 -0
  562. package/dist/esm/lib/v3/understudy/page.js +1941 -0
  563. package/dist/esm/lib/v3/understudy/page.js.map +1 -0
  564. package/dist/esm/lib/v3/understudy/piercer.d.ts +4 -0
  565. package/dist/esm/lib/v3/understudy/piercer.js +61 -0
  566. package/dist/esm/lib/v3/understudy/piercer.js.map +1 -0
  567. package/dist/esm/lib/v3/understudy/response.d.ts +137 -0
  568. package/dist/esm/lib/v3/understudy/response.js +330 -0
  569. package/dist/esm/lib/v3/understudy/response.js.map +1 -0
  570. package/dist/esm/lib/v3/understudy/screenshotUtils.d.ts +16 -0
  571. package/dist/esm/lib/v3/understudy/screenshotUtils.js +352 -0
  572. package/dist/esm/lib/v3/understudy/screenshotUtils.js.map +1 -0
  573. package/dist/esm/lib/v3/understudy/selectorResolver.d.ts +38 -0
  574. package/dist/esm/lib/v3/understudy/selectorResolver.js +296 -0
  575. package/dist/esm/lib/v3/understudy/selectorResolver.js.map +1 -0
  576. package/dist/esm/lib/v3/v3.d.ts +191 -0
  577. package/dist/esm/lib/v3/v3.js +1572 -0
  578. package/dist/esm/lib/v3/v3.js.map +1 -0
  579. package/dist/esm/lib/v3/zodCompat.d.ts +12 -0
  580. package/dist/esm/lib/v3/zodCompat.js +17 -0
  581. package/dist/esm/lib/v3/zodCompat.js.map +1 -0
  582. package/dist/esm/lib/v3Evaluator.d.ts +19 -0
  583. package/dist/esm/lib/v3Evaluator.js +210 -0
  584. package/dist/esm/lib/v3Evaluator.js.map +1 -0
  585. package/dist/esm/lib/version.d.ts +5 -0
  586. package/dist/esm/lib/version.js +6 -0
  587. package/dist/esm/lib/version.js.map +1 -0
  588. package/dist/esm/package.json +3 -0
  589. package/dist/esm/tests/agent-execution-model.test.js +139 -0
  590. package/dist/esm/tests/agent-execution-model.test.js.map +7 -0
  591. package/dist/esm/tests/browserbase-session-accessors.test.js +101 -0
  592. package/dist/esm/tests/browserbase-session-accessors.test.js.map +7 -0
  593. package/dist/esm/tests/cache-llm-resolution.test.js +187 -0
  594. package/dist/esm/tests/cache-llm-resolution.test.js.map +7 -0
  595. package/dist/esm/tests/helpers/mockCDPSession.js +27 -0
  596. package/dist/esm/tests/helpers/mockCDPSession.js.map +7 -0
  597. package/dist/esm/tests/llm-provider.test.js +57 -0
  598. package/dist/esm/tests/llm-provider.test.js.map +7 -0
  599. package/dist/esm/tests/model-deprecation.test.js +135 -0
  600. package/dist/esm/tests/model-deprecation.test.js.map +7 -0
  601. package/dist/esm/tests/model-utils.test.js +43 -0
  602. package/dist/esm/tests/model-utils.test.js.map +7 -0
  603. package/dist/esm/tests/page-snapshot.test.js +36 -0
  604. package/dist/esm/tests/page-snapshot.test.js.map +7 -0
  605. package/dist/esm/tests/public-api/export-surface.test.js +53 -0
  606. package/dist/esm/tests/public-api/export-surface.test.js.map +7 -0
  607. package/dist/esm/tests/public-api/llm-and-agents.test.js +128 -0
  608. package/dist/esm/tests/public-api/llm-and-agents.test.js.map +7 -0
  609. package/dist/esm/tests/public-api/public-error-types.test.js +71 -0
  610. package/dist/esm/tests/public-api/public-error-types.test.js.map +7 -0
  611. package/dist/esm/tests/public-api/public-types.test.js +74 -0
  612. package/dist/esm/tests/public-api/public-types.test.js.map +7 -0
  613. package/dist/esm/tests/public-api/runtime-utils.test.js +31 -0
  614. package/dist/esm/tests/public-api/runtime-utils.test.js.map +7 -0
  615. package/dist/esm/tests/public-api/schema-utils.test.js +78 -0
  616. package/dist/esm/tests/public-api/schema-utils.test.js.map +7 -0
  617. package/dist/esm/tests/public-api/timeout-error-types.test.js +81 -0
  618. package/dist/esm/tests/public-api/timeout-error-types.test.js.map +7 -0
  619. package/dist/esm/tests/public-api/tool-type-export.test.js +25 -0
  620. package/dist/esm/tests/public-api/tool-type-export.test.js.map +7 -0
  621. package/dist/esm/tests/public-api/v3-core.test.js +82 -0
  622. package/dist/esm/tests/public-api/v3-core.test.js.map +7 -0
  623. package/dist/esm/tests/safety-confirmation.test.js +134 -0
  624. package/dist/esm/tests/safety-confirmation.test.js.map +7 -0
  625. package/dist/esm/tests/snapshot-a11y-resolvers.test.js +348 -0
  626. package/dist/esm/tests/snapshot-a11y-resolvers.test.js.map +7 -0
  627. package/dist/esm/tests/snapshot-a11y-tree-utils.test.js +300 -0
  628. package/dist/esm/tests/snapshot-a11y-tree-utils.test.js.map +7 -0
  629. package/dist/esm/tests/snapshot-capture-orchestration.test.js +381 -0
  630. package/dist/esm/tests/snapshot-capture-orchestration.test.js.map +7 -0
  631. package/dist/esm/tests/snapshot-cbor.test.js +197 -0
  632. package/dist/esm/tests/snapshot-cbor.test.js.map +7 -0
  633. package/dist/esm/tests/snapshot-dom-session-builders.test.js +251 -0
  634. package/dist/esm/tests/snapshot-dom-session-builders.test.js.map +7 -0
  635. package/dist/esm/tests/snapshot-dom-tree-utils.test.js +109 -0
  636. package/dist/esm/tests/snapshot-dom-tree-utils.test.js.map +7 -0
  637. package/dist/esm/tests/snapshot-focus-selectors-utils.test.js +49 -0
  638. package/dist/esm/tests/snapshot-focus-selectors-utils.test.js.map +7 -0
  639. package/dist/esm/tests/snapshot-frame-merge.test.js +391 -0
  640. package/dist/esm/tests/snapshot-frame-merge.test.js.map +7 -0
  641. package/dist/esm/tests/snapshot-tree-format-utils.test.js +113 -0
  642. package/dist/esm/tests/snapshot-tree-format-utils.test.js.map +7 -0
  643. package/dist/esm/tests/snapshot-xpath-utils.test.js +79 -0
  644. package/dist/esm/tests/snapshot-xpath-utils.test.js.map +7 -0
  645. package/dist/esm/tests/timeout-handlers.test.js +850 -0
  646. package/dist/esm/tests/timeout-handlers.test.js.map +7 -0
  647. package/dist/esm/tests/xpath-parser.test.js +317 -0
  648. package/dist/esm/tests/xpath-parser.test.js.map +7 -0
  649. package/dist/esm/tests/xpath-resolver.test.js +73 -0
  650. package/dist/esm/tests/xpath-resolver.test.js.map +7 -0
  651. package/dist/esm/tests/zod-enum-compatibility.test.js +97 -0
  652. package/dist/esm/tests/zod-enum-compatibility.test.js.map +7 -0
  653. package/package.json +37 -24
  654. package/dist/index.d.ts +0 -4363
  655. package/dist/index.js +0 -76530
@@ -0,0 +1,753 @@
1
+ import * as fs from "fs";
2
+ import * as os from "os";
3
+ import * as path from "path";
4
+ import { locatorScriptBootstrap, locatorScriptGlobalRefs, locatorScriptSources, } from "../dom/build/locatorScripts.generated.js";
5
+ import { FrameSelectorResolver, } from "./selectorResolver.js";
6
+ import { StagehandElementNotFoundError, StagehandInvalidArgumentError, StagehandLocatorError, ElementNotVisibleError, } from "../types/public/sdkErrors.js";
7
+ import { normalizeInputFiles } from "./fileUploadUtils.js";
8
+ const MAX_REMOTE_UPLOAD_BYTES = 50 * 1024 * 1024; // 50MB guard copied from Playwright
9
+ /**
10
+ * Locator
11
+ *
12
+ * Purpose:
13
+ * A small, CDP-based element interaction helper scoped to a specific `Frame`.
14
+ * It resolves a CSS/XPath selector inside the frame’s **isolated world**, and then
15
+ * performs low-level actions (click, type, select) using DOM/Runtime/Input
16
+ * protocol domains with minimal abstraction.
17
+ *
18
+ * Key change:
19
+ * - Prefer **objectId**-based CDP calls (scroll, geometry) to avoid brittle
20
+ * frontend nodeId mappings. nodeId is resolved on a best-effort basis and
21
+ * returned for compatibility, but actions do not depend on it.
22
+ *
23
+ * Notes:
24
+ * - Resolution is lazy: every action resolves the selector again.
25
+ * - Uses `Page.createIsolatedWorld` so evaluation is isolated from page scripts.
26
+ * - Releases remote objects (`Runtime.releaseObject`) where appropriate.
27
+ */
28
+ export class Locator {
29
+ frame;
30
+ selector;
31
+ options;
32
+ selectorResolver;
33
+ selectorQuery;
34
+ // -1 means "no explicit nth()"; default locator resolves to first match for actions.
35
+ nthIndex;
36
+ constructor(frame, selector, options, nthIndex = -1) {
37
+ this.frame = frame;
38
+ this.selector = selector;
39
+ this.options = options;
40
+ this.selectorResolver = new FrameSelectorResolver(this.frame);
41
+ this.selectorQuery = FrameSelectorResolver.parseSelector(selector);
42
+ const normalized = Number.isFinite(nthIndex) ? Math.floor(nthIndex) : -1;
43
+ this.nthIndex = normalized < 0 ? -1 : normalized;
44
+ }
45
+ /** Return the owning Frame for this locator (typed accessor, no private access). */
46
+ getFrame() {
47
+ return this.frame;
48
+ }
49
+ /**
50
+ * Set files on an <input type="file"> element.
51
+ *
52
+ * Mirrors Playwright's Locator.setInputFiles basics:
53
+ * - Accepts file path(s) or payload object(s) { name, mimeType, buffer }.
54
+ * - Uses CDP DOM.setFileInputFiles under the hood.
55
+ * - Best‑effort dispatches change/input via CDP (Chrome does by default).
56
+ * - Passing an empty array clears the selection.
57
+ */
58
+ async setInputFiles(files) {
59
+ const session = this.frame.session;
60
+ const { objectId } = await this.resolveNode();
61
+ const tempFiles = [];
62
+ try {
63
+ // Validate element is an <input type="file">
64
+ try {
65
+ const res = await session.send("Runtime.callFunctionOn", {
66
+ objectId,
67
+ functionDeclaration: locatorScriptSources.ensureFileInputElement,
68
+ returnByValue: true,
69
+ });
70
+ const ok = Boolean(res.result.value);
71
+ if (!ok)
72
+ throw new StagehandInvalidArgumentError('Target is not an <input type="file"> element');
73
+ }
74
+ catch (e) {
75
+ throw new StagehandInvalidArgumentError(e instanceof Error
76
+ ? e.message
77
+ : "Unable to verify file input element");
78
+ }
79
+ const normalized = await normalizeInputFiles(files);
80
+ if (!normalized.length) {
81
+ await session.send("DOM.setFileInputFiles", {
82
+ objectId,
83
+ files: [],
84
+ });
85
+ return;
86
+ }
87
+ if (this.frame.isBrowserRemote()) {
88
+ await this.assignFilesViaPayloadInjection(objectId, normalized);
89
+ return;
90
+ }
91
+ const filePaths = [];
92
+ for (const payload of normalized) {
93
+ if (payload.absolutePath) {
94
+ filePaths.push(payload.absolutePath);
95
+ continue;
96
+ }
97
+ const ext = path.extname(payload.name);
98
+ const tmp = path.join(os.tmpdir(), `stagehand-upload-${Date.now()}-${Math.random().toString(36).slice(2)}${ext}`);
99
+ await fs.promises.writeFile(tmp, payload.buffer);
100
+ tempFiles.push(tmp);
101
+ filePaths.push(tmp);
102
+ }
103
+ await session.send("DOM.setFileInputFiles", {
104
+ objectId,
105
+ files: filePaths,
106
+ });
107
+ }
108
+ finally {
109
+ // Cleanup: release element and remove any temporary files we created
110
+ await session
111
+ .send("Runtime.releaseObject", { objectId })
112
+ .catch(() => { });
113
+ for (const p of tempFiles) {
114
+ try {
115
+ await fs.promises.unlink(p);
116
+ }
117
+ catch {
118
+ // ignore
119
+ }
120
+ }
121
+ }
122
+ }
123
+ /**
124
+ * Remote browser fallback: build File objects inside the page and attach them via JS.
125
+ *
126
+ * When Stagehand is driving a browser that cannot see the local filesystem (Browserbase,
127
+ * remote CDP, etc.), CDP's DOM.setFileInputFiles would fail because Chrome can't reach
128
+ * our temp files. Instead we base64-encode the payloads, send them into the page, and
129
+ * let a DOM helper create File objects + dispatch change/input events.
130
+ */
131
+ async assignFilesViaPayloadInjection(objectId, files) {
132
+ const session = this.frame.session;
133
+ for (const payload of files) {
134
+ if (payload.buffer.length > MAX_REMOTE_UPLOAD_BYTES) {
135
+ throw new StagehandInvalidArgumentError(`setInputFiles(): file "${payload.name}" is larger than the 50MB limit for remote uploads`);
136
+ }
137
+ }
138
+ const serialized = files.map((payload) => ({
139
+ name: payload.name,
140
+ mimeType: payload.mimeType,
141
+ lastModified: payload.lastModified,
142
+ base64: payload.buffer.toString("base64"),
143
+ }));
144
+ const res = await session.send("Runtime.callFunctionOn", {
145
+ objectId,
146
+ functionDeclaration: locatorScriptSources.assignFilePayloadsToInputElement,
147
+ arguments: [
148
+ {
149
+ value: serialized,
150
+ },
151
+ ],
152
+ returnByValue: true,
153
+ });
154
+ const ok = Boolean(res.result?.value);
155
+ if (!ok) {
156
+ throw new StagehandInvalidArgumentError("Unable to assign file payloads to remote input element");
157
+ }
158
+ }
159
+ /**
160
+ * Return the DOM backendNodeId for this locator's target element.
161
+ * Useful for identity comparisons without needing element handles.
162
+ */
163
+ async backendNodeId() {
164
+ const session = this.frame.session;
165
+ const { objectId } = await this.resolveNode();
166
+ try {
167
+ await session.send("DOM.enable").catch(() => { });
168
+ const { node } = await session.send("DOM.describeNode", { objectId });
169
+ return node.backendNodeId;
170
+ }
171
+ finally {
172
+ await session
173
+ .send("Runtime.releaseObject", { objectId })
174
+ .catch(() => { });
175
+ }
176
+ }
177
+ /** Return how many nodes the current selector resolves to. */
178
+ async count() {
179
+ const session = this.frame.session;
180
+ await session.send("Runtime.enable");
181
+ await session.send("DOM.enable");
182
+ return this.selectorResolver.count(this.selectorQuery);
183
+ }
184
+ /**
185
+ * Return the center of the element's bounding box in the owning frame's viewport
186
+ * (CSS pixels), rounded to integers. Scrolls into view best-effort.
187
+ */
188
+ async centroid() {
189
+ const session = this.frame.session;
190
+ const { objectId } = await this.resolveNode();
191
+ try {
192
+ await session
193
+ .send("DOM.scrollIntoViewIfNeeded", { objectId })
194
+ .catch(() => { });
195
+ const box = await session.send("DOM.getBoxModel", { objectId });
196
+ if (!box.model)
197
+ throw new ElementNotVisibleError(this.selector);
198
+ const { cx, cy } = this.centerFromBoxContent(box.model.content);
199
+ return { x: Math.round(cx), y: Math.round(cy) };
200
+ }
201
+ finally {
202
+ await session
203
+ .send("Runtime.releaseObject", { objectId })
204
+ .catch(() => { });
205
+ }
206
+ }
207
+ /**
208
+ * Highlight the element's bounding box using the CDP Overlay domain.
209
+ * - Scrolls element into view best-effort.
210
+ * - Shows a semi-transparent overlay briefly, then hides it.
211
+ */
212
+ async highlight(options) {
213
+ const session = this.frame.session;
214
+ const { objectId } = await this.resolveNode();
215
+ const duration = Math.max(0, options?.durationMs ?? 800);
216
+ const borderColor = options?.borderColor ?? { r: 255, g: 0, b: 0, a: 0.9 };
217
+ const contentColor = options?.contentColor ?? { r: 255, g: 200, b: 0, a: 0.2 };
218
+ try {
219
+ await session.send("Overlay.enable").catch(() => { });
220
+ await session
221
+ .send("DOM.scrollIntoViewIfNeeded", { objectId })
222
+ .catch(() => { });
223
+ // Prefer backendNodeId to keep highlight stable even if objectId is released.
224
+ await session.send("DOM.enable").catch(() => { });
225
+ let backendNodeId;
226
+ try {
227
+ const { node } = await session.send("DOM.describeNode", { objectId });
228
+ backendNodeId = node.backendNodeId;
229
+ }
230
+ catch {
231
+ backendNodeId = undefined;
232
+ }
233
+ const highlightConfig = {
234
+ showInfo: false,
235
+ showStyles: false,
236
+ showRulers: false,
237
+ showExtensionLines: false,
238
+ borderColor,
239
+ contentColor,
240
+ };
241
+ const highlightOnce = async () => {
242
+ await session.send("Overlay.highlightNode", {
243
+ ...(backendNodeId ? { backendNodeId } : { objectId }),
244
+ highlightConfig,
245
+ });
246
+ };
247
+ // Initial draw
248
+ await highlightOnce();
249
+ // Keep alive until duration elapses to resist overlay clears on mouse move/repaints
250
+ if (duration > 0) {
251
+ const start = Date.now();
252
+ const tick = Math.min(300, Math.max(100, Math.floor(duration / 50)));
253
+ while (Date.now() - start < duration) {
254
+ await new Promise((r) => setTimeout(r, tick));
255
+ try {
256
+ await highlightOnce();
257
+ }
258
+ catch {
259
+ // ignore transient errors
260
+ }
261
+ }
262
+ await session.send("Overlay.hideHighlight").catch(() => { });
263
+ }
264
+ }
265
+ finally {
266
+ // Releasing objectId should not affect highlight when using backendNodeId.
267
+ await session
268
+ .send("Runtime.releaseObject", { objectId })
269
+ .catch(() => { });
270
+ }
271
+ }
272
+ /**
273
+ * Move the mouse cursor to the element's visual center without clicking.
274
+ * - Scrolls into view best-effort, resolves geometry, then dispatches a mouse move.
275
+ */
276
+ async hover() {
277
+ const session = this.frame.session;
278
+ const { objectId } = await this.resolveNode();
279
+ try {
280
+ await session
281
+ .send("DOM.scrollIntoViewIfNeeded", { objectId })
282
+ .catch(() => { });
283
+ const box = await session.send("DOM.getBoxModel", { objectId });
284
+ if (!box.model)
285
+ throw new ElementNotVisibleError(this.selector);
286
+ const { cx, cy } = this.centerFromBoxContent(box.model.content);
287
+ await session.send("Input.dispatchMouseEvent", {
288
+ type: "mouseMoved",
289
+ x: cx,
290
+ y: cy,
291
+ button: "none",
292
+ });
293
+ }
294
+ finally {
295
+ await session
296
+ .send("Runtime.releaseObject", { objectId })
297
+ .catch(() => { });
298
+ }
299
+ }
300
+ /**
301
+ * Click the element at its visual center.
302
+ * Steps:
303
+ * 1) Resolve selector to { objectId } in the frame world.
304
+ * 2) Scroll into view via `DOM.scrollIntoViewIfNeeded({ objectId })`.
305
+ * 3) Read geometry via `DOM.getBoxModel({ objectId })` → compute a center point.
306
+ * 4) Synthesize mouse press + release via `Input.dispatchMouseEvent`.
307
+ */
308
+ async click(options) {
309
+ const session = this.frame.session;
310
+ const { objectId } = await this.resolveNode();
311
+ const button = options?.button ?? "left";
312
+ const clickCount = options?.clickCount ?? 1;
313
+ try {
314
+ // Scroll into view using objectId (avoids frontend nodeId dependence)
315
+ await session.send("DOM.scrollIntoViewIfNeeded", { objectId });
316
+ // Get geometry using objectId
317
+ const box = await session.send("DOM.getBoxModel", { objectId });
318
+ if (!box.model)
319
+ throw new ElementNotVisibleError(this.selector);
320
+ const { cx, cy } = this.centerFromBoxContent(box.model.content);
321
+ // Dispatch input (from the same session) without waiting between events.
322
+ // This keeps multi-clicks within tight thresholds on remote browsers.
323
+ const dispatches = [];
324
+ dispatches.push(session.send("Input.dispatchMouseEvent", {
325
+ type: "mouseMoved",
326
+ x: cx,
327
+ y: cy,
328
+ button: "none",
329
+ }));
330
+ for (let i = 1; i <= clickCount; i++) {
331
+ dispatches.push(session.send("Input.dispatchMouseEvent", {
332
+ type: "mousePressed",
333
+ x: cx,
334
+ y: cy,
335
+ button,
336
+ clickCount: i,
337
+ }));
338
+ dispatches.push(session.send("Input.dispatchMouseEvent", {
339
+ type: "mouseReleased",
340
+ x: cx,
341
+ y: cy,
342
+ button,
343
+ clickCount: i,
344
+ }));
345
+ }
346
+ await Promise.all(dispatches);
347
+ }
348
+ finally {
349
+ // release the element handle
350
+ try {
351
+ await session.send("Runtime.releaseObject", { objectId });
352
+ }
353
+ catch {
354
+ // If the context navigated or was destroyed (e.g., link opens new tab),
355
+ // releaseObject may fail with -32000. Ignore as best-effort cleanup.
356
+ }
357
+ }
358
+ }
359
+ /**
360
+ * Dispatch a DOM 'click' MouseEvent on the element itself.
361
+ * - Does not synthesize real pointer input; directly dispatches an event.
362
+ * - Useful for elements that rely on click handlers without needing hit-testing.
363
+ */
364
+ async sendClickEvent(options) {
365
+ const session = this.frame.session;
366
+ const { objectId } = await this.resolveNode();
367
+ const bubbles = options?.bubbles ?? true;
368
+ const cancelable = options?.cancelable ?? true;
369
+ const composed = options?.composed ?? true;
370
+ const detail = options?.detail ?? 1;
371
+ try {
372
+ await session
373
+ .send("DOM.scrollIntoViewIfNeeded", { objectId })
374
+ .catch(() => { });
375
+ await session.send("Runtime.callFunctionOn", {
376
+ objectId,
377
+ functionDeclaration: locatorScriptSources.dispatchDomClick,
378
+ arguments: [
379
+ {
380
+ value: { bubbles, cancelable, composed, detail },
381
+ },
382
+ ],
383
+ returnByValue: true,
384
+ });
385
+ }
386
+ finally {
387
+ await session
388
+ .send("Runtime.releaseObject", { objectId })
389
+ .catch(() => { });
390
+ }
391
+ }
392
+ /**
393
+ * Scroll the element vertically to a given percentage (0–100).
394
+ * - If the element is <html> or <body>, scrolls the window/document.
395
+ * - Otherwise, scrolls the element itself via element.scrollTo.
396
+ */
397
+ async scrollTo(percent) {
398
+ const session = this.frame.session;
399
+ const { objectId } = await this.resolveNode();
400
+ try {
401
+ await session.send("Runtime.callFunctionOn", {
402
+ objectId,
403
+ functionDeclaration: locatorScriptSources.scrollElementToPercent,
404
+ arguments: [{ value: percent }],
405
+ returnByValue: true,
406
+ });
407
+ }
408
+ finally {
409
+ await session
410
+ .send("Runtime.releaseObject", { objectId })
411
+ .catch(() => { });
412
+ }
413
+ }
414
+ /**
415
+ * Fill an input/textarea/contenteditable element.
416
+ * Mirrors Playwright semantics: the DOM helper either applies the native
417
+ * value setter (for special input types) or asks us to type text via the CDP
418
+ * Input domain after focusing/selecting.
419
+ */
420
+ async fill(value) {
421
+ const session = this.frame.session;
422
+ // Use the bundled locator globals; the raw fill snippet depends on helper symbols.
423
+ const fillDeclaration = `function(value) { ${locatorScriptBootstrap}; return ${locatorScriptGlobalRefs.fillElementValue}.call(this, value); }`;
424
+ const { objectId } = await this.resolveNode();
425
+ let releaseNeeded = true;
426
+ try {
427
+ const res = await session.send("Runtime.callFunctionOn", {
428
+ objectId,
429
+ functionDeclaration: fillDeclaration,
430
+ arguments: [{ value }],
431
+ returnByValue: true,
432
+ });
433
+ if (res.exceptionDetails) {
434
+ // prefer exception.description over text (eg "Uncaught")
435
+ const message = res.exceptionDetails.exception?.description ??
436
+ res.exceptionDetails.text ??
437
+ "Unknown exception during locator().fill()";
438
+ throw new StagehandLocatorError("Filling", this.selector, message);
439
+ }
440
+ const result = res.result.value;
441
+ const status = typeof result === "object" && result ? result.status : undefined;
442
+ if (status === "done") {
443
+ return;
444
+ }
445
+ if (status === "needsinput") {
446
+ // Release the current handle before synthesizing keyboard input to avoid leaking it.
447
+ await session
448
+ .send("Runtime.releaseObject", { objectId })
449
+ .catch(() => { });
450
+ releaseNeeded = false;
451
+ const valueToType = typeof result?.value === "string" ? result.value : value;
452
+ let prepared = false;
453
+ try {
454
+ const { objectId: prepObjectId } = await this.resolveNode();
455
+ try {
456
+ const prepRes = await session.send("Runtime.callFunctionOn", {
457
+ objectId: prepObjectId,
458
+ functionDeclaration: locatorScriptSources.prepareElementForTyping,
459
+ returnByValue: true,
460
+ });
461
+ prepared = Boolean(prepRes.result.value);
462
+ }
463
+ finally {
464
+ await session
465
+ .send("Runtime.releaseObject", { objectId: prepObjectId })
466
+ .catch(() => { });
467
+ }
468
+ }
469
+ catch {
470
+ // Ignore preparation failures; we'll fall back to typing best-effort.
471
+ }
472
+ if (!prepared && valueToType.length > 0) {
473
+ await this.type(valueToType);
474
+ return;
475
+ }
476
+ if (valueToType.length === 0) {
477
+ // Simulate deleting the currently selected text to clear the field.
478
+ await session.send("Input.dispatchKeyEvent", {
479
+ type: "keyDown",
480
+ key: "Backspace",
481
+ code: "Backspace",
482
+ windowsVirtualKeyCode: 8,
483
+ nativeVirtualKeyCode: 8,
484
+ });
485
+ await session.send("Input.dispatchKeyEvent", {
486
+ type: "keyUp",
487
+ key: "Backspace",
488
+ code: "Backspace",
489
+ windowsVirtualKeyCode: 8,
490
+ nativeVirtualKeyCode: 8,
491
+ });
492
+ }
493
+ else {
494
+ await session.send("Input.insertText", { text: valueToType });
495
+ }
496
+ return;
497
+ }
498
+ if (status === "error") {
499
+ const reason = typeof result?.reason === "string" && result.reason.length > 0
500
+ ? result.reason
501
+ : "Failed to fill element";
502
+ throw new StagehandInvalidArgumentError(`Failed to fill element (${reason})`);
503
+ }
504
+ // Backward compatibility: if no status is returned (older bundle), fall back to setter logic.
505
+ if (!status) {
506
+ await this.type(value);
507
+ }
508
+ }
509
+ finally {
510
+ if (releaseNeeded) {
511
+ await session
512
+ .send("Runtime.releaseObject", { objectId })
513
+ .catch(() => { });
514
+ }
515
+ }
516
+ }
517
+ /**
518
+ * Type text into the element (focuses first).
519
+ * - Focus via element.focus() in page JS (no DOM.focus(nodeId)).
520
+ * - If no delay, uses `Input.insertText` for efficiency.
521
+ * - With delay, synthesizes `keyDown`/`keyUp` per character.
522
+ */
523
+ async type(text, options) {
524
+ const session = this.frame.session;
525
+ const { objectId } = await this.resolveNode();
526
+ try {
527
+ // Focus using JS (avoids DOM.focus(nodeId))
528
+ await session.send("Runtime.callFunctionOn", {
529
+ objectId,
530
+ functionDeclaration: locatorScriptSources.focusElement,
531
+ returnByValue: true,
532
+ });
533
+ if (!options?.delay) {
534
+ await session.send("Input.insertText", { text });
535
+ return;
536
+ }
537
+ for (const ch of text) {
538
+ await session.send("Input.dispatchKeyEvent", {
539
+ type: "keyDown",
540
+ text: ch,
541
+ key: ch,
542
+ });
543
+ await session.send("Input.dispatchKeyEvent", {
544
+ type: "keyUp",
545
+ text: ch,
546
+ key: ch,
547
+ });
548
+ await new Promise((r) => setTimeout(r, options.delay));
549
+ }
550
+ }
551
+ finally {
552
+ await session.send("Runtime.releaseObject", { objectId });
553
+ }
554
+ }
555
+ /**
556
+ * Select one or more options on a `<select>` element.
557
+ * Returns the values actually selected after the operation.
558
+ */
559
+ async selectOption(values) {
560
+ const session = this.frame.session;
561
+ const desired = Array.isArray(values) ? values : [values];
562
+ const { objectId } = await this.resolveNode();
563
+ try {
564
+ const res = await session.send("Runtime.callFunctionOn", {
565
+ objectId,
566
+ functionDeclaration: locatorScriptSources.selectElementOptions,
567
+ arguments: [{ value: desired }],
568
+ returnByValue: true,
569
+ });
570
+ return res.result.value ?? [];
571
+ }
572
+ finally {
573
+ await session.send("Runtime.releaseObject", { objectId });
574
+ }
575
+ }
576
+ /**
577
+ * Return true if the element is attached and visible (rough heuristic).
578
+ */
579
+ async isVisible() {
580
+ const session = this.frame.session;
581
+ const { objectId } = await this.resolveNode();
582
+ try {
583
+ const res = await session.send("Runtime.callFunctionOn", {
584
+ objectId,
585
+ functionDeclaration: locatorScriptSources.isElementVisible,
586
+ returnByValue: true,
587
+ });
588
+ return Boolean(res.result.value);
589
+ }
590
+ finally {
591
+ await session.send("Runtime.releaseObject", { objectId });
592
+ }
593
+ }
594
+ /**
595
+ * Return true if the element is an input[type=checkbox|radio] and is checked.
596
+ * Also considers aria-checked for ARIA widgets.
597
+ */
598
+ async isChecked() {
599
+ const session = this.frame.session;
600
+ const { objectId } = await this.resolveNode();
601
+ try {
602
+ const res = await session.send("Runtime.callFunctionOn", {
603
+ objectId,
604
+ functionDeclaration: locatorScriptSources.isElementChecked,
605
+ returnByValue: true,
606
+ });
607
+ return Boolean(res.result.value);
608
+ }
609
+ finally {
610
+ await session.send("Runtime.releaseObject", { objectId });
611
+ }
612
+ }
613
+ /**
614
+ * Return the element's input value (for input/textarea/select/contenteditable).
615
+ */
616
+ async inputValue() {
617
+ const session = this.frame.session;
618
+ const { objectId } = await this.resolveNode();
619
+ try {
620
+ const res = await session.send("Runtime.callFunctionOn", {
621
+ objectId,
622
+ functionDeclaration: locatorScriptSources.readElementInputValue,
623
+ returnByValue: true,
624
+ });
625
+ return String(res.result.value ?? "");
626
+ }
627
+ finally {
628
+ await session.send("Runtime.releaseObject", { objectId });
629
+ }
630
+ }
631
+ /**
632
+ * Return the element's textContent (raw, not innerText).
633
+ */
634
+ async textContent() {
635
+ const session = this.frame.session;
636
+ const { objectId } = await this.resolveNode();
637
+ try {
638
+ const res = await session.send("Runtime.callFunctionOn", {
639
+ objectId,
640
+ functionDeclaration: locatorScriptSources.readElementTextContent,
641
+ returnByValue: true,
642
+ });
643
+ return String(res.result.value ?? "");
644
+ }
645
+ finally {
646
+ await session.send("Runtime.releaseObject", { objectId });
647
+ }
648
+ }
649
+ /**
650
+ * Return the element's innerHTML string.
651
+ */
652
+ async innerHtml() {
653
+ const session = this.frame.session;
654
+ const { objectId } = await this.resolveNode();
655
+ try {
656
+ const res = await session.send("Runtime.callFunctionOn", {
657
+ objectId,
658
+ functionDeclaration: locatorScriptSources.readElementInnerHTML,
659
+ returnByValue: true,
660
+ });
661
+ return String(res.result.value ?? "");
662
+ }
663
+ finally {
664
+ await session.send("Runtime.releaseObject", { objectId });
665
+ }
666
+ }
667
+ /**
668
+ * Return the element's innerText (layout-aware, visible text).
669
+ */
670
+ async innerText() {
671
+ const session = this.frame.session;
672
+ const { objectId } = await this.resolveNode();
673
+ try {
674
+ const res = await session.send("Runtime.callFunctionOn", {
675
+ objectId,
676
+ functionDeclaration: locatorScriptSources.readElementInnerText,
677
+ returnByValue: true,
678
+ });
679
+ return String(res.result.value ?? "");
680
+ }
681
+ finally {
682
+ await session.send("Runtime.releaseObject", { objectId });
683
+ }
684
+ }
685
+ /**
686
+ * Return a locator narrowed to the first match.
687
+ */
688
+ first() {
689
+ return this.nth(0);
690
+ }
691
+ /** Return a locator narrowed to the element at the given zero-based index. */
692
+ nth(index) {
693
+ const value = Number(index);
694
+ if (!Number.isFinite(value) || value < 0) {
695
+ throw new StagehandInvalidArgumentError("locator().nth() expects a non-negative index");
696
+ }
697
+ const nextIndex = Math.floor(value);
698
+ if (nextIndex === this.nthIndex) {
699
+ return this;
700
+ }
701
+ return new Locator(this.frame, this.selector, this.options, nextIndex);
702
+ }
703
+ // ---------- helpers ----------
704
+ /**
705
+ * Resolve `this.selector` within the frame to `{ objectId, nodeId? }`:
706
+ * Delegates to a shared selector resolver so all selector logic stays in sync.
707
+ */
708
+ async resolveNode() {
709
+ const session = this.frame.session;
710
+ await session.send("Runtime.enable");
711
+ await session.send("DOM.enable");
712
+ const index = this.nthIndex < 0 ? 0 : this.nthIndex;
713
+ const resolved = await this.selectorResolver.resolveAtIndex(this.selectorQuery, index);
714
+ if (!resolved) {
715
+ throw new StagehandElementNotFoundError([this.selector]);
716
+ }
717
+ return resolved;
718
+ }
719
+ /**
720
+ * Resolve all matching nodes for this locator.
721
+ * If the locator is narrowed via nth(), only that index is returned.
722
+ */
723
+ async resolveNodesForMask() {
724
+ const session = this.frame.session;
725
+ await session.send("Runtime.enable");
726
+ await session.send("DOM.enable");
727
+ if (this.nthIndex >= 0) {
728
+ const resolved = await this.selectorResolver.resolveAtIndex(this.selectorQuery, this.nthIndex);
729
+ if (!resolved) {
730
+ throw new StagehandElementNotFoundError([this.selector]);
731
+ }
732
+ return [resolved];
733
+ }
734
+ const resolved = await this.selectorResolver.resolveAll(this.selectorQuery);
735
+ if (!resolved.length) {
736
+ throw new StagehandElementNotFoundError([this.selector]);
737
+ }
738
+ return resolved;
739
+ }
740
+ /** Compute a center point from a BoxModel content quad */
741
+ centerFromBoxContent(content) {
742
+ // content is [x1,y1, x2,y2, x3,y3, x4,y4]
743
+ if (!content || content.length < 8) {
744
+ throw new StagehandInvalidArgumentError("Invalid box model content quad");
745
+ }
746
+ const xs = [content[0], content[2], content[4], content[6]];
747
+ const ys = [content[1], content[3], content[5], content[7]];
748
+ const cx = (xs[0] + xs[1] + xs[2] + xs[3]) / 4;
749
+ const cy = (ys[0] + ys[1] + ys[2] + ys[3]) / 4;
750
+ return { cx, cy };
751
+ }
752
+ }
753
+ //# sourceMappingURL=locator.js.map