@browserbasehq/orca 3.4.0-preview.0 → 3.5.0-vertex-test

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 (841) hide show
  1. package/dist/cjs/lib/inference.d.ts +2 -1
  2. package/dist/cjs/lib/inference.js +10 -3
  3. package/dist/cjs/lib/inference.js.map +1 -1
  4. package/dist/cjs/lib/prompt.d.ts +2 -2
  5. package/dist/cjs/lib/prompt.js +19 -4
  6. package/dist/cjs/lib/prompt.js.map +1 -1
  7. package/dist/cjs/lib/v3/agent/AgentProvider.d.ts +1 -1
  8. package/dist/cjs/lib/v3/agent/AgentProvider.js.map +1 -1
  9. package/dist/cjs/lib/v3/agent/AnthropicCUAClient.js +10 -0
  10. package/dist/cjs/lib/v3/agent/AnthropicCUAClient.js.map +1 -1
  11. package/dist/cjs/lib/v3/api.d.ts +6 -1
  12. package/dist/cjs/lib/v3/api.js +57 -12
  13. package/dist/cjs/lib/v3/api.js.map +1 -1
  14. package/dist/cjs/lib/v3/handlers/extractHandler.js +19 -2
  15. package/dist/cjs/lib/v3/handlers/extractHandler.js.map +1 -1
  16. package/dist/cjs/lib/v3/handlers/observeHandler.js +2 -1
  17. package/dist/cjs/lib/v3/handlers/observeHandler.js.map +1 -1
  18. package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.js +1 -0
  19. package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -1
  20. package/dist/cjs/lib/v3/index.d.ts +1 -0
  21. package/dist/cjs/lib/v3/index.js.map +1 -1
  22. package/dist/cjs/lib/v3/launch/local.d.ts +2 -7
  23. package/dist/cjs/lib/v3/launch/local.js +47 -7
  24. package/dist/cjs/lib/v3/launch/local.js.map +1 -1
  25. package/dist/cjs/lib/v3/llm/LLMProvider.js +0 -5
  26. package/dist/cjs/lib/v3/llm/LLMProvider.js.map +1 -1
  27. package/dist/cjs/lib/v3/llm/aisdk.js +5 -0
  28. package/dist/cjs/lib/v3/llm/aisdk.js.map +1 -1
  29. package/dist/cjs/lib/v3/types/private/handlers.d.ts +2 -0
  30. package/dist/cjs/lib/v3/types/private/handlers.js.map +1 -1
  31. package/dist/cjs/lib/v3/types/private/snapshot.d.ts +2 -0
  32. package/dist/cjs/lib/v3/types/private/snapshot.js.map +1 -1
  33. package/dist/cjs/lib/v3/types/public/agent.d.ts +1 -1
  34. package/dist/cjs/lib/v3/types/public/agent.js.map +1 -1
  35. package/dist/cjs/lib/v3/types/public/api.d.ts +287 -0
  36. package/dist/cjs/lib/v3/types/public/api.js +61 -3
  37. package/dist/cjs/lib/v3/types/public/api.js.map +1 -1
  38. package/dist/cjs/lib/v3/types/public/methods.d.ts +2 -0
  39. package/dist/cjs/lib/v3/types/public/methods.js.map +1 -1
  40. package/dist/cjs/lib/v3/types/public/model.d.ts +11 -7
  41. package/dist/cjs/lib/v3/types/public/model.js.map +1 -1
  42. package/dist/cjs/lib/v3/understudy/a11y/snapshot/a11yTree.js +25 -0
  43. package/dist/cjs/lib/v3/understudy/a11y/snapshot/a11yTree.js.map +1 -1
  44. package/dist/cjs/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js +10 -1
  45. package/dist/cjs/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js.map +1 -1
  46. package/dist/cjs/lib/v3/v3.d.ts +1 -0
  47. package/dist/cjs/lib/v3/v3.js +21 -47
  48. package/dist/cjs/lib/v3/v3.js.map +1 -1
  49. package/dist/cjs/lib/v3Evaluator.d.ts +20 -12
  50. package/dist/cjs/lib/v3Evaluator.js +41 -199
  51. package/dist/cjs/lib/v3Evaluator.js.map +1 -1
  52. package/dist/cjs/lib/v3LegacyEvaluator.d.ts +20 -0
  53. package/dist/cjs/lib/v3LegacyEvaluator.js +215 -0
  54. package/dist/cjs/lib/v3LegacyEvaluator.js.map +1 -0
  55. package/dist/cjs/lib/version.d.ts +1 -1
  56. package/dist/cjs/lib/version.js +1 -1
  57. package/dist/cjs/lib/version.js.map +1 -1
  58. package/dist/esm/lib/inference.d.ts +2 -1
  59. package/dist/esm/lib/inference.js +10 -3
  60. package/dist/esm/lib/inference.js.map +1 -1
  61. package/dist/esm/lib/prompt.d.ts +2 -2
  62. package/dist/esm/lib/prompt.js +19 -4
  63. package/dist/esm/lib/prompt.js.map +1 -1
  64. package/dist/esm/lib/v3/agent/AgentProvider.d.ts +1 -1
  65. package/dist/esm/lib/v3/agent/AgentProvider.js.map +1 -1
  66. package/dist/esm/lib/v3/agent/AnthropicCUAClient.js +10 -0
  67. package/dist/esm/lib/v3/agent/AnthropicCUAClient.js.map +1 -1
  68. package/dist/esm/lib/v3/api.d.ts +6 -1
  69. package/dist/esm/lib/v3/api.js +57 -12
  70. package/dist/esm/lib/v3/api.js.map +1 -1
  71. package/dist/esm/lib/v3/handlers/extractHandler.js +19 -2
  72. package/dist/esm/lib/v3/handlers/extractHandler.js.map +1 -1
  73. package/dist/esm/lib/v3/handlers/observeHandler.js +2 -1
  74. package/dist/esm/lib/v3/handlers/observeHandler.js.map +1 -1
  75. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js +1 -0
  76. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -1
  77. package/dist/esm/lib/v3/index.d.ts +1 -0
  78. package/dist/esm/lib/v3/index.js.map +1 -1
  79. package/dist/esm/lib/v3/launch/local.d.ts +2 -7
  80. package/dist/esm/lib/v3/launch/local.js +48 -8
  81. package/dist/esm/lib/v3/launch/local.js.map +1 -1
  82. package/dist/esm/lib/v3/llm/LLMProvider.js +1 -6
  83. package/dist/esm/lib/v3/llm/LLMProvider.js.map +1 -1
  84. package/dist/esm/lib/v3/llm/aisdk.js +5 -0
  85. package/dist/esm/lib/v3/llm/aisdk.js.map +1 -1
  86. package/dist/esm/lib/v3/types/private/handlers.d.ts +2 -0
  87. package/dist/esm/lib/v3/types/private/handlers.js.map +1 -1
  88. package/dist/esm/lib/v3/types/private/snapshot.d.ts +2 -0
  89. package/dist/esm/lib/v3/types/private/snapshot.js.map +1 -1
  90. package/dist/esm/lib/v3/types/public/agent.d.ts +1 -1
  91. package/dist/esm/lib/v3/types/public/agent.js.map +1 -1
  92. package/dist/esm/lib/v3/types/public/api.d.ts +287 -0
  93. package/dist/esm/lib/v3/types/public/api.js +59 -1
  94. package/dist/esm/lib/v3/types/public/api.js.map +1 -1
  95. package/dist/esm/lib/v3/types/public/methods.d.ts +2 -0
  96. package/dist/esm/lib/v3/types/public/methods.js.map +1 -1
  97. package/dist/esm/lib/v3/types/public/model.d.ts +11 -7
  98. package/dist/esm/lib/v3/types/public/model.js.map +1 -1
  99. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js +25 -0
  100. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js.map +1 -1
  101. package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js +10 -1
  102. package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js.map +1 -1
  103. package/dist/esm/lib/v3/v3.d.ts +1 -0
  104. package/dist/esm/lib/v3/v3.js +21 -47
  105. package/dist/esm/lib/v3/v3.js.map +1 -1
  106. package/dist/esm/lib/v3Evaluator.d.ts +20 -12
  107. package/dist/esm/lib/v3Evaluator.js +41 -199
  108. package/dist/esm/lib/v3Evaluator.js.map +1 -1
  109. package/dist/esm/lib/v3LegacyEvaluator.d.ts +20 -0
  110. package/dist/esm/lib/v3LegacyEvaluator.js +211 -0
  111. package/dist/esm/lib/v3LegacyEvaluator.js.map +1 -0
  112. package/dist/esm/lib/version.d.ts +1 -1
  113. package/dist/esm/lib/version.js +1 -1
  114. package/dist/esm/lib/version.js.map +1 -1
  115. package/package.json +30 -18
  116. package/dist/cjs/tests/cache-variables.test.d.ts +0 -1
  117. package/dist/cjs/tests/cache-variables.test.js +0 -221
  118. package/dist/cjs/tests/cache-variables.test.js.map +0 -1
  119. package/dist/cjs/tests/integration/agent-abort-signal.spec.d.ts +0 -1
  120. package/dist/cjs/tests/integration/agent-abort-signal.spec.js +0 -123
  121. package/dist/cjs/tests/integration/agent-abort-signal.spec.js.map +0 -1
  122. package/dist/cjs/tests/integration/agent-cache-self-heal.spec.d.ts +0 -1
  123. package/dist/cjs/tests/integration/agent-cache-self-heal.spec.js +0 -83
  124. package/dist/cjs/tests/integration/agent-cache-self-heal.spec.js.map +0 -1
  125. package/dist/cjs/tests/integration/agent-callbacks.spec.d.ts +0 -1
  126. package/dist/cjs/tests/integration/agent-callbacks.spec.js +0 -385
  127. package/dist/cjs/tests/integration/agent-callbacks.spec.js.map +0 -1
  128. package/dist/cjs/tests/integration/agent-experimental-validation.spec.d.ts +0 -1
  129. package/dist/cjs/tests/integration/agent-experimental-validation.spec.js +0 -362
  130. package/dist/cjs/tests/integration/agent-experimental-validation.spec.js.map +0 -1
  131. package/dist/cjs/tests/integration/agent-hybrid-mode.spec.d.ts +0 -1
  132. package/dist/cjs/tests/integration/agent-hybrid-mode.spec.js +0 -262
  133. package/dist/cjs/tests/integration/agent-hybrid-mode.spec.js.map +0 -1
  134. package/dist/cjs/tests/integration/agent-message-continuation.spec.d.ts +0 -1
  135. package/dist/cjs/tests/integration/agent-message-continuation.spec.js +0 -112
  136. package/dist/cjs/tests/integration/agent-message-continuation.spec.js.map +0 -1
  137. package/dist/cjs/tests/integration/agent-streaming.spec.d.ts +0 -1
  138. package/dist/cjs/tests/integration/agent-streaming.spec.js +0 -140
  139. package/dist/cjs/tests/integration/agent-streaming.spec.js.map +0 -1
  140. package/dist/cjs/tests/integration/cdp-close-api-region.spec.d.ts +0 -1
  141. package/dist/cjs/tests/integration/cdp-close-api-region.spec.js +0 -41
  142. package/dist/cjs/tests/integration/cdp-close-api-region.spec.js.map +0 -1
  143. package/dist/cjs/tests/integration/cdp-connection-close.spec.d.ts +0 -1
  144. package/dist/cjs/tests/integration/cdp-connection-close.spec.js +0 -76
  145. package/dist/cjs/tests/integration/cdp-connection-close.spec.js.map +0 -1
  146. package/dist/cjs/tests/integration/cdp-session-detached.spec.d.ts +0 -1
  147. package/dist/cjs/tests/integration/cdp-session-detached.spec.js +0 -45
  148. package/dist/cjs/tests/integration/cdp-session-detached.spec.js.map +0 -1
  149. package/dist/cjs/tests/integration/chrome-newtab-page-tracking.spec.d.ts +0 -1
  150. package/dist/cjs/tests/integration/chrome-newtab-page-tracking.spec.js +0 -56
  151. package/dist/cjs/tests/integration/chrome-newtab-page-tracking.spec.js.map +0 -1
  152. package/dist/cjs/tests/integration/click-count.spec.d.ts +0 -1
  153. package/dist/cjs/tests/integration/click-count.spec.js +0 -163
  154. package/dist/cjs/tests/integration/click-count.spec.js.map +0 -1
  155. package/dist/cjs/tests/integration/connect-to-existing-browser.spec.d.ts +0 -1
  156. package/dist/cjs/tests/integration/connect-to-existing-browser.spec.js +0 -99
  157. package/dist/cjs/tests/integration/connect-to-existing-browser.spec.js.map +0 -1
  158. package/dist/cjs/tests/integration/context-addInitScript.spec.d.ts +0 -1
  159. package/dist/cjs/tests/integration/context-addInitScript.spec.js +0 -285
  160. package/dist/cjs/tests/integration/context-addInitScript.spec.js.map +0 -1
  161. package/dist/cjs/tests/integration/context-extra-http-headers.spec.d.ts +0 -1
  162. package/dist/cjs/tests/integration/context-extra-http-headers.spec.js +0 -49
  163. package/dist/cjs/tests/integration/context-extra-http-headers.spec.js.map +0 -1
  164. package/dist/cjs/tests/integration/cookies.spec.d.ts +0 -1
  165. package/dist/cjs/tests/integration/cookies.spec.js +0 -187
  166. package/dist/cjs/tests/integration/cookies.spec.js.map +0 -1
  167. package/dist/cjs/tests/integration/default-page-tracking.spec.d.ts +0 -1
  168. package/dist/cjs/tests/integration/default-page-tracking.spec.js +0 -52
  169. package/dist/cjs/tests/integration/default-page-tracking.spec.js.map +0 -1
  170. package/dist/cjs/tests/integration/downloads.spec.d.ts +0 -1
  171. package/dist/cjs/tests/integration/downloads.spec.js +0 -52
  172. package/dist/cjs/tests/integration/downloads.spec.js.map +0 -1
  173. package/dist/cjs/tests/integration/flowLogger.spec.d.ts +0 -1
  174. package/dist/cjs/tests/integration/flowLogger.spec.js +0 -718
  175. package/dist/cjs/tests/integration/flowLogger.spec.js.map +0 -1
  176. package/dist/cjs/tests/integration/frame-get-location-and-click.spec.d.ts +0 -1
  177. package/dist/cjs/tests/integration/frame-get-location-and-click.spec.js +0 -57
  178. package/dist/cjs/tests/integration/frame-get-location-and-click.spec.js.map +0 -1
  179. package/dist/cjs/tests/integration/iframe-ctx-addInitScript-race.spec.d.ts +0 -1
  180. package/dist/cjs/tests/integration/iframe-ctx-addInitScript-race.spec.js +0 -219
  181. package/dist/cjs/tests/integration/iframe-ctx-addInitScript-race.spec.js.map +0 -1
  182. package/dist/cjs/tests/integration/iframe-ctx-addInitScript.spec.d.ts +0 -1
  183. package/dist/cjs/tests/integration/iframe-ctx-addInitScript.spec.js +0 -474
  184. package/dist/cjs/tests/integration/iframe-ctx-addInitScript.spec.js.map +0 -1
  185. package/dist/cjs/tests/integration/keep-alive.child.d.ts +0 -1
  186. package/dist/cjs/tests/integration/keep-alive.child.js +0 -85
  187. package/dist/cjs/tests/integration/keep-alive.child.js.map +0 -1
  188. package/dist/cjs/tests/integration/keep-alive.spec.d.ts +0 -22
  189. package/dist/cjs/tests/integration/keep-alive.spec.js +0 -490
  190. package/dist/cjs/tests/integration/keep-alive.spec.js.map +0 -1
  191. package/dist/cjs/tests/integration/keyboard.spec.d.ts +0 -1
  192. package/dist/cjs/tests/integration/keyboard.spec.js +0 -259
  193. package/dist/cjs/tests/integration/keyboard.spec.js.map +0 -1
  194. package/dist/cjs/tests/integration/locator-backend-node-id.spec.d.ts +0 -1
  195. package/dist/cjs/tests/integration/locator-backend-node-id.spec.js +0 -150
  196. package/dist/cjs/tests/integration/locator-backend-node-id.spec.js.map +0 -1
  197. package/dist/cjs/tests/integration/locator-content-methods.spec.d.ts +0 -1
  198. package/dist/cjs/tests/integration/locator-content-methods.spec.js +0 -180
  199. package/dist/cjs/tests/integration/locator-content-methods.spec.js.map +0 -1
  200. package/dist/cjs/tests/integration/locator-count-iframe.spec.d.ts +0 -1
  201. package/dist/cjs/tests/integration/locator-count-iframe.spec.js +0 -129
  202. package/dist/cjs/tests/integration/locator-count-iframe.spec.js.map +0 -1
  203. package/dist/cjs/tests/integration/locator-count.spec.d.ts +0 -1
  204. package/dist/cjs/tests/integration/locator-count.spec.js +0 -68
  205. package/dist/cjs/tests/integration/locator-count.spec.js.map +0 -1
  206. package/dist/cjs/tests/integration/locator-fill.spec.d.ts +0 -1
  207. package/dist/cjs/tests/integration/locator-fill.spec.js +0 -117
  208. package/dist/cjs/tests/integration/locator-fill.spec.js.map +0 -1
  209. package/dist/cjs/tests/integration/locator-input-methods.spec.d.ts +0 -1
  210. package/dist/cjs/tests/integration/locator-input-methods.spec.js +0 -127
  211. package/dist/cjs/tests/integration/locator-input-methods.spec.js.map +0 -1
  212. package/dist/cjs/tests/integration/locator-nth.spec.d.ts +0 -1
  213. package/dist/cjs/tests/integration/locator-nth.spec.js +0 -175
  214. package/dist/cjs/tests/integration/locator-nth.spec.js.map +0 -1
  215. package/dist/cjs/tests/integration/locator-select-option.spec.d.ts +0 -1
  216. package/dist/cjs/tests/integration/locator-select-option.spec.js +0 -216
  217. package/dist/cjs/tests/integration/locator-select-option.spec.js.map +0 -1
  218. package/dist/cjs/tests/integration/logger-initialization.spec.d.ts +0 -1
  219. package/dist/cjs/tests/integration/logger-initialization.spec.js +0 -597
  220. package/dist/cjs/tests/integration/logger-initialization.spec.js.map +0 -1
  221. package/dist/cjs/tests/integration/multi-instance-logger.spec.d.ts +0 -1
  222. package/dist/cjs/tests/integration/multi-instance-logger.spec.js +0 -293
  223. package/dist/cjs/tests/integration/multi-instance-logger.spec.js.map +0 -1
  224. package/dist/cjs/tests/integration/nested-div.spec.d.ts +0 -1
  225. package/dist/cjs/tests/integration/nested-div.spec.js +0 -22
  226. package/dist/cjs/tests/integration/nested-div.spec.js.map +0 -1
  227. package/dist/cjs/tests/integration/observe-element-id-format.spec.d.ts +0 -1
  228. package/dist/cjs/tests/integration/observe-element-id-format.spec.js +0 -130
  229. package/dist/cjs/tests/integration/observe-element-id-format.spec.js.map +0 -1
  230. package/dist/cjs/tests/integration/page-addInitScript.spec.d.ts +0 -1
  231. package/dist/cjs/tests/integration/page-addInitScript.spec.js +0 -94
  232. package/dist/cjs/tests/integration/page-addInitScript.spec.js.map +0 -1
  233. package/dist/cjs/tests/integration/page-console.spec.d.ts +0 -1
  234. package/dist/cjs/tests/integration/page-console.spec.js +0 -47
  235. package/dist/cjs/tests/integration/page-console.spec.js.map +0 -1
  236. package/dist/cjs/tests/integration/page-drag-and-drop.spec.d.ts +0 -1
  237. package/dist/cjs/tests/integration/page-drag-and-drop.spec.js +0 -437
  238. package/dist/cjs/tests/integration/page-drag-and-drop.spec.js.map +0 -1
  239. package/dist/cjs/tests/integration/page-extra-http-headers.spec.d.ts +0 -1
  240. package/dist/cjs/tests/integration/page-extra-http-headers.spec.js +0 -85
  241. package/dist/cjs/tests/integration/page-extra-http-headers.spec.js.map +0 -1
  242. package/dist/cjs/tests/integration/page-goto-response.spec.d.ts +0 -1
  243. package/dist/cjs/tests/integration/page-goto-response.spec.js +0 -34
  244. package/dist/cjs/tests/integration/page-goto-response.spec.js.map +0 -1
  245. package/dist/cjs/tests/integration/page-hover.spec.d.ts +0 -1
  246. package/dist/cjs/tests/integration/page-hover.spec.js +0 -165
  247. package/dist/cjs/tests/integration/page-hover.spec.js.map +0 -1
  248. package/dist/cjs/tests/integration/page-screenshot.spec.d.ts +0 -1
  249. package/dist/cjs/tests/integration/page-screenshot.spec.js +0 -292
  250. package/dist/cjs/tests/integration/page-screenshot.spec.js.map +0 -1
  251. package/dist/cjs/tests/integration/page-scroll.spec.d.ts +0 -1
  252. package/dist/cjs/tests/integration/page-scroll.spec.js +0 -183
  253. package/dist/cjs/tests/integration/page-scroll.spec.js.map +0 -1
  254. package/dist/cjs/tests/integration/page-send-cdp.spec.d.ts +0 -1
  255. package/dist/cjs/tests/integration/page-send-cdp.spec.js +0 -47
  256. package/dist/cjs/tests/integration/page-send-cdp.spec.js.map +0 -1
  257. package/dist/cjs/tests/integration/perform-understudy-method.spec.d.ts +0 -1
  258. package/dist/cjs/tests/integration/perform-understudy-method.spec.js +0 -63
  259. package/dist/cjs/tests/integration/perform-understudy-method.spec.js.map +0 -1
  260. package/dist/cjs/tests/integration/setinputfiles.spec.d.ts +0 -1
  261. package/dist/cjs/tests/integration/setinputfiles.spec.js +0 -133
  262. package/dist/cjs/tests/integration/setinputfiles.spec.js.map +0 -1
  263. package/dist/cjs/tests/integration/shadow-iframe-oopif.spec.d.ts +0 -1
  264. package/dist/cjs/tests/integration/shadow-iframe-oopif.spec.js +0 -161
  265. package/dist/cjs/tests/integration/shadow-iframe-oopif.spec.js.map +0 -1
  266. package/dist/cjs/tests/integration/shadow-iframe-spif.spec.d.ts +0 -1
  267. package/dist/cjs/tests/integration/shadow-iframe-spif.spec.js +0 -160
  268. package/dist/cjs/tests/integration/shadow-iframe-spif.spec.js.map +0 -1
  269. package/dist/cjs/tests/integration/testUtils.d.ts +0 -40
  270. package/dist/cjs/tests/integration/testUtils.js +0 -188
  271. package/dist/cjs/tests/integration/testUtils.js.map +0 -1
  272. package/dist/cjs/tests/integration/text-selector-innermost.spec.d.ts +0 -1
  273. package/dist/cjs/tests/integration/text-selector-innermost.spec.js +0 -105
  274. package/dist/cjs/tests/integration/text-selector-innermost.spec.js.map +0 -1
  275. package/dist/cjs/tests/integration/timeouts.spec.d.ts +0 -1
  276. package/dist/cjs/tests/integration/timeouts.spec.js +0 -309
  277. package/dist/cjs/tests/integration/timeouts.spec.js.map +0 -1
  278. package/dist/cjs/tests/integration/user-data-dir.spec.d.ts +0 -1
  279. package/dist/cjs/tests/integration/user-data-dir.spec.js +0 -77
  280. package/dist/cjs/tests/integration/user-data-dir.spec.js.map +0 -1
  281. package/dist/cjs/tests/integration/v3.config.d.ts +0 -4
  282. package/dist/cjs/tests/integration/v3.config.js +0 -11
  283. package/dist/cjs/tests/integration/v3.config.js.map +0 -1
  284. package/dist/cjs/tests/integration/v3.dynamic.config.d.ts +0 -4
  285. package/dist/cjs/tests/integration/v3.dynamic.config.js +0 -48
  286. package/dist/cjs/tests/integration/v3.dynamic.config.js.map +0 -1
  287. package/dist/cjs/tests/integration/v3.playwright.config.d.ts +0 -2
  288. package/dist/cjs/tests/integration/v3.playwright.config.js +0 -48
  289. package/dist/cjs/tests/integration/v3.playwright.config.js.map +0 -1
  290. package/dist/cjs/tests/integration/wait-for-selector.spec.d.ts +0 -1
  291. package/dist/cjs/tests/integration/wait-for-selector.spec.js +0 -683
  292. package/dist/cjs/tests/integration/wait-for-selector.spec.js.map +0 -1
  293. package/dist/cjs/tests/integration/wait-for-timeout.spec.d.ts +0 -1
  294. package/dist/cjs/tests/integration/wait-for-timeout.spec.js +0 -118
  295. package/dist/cjs/tests/integration/wait-for-timeout.spec.js.map +0 -1
  296. package/dist/cjs/tests/integration/xpath-for-location-deep.spec.d.ts +0 -1
  297. package/dist/cjs/tests/integration/xpath-for-location-deep.spec.js +0 -87
  298. package/dist/cjs/tests/integration/xpath-for-location-deep.spec.js.map +0 -1
  299. package/dist/cjs/tests/unit/agent-captcha-hooks.test.d.ts +0 -1
  300. package/dist/cjs/tests/unit/agent-captcha-hooks.test.js +0 -341
  301. package/dist/cjs/tests/unit/agent-captcha-hooks.test.js.map +0 -1
  302. package/dist/cjs/tests/unit/agent-execution-model.test.d.ts +0 -1
  303. package/dist/cjs/tests/unit/agent-execution-model.test.js +0 -150
  304. package/dist/cjs/tests/unit/agent-execution-model.test.js.map +0 -1
  305. package/dist/cjs/tests/unit/agent-metrics.test.d.ts +0 -1
  306. package/dist/cjs/tests/unit/agent-metrics.test.js +0 -112
  307. package/dist/cjs/tests/unit/agent-metrics.test.js.map +0 -1
  308. package/dist/cjs/tests/unit/agent-mode-routing.test.d.ts +0 -1
  309. package/dist/cjs/tests/unit/agent-mode-routing.test.js +0 -88
  310. package/dist/cjs/tests/unit/agent-mode-routing.test.js.map +0 -1
  311. package/dist/cjs/tests/unit/agent-system-prompt-variables.test.d.ts +0 -1
  312. package/dist/cjs/tests/unit/agent-system-prompt-variables.test.js +0 -23
  313. package/dist/cjs/tests/unit/agent-system-prompt-variables.test.js.map +0 -1
  314. package/dist/cjs/tests/unit/agent-temperature.test.d.ts +0 -1
  315. package/dist/cjs/tests/unit/agent-temperature.test.js +0 -191
  316. package/dist/cjs/tests/unit/agent-temperature.test.js.map +0 -1
  317. package/dist/cjs/tests/unit/agent-variables-validation.test.d.ts +0 -1
  318. package/dist/cjs/tests/unit/agent-variables-validation.test.js +0 -43
  319. package/dist/cjs/tests/unit/agent-variables-validation.test.js.map +0 -1
  320. package/dist/cjs/tests/unit/aisdk-clients.test.d.ts +0 -1
  321. package/dist/cjs/tests/unit/aisdk-clients.test.js +0 -86
  322. package/dist/cjs/tests/unit/aisdk-clients.test.js.map +0 -1
  323. package/dist/cjs/tests/unit/anthropic-cua-adaptive-thinking.test.d.ts +0 -1
  324. package/dist/cjs/tests/unit/anthropic-cua-adaptive-thinking.test.js +0 -250
  325. package/dist/cjs/tests/unit/anthropic-cua-adaptive-thinking.test.js.map +0 -1
  326. package/dist/cjs/tests/unit/api-client-observe-variables.test.d.ts +0 -1
  327. package/dist/cjs/tests/unit/api-client-observe-variables.test.js +0 -133
  328. package/dist/cjs/tests/unit/api-client-observe-variables.test.js.map +0 -1
  329. package/dist/cjs/tests/unit/api-multiregion.test.d.ts +0 -1
  330. package/dist/cjs/tests/unit/api-multiregion.test.js +0 -58
  331. package/dist/cjs/tests/unit/api-multiregion.test.js.map +0 -1
  332. package/dist/cjs/tests/unit/api-optional-model-api-key.test.d.ts +0 -1
  333. package/dist/cjs/tests/unit/api-optional-model-api-key.test.js +0 -155
  334. package/dist/cjs/tests/unit/api-optional-model-api-key.test.js.map +0 -1
  335. package/dist/cjs/tests/unit/api-variables-schema.test.d.ts +0 -1
  336. package/dist/cjs/tests/unit/api-variables-schema.test.js +0 -62
  337. package/dist/cjs/tests/unit/api-variables-schema.test.js.map +0 -1
  338. package/dist/cjs/tests/unit/browserbase-session-accessors.test.d.ts +0 -1
  339. package/dist/cjs/tests/unit/browserbase-session-accessors.test.js +0 -142
  340. package/dist/cjs/tests/unit/browserbase-session-accessors.test.js.map +0 -1
  341. package/dist/cjs/tests/unit/cache-llm-resolution.test.d.ts +0 -1
  342. package/dist/cjs/tests/unit/cache-llm-resolution.test.js +0 -186
  343. package/dist/cjs/tests/unit/cache-llm-resolution.test.js.map +0 -1
  344. package/dist/cjs/tests/unit/captcha-solver.test.d.ts +0 -1
  345. package/dist/cjs/tests/unit/captcha-solver.test.js +0 -154
  346. package/dist/cjs/tests/unit/captcha-solver.test.js.map +0 -1
  347. package/dist/cjs/tests/unit/cdp-connection-close.test.d.ts +0 -1
  348. package/dist/cjs/tests/unit/cdp-connection-close.test.js +0 -74
  349. package/dist/cjs/tests/unit/cdp-connection-close.test.js.map +0 -1
  350. package/dist/cjs/tests/unit/context-extra-http-headers.test.d.ts +0 -1
  351. package/dist/cjs/tests/unit/context-extra-http-headers.test.js +0 -58
  352. package/dist/cjs/tests/unit/context-extra-http-headers.test.js.map +0 -1
  353. package/dist/cjs/tests/unit/cookies.test.d.ts +0 -1
  354. package/dist/cjs/tests/unit/cookies.test.js +0 -944
  355. package/dist/cjs/tests/unit/cookies.test.js.map +0 -1
  356. package/dist/cjs/tests/unit/flowlogger-capturing-cdp.test.d.ts +0 -1
  357. package/dist/cjs/tests/unit/flowlogger-capturing-cdp.test.js +0 -95
  358. package/dist/cjs/tests/unit/flowlogger-capturing-cdp.test.js.map +0 -1
  359. package/dist/cjs/tests/unit/flowlogger-capturing-llm.test.d.ts +0 -1
  360. package/dist/cjs/tests/unit/flowlogger-capturing-llm.test.js +0 -43
  361. package/dist/cjs/tests/unit/flowlogger-capturing-llm.test.js.map +0 -1
  362. package/dist/cjs/tests/unit/flowlogger-eventstore.test.d.ts +0 -1
  363. package/dist/cjs/tests/unit/flowlogger-eventstore.test.js +0 -250
  364. package/dist/cjs/tests/unit/flowlogger-eventstore.test.js.map +0 -1
  365. package/dist/cjs/tests/unit/frame-registry-oopif-adoption.test.d.ts +0 -1
  366. package/dist/cjs/tests/unit/frame-registry-oopif-adoption.test.js +0 -60
  367. package/dist/cjs/tests/unit/frame-registry-oopif-adoption.test.js.map +0 -1
  368. package/dist/cjs/tests/unit/helpers/mockCDPSession.d.ts +0 -19
  369. package/dist/cjs/tests/unit/helpers/mockCDPSession.js +0 -29
  370. package/dist/cjs/tests/unit/helpers/mockCDPSession.js.map +0 -1
  371. package/dist/cjs/tests/unit/inference-temperature.test.d.ts +0 -1
  372. package/dist/cjs/tests/unit/inference-temperature.test.js +0 -65
  373. package/dist/cjs/tests/unit/inference-temperature.test.js.map +0 -1
  374. package/dist/cjs/tests/unit/llm-middleware.test.d.ts +0 -1
  375. package/dist/cjs/tests/unit/llm-middleware.test.js +0 -495
  376. package/dist/cjs/tests/unit/llm-middleware.test.js.map +0 -1
  377. package/dist/cjs/tests/unit/llm-provider.test.d.ts +0 -1
  378. package/dist/cjs/tests/unit/llm-provider.test.js +0 -64
  379. package/dist/cjs/tests/unit/llm-provider.test.js.map +0 -1
  380. package/dist/cjs/tests/unit/microsoft-cua-client.test.d.ts +0 -1
  381. package/dist/cjs/tests/unit/microsoft-cua-client.test.js +0 -86
  382. package/dist/cjs/tests/unit/microsoft-cua-client.test.js.map +0 -1
  383. package/dist/cjs/tests/unit/model-deprecation.test.d.ts +0 -1
  384. package/dist/cjs/tests/unit/model-deprecation.test.js +0 -142
  385. package/dist/cjs/tests/unit/model-deprecation.test.js.map +0 -1
  386. package/dist/cjs/tests/unit/model-utils.test.d.ts +0 -1
  387. package/dist/cjs/tests/unit/model-utils.test.js +0 -42
  388. package/dist/cjs/tests/unit/model-utils.test.js.map +0 -1
  389. package/dist/cjs/tests/unit/openai-compatible-temperature.test.d.ts +0 -1
  390. package/dist/cjs/tests/unit/openai-compatible-temperature.test.js +0 -84
  391. package/dist/cjs/tests/unit/openai-compatible-temperature.test.js.map +0 -1
  392. package/dist/cjs/tests/unit/openai-cua-client.test.d.ts +0 -1
  393. package/dist/cjs/tests/unit/openai-cua-client.test.js +0 -71
  394. package/dist/cjs/tests/unit/openai-cua-client.test.js.map +0 -1
  395. package/dist/cjs/tests/unit/page-extra-http-headers.test.d.ts +0 -1
  396. package/dist/cjs/tests/unit/page-extra-http-headers.test.js +0 -92
  397. package/dist/cjs/tests/unit/page-extra-http-headers.test.js.map +0 -1
  398. package/dist/cjs/tests/unit/page-snapshot.test.d.ts +0 -1
  399. package/dist/cjs/tests/unit/page-snapshot.test.js +0 -75
  400. package/dist/cjs/tests/unit/page-snapshot.test.js.map +0 -1
  401. package/dist/cjs/tests/unit/prompt-observe-variables.test.d.ts +0 -1
  402. package/dist/cjs/tests/unit/prompt-observe-variables.test.js +0 -25
  403. package/dist/cjs/tests/unit/prompt-observe-variables.test.js.map +0 -1
  404. package/dist/cjs/tests/unit/public-api/export-surface.test.d.ts +0 -1
  405. package/dist/cjs/tests/unit/public-api/export-surface.test.js +0 -107
  406. package/dist/cjs/tests/unit/public-api/export-surface.test.js.map +0 -1
  407. package/dist/cjs/tests/unit/public-api/llm-and-agents.test.d.ts +0 -1
  408. package/dist/cjs/tests/unit/public-api/llm-and-agents.test.js +0 -179
  409. package/dist/cjs/tests/unit/public-api/llm-and-agents.test.js.map +0 -1
  410. package/dist/cjs/tests/unit/public-api/public-error-types.test.d.ts +0 -62
  411. package/dist/cjs/tests/unit/public-api/public-error-types.test.js +0 -110
  412. package/dist/cjs/tests/unit/public-api/public-error-types.test.js.map +0 -1
  413. package/dist/cjs/tests/unit/public-api/public-types.test.d.ts +0 -1
  414. package/dist/cjs/tests/unit/public-api/public-types.test.js +0 -99
  415. package/dist/cjs/tests/unit/public-api/public-types.test.js.map +0 -1
  416. package/dist/cjs/tests/unit/public-api/runtime-utils.test.d.ts +0 -1
  417. package/dist/cjs/tests/unit/public-api/runtime-utils.test.js +0 -60
  418. package/dist/cjs/tests/unit/public-api/runtime-utils.test.js.map +0 -1
  419. package/dist/cjs/tests/unit/public-api/schema-utils.test.d.ts +0 -1
  420. package/dist/cjs/tests/unit/public-api/schema-utils.test.js +0 -95
  421. package/dist/cjs/tests/unit/public-api/schema-utils.test.js.map +0 -1
  422. package/dist/cjs/tests/unit/public-api/timeout-error-types.test.d.ts +0 -1
  423. package/dist/cjs/tests/unit/public-api/timeout-error-types.test.js +0 -121
  424. package/dist/cjs/tests/unit/public-api/timeout-error-types.test.js.map +0 -1
  425. package/dist/cjs/tests/unit/public-api/tool-type-export.test.d.ts +0 -1
  426. package/dist/cjs/tests/unit/public-api/tool-type-export.test.js +0 -65
  427. package/dist/cjs/tests/unit/public-api/tool-type-export.test.js.map +0 -1
  428. package/dist/cjs/tests/unit/public-api/v3-core.test.d.ts +0 -1
  429. package/dist/cjs/tests/unit/public-api/v3-core.test.js +0 -108
  430. package/dist/cjs/tests/unit/public-api/v3-core.test.js.map +0 -1
  431. package/dist/cjs/tests/unit/safety-confirmation.test.d.ts +0 -1
  432. package/dist/cjs/tests/unit/safety-confirmation.test.js +0 -110
  433. package/dist/cjs/tests/unit/safety-confirmation.test.js.map +0 -1
  434. package/dist/cjs/tests/unit/snapshot-a11y-resolvers.test.d.ts +0 -1
  435. package/dist/cjs/tests/unit/snapshot-a11y-resolvers.test.js +0 -431
  436. package/dist/cjs/tests/unit/snapshot-a11y-resolvers.test.js.map +0 -1
  437. package/dist/cjs/tests/unit/snapshot-a11y-tree-utils.test.d.ts +0 -1
  438. package/dist/cjs/tests/unit/snapshot-a11y-tree-utils.test.js +0 -306
  439. package/dist/cjs/tests/unit/snapshot-a11y-tree-utils.test.js.map +0 -1
  440. package/dist/cjs/tests/unit/snapshot-capture-orchestration.test.d.ts +0 -1
  441. package/dist/cjs/tests/unit/snapshot-capture-orchestration.test.js +0 -504
  442. package/dist/cjs/tests/unit/snapshot-capture-orchestration.test.js.map +0 -1
  443. package/dist/cjs/tests/unit/snapshot-cbor.test.d.ts +0 -1
  444. package/dist/cjs/tests/unit/snapshot-cbor.test.js +0 -204
  445. package/dist/cjs/tests/unit/snapshot-cbor.test.js.map +0 -1
  446. package/dist/cjs/tests/unit/snapshot-dom-session-builders.test.d.ts +0 -1
  447. package/dist/cjs/tests/unit/snapshot-dom-session-builders.test.js +0 -220
  448. package/dist/cjs/tests/unit/snapshot-dom-session-builders.test.js.map +0 -1
  449. package/dist/cjs/tests/unit/snapshot-dom-tree-utils.test.d.ts +0 -1
  450. package/dist/cjs/tests/unit/snapshot-dom-tree-utils.test.js +0 -107
  451. package/dist/cjs/tests/unit/snapshot-dom-tree-utils.test.js.map +0 -1
  452. package/dist/cjs/tests/unit/snapshot-focus-selectors-utils.test.d.ts +0 -1
  453. package/dist/cjs/tests/unit/snapshot-focus-selectors-utils.test.js +0 -89
  454. package/dist/cjs/tests/unit/snapshot-focus-selectors-utils.test.js.map +0 -1
  455. package/dist/cjs/tests/unit/snapshot-frame-merge.test.d.ts +0 -1
  456. package/dist/cjs/tests/unit/snapshot-frame-merge.test.js +0 -335
  457. package/dist/cjs/tests/unit/snapshot-frame-merge.test.js.map +0 -1
  458. package/dist/cjs/tests/unit/snapshot-tree-format-utils.test.d.ts +0 -1
  459. package/dist/cjs/tests/unit/snapshot-tree-format-utils.test.js +0 -84
  460. package/dist/cjs/tests/unit/snapshot-tree-format-utils.test.js.map +0 -1
  461. package/dist/cjs/tests/unit/snapshot-xpath-utils.test.d.ts +0 -1
  462. package/dist/cjs/tests/unit/snapshot-xpath-utils.test.js +0 -74
  463. package/dist/cjs/tests/unit/snapshot-xpath-utils.test.js.map +0 -1
  464. package/dist/cjs/tests/unit/timeout-handlers.test.d.ts +0 -1
  465. package/dist/cjs/tests/unit/timeout-handlers.test.js +0 -897
  466. package/dist/cjs/tests/unit/timeout-handlers.test.js.map +0 -1
  467. package/dist/cjs/tests/unit/understudy-command-exception.test.d.ts +0 -1
  468. package/dist/cjs/tests/unit/understudy-command-exception.test.js +0 -57
  469. package/dist/cjs/tests/unit/understudy-command-exception.test.js.map +0 -1
  470. package/dist/cjs/tests/unit/xpath-parser.test.d.ts +0 -1
  471. package/dist/cjs/tests/unit/xpath-parser.test.js +0 -311
  472. package/dist/cjs/tests/unit/xpath-parser.test.js.map +0 -1
  473. package/dist/cjs/tests/unit/xpath-resolver.test.d.ts +0 -1
  474. package/dist/cjs/tests/unit/xpath-resolver.test.js +0 -80
  475. package/dist/cjs/tests/unit/xpath-resolver.test.js.map +0 -1
  476. package/dist/cjs/tests/unit/zod-enum-compatibility.test.d.ts +0 -1
  477. package/dist/cjs/tests/unit/zod-enum-compatibility.test.js +0 -149
  478. package/dist/cjs/tests/unit/zod-enum-compatibility.test.js.map +0 -1
  479. package/dist/esm/tests/cache-variables.test.d.ts +0 -1
  480. package/dist/esm/tests/cache-variables.test.js +0 -219
  481. package/dist/esm/tests/cache-variables.test.js.map +0 -1
  482. package/dist/esm/tests/integration/agent-abort-signal.spec.d.ts +0 -1
  483. package/dist/esm/tests/integration/agent-abort-signal.spec.js +0 -121
  484. package/dist/esm/tests/integration/agent-abort-signal.spec.js.map +0 -1
  485. package/dist/esm/tests/integration/agent-cache-self-heal.spec.d.ts +0 -1
  486. package/dist/esm/tests/integration/agent-cache-self-heal.spec.js +0 -78
  487. package/dist/esm/tests/integration/agent-cache-self-heal.spec.js.map +0 -1
  488. package/dist/esm/tests/integration/agent-callbacks.spec.d.ts +0 -1
  489. package/dist/esm/tests/integration/agent-callbacks.spec.js +0 -383
  490. package/dist/esm/tests/integration/agent-callbacks.spec.js.map +0 -1
  491. package/dist/esm/tests/integration/agent-experimental-validation.spec.d.ts +0 -1
  492. package/dist/esm/tests/integration/agent-experimental-validation.spec.js +0 -360
  493. package/dist/esm/tests/integration/agent-experimental-validation.spec.js.map +0 -1
  494. package/dist/esm/tests/integration/agent-hybrid-mode.spec.d.ts +0 -1
  495. package/dist/esm/tests/integration/agent-hybrid-mode.spec.js +0 -260
  496. package/dist/esm/tests/integration/agent-hybrid-mode.spec.js.map +0 -1
  497. package/dist/esm/tests/integration/agent-message-continuation.spec.d.ts +0 -1
  498. package/dist/esm/tests/integration/agent-message-continuation.spec.js +0 -110
  499. package/dist/esm/tests/integration/agent-message-continuation.spec.js.map +0 -1
  500. package/dist/esm/tests/integration/agent-streaming.spec.d.ts +0 -1
  501. package/dist/esm/tests/integration/agent-streaming.spec.js +0 -138
  502. package/dist/esm/tests/integration/agent-streaming.spec.js.map +0 -1
  503. package/dist/esm/tests/integration/cdp-close-api-region.spec.d.ts +0 -1
  504. package/dist/esm/tests/integration/cdp-close-api-region.spec.js +0 -39
  505. package/dist/esm/tests/integration/cdp-close-api-region.spec.js.map +0 -1
  506. package/dist/esm/tests/integration/cdp-connection-close.spec.d.ts +0 -1
  507. package/dist/esm/tests/integration/cdp-connection-close.spec.js +0 -74
  508. package/dist/esm/tests/integration/cdp-connection-close.spec.js.map +0 -1
  509. package/dist/esm/tests/integration/cdp-session-detached.spec.d.ts +0 -1
  510. package/dist/esm/tests/integration/cdp-session-detached.spec.js +0 -43
  511. package/dist/esm/tests/integration/cdp-session-detached.spec.js.map +0 -1
  512. package/dist/esm/tests/integration/chrome-newtab-page-tracking.spec.d.ts +0 -1
  513. package/dist/esm/tests/integration/chrome-newtab-page-tracking.spec.js +0 -54
  514. package/dist/esm/tests/integration/chrome-newtab-page-tracking.spec.js.map +0 -1
  515. package/dist/esm/tests/integration/click-count.spec.d.ts +0 -1
  516. package/dist/esm/tests/integration/click-count.spec.js +0 -161
  517. package/dist/esm/tests/integration/click-count.spec.js.map +0 -1
  518. package/dist/esm/tests/integration/connect-to-existing-browser.spec.d.ts +0 -1
  519. package/dist/esm/tests/integration/connect-to-existing-browser.spec.js +0 -97
  520. package/dist/esm/tests/integration/connect-to-existing-browser.spec.js.map +0 -1
  521. package/dist/esm/tests/integration/context-addInitScript.spec.d.ts +0 -1
  522. package/dist/esm/tests/integration/context-addInitScript.spec.js +0 -283
  523. package/dist/esm/tests/integration/context-addInitScript.spec.js.map +0 -1
  524. package/dist/esm/tests/integration/context-extra-http-headers.spec.d.ts +0 -1
  525. package/dist/esm/tests/integration/context-extra-http-headers.spec.js +0 -47
  526. package/dist/esm/tests/integration/context-extra-http-headers.spec.js.map +0 -1
  527. package/dist/esm/tests/integration/cookies.spec.d.ts +0 -1
  528. package/dist/esm/tests/integration/cookies.spec.js +0 -185
  529. package/dist/esm/tests/integration/cookies.spec.js.map +0 -1
  530. package/dist/esm/tests/integration/default-page-tracking.spec.d.ts +0 -1
  531. package/dist/esm/tests/integration/default-page-tracking.spec.js +0 -50
  532. package/dist/esm/tests/integration/default-page-tracking.spec.js.map +0 -1
  533. package/dist/esm/tests/integration/downloads.spec.d.ts +0 -1
  534. package/dist/esm/tests/integration/downloads.spec.js +0 -47
  535. package/dist/esm/tests/integration/downloads.spec.js.map +0 -1
  536. package/dist/esm/tests/integration/flowLogger.spec.d.ts +0 -1
  537. package/dist/esm/tests/integration/flowLogger.spec.js +0 -716
  538. package/dist/esm/tests/integration/flowLogger.spec.js.map +0 -1
  539. package/dist/esm/tests/integration/frame-get-location-and-click.spec.d.ts +0 -1
  540. package/dist/esm/tests/integration/frame-get-location-and-click.spec.js +0 -55
  541. package/dist/esm/tests/integration/frame-get-location-and-click.spec.js.map +0 -1
  542. package/dist/esm/tests/integration/iframe-ctx-addInitScript-race.spec.d.ts +0 -1
  543. package/dist/esm/tests/integration/iframe-ctx-addInitScript-race.spec.js +0 -217
  544. package/dist/esm/tests/integration/iframe-ctx-addInitScript-race.spec.js.map +0 -1
  545. package/dist/esm/tests/integration/iframe-ctx-addInitScript.spec.d.ts +0 -1
  546. package/dist/esm/tests/integration/iframe-ctx-addInitScript.spec.js +0 -472
  547. package/dist/esm/tests/integration/iframe-ctx-addInitScript.spec.js.map +0 -1
  548. package/dist/esm/tests/integration/keep-alive.child.d.ts +0 -1
  549. package/dist/esm/tests/integration/keep-alive.child.js +0 -83
  550. package/dist/esm/tests/integration/keep-alive.child.js.map +0 -1
  551. package/dist/esm/tests/integration/keep-alive.spec.d.ts +0 -22
  552. package/dist/esm/tests/integration/keep-alive.spec.js +0 -482
  553. package/dist/esm/tests/integration/keep-alive.spec.js.map +0 -1
  554. package/dist/esm/tests/integration/keyboard.spec.d.ts +0 -1
  555. package/dist/esm/tests/integration/keyboard.spec.js +0 -257
  556. package/dist/esm/tests/integration/keyboard.spec.js.map +0 -1
  557. package/dist/esm/tests/integration/locator-backend-node-id.spec.d.ts +0 -1
  558. package/dist/esm/tests/integration/locator-backend-node-id.spec.js +0 -148
  559. package/dist/esm/tests/integration/locator-backend-node-id.spec.js.map +0 -1
  560. package/dist/esm/tests/integration/locator-content-methods.spec.d.ts +0 -1
  561. package/dist/esm/tests/integration/locator-content-methods.spec.js +0 -178
  562. package/dist/esm/tests/integration/locator-content-methods.spec.js.map +0 -1
  563. package/dist/esm/tests/integration/locator-count-iframe.spec.d.ts +0 -1
  564. package/dist/esm/tests/integration/locator-count-iframe.spec.js +0 -127
  565. package/dist/esm/tests/integration/locator-count-iframe.spec.js.map +0 -1
  566. package/dist/esm/tests/integration/locator-count.spec.d.ts +0 -1
  567. package/dist/esm/tests/integration/locator-count.spec.js +0 -66
  568. package/dist/esm/tests/integration/locator-count.spec.js.map +0 -1
  569. package/dist/esm/tests/integration/locator-fill.spec.d.ts +0 -1
  570. package/dist/esm/tests/integration/locator-fill.spec.js +0 -115
  571. package/dist/esm/tests/integration/locator-fill.spec.js.map +0 -1
  572. package/dist/esm/tests/integration/locator-input-methods.spec.d.ts +0 -1
  573. package/dist/esm/tests/integration/locator-input-methods.spec.js +0 -125
  574. package/dist/esm/tests/integration/locator-input-methods.spec.js.map +0 -1
  575. package/dist/esm/tests/integration/locator-nth.spec.d.ts +0 -1
  576. package/dist/esm/tests/integration/locator-nth.spec.js +0 -173
  577. package/dist/esm/tests/integration/locator-nth.spec.js.map +0 -1
  578. package/dist/esm/tests/integration/locator-select-option.spec.d.ts +0 -1
  579. package/dist/esm/tests/integration/locator-select-option.spec.js +0 -214
  580. package/dist/esm/tests/integration/locator-select-option.spec.js.map +0 -1
  581. package/dist/esm/tests/integration/logger-initialization.spec.d.ts +0 -1
  582. package/dist/esm/tests/integration/logger-initialization.spec.js +0 -595
  583. package/dist/esm/tests/integration/logger-initialization.spec.js.map +0 -1
  584. package/dist/esm/tests/integration/multi-instance-logger.spec.d.ts +0 -1
  585. package/dist/esm/tests/integration/multi-instance-logger.spec.js +0 -291
  586. package/dist/esm/tests/integration/multi-instance-logger.spec.js.map +0 -1
  587. package/dist/esm/tests/integration/nested-div.spec.d.ts +0 -1
  588. package/dist/esm/tests/integration/nested-div.spec.js +0 -20
  589. package/dist/esm/tests/integration/nested-div.spec.js.map +0 -1
  590. package/dist/esm/tests/integration/observe-element-id-format.spec.d.ts +0 -1
  591. package/dist/esm/tests/integration/observe-element-id-format.spec.js +0 -128
  592. package/dist/esm/tests/integration/observe-element-id-format.spec.js.map +0 -1
  593. package/dist/esm/tests/integration/page-addInitScript.spec.d.ts +0 -1
  594. package/dist/esm/tests/integration/page-addInitScript.spec.js +0 -92
  595. package/dist/esm/tests/integration/page-addInitScript.spec.js.map +0 -1
  596. package/dist/esm/tests/integration/page-console.spec.d.ts +0 -1
  597. package/dist/esm/tests/integration/page-console.spec.js +0 -45
  598. package/dist/esm/tests/integration/page-console.spec.js.map +0 -1
  599. package/dist/esm/tests/integration/page-drag-and-drop.spec.d.ts +0 -1
  600. package/dist/esm/tests/integration/page-drag-and-drop.spec.js +0 -435
  601. package/dist/esm/tests/integration/page-drag-and-drop.spec.js.map +0 -1
  602. package/dist/esm/tests/integration/page-extra-http-headers.spec.d.ts +0 -1
  603. package/dist/esm/tests/integration/page-extra-http-headers.spec.js +0 -83
  604. package/dist/esm/tests/integration/page-extra-http-headers.spec.js.map +0 -1
  605. package/dist/esm/tests/integration/page-goto-response.spec.d.ts +0 -1
  606. package/dist/esm/tests/integration/page-goto-response.spec.js +0 -32
  607. package/dist/esm/tests/integration/page-goto-response.spec.js.map +0 -1
  608. package/dist/esm/tests/integration/page-hover.spec.d.ts +0 -1
  609. package/dist/esm/tests/integration/page-hover.spec.js +0 -163
  610. package/dist/esm/tests/integration/page-hover.spec.js.map +0 -1
  611. package/dist/esm/tests/integration/page-screenshot.spec.d.ts +0 -1
  612. package/dist/esm/tests/integration/page-screenshot.spec.js +0 -257
  613. package/dist/esm/tests/integration/page-screenshot.spec.js.map +0 -1
  614. package/dist/esm/tests/integration/page-scroll.spec.d.ts +0 -1
  615. package/dist/esm/tests/integration/page-scroll.spec.js +0 -181
  616. package/dist/esm/tests/integration/page-scroll.spec.js.map +0 -1
  617. package/dist/esm/tests/integration/page-send-cdp.spec.d.ts +0 -1
  618. package/dist/esm/tests/integration/page-send-cdp.spec.js +0 -45
  619. package/dist/esm/tests/integration/page-send-cdp.spec.js.map +0 -1
  620. package/dist/esm/tests/integration/perform-understudy-method.spec.d.ts +0 -1
  621. package/dist/esm/tests/integration/perform-understudy-method.spec.js +0 -61
  622. package/dist/esm/tests/integration/perform-understudy-method.spec.js.map +0 -1
  623. package/dist/esm/tests/integration/setinputfiles.spec.d.ts +0 -1
  624. package/dist/esm/tests/integration/setinputfiles.spec.js +0 -128
  625. package/dist/esm/tests/integration/setinputfiles.spec.js.map +0 -1
  626. package/dist/esm/tests/integration/shadow-iframe-oopif.spec.d.ts +0 -1
  627. package/dist/esm/tests/integration/shadow-iframe-oopif.spec.js +0 -156
  628. package/dist/esm/tests/integration/shadow-iframe-oopif.spec.js.map +0 -1
  629. package/dist/esm/tests/integration/shadow-iframe-spif.spec.d.ts +0 -1
  630. package/dist/esm/tests/integration/shadow-iframe-spif.spec.js +0 -155
  631. package/dist/esm/tests/integration/shadow-iframe-spif.spec.js.map +0 -1
  632. package/dist/esm/tests/integration/testUtils.d.ts +0 -40
  633. package/dist/esm/tests/integration/testUtils.js +0 -178
  634. package/dist/esm/tests/integration/testUtils.js.map +0 -1
  635. package/dist/esm/tests/integration/text-selector-innermost.spec.d.ts +0 -1
  636. package/dist/esm/tests/integration/text-selector-innermost.spec.js +0 -103
  637. package/dist/esm/tests/integration/text-selector-innermost.spec.js.map +0 -1
  638. package/dist/esm/tests/integration/timeouts.spec.d.ts +0 -1
  639. package/dist/esm/tests/integration/timeouts.spec.js +0 -307
  640. package/dist/esm/tests/integration/timeouts.spec.js.map +0 -1
  641. package/dist/esm/tests/integration/user-data-dir.spec.d.ts +0 -1
  642. package/dist/esm/tests/integration/user-data-dir.spec.js +0 -42
  643. package/dist/esm/tests/integration/user-data-dir.spec.js.map +0 -1
  644. package/dist/esm/tests/integration/v3.config.d.ts +0 -4
  645. package/dist/esm/tests/integration/v3.config.js +0 -7
  646. package/dist/esm/tests/integration/v3.config.js.map +0 -1
  647. package/dist/esm/tests/integration/v3.dynamic.config.d.ts +0 -4
  648. package/dist/esm/tests/integration/v3.dynamic.config.js +0 -44
  649. package/dist/esm/tests/integration/v3.dynamic.config.js.map +0 -1
  650. package/dist/esm/tests/integration/v3.playwright.config.d.ts +0 -2
  651. package/dist/esm/tests/integration/v3.playwright.config.js +0 -46
  652. package/dist/esm/tests/integration/v3.playwright.config.js.map +0 -1
  653. package/dist/esm/tests/integration/wait-for-selector.spec.d.ts +0 -1
  654. package/dist/esm/tests/integration/wait-for-selector.spec.js +0 -681
  655. package/dist/esm/tests/integration/wait-for-selector.spec.js.map +0 -1
  656. package/dist/esm/tests/integration/wait-for-timeout.spec.d.ts +0 -1
  657. package/dist/esm/tests/integration/wait-for-timeout.spec.js +0 -116
  658. package/dist/esm/tests/integration/wait-for-timeout.spec.js.map +0 -1
  659. package/dist/esm/tests/integration/xpath-for-location-deep.spec.d.ts +0 -1
  660. package/dist/esm/tests/integration/xpath-for-location-deep.spec.js +0 -85
  661. package/dist/esm/tests/integration/xpath-for-location-deep.spec.js.map +0 -1
  662. package/dist/esm/tests/unit/agent-captcha-hooks.test.d.ts +0 -1
  663. package/dist/esm/tests/unit/agent-captcha-hooks.test.js +0 -339
  664. package/dist/esm/tests/unit/agent-captcha-hooks.test.js.map +0 -1
  665. package/dist/esm/tests/unit/agent-execution-model.test.d.ts +0 -1
  666. package/dist/esm/tests/unit/agent-execution-model.test.js +0 -148
  667. package/dist/esm/tests/unit/agent-execution-model.test.js.map +0 -1
  668. package/dist/esm/tests/unit/agent-metrics.test.d.ts +0 -1
  669. package/dist/esm/tests/unit/agent-metrics.test.js +0 -110
  670. package/dist/esm/tests/unit/agent-metrics.test.js.map +0 -1
  671. package/dist/esm/tests/unit/agent-mode-routing.test.d.ts +0 -1
  672. package/dist/esm/tests/unit/agent-mode-routing.test.js +0 -86
  673. package/dist/esm/tests/unit/agent-mode-routing.test.js.map +0 -1
  674. package/dist/esm/tests/unit/agent-system-prompt-variables.test.d.ts +0 -1
  675. package/dist/esm/tests/unit/agent-system-prompt-variables.test.js +0 -21
  676. package/dist/esm/tests/unit/agent-system-prompt-variables.test.js.map +0 -1
  677. package/dist/esm/tests/unit/agent-temperature.test.d.ts +0 -1
  678. package/dist/esm/tests/unit/agent-temperature.test.js +0 -189
  679. package/dist/esm/tests/unit/agent-temperature.test.js.map +0 -1
  680. package/dist/esm/tests/unit/agent-variables-validation.test.d.ts +0 -1
  681. package/dist/esm/tests/unit/agent-variables-validation.test.js +0 -41
  682. package/dist/esm/tests/unit/agent-variables-validation.test.js.map +0 -1
  683. package/dist/esm/tests/unit/aisdk-clients.test.d.ts +0 -1
  684. package/dist/esm/tests/unit/aisdk-clients.test.js +0 -84
  685. package/dist/esm/tests/unit/aisdk-clients.test.js.map +0 -1
  686. package/dist/esm/tests/unit/anthropic-cua-adaptive-thinking.test.d.ts +0 -1
  687. package/dist/esm/tests/unit/anthropic-cua-adaptive-thinking.test.js +0 -245
  688. package/dist/esm/tests/unit/anthropic-cua-adaptive-thinking.test.js.map +0 -1
  689. package/dist/esm/tests/unit/api-client-observe-variables.test.d.ts +0 -1
  690. package/dist/esm/tests/unit/api-client-observe-variables.test.js +0 -131
  691. package/dist/esm/tests/unit/api-client-observe-variables.test.js.map +0 -1
  692. package/dist/esm/tests/unit/api-multiregion.test.d.ts +0 -1
  693. package/dist/esm/tests/unit/api-multiregion.test.js +0 -56
  694. package/dist/esm/tests/unit/api-multiregion.test.js.map +0 -1
  695. package/dist/esm/tests/unit/api-optional-model-api-key.test.d.ts +0 -1
  696. package/dist/esm/tests/unit/api-optional-model-api-key.test.js +0 -153
  697. package/dist/esm/tests/unit/api-optional-model-api-key.test.js.map +0 -1
  698. package/dist/esm/tests/unit/api-variables-schema.test.d.ts +0 -1
  699. package/dist/esm/tests/unit/api-variables-schema.test.js +0 -60
  700. package/dist/esm/tests/unit/api-variables-schema.test.js.map +0 -1
  701. package/dist/esm/tests/unit/browserbase-session-accessors.test.d.ts +0 -1
  702. package/dist/esm/tests/unit/browserbase-session-accessors.test.js +0 -140
  703. package/dist/esm/tests/unit/browserbase-session-accessors.test.js.map +0 -1
  704. package/dist/esm/tests/unit/cache-llm-resolution.test.d.ts +0 -1
  705. package/dist/esm/tests/unit/cache-llm-resolution.test.js +0 -184
  706. package/dist/esm/tests/unit/cache-llm-resolution.test.js.map +0 -1
  707. package/dist/esm/tests/unit/captcha-solver.test.d.ts +0 -1
  708. package/dist/esm/tests/unit/captcha-solver.test.js +0 -152
  709. package/dist/esm/tests/unit/captcha-solver.test.js.map +0 -1
  710. package/dist/esm/tests/unit/cdp-connection-close.test.d.ts +0 -1
  711. package/dist/esm/tests/unit/cdp-connection-close.test.js +0 -72
  712. package/dist/esm/tests/unit/cdp-connection-close.test.js.map +0 -1
  713. package/dist/esm/tests/unit/context-extra-http-headers.test.d.ts +0 -1
  714. package/dist/esm/tests/unit/context-extra-http-headers.test.js +0 -56
  715. package/dist/esm/tests/unit/context-extra-http-headers.test.js.map +0 -1
  716. package/dist/esm/tests/unit/cookies.test.d.ts +0 -1
  717. package/dist/esm/tests/unit/cookies.test.js +0 -909
  718. package/dist/esm/tests/unit/cookies.test.js.map +0 -1
  719. package/dist/esm/tests/unit/flowlogger-capturing-cdp.test.d.ts +0 -1
  720. package/dist/esm/tests/unit/flowlogger-capturing-cdp.test.js +0 -93
  721. package/dist/esm/tests/unit/flowlogger-capturing-cdp.test.js.map +0 -1
  722. package/dist/esm/tests/unit/flowlogger-capturing-llm.test.d.ts +0 -1
  723. package/dist/esm/tests/unit/flowlogger-capturing-llm.test.js +0 -41
  724. package/dist/esm/tests/unit/flowlogger-capturing-llm.test.js.map +0 -1
  725. package/dist/esm/tests/unit/flowlogger-eventstore.test.d.ts +0 -1
  726. package/dist/esm/tests/unit/flowlogger-eventstore.test.js +0 -248
  727. package/dist/esm/tests/unit/flowlogger-eventstore.test.js.map +0 -1
  728. package/dist/esm/tests/unit/frame-registry-oopif-adoption.test.d.ts +0 -1
  729. package/dist/esm/tests/unit/frame-registry-oopif-adoption.test.js +0 -58
  730. package/dist/esm/tests/unit/frame-registry-oopif-adoption.test.js.map +0 -1
  731. package/dist/esm/tests/unit/helpers/mockCDPSession.d.ts +0 -19
  732. package/dist/esm/tests/unit/helpers/mockCDPSession.js +0 -25
  733. package/dist/esm/tests/unit/helpers/mockCDPSession.js.map +0 -1
  734. package/dist/esm/tests/unit/inference-temperature.test.d.ts +0 -1
  735. package/dist/esm/tests/unit/inference-temperature.test.js +0 -63
  736. package/dist/esm/tests/unit/inference-temperature.test.js.map +0 -1
  737. package/dist/esm/tests/unit/llm-middleware.test.d.ts +0 -1
  738. package/dist/esm/tests/unit/llm-middleware.test.js +0 -460
  739. package/dist/esm/tests/unit/llm-middleware.test.js.map +0 -1
  740. package/dist/esm/tests/unit/llm-provider.test.d.ts +0 -1
  741. package/dist/esm/tests/unit/llm-provider.test.js +0 -62
  742. package/dist/esm/tests/unit/llm-provider.test.js.map +0 -1
  743. package/dist/esm/tests/unit/microsoft-cua-client.test.d.ts +0 -1
  744. package/dist/esm/tests/unit/microsoft-cua-client.test.js +0 -84
  745. package/dist/esm/tests/unit/microsoft-cua-client.test.js.map +0 -1
  746. package/dist/esm/tests/unit/model-deprecation.test.d.ts +0 -1
  747. package/dist/esm/tests/unit/model-deprecation.test.js +0 -140
  748. package/dist/esm/tests/unit/model-deprecation.test.js.map +0 -1
  749. package/dist/esm/tests/unit/model-utils.test.d.ts +0 -1
  750. package/dist/esm/tests/unit/model-utils.test.js +0 -40
  751. package/dist/esm/tests/unit/model-utils.test.js.map +0 -1
  752. package/dist/esm/tests/unit/openai-compatible-temperature.test.d.ts +0 -1
  753. package/dist/esm/tests/unit/openai-compatible-temperature.test.js +0 -82
  754. package/dist/esm/tests/unit/openai-compatible-temperature.test.js.map +0 -1
  755. package/dist/esm/tests/unit/openai-cua-client.test.d.ts +0 -1
  756. package/dist/esm/tests/unit/openai-cua-client.test.js +0 -69
  757. package/dist/esm/tests/unit/openai-cua-client.test.js.map +0 -1
  758. package/dist/esm/tests/unit/page-extra-http-headers.test.d.ts +0 -1
  759. package/dist/esm/tests/unit/page-extra-http-headers.test.js +0 -90
  760. package/dist/esm/tests/unit/page-extra-http-headers.test.js.map +0 -1
  761. package/dist/esm/tests/unit/page-snapshot.test.d.ts +0 -1
  762. package/dist/esm/tests/unit/page-snapshot.test.js +0 -40
  763. package/dist/esm/tests/unit/page-snapshot.test.js.map +0 -1
  764. package/dist/esm/tests/unit/prompt-observe-variables.test.d.ts +0 -1
  765. package/dist/esm/tests/unit/prompt-observe-variables.test.js +0 -23
  766. package/dist/esm/tests/unit/prompt-observe-variables.test.js.map +0 -1
  767. package/dist/esm/tests/unit/public-api/export-surface.test.d.ts +0 -1
  768. package/dist/esm/tests/unit/public-api/export-surface.test.js +0 -72
  769. package/dist/esm/tests/unit/public-api/export-surface.test.js.map +0 -1
  770. package/dist/esm/tests/unit/public-api/llm-and-agents.test.d.ts +0 -1
  771. package/dist/esm/tests/unit/public-api/llm-and-agents.test.js +0 -144
  772. package/dist/esm/tests/unit/public-api/llm-and-agents.test.js.map +0 -1
  773. package/dist/esm/tests/unit/public-api/public-error-types.test.d.ts +0 -62
  774. package/dist/esm/tests/unit/public-api/public-error-types.test.js +0 -74
  775. package/dist/esm/tests/unit/public-api/public-error-types.test.js.map +0 -1
  776. package/dist/esm/tests/unit/public-api/public-types.test.d.ts +0 -1
  777. package/dist/esm/tests/unit/public-api/public-types.test.js +0 -97
  778. package/dist/esm/tests/unit/public-api/public-types.test.js.map +0 -1
  779. package/dist/esm/tests/unit/public-api/runtime-utils.test.d.ts +0 -1
  780. package/dist/esm/tests/unit/public-api/runtime-utils.test.js +0 -25
  781. package/dist/esm/tests/unit/public-api/runtime-utils.test.js.map +0 -1
  782. package/dist/esm/tests/unit/public-api/schema-utils.test.d.ts +0 -1
  783. package/dist/esm/tests/unit/public-api/schema-utils.test.js +0 -60
  784. package/dist/esm/tests/unit/public-api/schema-utils.test.js.map +0 -1
  785. package/dist/esm/tests/unit/public-api/timeout-error-types.test.d.ts +0 -1
  786. package/dist/esm/tests/unit/public-api/timeout-error-types.test.js +0 -86
  787. package/dist/esm/tests/unit/public-api/timeout-error-types.test.js.map +0 -1
  788. package/dist/esm/tests/unit/public-api/tool-type-export.test.d.ts +0 -1
  789. package/dist/esm/tests/unit/public-api/tool-type-export.test.js +0 -30
  790. package/dist/esm/tests/unit/public-api/tool-type-export.test.js.map +0 -1
  791. package/dist/esm/tests/unit/public-api/v3-core.test.d.ts +0 -1
  792. package/dist/esm/tests/unit/public-api/v3-core.test.js +0 -73
  793. package/dist/esm/tests/unit/public-api/v3-core.test.js.map +0 -1
  794. package/dist/esm/tests/unit/safety-confirmation.test.d.ts +0 -1
  795. package/dist/esm/tests/unit/safety-confirmation.test.js +0 -108
  796. package/dist/esm/tests/unit/safety-confirmation.test.js.map +0 -1
  797. package/dist/esm/tests/unit/snapshot-a11y-resolvers.test.d.ts +0 -1
  798. package/dist/esm/tests/unit/snapshot-a11y-resolvers.test.js +0 -396
  799. package/dist/esm/tests/unit/snapshot-a11y-resolvers.test.js.map +0 -1
  800. package/dist/esm/tests/unit/snapshot-a11y-tree-utils.test.d.ts +0 -1
  801. package/dist/esm/tests/unit/snapshot-a11y-tree-utils.test.js +0 -304
  802. package/dist/esm/tests/unit/snapshot-a11y-tree-utils.test.js.map +0 -1
  803. package/dist/esm/tests/unit/snapshot-capture-orchestration.test.d.ts +0 -1
  804. package/dist/esm/tests/unit/snapshot-capture-orchestration.test.js +0 -469
  805. package/dist/esm/tests/unit/snapshot-capture-orchestration.test.js.map +0 -1
  806. package/dist/esm/tests/unit/snapshot-cbor.test.d.ts +0 -1
  807. package/dist/esm/tests/unit/snapshot-cbor.test.js +0 -202
  808. package/dist/esm/tests/unit/snapshot-cbor.test.js.map +0 -1
  809. package/dist/esm/tests/unit/snapshot-dom-session-builders.test.d.ts +0 -1
  810. package/dist/esm/tests/unit/snapshot-dom-session-builders.test.js +0 -218
  811. package/dist/esm/tests/unit/snapshot-dom-session-builders.test.js.map +0 -1
  812. package/dist/esm/tests/unit/snapshot-dom-tree-utils.test.d.ts +0 -1
  813. package/dist/esm/tests/unit/snapshot-dom-tree-utils.test.js +0 -105
  814. package/dist/esm/tests/unit/snapshot-dom-tree-utils.test.js.map +0 -1
  815. package/dist/esm/tests/unit/snapshot-focus-selectors-utils.test.d.ts +0 -1
  816. package/dist/esm/tests/unit/snapshot-focus-selectors-utils.test.js +0 -87
  817. package/dist/esm/tests/unit/snapshot-focus-selectors-utils.test.js.map +0 -1
  818. package/dist/esm/tests/unit/snapshot-frame-merge.test.d.ts +0 -1
  819. package/dist/esm/tests/unit/snapshot-frame-merge.test.js +0 -333
  820. package/dist/esm/tests/unit/snapshot-frame-merge.test.js.map +0 -1
  821. package/dist/esm/tests/unit/snapshot-tree-format-utils.test.d.ts +0 -1
  822. package/dist/esm/tests/unit/snapshot-tree-format-utils.test.js +0 -82
  823. package/dist/esm/tests/unit/snapshot-tree-format-utils.test.js.map +0 -1
  824. package/dist/esm/tests/unit/snapshot-xpath-utils.test.d.ts +0 -1
  825. package/dist/esm/tests/unit/snapshot-xpath-utils.test.js +0 -72
  826. package/dist/esm/tests/unit/snapshot-xpath-utils.test.js.map +0 -1
  827. package/dist/esm/tests/unit/timeout-handlers.test.d.ts +0 -1
  828. package/dist/esm/tests/unit/timeout-handlers.test.js +0 -862
  829. package/dist/esm/tests/unit/timeout-handlers.test.js.map +0 -1
  830. package/dist/esm/tests/unit/understudy-command-exception.test.d.ts +0 -1
  831. package/dist/esm/tests/unit/understudy-command-exception.test.js +0 -55
  832. package/dist/esm/tests/unit/understudy-command-exception.test.js.map +0 -1
  833. package/dist/esm/tests/unit/xpath-parser.test.d.ts +0 -1
  834. package/dist/esm/tests/unit/xpath-parser.test.js +0 -309
  835. package/dist/esm/tests/unit/xpath-parser.test.js.map +0 -1
  836. package/dist/esm/tests/unit/xpath-resolver.test.d.ts +0 -1
  837. package/dist/esm/tests/unit/xpath-resolver.test.js +0 -78
  838. package/dist/esm/tests/unit/xpath-resolver.test.js.map +0 -1
  839. package/dist/esm/tests/unit/zod-enum-compatibility.test.d.ts +0 -1
  840. package/dist/esm/tests/unit/zod-enum-compatibility.test.js +0 -114
  841. package/dist/esm/tests/unit/zod-enum-compatibility.test.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../lib/version.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,iBAAiB,GAAG,OAAgB,CAAC","sourcesContent":["/**\n * AUTO-GENERATED — DO NOT EDIT BY HAND\n * Run `pnpm run gen-version` to refresh.\n */\nexport const STAGEHAND_VERSION = \"3.3.0\" as const;\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../lib/version.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,iBAAiB,GAAG,OAAgB,CAAC","sourcesContent":["/**\n * AUTO-GENERATED — DO NOT EDIT BY HAND\n * Run `pnpm run gen-version` to refresh.\n */\nexport const STAGEHAND_VERSION = \"3.4.0\" as const;\n"]}
@@ -3,7 +3,7 @@ import { LLMClient } from "./v3/llm/LLMClient.js";
3
3
  import type { InferStagehandSchema, StagehandZodObject } from "./v3/zodCompat.js";
4
4
  import type { Variables } from "./v3/types/public/agent.js";
5
5
  export type { LLMParsedResponse, LLMUsage } from "./v3/llm/LLMClient.js";
6
- export declare function extract<T extends StagehandZodObject>({ instruction, domElements, schema, llmClient, logger, userProvidedInstructions, logInferenceToFile, }: {
6
+ export declare function extract<T extends StagehandZodObject>({ instruction, domElements, schema, llmClient, logger, userProvidedInstructions, logInferenceToFile, screenshot, }: {
7
7
  instruction: string;
8
8
  domElements: string;
9
9
  schema: T;
@@ -11,6 +11,7 @@ export declare function extract<T extends StagehandZodObject>({ instruction, dom
11
11
  userProvidedInstructions?: string;
12
12
  logger: (message: LogLine) => void;
13
13
  logInferenceToFile?: boolean;
14
+ screenshot?: Buffer;
14
15
  }): Promise<InferStagehandSchema<T> & {
15
16
  metadata: {
16
17
  completed: boolean;
@@ -3,10 +3,11 @@ import { getEnvTimeoutMs, withTimeout } from "./v3/timeoutConfig.js";
3
3
  import { buildActSystemPrompt, buildExtractSystemPrompt, buildExtractUserPrompt, buildMetadataPrompt, buildMetadataSystemPrompt, buildObserveSystemPrompt, buildObserveUserMessage, } from "./prompt.js";
4
4
  import { appendSummary, writeTimestampedTxtFile } from "./inferenceLogUtils.js";
5
5
  import { SupportedUnderstudyAction } from "./v3/types/private/handlers.js";
6
+ import { StagehandInvalidArgumentError } from "./v3/types/public/sdkErrors.js";
6
7
  function withLlmTimeout(promise, operation) {
7
8
  return withTimeout(promise, getEnvTimeoutMs("LLM_MAX_MS"), `LLM ${operation}`);
8
9
  }
9
- export async function extract({ instruction, domElements, schema, llmClient, logger, userProvidedInstructions, logInferenceToFile = false, }) {
10
+ export async function extract({ instruction, domElements, schema, llmClient, logger, userProvidedInstructions, logInferenceToFile = false, screenshot, }) {
10
11
  const metadataSchema = z.object({
11
12
  progress: z
12
13
  .string()
@@ -16,9 +17,15 @@ export async function extract({ instruction, domElements, schema, llmClient, log
16
17
  .describe("true if the goal is now accomplished. Use this conservatively, only when sure that the goal has been completed."),
17
18
  });
18
19
  const isUsingAnthropic = llmClient.type === "anthropic";
20
+ if (screenshot && llmClient.type !== "aisdk") {
21
+ throw new StagehandInvalidArgumentError("extract({ screenshot: true }) is only supported with AI SDK clients.");
22
+ }
23
+ const screenshotDataUrl = screenshot
24
+ ? `data:image/png;base64,${screenshot.toString("base64")}`
25
+ : undefined;
19
26
  const extractCallMessages = [
20
- buildExtractSystemPrompt(isUsingAnthropic, userProvidedInstructions),
21
- buildExtractUserPrompt(instruction, domElements, isUsingAnthropic),
27
+ buildExtractSystemPrompt(isUsingAnthropic, userProvidedInstructions, Boolean(screenshotDataUrl)),
28
+ buildExtractUserPrompt(instruction, domElements, isUsingAnthropic, screenshotDataUrl),
22
29
  ];
23
30
  let extractCallFile = "";
24
31
  let extractCallTimestamp = "";
@@ -1 +1 @@
1
- {"version":3,"file":"inference.js","sourceRoot":"","sources":["../../../lib/inference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAKhF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAM3E,SAAS,cAAc,CAAI,OAAmB,EAAE,SAAiB;IAC/D,OAAO,WAAW,CAChB,OAAO,EACP,eAAe,CAAC,YAAY,CAAC,EAC7B,OAAO,SAAS,EAAE,CACnB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAA+B,EAC1D,WAAW,EACX,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,wBAAwB,EACxB,kBAAkB,GAAG,KAAK,GAS3B;IACC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;QAC9B,QAAQ,EAAE,CAAC;a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AAc,EAAE,QAAQ;YACxB,eAAe,EAAE,YAAY;YAC7B,aAAa,EAAE,YAAY;YAC3B,iBAAiB,EAAE,gBAAgB;YACnC,gBAAgB,EAAE,eAAe;YACjC,mBAAmB,EAAE,iBAAiB;YACtC,iBAAiB,EAAE,WAAW;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM;QAClC,CAAC,CAAC;YACE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS;YACnC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;YAC/C,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;YACrC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS;SACpC;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,OAAO,EAAE,aAAa;QACtB,aAAa,EAAE,YAAY;QAC3B,iBAAiB,EAAE,gBAAgB;QACnC,gBAAgB,EAAE,eAAe;QACjC,mBAAmB,EAAE,iBAAiB;QACtC,iBAAiB,EAAE,WAAW;QAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { LogLine } from \"./v3/types/public/logs.js\";\nimport { ChatMessage, LLMClient } from \"./v3/llm/LLMClient.js\";\nimport { getEnvTimeoutMs, withTimeout } from \"./v3/timeoutConfig.js\";\nimport {\n buildActSystemPrompt,\n buildExtractSystemPrompt,\n buildExtractUserPrompt,\n buildMetadataPrompt,\n buildMetadataSystemPrompt,\n buildObserveSystemPrompt,\n buildObserveUserMessage,\n} from \"./prompt.js\";\nimport { appendSummary, writeTimestampedTxtFile } from \"./inferenceLogUtils.js\";\nimport type {\n InferStagehandSchema,\n StagehandZodObject,\n} from \"./v3/zodCompat.js\";\nimport { SupportedUnderstudyAction } from \"./v3/types/private/handlers.js\";\nimport type { Variables } from \"./v3/types/public/agent.js\";\n\n// Re-export for backward compatibility\nexport type { LLMParsedResponse, LLMUsage } from \"./v3/llm/LLMClient.js\";\n\nfunction withLlmTimeout<T>(promise: Promise<T>, operation: string): Promise<T> {\n return withTimeout(\n promise,\n getEnvTimeoutMs(\"LLM_MAX_MS\"),\n `LLM ${operation}`,\n );\n}\n\nexport async function extract<T extends StagehandZodObject>({\n instruction,\n domElements,\n schema,\n llmClient,\n logger,\n userProvidedInstructions,\n logInferenceToFile = false,\n}: {\n instruction: string;\n domElements: string;\n schema: T;\n llmClient: LLMClient;\n userProvidedInstructions?: string;\n logger: (message: LogLine) => void;\n logInferenceToFile?: boolean;\n}) {\n const metadataSchema = z.object({\n progress: z\n .string()\n .describe(\n \"progress of what has been extracted so far, as concise as possible\",\n ),\n completed: z\n .boolean()\n .describe(\n \"true if the goal is now accomplished. Use this conservatively, only when sure that the goal has been completed.\",\n ),\n });\n\n type ExtractionResponse = InferStagehandSchema<T>;\n type MetadataResponse = z.infer<typeof metadataSchema>;\n\n const isUsingAnthropic = llmClient.type === \"anthropic\";\n\n const extractCallMessages: ChatMessage[] = [\n buildExtractSystemPrompt(isUsingAnthropic, userProvidedInstructions),\n buildExtractUserPrompt(instruction, domElements, isUsingAnthropic),\n ];\n\n let extractCallFile = \"\";\n let extractCallTimestamp = \"\";\n if (logInferenceToFile) {\n const { fileName, timestamp } = writeTimestampedTxtFile(\n \"extract_summary\",\n \"extract_call\",\n {\n modelCall: \"extract\",\n messages: extractCallMessages,\n },\n );\n extractCallFile = fileName;\n extractCallTimestamp = timestamp;\n }\n\n const extractStartTime = Date.now();\n const extractionResponse = await withLlmTimeout(\n llmClient.createChatCompletion<ExtractionResponse>({\n options: {\n messages: extractCallMessages,\n response_model: {\n schema,\n name: \"Extraction\",\n },\n top_p: 1,\n frequency_penalty: 0,\n presence_penalty: 0,\n },\n logger,\n }),\n \"extract\",\n );\n const extractEndTime = Date.now();\n\n const { data: extractedData, usage: extractUsage } = extractionResponse;\n\n let extractResponseFile: string;\n if (logInferenceToFile) {\n const { fileName } = writeTimestampedTxtFile(\n \"extract_summary\",\n \"extract_response\",\n {\n modelResponse: \"extract\",\n rawResponse: extractedData,\n },\n );\n extractResponseFile = fileName;\n\n appendSummary(\"extract\", {\n extract_inference_type: \"extract\",\n timestamp: extractCallTimestamp,\n LLM_input_file: extractCallFile,\n LLM_output_file: extractResponseFile,\n prompt_tokens: extractUsage?.prompt_tokens ?? 0,\n completion_tokens: extractUsage?.completion_tokens ?? 0,\n reasoning_tokens: extractUsage?.reasoning_tokens ?? 0,\n cached_input_tokens: extractUsage?.cached_input_tokens ?? 0,\n inference_time_ms: extractEndTime - extractStartTime,\n });\n }\n\n const metadataCallMessages: ChatMessage[] = [\n buildMetadataSystemPrompt(),\n buildMetadataPrompt(instruction, extractedData),\n ];\n\n let metadataCallFile = \"\";\n let metadataCallTimestamp = \"\";\n if (logInferenceToFile) {\n const { fileName, timestamp } = writeTimestampedTxtFile(\n \"extract_summary\",\n \"metadata_call\",\n {\n modelCall: \"metadata\",\n messages: metadataCallMessages,\n },\n );\n metadataCallFile = fileName;\n metadataCallTimestamp = timestamp;\n }\n\n const metadataStartTime = Date.now();\n const metadataResponse = await withLlmTimeout(\n llmClient.createChatCompletion<MetadataResponse>({\n options: {\n messages: metadataCallMessages,\n response_model: {\n name: \"Metadata\",\n schema: metadataSchema,\n },\n top_p: 1,\n frequency_penalty: 0,\n presence_penalty: 0,\n },\n logger,\n }),\n \"extract metadata\",\n );\n const metadataEndTime = Date.now();\n\n const {\n data: {\n completed: metadataResponseCompleted,\n progress: metadataResponseProgress,\n },\n usage: metadataResponseUsage,\n } = metadataResponse;\n\n let metadataResponseFile: string;\n if (logInferenceToFile) {\n const { fileName } = writeTimestampedTxtFile(\n \"extract_summary\",\n \"metadata_response\",\n {\n modelResponse: \"metadata\",\n completed: metadataResponseCompleted,\n progress: metadataResponseProgress,\n },\n );\n metadataResponseFile = fileName;\n\n appendSummary(\"extract\", {\n extract_inference_type: \"metadata\",\n timestamp: metadataCallTimestamp,\n LLM_input_file: metadataCallFile,\n LLM_output_file: metadataResponseFile,\n prompt_tokens: metadataResponseUsage?.prompt_tokens ?? 0,\n completion_tokens: metadataResponseUsage?.completion_tokens ?? 0,\n reasoning_tokens: metadataResponseUsage?.reasoning_tokens ?? 0,\n cached_input_tokens: metadataResponseUsage?.cached_input_tokens ?? 0,\n inference_time_ms: metadataEndTime - metadataStartTime,\n });\n }\n\n const totalPromptTokens =\n (extractUsage?.prompt_tokens ?? 0) +\n (metadataResponseUsage?.prompt_tokens ?? 0);\n\n const totalCompletionTokens =\n (extractUsage?.completion_tokens ?? 0) +\n (metadataResponseUsage?.completion_tokens ?? 0);\n\n const totalInferenceTimeMs =\n extractEndTime - extractStartTime + (metadataEndTime - metadataStartTime);\n const totalReasoningTokens =\n (extractUsage?.reasoning_tokens ?? 0) +\n (metadataResponseUsage?.reasoning_tokens ?? 0);\n const totalCachedInputTokens =\n (extractUsage?.cached_input_tokens ?? 0) +\n (metadataResponseUsage?.cached_input_tokens ?? 0);\n\n return {\n ...extractedData,\n metadata: {\n completed: metadataResponseCompleted,\n progress: metadataResponseProgress,\n },\n prompt_tokens: totalPromptTokens,\n completion_tokens: totalCompletionTokens,\n reasoning_tokens: totalReasoningTokens,\n cached_input_tokens: totalCachedInputTokens,\n inference_time_ms: totalInferenceTimeMs,\n };\n}\n\nexport async function observe({\n instruction,\n domElements,\n llmClient,\n userProvidedInstructions,\n logger,\n logInferenceToFile = false,\n supportedActions,\n variables,\n}: {\n instruction: string;\n domElements: string;\n llmClient: LLMClient;\n userProvidedInstructions?: string;\n logger: (message: LogLine) => void;\n logInferenceToFile?: boolean;\n supportedActions?: string[];\n variables?: Variables;\n}) {\n const observeSchema = z.object({\n elements: z\n .array(\n z.object({\n elementId: z\n .string()\n .regex(/^\\d+-\\d+$/)\n .describe(\n \"the exact ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'. For example, if the accessibility tree shows [0-18372], return '0-18372', not '18372'.\",\n ),\n description: z\n .string()\n .describe(\n \"a description of the accessible element and its purpose\",\n ),\n method: z\n .enum(\n // Use Object.values() for Zod v3 compatibility - z.enum() in v3 doesn't accept TypeScript enums directly\n Object.values(SupportedUnderstudyAction) as unknown as readonly [\n string,\n ...string[],\n ],\n )\n .describe(\n `the candidate method/action to interact with the element. Select one of the available Understudy interaction methods.`,\n ),\n arguments: z.array(\n z\n .string()\n .describe(\n \"the arguments to pass to the method. For example, for a click, the arguments are empty, but for a fill, the arguments are the value to fill in.\",\n ),\n ),\n }),\n )\n .describe(\"an array of accessible elements that match the instruction\"),\n });\n\n type ObserveResponse = z.infer<typeof observeSchema>;\n\n const messages: ChatMessage[] = [\n buildObserveSystemPrompt(\n userProvidedInstructions,\n supportedActions,\n variables,\n ),\n buildObserveUserMessage(instruction, domElements),\n ];\n\n let callTimestamp = \"\";\n let callFile = \"\";\n if (logInferenceToFile) {\n const { fileName, timestamp } = writeTimestampedTxtFile(\n `observe_summary`,\n `observe_call`,\n {\n modelCall: \"observe\",\n messages,\n },\n );\n callFile = fileName;\n callTimestamp = timestamp;\n }\n\n const start = Date.now();\n const rawResponse = await llmClient.createChatCompletion<ObserveResponse>({\n options: {\n messages,\n response_model: {\n schema: observeSchema,\n name: \"Observation\",\n },\n top_p: 1,\n frequency_penalty: 0,\n presence_penalty: 0,\n },\n logger,\n });\n const end = Date.now();\n const usageTimeMs = end - start;\n\n const { data: observeData, usage: observeUsage } = rawResponse;\n const promptTokens = observeUsage?.prompt_tokens ?? 0;\n const completionTokens = observeUsage?.completion_tokens ?? 0;\n const reasoningTokens = observeUsage?.reasoning_tokens ?? 0;\n const cachedInputTokens = observeUsage?.cached_input_tokens ?? 0;\n\n let responseFile: string;\n if (logInferenceToFile) {\n const { fileName: responseFileName } = writeTimestampedTxtFile(\n `observe_summary`,\n `observe_response`,\n {\n modelResponse: \"observe\",\n rawResponse: observeData,\n },\n );\n responseFile = responseFileName;\n\n appendSummary(\"observe\", {\n [`observe_inference_type`]: \"observe\",\n timestamp: callTimestamp,\n LLM_input_file: callFile,\n LLM_output_file: responseFile,\n prompt_tokens: promptTokens,\n completion_tokens: completionTokens,\n reasoning_tokens: reasoningTokens,\n cached_input_tokens: cachedInputTokens,\n inference_time_ms: usageTimeMs,\n });\n }\n\n const parsedElements =\n observeData.elements?.map((el) => {\n const base = {\n elementId: el.elementId,\n description: String(el.description),\n method: String(el.method),\n arguments: el.arguments,\n };\n return base;\n }) ?? [];\n\n return {\n elements: parsedElements,\n prompt_tokens: promptTokens,\n completion_tokens: completionTokens,\n reasoning_tokens: reasoningTokens,\n cached_input_tokens: cachedInputTokens,\n inference_time_ms: usageTimeMs,\n };\n}\n\nexport async function act({\n instruction,\n domElements,\n llmClient,\n userProvidedInstructions,\n logger,\n logInferenceToFile = false,\n}: {\n instruction: string;\n domElements: string;\n llmClient: LLMClient;\n userProvidedInstructions?: string;\n logger: (message: LogLine) => void;\n logInferenceToFile?: boolean;\n}) {\n const actSchema = z.object({\n action: z\n .object({\n elementId: z\n .string()\n .regex(/^\\d+-\\d+$/)\n .describe(\n \"the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'. for example, '0-76' or '16-21'\",\n ),\n description: z\n .string()\n .describe(\"a description of the accessible element and its purpose\"),\n method: z\n .enum(\n // Use Object.values() for Zod v3 compatibility - z.enum() in v3 doesn't accept TypeScript enums directly\n Object.values(SupportedUnderstudyAction) as unknown as readonly [\n string,\n ...string[],\n ],\n )\n .describe(\n \"the candidate method/action to interact with the element. Select one of the available Understudy interaction methods.\",\n ),\n arguments: z.array(\n z\n .string()\n .describe(\n \"the arguments to pass to the method. For example, for a click, the arguments are empty, but for a fill, the arguments are the value to fill in.\",\n ),\n ),\n })\n .nullable()\n .describe(\n \"The element to act on. Return null if no element on the page matches the instruction — do NOT fabricate or guess an element, and never emit empty strings or placeholder values.\",\n ),\n twoStep: z.boolean(),\n });\n\n type ActResponse = z.infer<typeof actSchema>;\n\n const messages: ChatMessage[] = [\n buildActSystemPrompt(userProvidedInstructions),\n buildObserveUserMessage(instruction, domElements),\n ];\n\n let callTimestamp = \"\";\n let callFile = \"\";\n if (logInferenceToFile) {\n const { fileName, timestamp } = writeTimestampedTxtFile(\n `act_summary`,\n `act_call`,\n {\n modelCall: \"act\",\n messages,\n },\n );\n callFile = fileName;\n callTimestamp = timestamp;\n }\n\n const start = Date.now();\n const rawResponse = await llmClient.createChatCompletion<ActResponse>({\n options: {\n messages,\n response_model: {\n schema: actSchema,\n name: \"act\",\n },\n top_p: 1,\n frequency_penalty: 0,\n presence_penalty: 0,\n },\n logger,\n });\n const end = Date.now();\n const usageTimeMs = end - start;\n\n const { data: actData, usage: actUsage } = rawResponse;\n const promptTokens = actUsage?.prompt_tokens ?? 0;\n const completionTokens = actUsage?.completion_tokens ?? 0;\n const reasoningTokens = actUsage?.reasoning_tokens ?? 0;\n const cachedInputTokens = actUsage?.cached_input_tokens ?? 0;\n\n let responseFile: string;\n if (logInferenceToFile) {\n const { fileName: responseFileName } = writeTimestampedTxtFile(\n `act_summary`,\n `act_response`,\n {\n modelResponse: \"act\",\n rawResponse: actData,\n },\n );\n responseFile = responseFileName;\n\n appendSummary(\"act\", {\n [`act_inference_type`]: \"act\",\n timestamp: callTimestamp,\n LLM_input_file: callFile,\n LLM_output_file: responseFile,\n prompt_tokens: promptTokens,\n completion_tokens: completionTokens,\n reasoning_tokens: reasoningTokens,\n cached_input_tokens: cachedInputTokens,\n inference_time_ms: usageTimeMs,\n });\n }\n\n const parsedElement = actData.action\n ? {\n elementId: actData.action.elementId,\n description: String(actData.action.description),\n method: String(actData.action.method),\n arguments: actData.action.arguments,\n }\n : undefined;\n\n return {\n element: parsedElement,\n prompt_tokens: promptTokens,\n completion_tokens: completionTokens,\n reasoning_tokens: reasoningTokens,\n cached_input_tokens: cachedInputTokens,\n inference_time_ms: usageTimeMs,\n twoStep: actData.twoStep,\n };\n}\n"]}
1
+ {"version":3,"file":"inference.js","sourceRoot":"","sources":["../../../lib/inference.ts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ACnC,gBAAgB,EAAE,eAAe;YACjC,mBAAmB,EAAE,iBAAiB;YACtC,iBAAiB,EAAE,WAAW;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM;QAClC,CAAC,CAAC;YACE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS;YACnC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;YAC/C,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;YACrC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS;SACpC;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,OAAO,EAAE,aAAa;QACtB,aAAa,EAAE,YAAY;QAC3B,iBAAiB,EAAE,gBAAgB;QACnC,gBAAgB,EAAE,eAAe;QACjC,mBAAmB,EAAE,iBAAiB;QACtC,iBAAiB,EAAE,WAAW;QAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { LogLine } from \"./v3/types/public/logs.js\";\nimport { ChatMessage, LLMClient } from \"./v3/llm/LLMClient.js\";\nimport { getEnvTimeoutMs, withTimeout } from \"./v3/timeoutConfig.js\";\nimport {\n buildActSystemPrompt,\n buildExtractSystemPrompt,\n buildExtractUserPrompt,\n buildMetadataPrompt,\n buildMetadataSystemPrompt,\n buildObserveSystemPrompt,\n buildObserveUserMessage,\n} from \"./prompt.js\";\nimport { appendSummary, writeTimestampedTxtFile } from \"./inferenceLogUtils.js\";\nimport type {\n InferStagehandSchema,\n StagehandZodObject,\n} from \"./v3/zodCompat.js\";\nimport { SupportedUnderstudyAction } from \"./v3/types/private/handlers.js\";\nimport type { Variables } from \"./v3/types/public/agent.js\";\nimport { StagehandInvalidArgumentError } from \"./v3/types/public/sdkErrors.js\";\n\n// Re-export for backward compatibility\nexport type { LLMParsedResponse, LLMUsage } from \"./v3/llm/LLMClient.js\";\n\nfunction withLlmTimeout<T>(promise: Promise<T>, operation: string): Promise<T> {\n return withTimeout(\n promise,\n getEnvTimeoutMs(\"LLM_MAX_MS\"),\n `LLM ${operation}`,\n );\n}\n\nexport async function extract<T extends StagehandZodObject>({\n instruction,\n domElements,\n schema,\n llmClient,\n logger,\n userProvidedInstructions,\n logInferenceToFile = false,\n screenshot,\n}: {\n instruction: string;\n domElements: string;\n schema: T;\n llmClient: LLMClient;\n userProvidedInstructions?: string;\n logger: (message: LogLine) => void;\n logInferenceToFile?: boolean;\n screenshot?: Buffer;\n}) {\n const metadataSchema = z.object({\n progress: z\n .string()\n .describe(\n \"progress of what has been extracted so far, as concise as possible\",\n ),\n completed: z\n .boolean()\n .describe(\n \"true if the goal is now accomplished. Use this conservatively, only when sure that the goal has been completed.\",\n ),\n });\n\n type ExtractionResponse = InferStagehandSchema<T>;\n type MetadataResponse = z.infer<typeof metadataSchema>;\n\n const isUsingAnthropic = llmClient.type === \"anthropic\";\n if (screenshot && llmClient.type !== \"aisdk\") {\n throw new StagehandInvalidArgumentError(\n \"extract({ screenshot: true }) is only supported with AI SDK clients.\",\n );\n }\n const screenshotDataUrl = screenshot\n ? `data:image/png;base64,${screenshot.toString(\"base64\")}`\n : undefined;\n\n const extractCallMessages: ChatMessage[] = [\n buildExtractSystemPrompt(\n isUsingAnthropic,\n userProvidedInstructions,\n Boolean(screenshotDataUrl),\n ),\n buildExtractUserPrompt(\n instruction,\n domElements,\n isUsingAnthropic,\n screenshotDataUrl,\n ),\n ];\n\n let extractCallFile = \"\";\n let extractCallTimestamp = \"\";\n if (logInferenceToFile) {\n const { fileName, timestamp } = writeTimestampedTxtFile(\n \"extract_summary\",\n \"extract_call\",\n {\n modelCall: \"extract\",\n messages: extractCallMessages,\n },\n );\n extractCallFile = fileName;\n extractCallTimestamp = timestamp;\n }\n\n const extractStartTime = Date.now();\n const extractionResponse = await withLlmTimeout(\n llmClient.createChatCompletion<ExtractionResponse>({\n options: {\n messages: extractCallMessages,\n response_model: {\n schema,\n name: \"Extraction\",\n },\n top_p: 1,\n frequency_penalty: 0,\n presence_penalty: 0,\n },\n logger,\n }),\n \"extract\",\n );\n const extractEndTime = Date.now();\n\n const { data: extractedData, usage: extractUsage } = extractionResponse;\n\n let extractResponseFile: string;\n if (logInferenceToFile) {\n const { fileName } = writeTimestampedTxtFile(\n \"extract_summary\",\n \"extract_response\",\n {\n modelResponse: \"extract\",\n rawResponse: extractedData,\n },\n );\n extractResponseFile = fileName;\n\n appendSummary(\"extract\", {\n extract_inference_type: \"extract\",\n timestamp: extractCallTimestamp,\n LLM_input_file: extractCallFile,\n LLM_output_file: extractResponseFile,\n prompt_tokens: extractUsage?.prompt_tokens ?? 0,\n completion_tokens: extractUsage?.completion_tokens ?? 0,\n reasoning_tokens: extractUsage?.reasoning_tokens ?? 0,\n cached_input_tokens: extractUsage?.cached_input_tokens ?? 0,\n inference_time_ms: extractEndTime - extractStartTime,\n });\n }\n\n const metadataCallMessages: ChatMessage[] = [\n buildMetadataSystemPrompt(),\n buildMetadataPrompt(instruction, extractedData),\n ];\n\n let metadataCallFile = \"\";\n let metadataCallTimestamp = \"\";\n if (logInferenceToFile) {\n const { fileName, timestamp } = writeTimestampedTxtFile(\n \"extract_summary\",\n \"metadata_call\",\n {\n modelCall: \"metadata\",\n messages: metadataCallMessages,\n },\n );\n metadataCallFile = fileName;\n metadataCallTimestamp = timestamp;\n }\n\n const metadataStartTime = Date.now();\n const metadataResponse = await withLlmTimeout(\n llmClient.createChatCompletion<MetadataResponse>({\n options: {\n messages: metadataCallMessages,\n response_model: {\n name: \"Metadata\",\n schema: metadataSchema,\n },\n top_p: 1,\n frequency_penalty: 0,\n presence_penalty: 0,\n },\n logger,\n }),\n \"extract metadata\",\n );\n const metadataEndTime = Date.now();\n\n const {\n data: {\n completed: metadataResponseCompleted,\n progress: metadataResponseProgress,\n },\n usage: metadataResponseUsage,\n } = metadataResponse;\n\n let metadataResponseFile: string;\n if (logInferenceToFile) {\n const { fileName } = writeTimestampedTxtFile(\n \"extract_summary\",\n \"metadata_response\",\n {\n modelResponse: \"metadata\",\n completed: metadataResponseCompleted,\n progress: metadataResponseProgress,\n },\n );\n metadataResponseFile = fileName;\n\n appendSummary(\"extract\", {\n extract_inference_type: \"metadata\",\n timestamp: metadataCallTimestamp,\n LLM_input_file: metadataCallFile,\n LLM_output_file: metadataResponseFile,\n prompt_tokens: metadataResponseUsage?.prompt_tokens ?? 0,\n completion_tokens: metadataResponseUsage?.completion_tokens ?? 0,\n reasoning_tokens: metadataResponseUsage?.reasoning_tokens ?? 0,\n cached_input_tokens: metadataResponseUsage?.cached_input_tokens ?? 0,\n inference_time_ms: metadataEndTime - metadataStartTime,\n });\n }\n\n const totalPromptTokens =\n (extractUsage?.prompt_tokens ?? 0) +\n (metadataResponseUsage?.prompt_tokens ?? 0);\n\n const totalCompletionTokens =\n (extractUsage?.completion_tokens ?? 0) +\n (metadataResponseUsage?.completion_tokens ?? 0);\n\n const totalInferenceTimeMs =\n extractEndTime - extractStartTime + (metadataEndTime - metadataStartTime);\n const totalReasoningTokens =\n (extractUsage?.reasoning_tokens ?? 0) +\n (metadataResponseUsage?.reasoning_tokens ?? 0);\n const totalCachedInputTokens =\n (extractUsage?.cached_input_tokens ?? 0) +\n (metadataResponseUsage?.cached_input_tokens ?? 0);\n\n return {\n ...extractedData,\n metadata: {\n completed: metadataResponseCompleted,\n progress: metadataResponseProgress,\n },\n prompt_tokens: totalPromptTokens,\n completion_tokens: totalCompletionTokens,\n reasoning_tokens: totalReasoningTokens,\n cached_input_tokens: totalCachedInputTokens,\n inference_time_ms: totalInferenceTimeMs,\n };\n}\n\nexport async function observe({\n instruction,\n domElements,\n llmClient,\n userProvidedInstructions,\n logger,\n logInferenceToFile = false,\n supportedActions,\n variables,\n}: {\n instruction: string;\n domElements: string;\n llmClient: LLMClient;\n userProvidedInstructions?: string;\n logger: (message: LogLine) => void;\n logInferenceToFile?: boolean;\n supportedActions?: string[];\n variables?: Variables;\n}) {\n const observeSchema = z.object({\n elements: z\n .array(\n z.object({\n elementId: z\n .string()\n .regex(/^\\d+-\\d+$/)\n .describe(\n \"the exact ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'. For example, if the accessibility tree shows [0-18372], return '0-18372', not '18372'.\",\n ),\n description: z\n .string()\n .describe(\n \"a description of the accessible element and its purpose\",\n ),\n method: z\n .enum(\n // Use Object.values() for Zod v3 compatibility - z.enum() in v3 doesn't accept TypeScript enums directly\n Object.values(SupportedUnderstudyAction) as unknown as readonly [\n string,\n ...string[],\n ],\n )\n .describe(\n `the candidate method/action to interact with the element. Select one of the available Understudy interaction methods.`,\n ),\n arguments: z.array(\n z\n .string()\n .describe(\n \"the arguments to pass to the method. For example, for a click, the arguments are empty, but for a fill, the arguments are the value to fill in.\",\n ),\n ),\n }),\n )\n .describe(\"an array of accessible elements that match the instruction\"),\n });\n\n type ObserveResponse = z.infer<typeof observeSchema>;\n\n const messages: ChatMessage[] = [\n buildObserveSystemPrompt(\n userProvidedInstructions,\n supportedActions,\n variables,\n ),\n buildObserveUserMessage(instruction, domElements),\n ];\n\n let callTimestamp = \"\";\n let callFile = \"\";\n if (logInferenceToFile) {\n const { fileName, timestamp } = writeTimestampedTxtFile(\n `observe_summary`,\n `observe_call`,\n {\n modelCall: \"observe\",\n messages,\n },\n );\n callFile = fileName;\n callTimestamp = timestamp;\n }\n\n const start = Date.now();\n const rawResponse = await llmClient.createChatCompletion<ObserveResponse>({\n options: {\n messages,\n response_model: {\n schema: observeSchema,\n name: \"Observation\",\n },\n top_p: 1,\n frequency_penalty: 0,\n presence_penalty: 0,\n },\n logger,\n });\n const end = Date.now();\n const usageTimeMs = end - start;\n\n const { data: observeData, usage: observeUsage } = rawResponse;\n const promptTokens = observeUsage?.prompt_tokens ?? 0;\n const completionTokens = observeUsage?.completion_tokens ?? 0;\n const reasoningTokens = observeUsage?.reasoning_tokens ?? 0;\n const cachedInputTokens = observeUsage?.cached_input_tokens ?? 0;\n\n let responseFile: string;\n if (logInferenceToFile) {\n const { fileName: responseFileName } = writeTimestampedTxtFile(\n `observe_summary`,\n `observe_response`,\n {\n modelResponse: \"observe\",\n rawResponse: observeData,\n },\n );\n responseFile = responseFileName;\n\n appendSummary(\"observe\", {\n [`observe_inference_type`]: \"observe\",\n timestamp: callTimestamp,\n LLM_input_file: callFile,\n LLM_output_file: responseFile,\n prompt_tokens: promptTokens,\n completion_tokens: completionTokens,\n reasoning_tokens: reasoningTokens,\n cached_input_tokens: cachedInputTokens,\n inference_time_ms: usageTimeMs,\n });\n }\n\n const parsedElements =\n observeData.elements?.map((el) => {\n const base = {\n elementId: el.elementId,\n description: String(el.description),\n method: String(el.method),\n arguments: el.arguments,\n };\n return base;\n }) ?? [];\n\n return {\n elements: parsedElements,\n prompt_tokens: promptTokens,\n completion_tokens: completionTokens,\n reasoning_tokens: reasoningTokens,\n cached_input_tokens: cachedInputTokens,\n inference_time_ms: usageTimeMs,\n };\n}\n\nexport async function act({\n instruction,\n domElements,\n llmClient,\n userProvidedInstructions,\n logger,\n logInferenceToFile = false,\n}: {\n instruction: string;\n domElements: string;\n llmClient: LLMClient;\n userProvidedInstructions?: string;\n logger: (message: LogLine) => void;\n logInferenceToFile?: boolean;\n}) {\n const actSchema = z.object({\n action: z\n .object({\n elementId: z\n .string()\n .regex(/^\\d+-\\d+$/)\n .describe(\n \"the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'. for example, '0-76' or '16-21'\",\n ),\n description: z\n .string()\n .describe(\"a description of the accessible element and its purpose\"),\n method: z\n .enum(\n // Use Object.values() for Zod v3 compatibility - z.enum() in v3 doesn't accept TypeScript enums directly\n Object.values(SupportedUnderstudyAction) as unknown as readonly [\n string,\n ...string[],\n ],\n )\n .describe(\n \"the candidate method/action to interact with the element. Select one of the available Understudy interaction methods.\",\n ),\n arguments: z.array(\n z\n .string()\n .describe(\n \"the arguments to pass to the method. For example, for a click, the arguments are empty, but for a fill, the arguments are the value to fill in.\",\n ),\n ),\n })\n .nullable()\n .describe(\n \"The element to act on. Return null if no element on the page matches the instruction — do NOT fabricate or guess an element, and never emit empty strings or placeholder values.\",\n ),\n twoStep: z.boolean(),\n });\n\n type ActResponse = z.infer<typeof actSchema>;\n\n const messages: ChatMessage[] = [\n buildActSystemPrompt(userProvidedInstructions),\n buildObserveUserMessage(instruction, domElements),\n ];\n\n let callTimestamp = \"\";\n let callFile = \"\";\n if (logInferenceToFile) {\n const { fileName, timestamp } = writeTimestampedTxtFile(\n `act_summary`,\n `act_call`,\n {\n modelCall: \"act\",\n messages,\n },\n );\n callFile = fileName;\n callTimestamp = timestamp;\n }\n\n const start = Date.now();\n const rawResponse = await llmClient.createChatCompletion<ActResponse>({\n options: {\n messages,\n response_model: {\n schema: actSchema,\n name: \"act\",\n },\n top_p: 1,\n frequency_penalty: 0,\n presence_penalty: 0,\n },\n logger,\n });\n const end = Date.now();\n const usageTimeMs = end - start;\n\n const { data: actData, usage: actUsage } = rawResponse;\n const promptTokens = actUsage?.prompt_tokens ?? 0;\n const completionTokens = actUsage?.completion_tokens ?? 0;\n const reasoningTokens = actUsage?.reasoning_tokens ?? 0;\n const cachedInputTokens = actUsage?.cached_input_tokens ?? 0;\n\n let responseFile: string;\n if (logInferenceToFile) {\n const { fileName: responseFileName } = writeTimestampedTxtFile(\n `act_summary`,\n `act_response`,\n {\n modelResponse: \"act\",\n rawResponse: actData,\n },\n );\n responseFile = responseFileName;\n\n appendSummary(\"act\", {\n [`act_inference_type`]: \"act\",\n timestamp: callTimestamp,\n LLM_input_file: callFile,\n LLM_output_file: responseFile,\n prompt_tokens: promptTokens,\n completion_tokens: completionTokens,\n reasoning_tokens: reasoningTokens,\n cached_input_tokens: cachedInputTokens,\n inference_time_ms: usageTimeMs,\n });\n }\n\n const parsedElement = actData.action\n ? {\n elementId: actData.action.elementId,\n description: String(actData.action.description),\n method: String(actData.action.method),\n arguments: actData.action.arguments,\n }\n : undefined;\n\n return {\n element: parsedElement,\n prompt_tokens: promptTokens,\n completion_tokens: completionTokens,\n reasoning_tokens: reasoningTokens,\n cached_input_tokens: cachedInputTokens,\n inference_time_ms: usageTimeMs,\n twoStep: actData.twoStep,\n };\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { ChatMessage } from "./v3/llm/LLMClient.js";
2
2
  import type { Variables } from "./v3/types/public/agent.js";
3
3
  export declare function buildUserInstructionsString(userProvidedInstructions?: string): string;
4
- export declare function buildExtractSystemPrompt(isUsingPrintExtractedDataTool?: boolean, userProvidedInstructions?: string): ChatMessage;
5
- export declare function buildExtractUserPrompt(instruction: string, domElements: string, isUsingPrintExtractedDataTool?: boolean): ChatMessage;
4
+ export declare function buildExtractSystemPrompt(isUsingPrintExtractedDataTool?: boolean, userProvidedInstructions?: string, includeScreenshot?: boolean): ChatMessage;
5
+ export declare function buildExtractUserPrompt(instruction: string, domElements: string, isUsingPrintExtractedDataTool?: boolean, screenshotDataUrl?: string): ChatMessage;
6
6
  export declare function buildMetadataSystemPrompt(): ChatMessage;
7
7
  export declare function buildMetadataPrompt(instruction: string, extractionResponse: object): ChatMessage;
8
8
  export declare function buildObserveSystemPrompt(userProvidedInstructions?: string, supportedActions?: string[], variables?: Variables): ChatMessage;
@@ -11,7 +11,7 @@ User Instructions:
11
11
  ${userProvidedInstructions}`;
12
12
  }
13
13
  // extract
14
- export function buildExtractSystemPrompt(isUsingPrintExtractedDataTool = false, userProvidedInstructions) {
14
+ export function buildExtractSystemPrompt(isUsingPrintExtractedDataTool = false, userProvidedInstructions, includeScreenshot = false) {
15
15
  const baseContent = `You are extracting content on behalf of a user.
16
16
  If a user asks you to extract a 'list' of information, or 'all' information,
17
17
  YOU MUST EXTRACT ALL OF THE INFORMATION THAT THE USER REQUESTS.
@@ -19,7 +19,9 @@ export function buildExtractSystemPrompt(isUsingPrintExtractedDataTool = false,
19
19
  You will be given:
20
20
  1. An instruction
21
21
  2. `;
22
- const contentDetail = `A list of DOM elements to extract from.`;
22
+ const contentDetail = includeScreenshot
23
+ ? `A list of DOM elements to extract from and a screenshot of the current viewport to extract from. Use them together to extract content from the page.`
24
+ : `A list of DOM elements to extract from.`;
23
25
  const instructions = `
24
26
  Print the exact text from the DOM elements with all symbols, characters, and endlines as is.
25
27
  Print null or an empty string if no new information is found.
@@ -39,14 +41,27 @@ ONLY print the content using the print_extracted_data tool provided.
39
41
  content,
40
42
  };
41
43
  }
42
- export function buildExtractUserPrompt(instruction, domElements, isUsingPrintExtractedDataTool = false) {
43
- let content = `Instruction: ${instruction}
44
+ export function buildExtractUserPrompt(instruction, domElements, isUsingPrintExtractedDataTool = false, screenshotDataUrl) {
45
+ let content = screenshotDataUrl
46
+ ? `Instruction: ${instruction}
47
+ DOM: ${domElements}
48
+ Use the screenshot of the current viewport together with the accessibility tree to extract content from the page.`
49
+ : `Instruction: ${instruction}
44
50
  DOM: ${domElements}`;
45
51
  if (isUsingPrintExtractedDataTool) {
46
52
  content += `
47
53
  ONLY print the content using the print_extracted_data tool provided.
48
54
  ONLY print the content using the print_extracted_data tool provided.`;
49
55
  }
56
+ if (screenshotDataUrl) {
57
+ return {
58
+ role: "user",
59
+ content: [
60
+ { type: "text", text: content },
61
+ { type: "image_url", image_url: { url: screenshotDataUrl } },
62
+ ],
63
+ };
64
+ }
50
65
  return {
51
66
  role: "user",
52
67
  content,
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../lib/prompt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,UAAU,2BAA2B,CACzC,wBAAiC;IAEjC,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;;;;;EAKP,wBAAwB,EAAE,CAAC;AAC7B,CAAC;AAED,UAAU;AACV,MAAM,UAAU,wBAAwB,CACtC,gCAAyC,KAAK,EAC9C,wBAAiC;IAEjC,MAAM,WAAW,GAA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C,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;GAMvE,CAAC;IAEF,WAAW,IAAI,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAElD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;;;;;EAKX,IAAI;;;;;;;;;;;;;;;;;;;;;;;mFAuB6E;KAChF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO,gJAAgJ,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACnM,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;kBACK,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;;CAGvD;KACE,CAAC;AACJ,CAAC","sourcesContent":["import { ChatMessage } from \"./v3/llm/LLMClient.js\";\nimport type { Variables } from \"./v3/types/public/agent.js\";\nimport { getVariablePromptEntries } from \"./v3/agent/utils/variables.js\";\n\nexport function buildUserInstructionsString(\n userProvidedInstructions?: string,\n): string {\n if (!userProvidedInstructions) {\n return \"\";\n }\n\n return `\\n\\n# Custom Instructions Provided by the User\n \nPlease keep the user's instructions in mind when performing actions. If the user's instructions are not relevant to the current task, ignore them.\n\nUser Instructions:\n${userProvidedInstructions}`;\n}\n\n// extract\nexport function buildExtractSystemPrompt(\n isUsingPrintExtractedDataTool: boolean = false,\n userProvidedInstructions?: string,\n): ChatMessage {\n const baseContent = `You are extracting content on behalf of a user.\n If a user asks you to extract a 'list' of information, or 'all' information, \n YOU MUST EXTRACT ALL OF THE INFORMATION THAT THE USER REQUESTS.\n \n You will be given:\n1. An instruction\n2. `;\n\n const contentDetail = `A list of DOM elements to extract from.`;\n\n const instructions = `\nPrint the exact text from the DOM elements with all symbols, characters, and endlines as is.\nPrint null or an empty string if no new information is found.\n `.trim();\n\n const toolInstructions = isUsingPrintExtractedDataTool\n ? `\nONLY print the content using the print_extracted_data tool provided.\nONLY print the content using the print_extracted_data tool provided.\n `.trim()\n : \"\";\n\n const additionalInstructions =\n \"If a user is attempting to extract links or URLs, you MUST respond with ONLY the IDs of the link elements. \\n\" +\n \"Do not attempt to extract links directly from the text unless absolutely necessary. \";\n\n const userInstructions = buildUserInstructionsString(\n userProvidedInstructions,\n );\n\n const content =\n `${baseContent}${contentDetail}\\n\\n${instructions}\\n${toolInstructions}${\n additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\"\n }${userInstructions ? `\\n\\n${userInstructions}` : \"\"}`.replace(/\\s+/g, \" \");\n\n return {\n role: \"system\",\n content,\n };\n}\n\nexport function buildExtractUserPrompt(\n instruction: string,\n domElements: string,\n isUsingPrintExtractedDataTool: boolean = false,\n): ChatMessage {\n let content = `Instruction: ${instruction}\nDOM: ${domElements}`;\n\n if (isUsingPrintExtractedDataTool) {\n content += `\nONLY print the content using the print_extracted_data tool provided.\nONLY print the content using the print_extracted_data tool provided.`;\n }\n\n return {\n role: \"user\",\n content,\n };\n}\n\nconst metadataSystemPrompt = `You are an AI assistant tasked with evaluating the progress and completion status of an extraction task.\nAnalyze the extraction response and determine if the task is completed or if more information is needed.\nStrictly abide by the following criteria:\n1. Once the instruction has been satisfied by the current extraction response, ALWAYS set completion status to true and stop processing, regardless of remaining chunks.\n2. Only set completion status to false if BOTH of these conditions are true:\n - The instruction has not been satisfied yet\n - There are still chunks left to process (chunksTotal > chunksSeen)`;\n\nexport function buildMetadataSystemPrompt(): ChatMessage {\n return {\n role: \"system\",\n content: metadataSystemPrompt,\n };\n}\n\nexport function buildMetadataPrompt(\n instruction: string,\n extractionResponse: object,\n): ChatMessage {\n return {\n role: \"user\",\n content: `Instruction: ${instruction}\nExtracted content: ${JSON.stringify(extractionResponse, null, 2)}`,\n };\n}\n\n// observe\nexport function buildObserveSystemPrompt(\n userProvidedInstructions?: string,\n supportedActions?: string[],\n variables?: Variables,\n): ChatMessage {\n const actionsString = supportedActions?.length\n ? `\\n\\nSupported actions: ${supportedActions.join(\", \")}`\n : \"\";\n const variableEntries = getVariablePromptEntries(variables);\n const variablesString = variableEntries.length\n ? `\\n\\nAvailable variables: ${variableEntries\n .map(({ name, description }) => {\n return description ? `%${name}% (${description})` : `%${name}%`;\n })\n .join(\n \", \",\n )}. When an action needs a dynamic or sensitive value, return the matching %variableName% placeholder in the action arguments instead of a literal value`\n : \"\";\n\n const observeSystemPrompt = `\nYou are helping the user automate the browser by finding elements based on what the user wants to observe in the page.\n\nYou will be given:\n1. a instruction of elements to observe\n2. a hierarchical accessibility tree showing the semantic structure of the page. The tree is a hybrid of the DOM and the accessibility tree.\n\nReturn an array of elements that match the instruction if they exist, otherwise return an empty array.\nWhen returning elements, include the appropriate method from the supported actions list.${actionsString}${variablesString}. When choosing non-left click actions, provide right or middle as the argument.\n\nEach element in the accessibility tree has an ID in square brackets, like [0-18372]. The ID has two parts: frame ordinal and backend node ID. Always copy the complete ID exactly as shown inside the brackets into elementId, including the frame ordinal and hyphen. For example, if the tree shows [0-18372], return elementId \"0-18372\"; never return only \"18372\".`;\n const content = observeSystemPrompt.replace(/\\s+/g, \" \");\n\n return {\n role: \"system\",\n content: [content, buildUserInstructionsString(userProvidedInstructions)]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n };\n}\n\nexport function buildObserveUserMessage(\n instruction: string,\n domElements: string,\n): ChatMessage {\n return {\n role: \"user\",\n content: `instruction: ${instruction}\nAccessibility Tree: \\n${domElements}\\n`,\n };\n}\n\nexport function buildActSystemPrompt(\n userProvidedInstructions?: string,\n): ChatMessage {\n const actSystemPrompt = `\nYou are helping the user automate the browser by finding elements based on what action the user wants to take on the page\n\nYou will be given:\n1. a user defined instruction about what action to take\n2. a hierarchical accessibility tree showing the semantic structure of the page. The tree is a hybrid of the DOM and the accessibility tree.\n\nReturn the element that matches the instruction if it exists. If no element on the page matches the instruction, set \\`action\\` to null. Do not fabricate or guess an element — empty strings or placeholder values for elementId/description/method are not acceptable.`;\n const content = actSystemPrompt.replace(/\\s+/g, \" \");\n\n return {\n role: \"system\",\n content: [content, buildUserInstructionsString(userProvidedInstructions)]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n };\n}\n\nfunction buildActVariablesPrompt(variables?: Variables): string {\n if (!variables || Object.keys(variables).length === 0) {\n return \"\";\n }\n\n const variableNames = Object.keys(variables)\n .map((key) => `%${key}%`)\n .join(\", \");\n\n return ` The user has provided the following variables to be used in the action: ${variableNames} \\n\n Note that these are the variable names/keys, and not the actual variable values. \\n\n To use the variables in the action, you must respond with the variable name inside the 'arguments' array. The variable name must be wrapped in percentage signs (eg, %variableNameHere%) so that it can be replaced with the actual variable value before the action is taken. \\n`;\n}\n\nexport function buildActPrompt(\n action: string,\n supportedActions: string[],\n variables?: Variables,\n): string {\n // Base instruction\n let instruction = `Find the most relevant element to perform an action on given the following action: ${action}. \n IF AND ONLY IF the action EXPLICITLY includes the word 'dropdown' and implies choosing/selecting an option from a dropdown, ignore the 'General Instructions' section, and follow the 'Dropdown Specific Instructions' section carefully.\n \n General Instructions: \n Provide an action for this element such as ${supportedActions.join(\", \")}. Remember that to users, buttons and links look the same in most cases.\n When choosing non-left click actions, provide right or middle as the argument\n If the action is completely unrelated to a potential action to be taken on the page, or no matching element exists, set \\`action\\` to null. Do not fabricate or guess an element.\n ONLY return one action. If multiple actions are relevant, return the most relevant one.\n If the user is asking to scroll to a position on the page, e.g., 'halfway' or 0.75, etc, you must return the argument formatted as the correct percentage, e.g., '50%' or '75%', etc.\n If the user is asking to scroll to the next chunk/previous chunk, choose the nextChunk/prevChunk method. No arguments are required here.\n If the action implies a key press, e.g., 'press enter', 'press a', 'press space', etc., always choose the press method with the appropriate key as argument — e.g. 'a', 'Enter', 'Space'. Do not choose a click action on an on-screen keyboard. Capitalize the first character like 'Enter', 'Tab', 'Escape' only for special keys. \n \n Dropdown Specific Instructions:\n For interacting with dropdowns, there are two specific cases that you need to handle. \n \n CASE 1: the element is a 'select' element. \n - choose the selectOptionFromDropdown method,\n - set the argument to the exact text of the option that should be selected,\n - set twoStep to false.\n CASE 2: the element is NOT a 'select' element:\n - do not attempt to directly choose the element from the dropdown. You will need to click to expand the dropdown first. You will achieve this by following these instructions:\n - choose the node that most closely corresponds to the given instruction EVEN if it is a 'StaticText' element, or otherwise does not appear to be interactable. \n - choose the 'click' method\n - set twoStep to true.\n `;\n\n instruction += buildActVariablesPrompt(variables);\n\n return instruction;\n}\n\nexport function buildStepTwoPrompt(\n originalUserAction: string,\n previousAction: string,\n supportedActions: string[],\n variables?: Variables,\n): string {\n // Base instruction\n let instruction = `\n The original user action was: ${originalUserAction}.\n You have just taken the following action which completed step 1 of 2: ${previousAction}.\n \n Now, you must find the most relevant element to perform an action on in order to complete step 2 of 2. \n \n General Instructions: \n Provide an action for this element such as ${supportedActions.join(\", \")}. Remember that to users, buttons and links look the same in most cases.\n If the action is completely unrelated to a potential action to be taken on the page, or no matching element exists, set \\`action\\` to null. Do not fabricate or guess an element.\n ONLY return one action. If multiple actions are relevant, return the most relevant one.\n If the user is asking to scroll to a position on the page, e.g., 'halfway' or 0.75, etc, you must return the argument formatted as the correct percentage, e.g., '50%' or '75%', etc.\n If the user is asking to scroll to the next chunk/previous chunk, choose the nextChunk/prevChunk method. No arguments are required here.\n If the action implies a key press, e.g., 'press enter', 'press a', 'press space', etc., always choose the press method with the appropriate key as argument — e.g. 'a', 'Enter', 'Space'. Do not choose a click action on an on-screen keyboard. Capitalize the first character like 'Enter', 'Tab', 'Escape' only for special keys. \n `;\n\n instruction += buildActVariablesPrompt(variables);\n\n return instruction;\n}\n\nexport function buildOperatorSystemPrompt(goal: string): ChatMessage {\n return {\n role: \"system\",\n content: `You are a general-purpose agent whose job is to accomplish the user's goal across multiple model calls by running actions on the page.\n\nYou will be given a goal and a list of steps that have been taken so far. Your job is to determine if either the user's goal has been completed or if there are still steps that need to be taken.\n\n# Your current goal\n${goal}\n\n# CRITICAL: You MUST use the provided tools to take actions. Do not just describe what you want to do - actually call the appropriate tools.\n\n# Available tools and when to use them:\n- \\`act\\`: Use this to interact with the page (click, type, navigate, etc.)\n- \\`extract\\`: Use this to get information from the page\n- \\`goto\\`: Use this to navigate to a specific URL\n- \\`wait\\`: Use this to wait for a period of time\n- \\`navback\\`: Use this to go back to the previous page\n- \\`refresh\\`: Use this to refresh the current page\n- \\`close\\`: Use this ONLY when the task is complete or cannot be achieved\n- External tools: Use any additional tools (like search tools) as needed for your goal\n\n# Important guidelines\n1. ALWAYS use tools - never just provide text responses about what you plan to do\n2. Break down complex actions into individual atomic steps\n3. For \\`act\\` commands, use only one action at a time, such as:\n - Single click on a specific element\n - Type into a single input field\n - Select a single option\n4. Avoid combining multiple actions in one instruction\n5. If multiple actions are needed, they should be separate steps\n6. Only use \\`close\\` when the task is genuinely complete or impossible to achieve`,\n };\n}\n\nexport function buildCuaDefaultSystemPrompt(): string {\n return `You are a helpful assistant that can use a web browser.\\nDo not ask follow up questions, the user will trust your judgement. Today's date is ${new Date().toISOString().split(\"T\")[0]}.`;\n}\n\nexport function buildGoogleCUASystemPrompt(): ChatMessage {\n return {\n role: \"system\",\n content: `You are a general-purpose browser agent whose job is to accomplish the user's goal.\nToday's date is ${new Date().toISOString().split(\"T\")[0]}.\nYou have access to a search tool; however, in most cases you should operate within the page/url the user has provided. ONLY use the search tool if you're stuck or the task is impossible to complete within the current page.\nYou will be given a goal and a list of steps that have been taken so far. Avoid requesting the user for input as much as possible. Good luck!\n`,\n };\n}\n"]}
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../lib/prompt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,UAAU,2BAA2B,CACzC,wBAAiC;IAEjC,IAAI,CAAC,wBAAwB,EAA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K,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;;CAGvD;KACE,CAAC;AACJ,CAAC","sourcesContent":["import { ChatMessage } from \"./v3/llm/LLMClient.js\";\nimport type { Variables } from \"./v3/types/public/agent.js\";\nimport { getVariablePromptEntries } from \"./v3/agent/utils/variables.js\";\n\nexport function buildUserInstructionsString(\n userProvidedInstructions?: string,\n): string {\n if (!userProvidedInstructions) {\n return \"\";\n }\n\n return `\\n\\n# Custom Instructions Provided by the User\n \nPlease keep the user's instructions in mind when performing actions. If the user's instructions are not relevant to the current task, ignore them.\n\nUser Instructions:\n${userProvidedInstructions}`;\n}\n\n// extract\nexport function buildExtractSystemPrompt(\n isUsingPrintExtractedDataTool: boolean = false,\n userProvidedInstructions?: string,\n includeScreenshot: boolean = false,\n): ChatMessage {\n const baseContent = `You are extracting content on behalf of a user.\n If a user asks you to extract a 'list' of information, or 'all' information, \n YOU MUST EXTRACT ALL OF THE INFORMATION THAT THE USER REQUESTS.\n \n You will be given:\n1. An instruction\n2. `;\n\n const contentDetail = includeScreenshot\n ? `A list of DOM elements to extract from and a screenshot of the current viewport to extract from. Use them together to extract content from the page.`\n : `A list of DOM elements to extract from.`;\n\n const instructions = `\nPrint the exact text from the DOM elements with all symbols, characters, and endlines as is.\nPrint null or an empty string if no new information is found.\n `.trim();\n\n const toolInstructions = isUsingPrintExtractedDataTool\n ? `\nONLY print the content using the print_extracted_data tool provided.\nONLY print the content using the print_extracted_data tool provided.\n `.trim()\n : \"\";\n\n const additionalInstructions =\n \"If a user is attempting to extract links or URLs, you MUST respond with ONLY the IDs of the link elements. \\n\" +\n \"Do not attempt to extract links directly from the text unless absolutely necessary. \";\n\n const userInstructions = buildUserInstructionsString(\n userProvidedInstructions,\n );\n\n const content =\n `${baseContent}${contentDetail}\\n\\n${instructions}\\n${toolInstructions}${\n additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\"\n }${userInstructions ? `\\n\\n${userInstructions}` : \"\"}`.replace(/\\s+/g, \" \");\n\n return {\n role: \"system\",\n content,\n };\n}\n\nexport function buildExtractUserPrompt(\n instruction: string,\n domElements: string,\n isUsingPrintExtractedDataTool: boolean = false,\n screenshotDataUrl?: string,\n): ChatMessage {\n let content = screenshotDataUrl\n ? `Instruction: ${instruction}\nDOM: ${domElements}\nUse the screenshot of the current viewport together with the accessibility tree to extract content from the page.`\n : `Instruction: ${instruction}\nDOM: ${domElements}`;\n\n if (isUsingPrintExtractedDataTool) {\n content += `\nONLY print the content using the print_extracted_data tool provided.\nONLY print the content using the print_extracted_data tool provided.`;\n }\n\n if (screenshotDataUrl) {\n return {\n role: \"user\",\n content: [\n { type: \"text\", text: content },\n { type: \"image_url\", image_url: { url: screenshotDataUrl } },\n ],\n };\n }\n\n return {\n role: \"user\",\n content,\n };\n}\n\nconst metadataSystemPrompt = `You are an AI assistant tasked with evaluating the progress and completion status of an extraction task.\nAnalyze the extraction response and determine if the task is completed or if more information is needed.\nStrictly abide by the following criteria:\n1. Once the instruction has been satisfied by the current extraction response, ALWAYS set completion status to true and stop processing, regardless of remaining chunks.\n2. Only set completion status to false if BOTH of these conditions are true:\n - The instruction has not been satisfied yet\n - There are still chunks left to process (chunksTotal > chunksSeen)`;\n\nexport function buildMetadataSystemPrompt(): ChatMessage {\n return {\n role: \"system\",\n content: metadataSystemPrompt,\n };\n}\n\nexport function buildMetadataPrompt(\n instruction: string,\n extractionResponse: object,\n): ChatMessage {\n return {\n role: \"user\",\n content: `Instruction: ${instruction}\nExtracted content: ${JSON.stringify(extractionResponse, null, 2)}`,\n };\n}\n\n// observe\nexport function buildObserveSystemPrompt(\n userProvidedInstructions?: string,\n supportedActions?: string[],\n variables?: Variables,\n): ChatMessage {\n const actionsString = supportedActions?.length\n ? `\\n\\nSupported actions: ${supportedActions.join(\", \")}`\n : \"\";\n const variableEntries = getVariablePromptEntries(variables);\n const variablesString = variableEntries.length\n ? `\\n\\nAvailable variables: ${variableEntries\n .map(({ name, description }) => {\n return description ? `%${name}% (${description})` : `%${name}%`;\n })\n .join(\n \", \",\n )}. When an action needs a dynamic or sensitive value, return the matching %variableName% placeholder in the action arguments instead of a literal value`\n : \"\";\n\n const observeSystemPrompt = `\nYou are helping the user automate the browser by finding elements based on what the user wants to observe in the page.\n\nYou will be given:\n1. a instruction of elements to observe\n2. a hierarchical accessibility tree showing the semantic structure of the page. The tree is a hybrid of the DOM and the accessibility tree.\n\nReturn an array of elements that match the instruction if they exist, otherwise return an empty array.\nWhen returning elements, include the appropriate method from the supported actions list.${actionsString}${variablesString}. When choosing non-left click actions, provide right or middle as the argument.\n\nEach element in the accessibility tree has an ID in square brackets, like [0-18372]. The ID has two parts: frame ordinal and backend node ID. Always copy the complete ID exactly as shown inside the brackets into elementId, including the frame ordinal and hyphen. For example, if the tree shows [0-18372], return elementId \"0-18372\"; never return only \"18372\".`;\n const content = observeSystemPrompt.replace(/\\s+/g, \" \");\n\n return {\n role: \"system\",\n content: [content, buildUserInstructionsString(userProvidedInstructions)]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n };\n}\n\nexport function buildObserveUserMessage(\n instruction: string,\n domElements: string,\n): ChatMessage {\n return {\n role: \"user\",\n content: `instruction: ${instruction}\nAccessibility Tree: \\n${domElements}\\n`,\n };\n}\n\nexport function buildActSystemPrompt(\n userProvidedInstructions?: string,\n): ChatMessage {\n const actSystemPrompt = `\nYou are helping the user automate the browser by finding elements based on what action the user wants to take on the page\n\nYou will be given:\n1. a user defined instruction about what action to take\n2. a hierarchical accessibility tree showing the semantic structure of the page. The tree is a hybrid of the DOM and the accessibility tree.\n\nReturn the element that matches the instruction if it exists. If no element on the page matches the instruction, set \\`action\\` to null. Do not fabricate or guess an element — empty strings or placeholder values for elementId/description/method are not acceptable.`;\n const content = actSystemPrompt.replace(/\\s+/g, \" \");\n\n return {\n role: \"system\",\n content: [content, buildUserInstructionsString(userProvidedInstructions)]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n };\n}\n\nfunction buildActVariablesPrompt(variables?: Variables): string {\n if (!variables || Object.keys(variables).length === 0) {\n return \"\";\n }\n\n const variableNames = Object.keys(variables)\n .map((key) => `%${key}%`)\n .join(\", \");\n\n return ` The user has provided the following variables to be used in the action: ${variableNames} \\n\n Note that these are the variable names/keys, and not the actual variable values. \\n\n To use the variables in the action, you must respond with the variable name inside the 'arguments' array. The variable name must be wrapped in percentage signs (eg, %variableNameHere%) so that it can be replaced with the actual variable value before the action is taken. \\n`;\n}\n\nexport function buildActPrompt(\n action: string,\n supportedActions: string[],\n variables?: Variables,\n): string {\n // Base instruction\n let instruction = `Find the most relevant element to perform an action on given the following action: ${action}. \n IF AND ONLY IF the action EXPLICITLY includes the word 'dropdown' and implies choosing/selecting an option from a dropdown, ignore the 'General Instructions' section, and follow the 'Dropdown Specific Instructions' section carefully.\n \n General Instructions: \n Provide an action for this element such as ${supportedActions.join(\", \")}. Remember that to users, buttons and links look the same in most cases.\n When choosing non-left click actions, provide right or middle as the argument\n If the action is completely unrelated to a potential action to be taken on the page, or no matching element exists, set \\`action\\` to null. Do not fabricate or guess an element.\n ONLY return one action. If multiple actions are relevant, return the most relevant one.\n If the user is asking to scroll to a position on the page, e.g., 'halfway' or 0.75, etc, you must return the argument formatted as the correct percentage, e.g., '50%' or '75%', etc.\n If the user is asking to scroll to the next chunk/previous chunk, choose the nextChunk/prevChunk method. No arguments are required here.\n If the action implies a key press, e.g., 'press enter', 'press a', 'press space', etc., always choose the press method with the appropriate key as argument — e.g. 'a', 'Enter', 'Space'. Do not choose a click action on an on-screen keyboard. Capitalize the first character like 'Enter', 'Tab', 'Escape' only for special keys. \n \n Dropdown Specific Instructions:\n For interacting with dropdowns, there are two specific cases that you need to handle. \n \n CASE 1: the element is a 'select' element. \n - choose the selectOptionFromDropdown method,\n - set the argument to the exact text of the option that should be selected,\n - set twoStep to false.\n CASE 2: the element is NOT a 'select' element:\n - do not attempt to directly choose the element from the dropdown. You will need to click to expand the dropdown first. You will achieve this by following these instructions:\n - choose the node that most closely corresponds to the given instruction EVEN if it is a 'StaticText' element, or otherwise does not appear to be interactable. \n - choose the 'click' method\n - set twoStep to true.\n `;\n\n instruction += buildActVariablesPrompt(variables);\n\n return instruction;\n}\n\nexport function buildStepTwoPrompt(\n originalUserAction: string,\n previousAction: string,\n supportedActions: string[],\n variables?: Variables,\n): string {\n // Base instruction\n let instruction = `\n The original user action was: ${originalUserAction}.\n You have just taken the following action which completed step 1 of 2: ${previousAction}.\n \n Now, you must find the most relevant element to perform an action on in order to complete step 2 of 2. \n \n General Instructions: \n Provide an action for this element such as ${supportedActions.join(\", \")}. Remember that to users, buttons and links look the same in most cases.\n If the action is completely unrelated to a potential action to be taken on the page, or no matching element exists, set \\`action\\` to null. Do not fabricate or guess an element.\n ONLY return one action. If multiple actions are relevant, return the most relevant one.\n If the user is asking to scroll to a position on the page, e.g., 'halfway' or 0.75, etc, you must return the argument formatted as the correct percentage, e.g., '50%' or '75%', etc.\n If the user is asking to scroll to the next chunk/previous chunk, choose the nextChunk/prevChunk method. No arguments are required here.\n If the action implies a key press, e.g., 'press enter', 'press a', 'press space', etc., always choose the press method with the appropriate key as argument — e.g. 'a', 'Enter', 'Space'. Do not choose a click action on an on-screen keyboard. Capitalize the first character like 'Enter', 'Tab', 'Escape' only for special keys. \n `;\n\n instruction += buildActVariablesPrompt(variables);\n\n return instruction;\n}\n\nexport function buildOperatorSystemPrompt(goal: string): ChatMessage {\n return {\n role: \"system\",\n content: `You are a general-purpose agent whose job is to accomplish the user's goal across multiple model calls by running actions on the page.\n\nYou will be given a goal and a list of steps that have been taken so far. Your job is to determine if either the user's goal has been completed or if there are still steps that need to be taken.\n\n# Your current goal\n${goal}\n\n# CRITICAL: You MUST use the provided tools to take actions. Do not just describe what you want to do - actually call the appropriate tools.\n\n# Available tools and when to use them:\n- \\`act\\`: Use this to interact with the page (click, type, navigate, etc.)\n- \\`extract\\`: Use this to get information from the page\n- \\`goto\\`: Use this to navigate to a specific URL\n- \\`wait\\`: Use this to wait for a period of time\n- \\`navback\\`: Use this to go back to the previous page\n- \\`refresh\\`: Use this to refresh the current page\n- \\`close\\`: Use this ONLY when the task is complete or cannot be achieved\n- External tools: Use any additional tools (like search tools) as needed for your goal\n\n# Important guidelines\n1. ALWAYS use tools - never just provide text responses about what you plan to do\n2. Break down complex actions into individual atomic steps\n3. For \\`act\\` commands, use only one action at a time, such as:\n - Single click on a specific element\n - Type into a single input field\n - Select a single option\n4. Avoid combining multiple actions in one instruction\n5. If multiple actions are needed, they should be separate steps\n6. Only use \\`close\\` when the task is genuinely complete or impossible to achieve`,\n };\n}\n\nexport function buildCuaDefaultSystemPrompt(): string {\n return `You are a helpful assistant that can use a web browser.\\nDo not ask follow up questions, the user will trust your judgement. Today's date is ${new Date().toISOString().split(\"T\")[0]}.`;\n}\n\nexport function buildGoogleCUASystemPrompt(): ChatMessage {\n return {\n role: \"system\",\n content: `You are a general-purpose browser agent whose job is to accomplish the user's goal.\nToday's date is ${new Date().toISOString().split(\"T\")[0]}.\nYou have access to a search tool; however, in most cases you should operate within the page/url the user has provided. ONLY use the search tool if you're stuck or the task is impossible to complete within the current page.\nYou will be given a goal and a list of steps that have been taken so far. Avoid requesting the user for input as much as possible. Good luck!\n`,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { ToolSet } from "ai/dist";
1
+ import { ToolSet } from "ai";
2
2
  import { AgentProviderType } from "../types/public/agent.js";
3
3
  import { LogLine } from "../types/public/logs.js";
4
4
  import { ClientOptions } from "../types/public/model.js";
@@ -1 +1 @@
1
- {"version":3,"file":"AgentProvider.js","sourceRoot":"","sources":["../../../../../lib/v3/agent/AgentProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO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AAC,EACpC,oBAAoB,CACrB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ToolSet } from \"ai/dist\";\nimport { AgentProviderType } from \"../types/public/agent.js\";\nimport { LogLine } from \"../types/public/logs.js\";\nimport { ClientOptions } from \"../types/public/model.js\";\nimport {\n UnsupportedModelError,\n UnsupportedModelProviderError,\n} from \"../types/public/sdkErrors.js\";\nimport { AgentClient } from \"./AgentClient.js\";\nimport { AnthropicCUAClient } from \"./AnthropicCUAClient.js\";\nimport { OpenAICUAClient } from \"./OpenAICUAClient.js\";\nimport { GoogleCUAClient } from \"./GoogleCUAClient.js\";\nimport { MicrosoftCUAClient } from \"./MicrosoftCUAClient.js\";\n\n// Map model names to their provider types\nexport const modelToAgentProviderMap: Record<string, AgentProviderType> = {\n \"gpt-5.4\": \"openai\",\n \"gpt-5.4-mini\": \"openai\",\n \"gpt-5.5\": \"openai\",\n \"computer-use-preview\": \"openai\",\n \"computer-use-preview-2025-03-11\": \"openai\",\n \"claude-sonnet-4-20250514\": \"anthropic\",\n \"claude-sonnet-4-5-20250929\": \"anthropic\",\n \"claude-opus-4-5-20251101\": \"anthropic\",\n \"claude-opus-4-6\": \"anthropic\",\n \"claude-sonnet-4-6\": \"anthropic\",\n \"claude-haiku-4-5\": \"anthropic\",\n \"claude-haiku-4-5-20251001\": \"anthropic\",\n \"gemini-2.5-computer-use-preview-10-2025\": \"google\",\n \"gemini-3-flash-preview\": \"google\",\n \"gemini-3-pro-preview\": \"google\",\n \"fara-7b\": \"microsoft\",\n};\n\n/**\n * Provider for agent clients\n * This class is responsible for creating the appropriate agent client\n * based on the provider type\n */\nexport class AgentProvider {\n private logger: (message: LogLine) => void;\n\n /**\n * Create a new agent provider\n */\n constructor(logger: (message: LogLine) => void) {\n this.logger = logger;\n }\n\n getClient(\n modelName: string,\n clientOptions?: ClientOptions,\n userProvidedInstructions?: string,\n tools?: ToolSet,\n ): AgentClient {\n // Check if provider is explicitly set in clientOptions\n const explicitProvider = clientOptions?.provider as\n | AgentProviderType\n | undefined;\n const type = explicitProvider || AgentProvider.getAgentProvider(modelName);\n\n this.logger({\n category: \"agent\",\n message: `Getting agent client for type: ${type}, model: ${modelName}${explicitProvider ? \" (explicit provider)\" : \"\"}`,\n level: 2,\n });\n\n try {\n switch (type) {\n case \"openai\":\n return new OpenAICUAClient(\n type,\n modelName,\n userProvidedInstructions,\n clientOptions,\n tools,\n );\n case \"anthropic\":\n return new AnthropicCUAClient(\n type,\n modelName,\n userProvidedInstructions,\n clientOptions,\n tools,\n );\n case \"google\":\n return new GoogleCUAClient(\n type,\n modelName,\n userProvidedInstructions,\n clientOptions,\n tools,\n );\n case \"microsoft\":\n return new MicrosoftCUAClient(\n type,\n modelName,\n userProvidedInstructions,\n clientOptions,\n );\n default:\n throw new UnsupportedModelProviderError(\n [\"openai\", \"anthropic\", \"google\", \"microsoft\"],\n \"Computer Use Agent\",\n );\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger({\n category: \"agent\",\n message: `Error creating agent client: ${errorMessage}`,\n level: 0,\n });\n throw error;\n }\n }\n\n static getAgentProvider(modelName: string): AgentProviderType {\n const normalized = modelName.includes(\"/\")\n ? modelName.split(\"/\")[1]\n : modelName;\n\n if (normalized in modelToAgentProviderMap) {\n return modelToAgentProviderMap[normalized];\n }\n\n throw new UnsupportedModelError(\n Object.keys(modelToAgentProviderMap),\n \"Computer Use Agent\",\n );\n }\n}\n"]}
1
+ {"version":3,"file":"AgentProvider.js","sourceRoot":"","sources":["../../../../../lib/v3/agent/AgentProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAk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AAoB,CACrB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ToolSet } from \"ai\";\nimport { AgentProviderType } from \"../types/public/agent.js\";\nimport { LogLine } from \"../types/public/logs.js\";\nimport { ClientOptions } from \"../types/public/model.js\";\nimport {\n UnsupportedModelError,\n UnsupportedModelProviderError,\n} from \"../types/public/sdkErrors.js\";\nimport { AgentClient } from \"./AgentClient.js\";\nimport { AnthropicCUAClient } from \"./AnthropicCUAClient.js\";\nimport { OpenAICUAClient } from \"./OpenAICUAClient.js\";\nimport { GoogleCUAClient } from \"./GoogleCUAClient.js\";\nimport { MicrosoftCUAClient } from \"./MicrosoftCUAClient.js\";\n\n// Map model names to their provider types\nexport const modelToAgentProviderMap: Record<string, AgentProviderType> = {\n \"gpt-5.4\": \"openai\",\n \"gpt-5.4-mini\": \"openai\",\n \"gpt-5.5\": \"openai\",\n \"computer-use-preview\": \"openai\",\n \"computer-use-preview-2025-03-11\": \"openai\",\n \"claude-sonnet-4-20250514\": \"anthropic\",\n \"claude-sonnet-4-5-20250929\": \"anthropic\",\n \"claude-opus-4-5-20251101\": \"anthropic\",\n \"claude-opus-4-6\": \"anthropic\",\n \"claude-sonnet-4-6\": \"anthropic\",\n \"claude-haiku-4-5\": \"anthropic\",\n \"claude-haiku-4-5-20251001\": \"anthropic\",\n \"gemini-2.5-computer-use-preview-10-2025\": \"google\",\n \"gemini-3-flash-preview\": \"google\",\n \"gemini-3-pro-preview\": \"google\",\n \"fara-7b\": \"microsoft\",\n};\n\n/**\n * Provider for agent clients\n * This class is responsible for creating the appropriate agent client\n * based on the provider type\n */\nexport class AgentProvider {\n private logger: (message: LogLine) => void;\n\n /**\n * Create a new agent provider\n */\n constructor(logger: (message: LogLine) => void) {\n this.logger = logger;\n }\n\n getClient(\n modelName: string,\n clientOptions?: ClientOptions,\n userProvidedInstructions?: string,\n tools?: ToolSet,\n ): AgentClient {\n // Check if provider is explicitly set in clientOptions\n const explicitProvider = clientOptions?.provider as\n | AgentProviderType\n | undefined;\n const type = explicitProvider || AgentProvider.getAgentProvider(modelName);\n\n this.logger({\n category: \"agent\",\n message: `Getting agent client for type: ${type}, model: ${modelName}${explicitProvider ? \" (explicit provider)\" : \"\"}`,\n level: 2,\n });\n\n try {\n switch (type) {\n case \"openai\":\n return new OpenAICUAClient(\n type,\n modelName,\n userProvidedInstructions,\n clientOptions,\n tools,\n );\n case \"anthropic\":\n return new AnthropicCUAClient(\n type,\n modelName,\n userProvidedInstructions,\n clientOptions,\n tools,\n );\n case \"google\":\n return new GoogleCUAClient(\n type,\n modelName,\n userProvidedInstructions,\n clientOptions,\n tools,\n );\n case \"microsoft\":\n return new MicrosoftCUAClient(\n type,\n modelName,\n userProvidedInstructions,\n clientOptions,\n );\n default:\n throw new UnsupportedModelProviderError(\n [\"openai\", \"anthropic\", \"google\", \"microsoft\"],\n \"Computer Use Agent\",\n );\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger({\n category: \"agent\",\n message: `Error creating agent client: ${errorMessage}`,\n level: 0,\n });\n throw error;\n }\n }\n\n static getAgentProvider(modelName: string): AgentProviderType {\n const normalized = modelName.includes(\"/\")\n ? modelName.split(\"/\")[1]\n : modelName;\n\n if (normalized in modelToAgentProviderMap) {\n return modelToAgentProviderMap[normalized];\n }\n\n throw new UnsupportedModelError(\n Object.keys(modelToAgentProviderMap),\n \"Computer Use Agent\",\n );\n }\n}\n"]}
@@ -746,6 +746,16 @@ export class AnthropicCUAClient extends AgentClient {
746
746
  ...input,
747
747
  };
748
748
  }
749
+ else if (action === "triple_click" || action === "tripleClick") {
750
+ return {
751
+ type: "tripleClick",
752
+ x: input.x ||
753
+ (input.coordinate ? input.coordinate[0] : 0),
754
+ y: input.y ||
755
+ (input.coordinate ? input.coordinate[1] : 0),
756
+ ...input,
757
+ };
758
+ }
749
759
  else if (action === "scroll") {
750
760
  // Convert Anthropic's coordinate, scroll_amount and scroll_direction into scroll_x and scroll_y
751
761
  const x = input.x ||