@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,864 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var import_vitest = require("vitest");
24
+ var import_actHandler = require("../lib/v3/handlers/actHandler.js");
25
+ var import_extractHandler = require("../lib/v3/handlers/extractHandler.js");
26
+ var import_observeHandler = require("../lib/v3/handlers/observeHandler.js");
27
+ var import_timeoutGuard = require("../lib/v3/handlers/handlerUtils/timeoutGuard.js");
28
+ var import_actHandlerUtils = require("../lib/v3/handlers/handlerUtils/actHandlerUtils.js");
29
+ var import_snapshot = require("../lib/v3/understudy/a11y/snapshot/index.js");
30
+ var import_sdkErrors = require("../lib/v3/types/public/sdkErrors.js");
31
+ var import_inference = require("../lib/inference.js");
32
+ var import_methods = require("../lib/v3/types/public/methods.js");
33
+ import_vitest.vi.mock("../lib/v3/handlers/handlerUtils/timeoutGuard", () => ({
34
+ createTimeoutGuard: import_vitest.vi.fn()
35
+ }));
36
+ import_vitest.vi.mock("../lib/v3/handlers/handlerUtils/actHandlerUtils", () => ({
37
+ waitForDomNetworkQuiet: import_vitest.vi.fn(),
38
+ performUnderstudyMethod: import_vitest.vi.fn()
39
+ }));
40
+ import_vitest.vi.mock("../lib/v3/understudy/a11y/snapshot", () => ({
41
+ captureHybridSnapshot: import_vitest.vi.fn(),
42
+ diffCombinedTrees: import_vitest.vi.fn()
43
+ }));
44
+ import_vitest.vi.mock("../lib/inference", () => ({
45
+ act: import_vitest.vi.fn(),
46
+ extract: import_vitest.vi.fn(),
47
+ observe: import_vitest.vi.fn()
48
+ }));
49
+ (0, import_vitest.describe)("ActHandler timeout guard", () => {
50
+ (0, import_vitest.beforeEach)(() => {
51
+ import_vitest.vi.clearAllMocks();
52
+ });
53
+ (0, import_vitest.it)("throws ActTimeoutError when timeout expires before snapshot", async () => {
54
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
55
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
56
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
57
+ captureHybridSnapshotMock.mockResolvedValue({
58
+ combinedTree: "",
59
+ combinedXpathMap: {},
60
+ combinedUrlMap: {}
61
+ });
62
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
63
+ (timeoutMs, errorFactory) => {
64
+ let calls = 0;
65
+ return import_vitest.vi.fn(() => {
66
+ calls += 1;
67
+ if (calls >= 2) {
68
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ActTimeoutError(timeoutMs);
69
+ }
70
+ });
71
+ }
72
+ );
73
+ const handler = buildActHandler();
74
+ const fakePage = {
75
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
76
+ };
77
+ await (0, import_vitest.expect)(
78
+ handler.act({
79
+ instruction: "do something",
80
+ page: fakePage,
81
+ timeout: 5
82
+ })
83
+ ).rejects.toThrow(import_sdkErrors.ActTimeoutError);
84
+ (0, import_vitest.expect)(waitForDomNetworkQuietMock).toHaveBeenCalledTimes(1);
85
+ (0, import_vitest.expect)(captureHybridSnapshotMock).not.toHaveBeenCalled();
86
+ });
87
+ (0, import_vitest.it)("throws ActTimeoutError when timeout expires before LLM call", async () => {
88
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
89
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
90
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
91
+ captureHybridSnapshotMock.mockResolvedValue({
92
+ combinedTree: "tree content",
93
+ combinedXpathMap: {},
94
+ combinedUrlMap: {}
95
+ });
96
+ const actInferenceMock = import_vitest.vi.mocked(import_inference.act);
97
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
98
+ (timeoutMs, errorFactory) => {
99
+ let calls = 0;
100
+ return import_vitest.vi.fn(() => {
101
+ calls += 1;
102
+ if (calls >= 3) {
103
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ActTimeoutError(timeoutMs);
104
+ }
105
+ });
106
+ }
107
+ );
108
+ const handler = buildActHandler();
109
+ const fakePage = {
110
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
111
+ };
112
+ await (0, import_vitest.expect)(
113
+ handler.act({
114
+ instruction: "do something",
115
+ page: fakePage,
116
+ timeout: 5
117
+ })
118
+ ).rejects.toThrow(import_sdkErrors.ActTimeoutError);
119
+ (0, import_vitest.expect)(captureHybridSnapshotMock).toHaveBeenCalledTimes(1);
120
+ (0, import_vitest.expect)(actInferenceMock).not.toHaveBeenCalled();
121
+ });
122
+ (0, import_vitest.it)("throws ActTimeoutError with correct message format", async () => {
123
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
124
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
125
+ const timeoutMs = 100;
126
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation((ms, errorFactory) => {
127
+ return import_vitest.vi.fn(() => {
128
+ throw errorFactory ? errorFactory(ms) : new import_sdkErrors.ActTimeoutError(ms);
129
+ });
130
+ });
131
+ const handler = buildActHandler();
132
+ const fakePage = {
133
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
134
+ };
135
+ try {
136
+ await handler.act({
137
+ instruction: "do something",
138
+ page: fakePage,
139
+ timeout: timeoutMs
140
+ });
141
+ throw new Error("Expected ActTimeoutError to be thrown");
142
+ } catch (error) {
143
+ (0, import_vitest.expect)(error).toBeInstanceOf(import_sdkErrors.ActTimeoutError);
144
+ (0, import_vitest.expect)(error.message).toContain("act()");
145
+ (0, import_vitest.expect)(error.message).toContain(`${timeoutMs}ms`);
146
+ (0, import_vitest.expect)(error.name).toBe("ActTimeoutError");
147
+ }
148
+ });
149
+ });
150
+ (0, import_vitest.describe)("ActHandler two-step timeout", () => {
151
+ (0, import_vitest.beforeEach)(() => {
152
+ import_vitest.vi.clearAllMocks();
153
+ });
154
+ (0, import_vitest.it)("throws ActTimeoutError during step 2; step 2 action does not run", async () => {
155
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
156
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
157
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
158
+ captureHybridSnapshotMock.mockResolvedValue({
159
+ combinedTree: "tree content",
160
+ combinedXpathMap: { "1-0": "/html/body/button" },
161
+ combinedUrlMap: {}
162
+ });
163
+ const { performUnderstudyMethod } = await import("../lib/v3/handlers/handlerUtils/actHandlerUtils.js");
164
+ const performUnderstudyMethodMock = import_vitest.vi.mocked(performUnderstudyMethod);
165
+ performUnderstudyMethodMock.mockResolvedValue(void 0);
166
+ const actInferenceMock = import_vitest.vi.mocked(import_inference.act);
167
+ actInferenceMock.mockResolvedValueOnce({
168
+ element: {
169
+ elementId: "1-0",
170
+ description: "click button",
171
+ method: "click",
172
+ arguments: []
173
+ },
174
+ twoStep: true,
175
+ prompt_tokens: 100,
176
+ completion_tokens: 50,
177
+ inference_time_ms: 500
178
+ });
179
+ const diffCombinedTreesMock = import_vitest.vi.mocked(
180
+ (await import("../lib/v3/understudy/a11y/snapshot/index.js")).diffCombinedTrees
181
+ );
182
+ diffCombinedTreesMock.mockReturnValue("diff tree");
183
+ let callCount = 0;
184
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
185
+ (timeoutMs, errorFactory) => {
186
+ return import_vitest.vi.fn(() => {
187
+ callCount += 1;
188
+ if (callCount >= 7) {
189
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ActTimeoutError(timeoutMs);
190
+ }
191
+ });
192
+ }
193
+ );
194
+ const handler = buildActHandler();
195
+ const fakePage = {
196
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
197
+ };
198
+ await (0, import_vitest.expect)(
199
+ handler.act({
200
+ instruction: "click then type",
201
+ page: fakePage,
202
+ timeout: 50
203
+ })
204
+ ).rejects.toThrow(import_sdkErrors.ActTimeoutError);
205
+ (0, import_vitest.expect)(performUnderstudyMethodMock).toHaveBeenCalledTimes(1);
206
+ (0, import_vitest.expect)(actInferenceMock).toHaveBeenCalledTimes(1);
207
+ });
208
+ });
209
+ (0, import_vitest.describe)("ActHandler self-heal timeout", () => {
210
+ (0, import_vitest.beforeEach)(() => {
211
+ import_vitest.vi.clearAllMocks();
212
+ });
213
+ (0, import_vitest.it)("throws ActTimeoutError during self-heal snapshot; no retry action executes", async () => {
214
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
215
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
216
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
217
+ captureHybridSnapshotMock.mockResolvedValue({
218
+ combinedTree: "tree content",
219
+ combinedXpathMap: { "1-0": "/html/body/button" },
220
+ combinedUrlMap: {}
221
+ });
222
+ const { performUnderstudyMethod } = await import("../lib/v3/handlers/handlerUtils/actHandlerUtils.js");
223
+ const performUnderstudyMethodMock = import_vitest.vi.mocked(performUnderstudyMethod);
224
+ performUnderstudyMethodMock.mockRejectedValueOnce(
225
+ new Error("Element not found")
226
+ );
227
+ const actInferenceMock = import_vitest.vi.mocked(import_inference.act);
228
+ actInferenceMock.mockResolvedValue({
229
+ element: {
230
+ elementId: "1-0",
231
+ description: "click button",
232
+ method: "click",
233
+ arguments: []
234
+ },
235
+ twoStep: false,
236
+ prompt_tokens: 100,
237
+ completion_tokens: 50,
238
+ inference_time_ms: 500
239
+ });
240
+ let callCount = 0;
241
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
242
+ (timeoutMs, errorFactory) => {
243
+ return import_vitest.vi.fn(() => {
244
+ callCount += 1;
245
+ if (callCount >= 7) {
246
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ActTimeoutError(timeoutMs);
247
+ }
248
+ });
249
+ }
250
+ );
251
+ const handler = buildActHandler({ selfHeal: true });
252
+ const fakePage = {
253
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
254
+ };
255
+ await (0, import_vitest.expect)(
256
+ handler.act({
257
+ instruction: "click button",
258
+ page: fakePage,
259
+ timeout: 50
260
+ })
261
+ ).rejects.toThrow(import_sdkErrors.ActTimeoutError);
262
+ (0, import_vitest.expect)(performUnderstudyMethodMock).toHaveBeenCalledTimes(1);
263
+ (0, import_vitest.expect)(actInferenceMock).toHaveBeenCalledTimes(1);
264
+ (0, import_vitest.expect)(captureHybridSnapshotMock).toHaveBeenCalled();
265
+ });
266
+ (0, import_vitest.it)("throws ActTimeoutError during self-heal LLM inference; no retry action executes", async () => {
267
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
268
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
269
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
270
+ captureHybridSnapshotMock.mockResolvedValue({
271
+ combinedTree: "tree content",
272
+ combinedXpathMap: { "1-0": "/html/body/button" },
273
+ combinedUrlMap: {}
274
+ });
275
+ const { performUnderstudyMethod } = await import("../lib/v3/handlers/handlerUtils/actHandlerUtils.js");
276
+ const performUnderstudyMethodMock = import_vitest.vi.mocked(performUnderstudyMethod);
277
+ performUnderstudyMethodMock.mockRejectedValueOnce(
278
+ new Error("Element not found")
279
+ );
280
+ const actInferenceMock = import_vitest.vi.mocked(import_inference.act);
281
+ actInferenceMock.mockResolvedValueOnce({
282
+ element: {
283
+ elementId: "1-0",
284
+ description: "click button",
285
+ method: "click",
286
+ arguments: []
287
+ },
288
+ twoStep: false,
289
+ prompt_tokens: 100,
290
+ completion_tokens: 50,
291
+ inference_time_ms: 500
292
+ });
293
+ let callCount = 0;
294
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
295
+ (timeoutMs, errorFactory) => {
296
+ return import_vitest.vi.fn(() => {
297
+ callCount += 1;
298
+ if (callCount >= 8) {
299
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ActTimeoutError(timeoutMs);
300
+ }
301
+ });
302
+ }
303
+ );
304
+ const handler = buildActHandler({ selfHeal: true });
305
+ const fakePage = {
306
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
307
+ };
308
+ await (0, import_vitest.expect)(
309
+ handler.act({
310
+ instruction: "click button",
311
+ page: fakePage,
312
+ timeout: 50
313
+ })
314
+ ).rejects.toThrow(import_sdkErrors.ActTimeoutError);
315
+ (0, import_vitest.expect)(captureHybridSnapshotMock).toHaveBeenCalledTimes(2);
316
+ (0, import_vitest.expect)(actInferenceMock).toHaveBeenCalledTimes(1);
317
+ });
318
+ });
319
+ (0, import_vitest.describe)("ExtractHandler timeout guard", () => {
320
+ (0, import_vitest.beforeEach)(() => {
321
+ import_vitest.vi.clearAllMocks();
322
+ });
323
+ (0, import_vitest.it)("throws ExtractTimeoutError when timeout expires before snapshot", async () => {
324
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
325
+ captureHybridSnapshotMock.mockResolvedValue({
326
+ combinedTree: "tree content",
327
+ combinedXpathMap: {},
328
+ combinedUrlMap: {}
329
+ });
330
+ const extractInferenceMock = import_vitest.vi.mocked(import_inference.extract);
331
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
332
+ (timeoutMs, errorFactory) => {
333
+ return import_vitest.vi.fn(() => {
334
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ExtractTimeoutError(timeoutMs);
335
+ });
336
+ }
337
+ );
338
+ const handler = buildExtractHandler();
339
+ const fakePage = {
340
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
341
+ };
342
+ await (0, import_vitest.expect)(
343
+ handler.extract({
344
+ instruction: "extract title",
345
+ page: fakePage,
346
+ timeout: 5
347
+ })
348
+ ).rejects.toThrow(import_sdkErrors.ExtractTimeoutError);
349
+ (0, import_vitest.expect)(captureHybridSnapshotMock).not.toHaveBeenCalled();
350
+ (0, import_vitest.expect)(extractInferenceMock).not.toHaveBeenCalled();
351
+ });
352
+ (0, import_vitest.it)("throws ExtractTimeoutError when timeout expires before LLM call", async () => {
353
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
354
+ captureHybridSnapshotMock.mockResolvedValue({
355
+ combinedTree: "tree content",
356
+ combinedXpathMap: {},
357
+ combinedUrlMap: {}
358
+ });
359
+ const extractInferenceMock = import_vitest.vi.mocked(import_inference.extract);
360
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
361
+ (timeoutMs, errorFactory) => {
362
+ let calls = 0;
363
+ return import_vitest.vi.fn(() => {
364
+ calls += 1;
365
+ if (calls >= 2) {
366
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ExtractTimeoutError(timeoutMs);
367
+ }
368
+ });
369
+ }
370
+ );
371
+ const handler = buildExtractHandler();
372
+ const fakePage = {
373
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
374
+ };
375
+ await (0, import_vitest.expect)(
376
+ handler.extract({
377
+ instruction: "extract title",
378
+ page: fakePage,
379
+ timeout: 5
380
+ })
381
+ ).rejects.toThrow(import_sdkErrors.ExtractTimeoutError);
382
+ (0, import_vitest.expect)(captureHybridSnapshotMock).toHaveBeenCalledTimes(1);
383
+ (0, import_vitest.expect)(extractInferenceMock).not.toHaveBeenCalled();
384
+ });
385
+ (0, import_vitest.it)("throws ExtractTimeoutError with correct message format", async () => {
386
+ const timeoutMs = 200;
387
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation((ms, errorFactory) => {
388
+ return import_vitest.vi.fn(() => {
389
+ throw errorFactory ? errorFactory(ms) : new import_sdkErrors.ExtractTimeoutError(ms);
390
+ });
391
+ });
392
+ const handler = buildExtractHandler();
393
+ const fakePage = {
394
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
395
+ };
396
+ try {
397
+ await handler.extract({
398
+ instruction: "extract title",
399
+ page: fakePage,
400
+ timeout: timeoutMs
401
+ });
402
+ throw new Error("Expected ExtractTimeoutError to be thrown");
403
+ } catch (error) {
404
+ (0, import_vitest.expect)(error).toBeInstanceOf(import_sdkErrors.ExtractTimeoutError);
405
+ (0, import_vitest.expect)(error.message).toContain("extract()");
406
+ (0, import_vitest.expect)(error.message).toContain(
407
+ `${timeoutMs}ms`
408
+ );
409
+ (0, import_vitest.expect)(error.name).toBe("ExtractTimeoutError");
410
+ }
411
+ });
412
+ (0, import_vitest.it)("stops LLM and post-processing when timeout expires", async () => {
413
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
414
+ captureHybridSnapshotMock.mockResolvedValue({
415
+ combinedTree: "tree content",
416
+ combinedXpathMap: {},
417
+ combinedUrlMap: { "1-0": "https://example.com" }
418
+ });
419
+ const extractInferenceMock = import_vitest.vi.mocked(import_inference.extract);
420
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
421
+ (timeoutMs, errorFactory) => {
422
+ let calls = 0;
423
+ return import_vitest.vi.fn(() => {
424
+ calls += 1;
425
+ if (calls >= 2) {
426
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ExtractTimeoutError(timeoutMs);
427
+ }
428
+ });
429
+ }
430
+ );
431
+ const handler = buildExtractHandler();
432
+ const fakePage = {
433
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
434
+ };
435
+ await (0, import_vitest.expect)(
436
+ handler.extract({
437
+ instruction: "extract links",
438
+ page: fakePage,
439
+ timeout: 5
440
+ })
441
+ ).rejects.toThrow(import_sdkErrors.ExtractTimeoutError);
442
+ (0, import_vitest.expect)(extractInferenceMock).not.toHaveBeenCalled();
443
+ });
444
+ });
445
+ (0, import_vitest.describe)("ObserveHandler timeout guard", () => {
446
+ (0, import_vitest.beforeEach)(() => {
447
+ import_vitest.vi.clearAllMocks();
448
+ });
449
+ (0, import_vitest.it)("throws ObserveTimeoutError when timeout expires before snapshot", async () => {
450
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
451
+ captureHybridSnapshotMock.mockResolvedValue({
452
+ combinedTree: "tree content",
453
+ combinedXpathMap: {},
454
+ combinedUrlMap: {}
455
+ });
456
+ const observeInferenceMock = import_vitest.vi.mocked(import_inference.observe);
457
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
458
+ (timeoutMs, errorFactory) => {
459
+ return import_vitest.vi.fn(() => {
460
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ObserveTimeoutError(timeoutMs);
461
+ });
462
+ }
463
+ );
464
+ const handler = buildObserveHandler();
465
+ const fakePage = {
466
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
467
+ };
468
+ await (0, import_vitest.expect)(
469
+ handler.observe({
470
+ instruction: "find buttons",
471
+ page: fakePage,
472
+ timeout: 5
473
+ })
474
+ ).rejects.toThrow(import_sdkErrors.ObserveTimeoutError);
475
+ (0, import_vitest.expect)(captureHybridSnapshotMock).not.toHaveBeenCalled();
476
+ (0, import_vitest.expect)(observeInferenceMock).not.toHaveBeenCalled();
477
+ });
478
+ (0, import_vitest.it)("throws ObserveTimeoutError when timeout expires before LLM call", async () => {
479
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
480
+ captureHybridSnapshotMock.mockResolvedValue({
481
+ combinedTree: "tree content",
482
+ combinedXpathMap: {},
483
+ combinedUrlMap: {}
484
+ });
485
+ const observeInferenceMock = import_vitest.vi.mocked(import_inference.observe);
486
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
487
+ (timeoutMs, errorFactory) => {
488
+ let calls = 0;
489
+ return import_vitest.vi.fn(() => {
490
+ calls += 1;
491
+ if (calls >= 2) {
492
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ObserveTimeoutError(timeoutMs);
493
+ }
494
+ });
495
+ }
496
+ );
497
+ const handler = buildObserveHandler();
498
+ const fakePage = {
499
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
500
+ };
501
+ await (0, import_vitest.expect)(
502
+ handler.observe({
503
+ instruction: "find buttons",
504
+ page: fakePage,
505
+ timeout: 5
506
+ })
507
+ ).rejects.toThrow(import_sdkErrors.ObserveTimeoutError);
508
+ (0, import_vitest.expect)(captureHybridSnapshotMock).toHaveBeenCalledTimes(1);
509
+ (0, import_vitest.expect)(observeInferenceMock).not.toHaveBeenCalled();
510
+ });
511
+ (0, import_vitest.it)("throws ObserveTimeoutError with correct message format", async () => {
512
+ const timeoutMs = 150;
513
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation((ms, errorFactory) => {
514
+ return import_vitest.vi.fn(() => {
515
+ throw errorFactory ? errorFactory(ms) : new import_sdkErrors.ObserveTimeoutError(ms);
516
+ });
517
+ });
518
+ const handler = buildObserveHandler();
519
+ const fakePage = {
520
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
521
+ };
522
+ try {
523
+ await handler.observe({
524
+ instruction: "find buttons",
525
+ page: fakePage,
526
+ timeout: timeoutMs
527
+ });
528
+ throw new Error("Expected ObserveTimeoutError to be thrown");
529
+ } catch (error) {
530
+ (0, import_vitest.expect)(error).toBeInstanceOf(import_sdkErrors.ObserveTimeoutError);
531
+ (0, import_vitest.expect)(error.message).toContain("observe()");
532
+ (0, import_vitest.expect)(error.message).toContain(
533
+ `${timeoutMs}ms`
534
+ );
535
+ (0, import_vitest.expect)(error.name).toBe("ObserveTimeoutError");
536
+ }
537
+ });
538
+ (0, import_vitest.it)("aborts result processing when timeout expires", async () => {
539
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
540
+ captureHybridSnapshotMock.mockResolvedValue({
541
+ combinedTree: "tree content",
542
+ combinedXpathMap: { "1-0": "/html/body/button" },
543
+ combinedUrlMap: {}
544
+ });
545
+ const observeInferenceMock = import_vitest.vi.mocked(import_inference.observe);
546
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(
547
+ (timeoutMs, errorFactory) => {
548
+ let calls = 0;
549
+ return import_vitest.vi.fn(() => {
550
+ calls += 1;
551
+ if (calls >= 2) {
552
+ throw errorFactory ? errorFactory(timeoutMs) : new import_sdkErrors.ObserveTimeoutError(timeoutMs);
553
+ }
554
+ });
555
+ }
556
+ );
557
+ const handler = buildObserveHandler();
558
+ const fakePage = {
559
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
560
+ };
561
+ await (0, import_vitest.expect)(
562
+ handler.observe({
563
+ instruction: "find all interactive elements",
564
+ page: fakePage,
565
+ timeout: 5
566
+ })
567
+ ).rejects.toThrow(import_sdkErrors.ObserveTimeoutError);
568
+ (0, import_vitest.expect)(observeInferenceMock).not.toHaveBeenCalled();
569
+ });
570
+ });
571
+ (0, import_vitest.describe)("No-timeout success paths", () => {
572
+ (0, import_vitest.beforeEach)(() => {
573
+ import_vitest.vi.clearAllMocks();
574
+ });
575
+ (0, import_vitest.it)("act() completes successfully without timeout and records metrics", async () => {
576
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
577
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
578
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
579
+ captureHybridSnapshotMock.mockResolvedValue({
580
+ combinedTree: "tree content",
581
+ combinedXpathMap: { "1-0": "/html/body/button" },
582
+ combinedUrlMap: {}
583
+ });
584
+ const { performUnderstudyMethod } = await import("../lib/v3/handlers/handlerUtils/actHandlerUtils.js");
585
+ const performUnderstudyMethodMock = import_vitest.vi.mocked(performUnderstudyMethod);
586
+ performUnderstudyMethodMock.mockResolvedValue(void 0);
587
+ const actInferenceMock = import_vitest.vi.mocked(import_inference.act);
588
+ actInferenceMock.mockResolvedValue({
589
+ element: {
590
+ elementId: "1-0",
591
+ description: "click button",
592
+ method: "click",
593
+ arguments: []
594
+ },
595
+ twoStep: false,
596
+ prompt_tokens: 100,
597
+ completion_tokens: 50,
598
+ reasoning_tokens: 10,
599
+ cached_input_tokens: 5,
600
+ inference_time_ms: 500
601
+ });
602
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(() => {
603
+ return import_vitest.vi.fn(() => {
604
+ });
605
+ });
606
+ const metricsCallback = import_vitest.vi.fn();
607
+ const handler = buildActHandler({ onMetrics: metricsCallback });
608
+ const fakePage = {
609
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
610
+ };
611
+ const result = await handler.act({
612
+ instruction: "click button",
613
+ page: fakePage
614
+ // No timeout specified
615
+ });
616
+ (0, import_vitest.expect)(result.success).toBe(true);
617
+ (0, import_vitest.expect)(metricsCallback).toHaveBeenCalledWith(
618
+ import_methods.V3FunctionName.ACT,
619
+ 100,
620
+ 50,
621
+ 10,
622
+ 5,
623
+ 500
624
+ );
625
+ });
626
+ (0, import_vitest.it)("extract() completes successfully without timeout and records metrics", async () => {
627
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
628
+ captureHybridSnapshotMock.mockResolvedValue({
629
+ combinedTree: "tree content",
630
+ combinedXpathMap: {},
631
+ combinedUrlMap: {}
632
+ });
633
+ const extractInferenceMock = import_vitest.vi.mocked(import_inference.extract);
634
+ extractInferenceMock.mockResolvedValue({
635
+ title: "Test Title",
636
+ metadata: { completed: true, progress: "100%" },
637
+ prompt_tokens: 200,
638
+ completion_tokens: 100,
639
+ reasoning_tokens: 20,
640
+ cached_input_tokens: 10,
641
+ inference_time_ms: 800
642
+ });
643
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(() => {
644
+ return import_vitest.vi.fn(() => {
645
+ });
646
+ });
647
+ const metricsCallback = import_vitest.vi.fn();
648
+ const handler = buildExtractHandler({ onMetrics: metricsCallback });
649
+ const fakePage = {
650
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
651
+ };
652
+ const result = await handler.extract({
653
+ instruction: "extract title",
654
+ page: fakePage
655
+ // No timeout specified
656
+ });
657
+ (0, import_vitest.expect)(result).toHaveProperty("title", "Test Title");
658
+ (0, import_vitest.expect)(metricsCallback).toHaveBeenCalledWith(
659
+ import_methods.V3FunctionName.EXTRACT,
660
+ 200,
661
+ 100,
662
+ 20,
663
+ 10,
664
+ 800
665
+ );
666
+ });
667
+ (0, import_vitest.it)("observe() completes successfully without timeout and records metrics", async () => {
668
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
669
+ captureHybridSnapshotMock.mockResolvedValue({
670
+ combinedTree: "tree content",
671
+ combinedXpathMap: { "1-0": "/html/body/button" },
672
+ combinedUrlMap: {}
673
+ });
674
+ const observeInferenceMock = import_vitest.vi.mocked(import_inference.observe);
675
+ observeInferenceMock.mockResolvedValue({
676
+ elements: [
677
+ {
678
+ elementId: "1-0",
679
+ description: "Submit button"
680
+ }
681
+ ],
682
+ prompt_tokens: 150,
683
+ completion_tokens: 75,
684
+ reasoning_tokens: 15,
685
+ cached_input_tokens: 8,
686
+ inference_time_ms: 600
687
+ });
688
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation(() => {
689
+ return import_vitest.vi.fn(() => {
690
+ });
691
+ });
692
+ const metricsCallback = import_vitest.vi.fn();
693
+ const handler = buildObserveHandler({ onMetrics: metricsCallback });
694
+ const fakePage = {
695
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
696
+ };
697
+ const result = await handler.observe({
698
+ instruction: "find buttons",
699
+ page: fakePage
700
+ // No timeout specified
701
+ });
702
+ (0, import_vitest.expect)(result).toHaveLength(1);
703
+ (0, import_vitest.expect)(result[0]).toHaveProperty("description", "Submit button");
704
+ (0, import_vitest.expect)(metricsCallback).toHaveBeenCalledWith(
705
+ import_methods.V3FunctionName.OBSERVE,
706
+ 150,
707
+ 75,
708
+ 15,
709
+ 8,
710
+ 600
711
+ );
712
+ });
713
+ (0, import_vitest.it)("act() with zero timeout behaves as no timeout", async () => {
714
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
715
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
716
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
717
+ captureHybridSnapshotMock.mockResolvedValue({
718
+ combinedTree: "tree content",
719
+ combinedXpathMap: { "1-0": "/html/body/button" },
720
+ combinedUrlMap: {}
721
+ });
722
+ const { performUnderstudyMethod } = await import("../lib/v3/handlers/handlerUtils/actHandlerUtils.js");
723
+ const performUnderstudyMethodMock = import_vitest.vi.mocked(performUnderstudyMethod);
724
+ performUnderstudyMethodMock.mockResolvedValue(void 0);
725
+ const actInferenceMock = import_vitest.vi.mocked(import_inference.act);
726
+ actInferenceMock.mockResolvedValue({
727
+ element: {
728
+ elementId: "1-0",
729
+ description: "click button",
730
+ method: "click",
731
+ arguments: []
732
+ },
733
+ twoStep: false,
734
+ prompt_tokens: 100,
735
+ completion_tokens: 50,
736
+ inference_time_ms: 500
737
+ });
738
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation((timeoutMs) => {
739
+ if (!timeoutMs || timeoutMs <= 0) {
740
+ return import_vitest.vi.fn(() => {
741
+ });
742
+ }
743
+ return import_vitest.vi.fn(() => {
744
+ throw new import_sdkErrors.ActTimeoutError(timeoutMs);
745
+ });
746
+ });
747
+ const handler = buildActHandler();
748
+ const fakePage = {
749
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
750
+ };
751
+ const result = await handler.act({
752
+ instruction: "click button",
753
+ page: fakePage,
754
+ timeout: 0
755
+ // Zero timeout should be treated as "no timeout"
756
+ });
757
+ (0, import_vitest.expect)(result.success).toBe(true);
758
+ });
759
+ (0, import_vitest.it)("act() with negative timeout behaves as no timeout", async () => {
760
+ const waitForDomNetworkQuietMock = import_vitest.vi.mocked(import_actHandlerUtils.waitForDomNetworkQuiet);
761
+ waitForDomNetworkQuietMock.mockResolvedValue(void 0);
762
+ const captureHybridSnapshotMock = import_vitest.vi.mocked(import_snapshot.captureHybridSnapshot);
763
+ captureHybridSnapshotMock.mockResolvedValue({
764
+ combinedTree: "tree content",
765
+ combinedXpathMap: { "1-0": "/html/body/button" },
766
+ combinedUrlMap: {}
767
+ });
768
+ const { performUnderstudyMethod } = await import("../lib/v3/handlers/handlerUtils/actHandlerUtils.js");
769
+ const performUnderstudyMethodMock = import_vitest.vi.mocked(performUnderstudyMethod);
770
+ performUnderstudyMethodMock.mockResolvedValue(void 0);
771
+ const actInferenceMock = import_vitest.vi.mocked(import_inference.act);
772
+ actInferenceMock.mockResolvedValue({
773
+ element: {
774
+ elementId: "1-0",
775
+ description: "click button",
776
+ method: "click",
777
+ arguments: []
778
+ },
779
+ twoStep: false,
780
+ prompt_tokens: 100,
781
+ completion_tokens: 50,
782
+ inference_time_ms: 500
783
+ });
784
+ import_vitest.vi.mocked(import_timeoutGuard.createTimeoutGuard).mockImplementation((timeoutMs) => {
785
+ if (!timeoutMs || timeoutMs <= 0) {
786
+ return import_vitest.vi.fn(() => {
787
+ });
788
+ }
789
+ return import_vitest.vi.fn(() => {
790
+ throw new import_sdkErrors.ActTimeoutError(timeoutMs);
791
+ });
792
+ });
793
+ const handler = buildActHandler();
794
+ const fakePage = {
795
+ mainFrame: import_vitest.vi.fn().mockReturnValue({})
796
+ };
797
+ const result = await handler.act({
798
+ instruction: "click button",
799
+ page: fakePage,
800
+ timeout: -100
801
+ // Negative timeout should be treated as "no timeout"
802
+ });
803
+ (0, import_vitest.expect)(result.success).toBe(true);
804
+ });
805
+ });
806
+ function buildActHandler(options = {}) {
807
+ const defaultClientOptions = {};
808
+ const fakeClient = {
809
+ type: "openai",
810
+ modelName: "gpt-4o",
811
+ clientOptions: defaultClientOptions
812
+ };
813
+ const resolveLlmClient = import_vitest.vi.fn().mockReturnValue(fakeClient);
814
+ return new import_actHandler.ActHandler(
815
+ fakeClient,
816
+ "gpt-4o",
817
+ defaultClientOptions,
818
+ resolveLlmClient,
819
+ void 0,
820
+ false,
821
+ options.selfHeal ?? false,
822
+ options.onMetrics,
823
+ void 0
824
+ );
825
+ }
826
+ function buildExtractHandler(options = {}) {
827
+ const defaultClientOptions = {};
828
+ const fakeClient = {
829
+ type: "openai",
830
+ modelName: "gpt-4o",
831
+ clientOptions: defaultClientOptions
832
+ };
833
+ const resolveLlmClient = import_vitest.vi.fn().mockReturnValue(fakeClient);
834
+ return new import_extractHandler.ExtractHandler(
835
+ fakeClient,
836
+ "gpt-4o",
837
+ defaultClientOptions,
838
+ resolveLlmClient,
839
+ void 0,
840
+ false,
841
+ false,
842
+ options.onMetrics
843
+ );
844
+ }
845
+ function buildObserveHandler(options = {}) {
846
+ const defaultClientOptions = {};
847
+ const fakeClient = {
848
+ type: "openai",
849
+ modelName: "gpt-4o",
850
+ clientOptions: defaultClientOptions
851
+ };
852
+ const resolveLlmClient = import_vitest.vi.fn().mockReturnValue(fakeClient);
853
+ return new import_observeHandler.ObserveHandler(
854
+ fakeClient,
855
+ "gpt-4o",
856
+ defaultClientOptions,
857
+ resolveLlmClient,
858
+ void 0,
859
+ false,
860
+ false,
861
+ options.onMetrics
862
+ );
863
+ }
864
+ //# sourceMappingURL=timeout-handlers.test.js.map