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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (655) hide show
  1. package/dist/esm/index.d.ts +3 -0
  2. package/dist/esm/index.js +3 -0
  3. package/dist/esm/lib/inference.d.ts +65 -0
  4. package/dist/esm/lib/inference.js +333 -0
  5. package/dist/esm/lib/inference.js.map +1 -0
  6. package/dist/esm/lib/inferenceLogUtils.d.ts +12 -0
  7. package/dist/esm/lib/inferenceLogUtils.js +92 -0
  8. package/dist/esm/lib/inferenceLogUtils.js.map +1 -0
  9. package/dist/esm/lib/logger.d.ts +69 -0
  10. package/dist/esm/lib/logger.js +323 -0
  11. package/dist/esm/lib/logger.js.map +1 -0
  12. package/dist/esm/lib/modelUtils.d.ts +14 -0
  13. package/dist/esm/lib/modelUtils.js +48 -0
  14. package/dist/esm/lib/modelUtils.js.map +1 -0
  15. package/dist/esm/lib/prompt.d.ts +14 -0
  16. package/dist/esm/lib/prompt.js +230 -0
  17. package/dist/esm/lib/prompt.js.map +1 -0
  18. package/dist/esm/lib/utils.d.ts +68 -0
  19. package/dist/esm/lib/utils.js +654 -0
  20. package/dist/esm/lib/utils.js.map +1 -0
  21. package/dist/esm/lib/v3/agent/AgentClient.d.ts +19 -0
  22. package/dist/esm/lib/v3/agent/AgentClient.js +17 -0
  23. package/dist/esm/lib/v3/agent/AgentClient.js.map +1 -0
  24. package/dist/esm/lib/v3/agent/AgentProvider.d.ts +20 -0
  25. package/dist/esm/lib/v3/agent/AgentProvider.js +77 -0
  26. package/dist/esm/lib/v3/agent/AgentProvider.js.map +1 -0
  27. package/dist/esm/lib/v3/agent/AnthropicCUAClient.d.ts +57 -0
  28. package/dist/esm/lib/v3/agent/AnthropicCUAClient.js +822 -0
  29. package/dist/esm/lib/v3/agent/AnthropicCUAClient.js.map +1 -0
  30. package/dist/esm/lib/v3/agent/GoogleCUAClient.d.ts +74 -0
  31. package/dist/esm/lib/v3/agent/GoogleCUAClient.js +799 -0
  32. package/dist/esm/lib/v3/agent/GoogleCUAClient.js.map +1 -0
  33. package/dist/esm/lib/v3/agent/MicrosoftCUAClient.d.ts +71 -0
  34. package/dist/esm/lib/v3/agent/MicrosoftCUAClient.js +770 -0
  35. package/dist/esm/lib/v3/agent/MicrosoftCUAClient.js.map +1 -0
  36. package/dist/esm/lib/v3/agent/OpenAICUAClient.d.ts +69 -0
  37. package/dist/esm/lib/v3/agent/OpenAICUAClient.js +615 -0
  38. package/dist/esm/lib/v3/agent/OpenAICUAClient.js.map +1 -0
  39. package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.d.ts +12 -0
  40. package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.js +186 -0
  41. package/dist/esm/lib/v3/agent/prompts/agentSystemPrompt.js.map +1 -0
  42. package/dist/esm/lib/v3/agent/tools/act.d.ts +13 -0
  43. package/dist/esm/lib/v3/agent/tools/act.js +49 -0
  44. package/dist/esm/lib/v3/agent/tools/act.js.map +1 -0
  45. package/dist/esm/lib/v3/agent/tools/ariaTree.d.ts +5 -0
  46. package/dist/esm/lib/v3/agent/tools/ariaTree.js +31 -0
  47. package/dist/esm/lib/v3/agent/tools/ariaTree.js.map +1 -0
  48. package/dist/esm/lib/v3/agent/tools/click.d.ts +6 -0
  49. package/dist/esm/lib/v3/agent/tools/click.js +104 -0
  50. package/dist/esm/lib/v3/agent/tools/click.js.map +1 -0
  51. package/dist/esm/lib/v3/agent/tools/clickAndHold.d.ts +14 -0
  52. package/dist/esm/lib/v3/agent/tools/clickAndHold.js +68 -0
  53. package/dist/esm/lib/v3/agent/tools/clickAndHold.js.map +1 -0
  54. package/dist/esm/lib/v3/agent/tools/dragAndDrop.d.ts +7 -0
  55. package/dist/esm/lib/v3/agent/tools/dragAndDrop.js +105 -0
  56. package/dist/esm/lib/v3/agent/tools/dragAndDrop.js.map +1 -0
  57. package/dist/esm/lib/v3/agent/tools/extract.d.ts +21 -0
  58. package/dist/esm/lib/v3/agent/tools/extract.js +93 -0
  59. package/dist/esm/lib/v3/agent/tools/extract.js.map +1 -0
  60. package/dist/esm/lib/v3/agent/tools/fillFormVision.d.ts +12 -0
  61. package/dist/esm/lib/v3/agent/tools/fillFormVision.js +143 -0
  62. package/dist/esm/lib/v3/agent/tools/fillFormVision.js.map +1 -0
  63. package/dist/esm/lib/v3/agent/tools/fillform.d.ts +13 -0
  64. package/dist/esm/lib/v3/agent/tools/fillform.js +56 -0
  65. package/dist/esm/lib/v3/agent/tools/fillform.js.map +1 -0
  66. package/dist/esm/lib/v3/agent/tools/goto.d.ts +12 -0
  67. package/dist/esm/lib/v3/agent/tools/goto.js +31 -0
  68. package/dist/esm/lib/v3/agent/tools/goto.js.map +1 -0
  69. package/dist/esm/lib/v3/agent/tools/index.d.ts +92 -0
  70. package/dist/esm/lib/v3/agent/tools/index.js +74 -0
  71. package/dist/esm/lib/v3/agent/tools/index.js.map +1 -0
  72. package/dist/esm/lib/v3/agent/tools/keys.d.ts +24 -0
  73. package/dist/esm/lib/v3/agent/tools/keys.js +60 -0
  74. package/dist/esm/lib/v3/agent/tools/keys.js.map +1 -0
  75. package/dist/esm/lib/v3/agent/tools/navback.d.ts +6 -0
  76. package/dist/esm/lib/v3/agent/tools/navback.js +23 -0
  77. package/dist/esm/lib/v3/agent/tools/navback.js.map +1 -0
  78. package/dist/esm/lib/v3/agent/tools/screenshot.d.ts +6 -0
  79. package/dist/esm/lib/v3/agent/tools/screenshot.js +26 -0
  80. package/dist/esm/lib/v3/agent/tools/screenshot.js.map +1 -0
  81. package/dist/esm/lib/v3/agent/tools/scroll.d.ts +19 -0
  82. package/dist/esm/lib/v3/agent/tools/scroll.js +142 -0
  83. package/dist/esm/lib/v3/agent/tools/scroll.js.map +1 -0
  84. package/dist/esm/lib/v3/agent/tools/search.d.ts +15 -0
  85. package/dist/esm/lib/v3/agent/tools/search.js +73 -0
  86. package/dist/esm/lib/v3/agent/tools/search.js.map +1 -0
  87. package/dist/esm/lib/v3/agent/tools/think.d.ts +6 -0
  88. package/dist/esm/lib/v3/agent/tools/think.js +24 -0
  89. package/dist/esm/lib/v3/agent/tools/think.js.map +1 -0
  90. package/dist/esm/lib/v3/agent/tools/type.d.ts +7 -0
  91. package/dist/esm/lib/v3/agent/tools/type.js +106 -0
  92. package/dist/esm/lib/v3/agent/tools/type.js.map +1 -0
  93. package/dist/esm/lib/v3/agent/tools/wait.d.ts +5 -0
  94. package/dist/esm/lib/v3/agent/tools/wait.js +53 -0
  95. package/dist/esm/lib/v3/agent/tools/wait.js.map +1 -0
  96. package/dist/esm/lib/v3/agent/utils/actionMapping.d.ts +3 -0
  97. package/dist/esm/lib/v3/agent/utils/actionMapping.js +100 -0
  98. package/dist/esm/lib/v3/agent/utils/actionMapping.js.map +1 -0
  99. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.d.ts +13 -0
  100. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js +28 -0
  101. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js.map +1 -0
  102. package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.d.ts +10 -0
  103. package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.js +62 -0
  104. package/dist/esm/lib/v3/agent/utils/cuaKeyMapping.js.map +1 -0
  105. package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.d.ts +25 -0
  106. package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.js +145 -0
  107. package/dist/esm/lib/v3/agent/utils/googleCustomToolHandler.js.map +1 -0
  108. package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.d.ts +22 -0
  109. package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js +101 -0
  110. package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js.map +1 -0
  111. package/dist/esm/lib/v3/agent/utils/imageCompression.d.ts +53 -0
  112. package/dist/esm/lib/v3/agent/utils/imageCompression.js +204 -0
  113. package/dist/esm/lib/v3/agent/utils/imageCompression.js.map +1 -0
  114. package/dist/esm/lib/v3/agent/utils/messageProcessing.d.ts +12 -0
  115. package/dist/esm/lib/v3/agent/utils/messageProcessing.js +164 -0
  116. package/dist/esm/lib/v3/agent/utils/messageProcessing.js.map +1 -0
  117. package/dist/esm/lib/v3/agent/utils/screenshotHandler.d.ts +10 -0
  118. package/dist/esm/lib/v3/agent/utils/screenshotHandler.js +26 -0
  119. package/dist/esm/lib/v3/agent/utils/screenshotHandler.js.map +1 -0
  120. package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.d.ts +26 -0
  121. package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.js +79 -0
  122. package/dist/esm/lib/v3/agent/utils/validateExperimentalFeatures.js.map +1 -0
  123. package/dist/esm/lib/v3/agent/utils/xpath.d.ts +11 -0
  124. package/dist/esm/lib/v3/agent/utils/xpath.js +19 -0
  125. package/dist/esm/lib/v3/agent/utils/xpath.js.map +1 -0
  126. package/dist/esm/lib/v3/api.d.ts +86 -0
  127. package/dist/esm/lib/v3/api.js +484 -0
  128. package/dist/esm/lib/v3/api.js.map +1 -0
  129. package/dist/esm/lib/v3/cache/ActCache.d.ts +23 -0
  130. package/dist/esm/lib/v3/cache/ActCache.js +292 -0
  131. package/dist/esm/lib/v3/cache/ActCache.js.map +1 -0
  132. package/dist/esm/lib/v3/cache/AgentCache.d.ts +109 -0
  133. package/dist/esm/lib/v3/cache/AgentCache.js +640 -0
  134. package/dist/esm/lib/v3/cache/AgentCache.js.map +1 -0
  135. package/dist/esm/lib/v3/cache/CacheStorage.d.ts +17 -0
  136. package/dist/esm/lib/v3/cache/CacheStorage.js +98 -0
  137. package/dist/esm/lib/v3/cache/CacheStorage.js.map +1 -0
  138. package/dist/esm/lib/v3/cache/serverAgentCache.d.ts +7 -0
  139. package/dist/esm/lib/v3/cache/serverAgentCache.js +49 -0
  140. package/dist/esm/lib/v3/cache/serverAgentCache.js.map +1 -0
  141. package/dist/esm/lib/v3/cache/utils.d.ts +15 -0
  142. package/dist/esm/lib/v3/cache/utils.js +39 -0
  143. package/dist/esm/lib/v3/cache/utils.js.map +1 -0
  144. package/dist/esm/lib/v3/dom/a11yScripts/index.d.ts +11 -0
  145. package/dist/esm/lib/v3/dom/a11yScripts/index.js +117 -0
  146. package/dist/esm/lib/v3/dom/a11yScripts/index.js.map +1 -0
  147. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.d.ts +16 -0
  148. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js +20 -0
  149. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js.map +1 -0
  150. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.d.ts +52 -0
  151. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js +56 -0
  152. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js.map +1 -0
  153. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.d.ts +1 -0
  154. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js +2 -0
  155. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js.map +1 -0
  156. package/dist/esm/lib/v3/dom/build/rerender-index.js +1 -0
  157. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.d.ts +4 -0
  158. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js +8 -0
  159. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js.map +1 -0
  160. package/dist/esm/lib/v3/dom/build/scriptV3Content.d.ts +1 -0
  161. package/dist/esm/lib/v3/dom/build/scriptV3Content.js +2 -0
  162. package/dist/esm/lib/v3/dom/build/scriptV3Content.js.map +1 -0
  163. package/dist/esm/lib/v3/dom/build/v3-index.js +1 -0
  164. package/dist/esm/lib/v3/dom/genA11yScripts.d.ts +1 -0
  165. package/dist/esm/lib/v3/dom/genA11yScripts.js +54 -0
  166. package/dist/esm/lib/v3/dom/genA11yScripts.js.map +1 -0
  167. package/dist/esm/lib/v3/dom/genDomScripts.d.ts +1 -0
  168. package/dist/esm/lib/v3/dom/genDomScripts.js +38 -0
  169. package/dist/esm/lib/v3/dom/genDomScripts.js.map +1 -0
  170. package/dist/esm/lib/v3/dom/genLocatorScripts.d.ts +1 -0
  171. package/dist/esm/lib/v3/dom/genLocatorScripts.js +51 -0
  172. package/dist/esm/lib/v3/dom/genLocatorScripts.js.map +1 -0
  173. package/dist/esm/lib/v3/dom/genScreenshotScripts.d.ts +1 -0
  174. package/dist/esm/lib/v3/dom/genScreenshotScripts.js +37 -0
  175. package/dist/esm/lib/v3/dom/genScreenshotScripts.js.map +1 -0
  176. package/dist/esm/lib/v3/dom/index.d.ts +1 -0
  177. package/dist/esm/lib/v3/dom/index.js +2 -0
  178. package/dist/esm/lib/v3/dom/index.js.map +1 -0
  179. package/dist/esm/lib/v3/dom/locatorScripts/counts.d.ts +15 -0
  180. package/dist/esm/lib/v3/dom/locatorScripts/counts.js +272 -0
  181. package/dist/esm/lib/v3/dom/locatorScripts/counts.js.map +1 -0
  182. package/dist/esm/lib/v3/dom/locatorScripts/index.d.ts +4 -0
  183. package/dist/esm/lib/v3/dom/locatorScripts/index.js +5 -0
  184. package/dist/esm/lib/v3/dom/locatorScripts/index.js.map +1 -0
  185. package/dist/esm/lib/v3/dom/locatorScripts/scripts.d.ts +37 -0
  186. package/dist/esm/lib/v3/dom/locatorScripts/scripts.js +458 -0
  187. package/dist/esm/lib/v3/dom/locatorScripts/scripts.js.map +1 -0
  188. package/dist/esm/lib/v3/dom/locatorScripts/selectors.d.ts +4 -0
  189. package/dist/esm/lib/v3/dom/locatorScripts/selectors.js +283 -0
  190. package/dist/esm/lib/v3/dom/locatorScripts/selectors.js.map +1 -0
  191. package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.d.ts +19 -0
  192. package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.js +283 -0
  193. package/dist/esm/lib/v3/dom/locatorScripts/waitForSelector.js.map +1 -0
  194. package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.d.ts +76 -0
  195. package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.js +376 -0
  196. package/dist/esm/lib/v3/dom/locatorScripts/xpathParser.js.map +1 -0
  197. package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.d.ts +9 -0
  198. package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.js +196 -0
  199. package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.js.map +1 -0
  200. package/dist/esm/lib/v3/dom/piercer.entry.d.ts +1 -0
  201. package/dist/esm/lib/v3/dom/piercer.entry.js +3 -0
  202. package/dist/esm/lib/v3/dom/piercer.entry.js.map +1 -0
  203. package/dist/esm/lib/v3/dom/piercer.runtime.d.ts +23 -0
  204. package/dist/esm/lib/v3/dom/piercer.runtime.js +90 -0
  205. package/dist/esm/lib/v3/dom/piercer.runtime.js.map +1 -0
  206. package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.d.ts +1 -0
  207. package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.js +3 -0
  208. package/dist/esm/lib/v3/dom/rerenderMissingShadows.entry.js.map +1 -0
  209. package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.d.ts +1 -0
  210. package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.js +40 -0
  211. package/dist/esm/lib/v3/dom/rerenderMissingShadows.runtime.js.map +1 -0
  212. package/dist/esm/lib/v3/dom/screenshotScripts/index.d.ts +1 -0
  213. package/dist/esm/lib/v3/dom/screenshotScripts/index.js +2 -0
  214. package/dist/esm/lib/v3/dom/screenshotScripts/index.js.map +1 -0
  215. package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.d.ts +8 -0
  216. package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.js +82 -0
  217. package/dist/esm/lib/v3/dom/screenshotScripts/resolveMaskRect.js.map +1 -0
  218. package/dist/esm/lib/v3/external_clients/aisdk.d.ts +11 -0
  219. package/dist/esm/lib/v3/external_clients/aisdk.js +103 -0
  220. package/dist/esm/lib/v3/external_clients/aisdk.js.map +1 -0
  221. package/dist/esm/lib/v3/external_clients/customOpenAI.d.ts +18 -0
  222. package/dist/esm/lib/v3/external_clients/customOpenAI.js +220 -0
  223. package/dist/esm/lib/v3/external_clients/customOpenAI.js.map +1 -0
  224. package/dist/esm/lib/v3/flowLogger.d.ts +139 -0
  225. package/dist/esm/lib/v3/flowLogger.js +868 -0
  226. package/dist/esm/lib/v3/flowLogger.js.map +1 -0
  227. package/dist/esm/lib/v3/handlers/actHandler.d.ts +21 -0
  228. package/dist/esm/lib/v3/handlers/actHandler.js +340 -0
  229. package/dist/esm/lib/v3/handlers/actHandler.js.map +1 -0
  230. package/dist/esm/lib/v3/handlers/extractHandler.d.ts +31 -0
  231. package/dist/esm/lib/v3/handlers/extractHandler.js +139 -0
  232. package/dist/esm/lib/v3/handlers/extractHandler.js.map +1 -0
  233. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +24 -0
  234. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js +623 -0
  235. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -0
  236. package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.d.ts +2 -0
  237. package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.js +14 -0
  238. package/dist/esm/lib/v3/handlers/handlerUtils/timeoutGuard.js.map +1 -0
  239. package/dist/esm/lib/v3/handlers/observeHandler.d.ts +17 -0
  240. package/dist/esm/lib/v3/handlers/observeHandler.js +156 -0
  241. package/dist/esm/lib/v3/handlers/observeHandler.js.map +1 -0
  242. package/dist/esm/lib/v3/handlers/v3AgentHandler.d.ts +32 -0
  243. package/dist/esm/lib/v3/handlers/v3AgentHandler.js +461 -0
  244. package/dist/esm/lib/v3/handlers/v3AgentHandler.js.map +1 -0
  245. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.d.ts +33 -0
  246. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js +528 -0
  247. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -0
  248. package/dist/esm/lib/v3/index.d.ts +17 -0
  249. package/dist/esm/lib/v3/index.js +13 -0
  250. package/dist/esm/lib/v3/index.js.map +1 -0
  251. package/dist/esm/lib/v3/launch/browserbase.d.ts +7 -0
  252. package/dist/esm/lib/v3/launch/browserbase.js +46 -0
  253. package/dist/esm/lib/v3/launch/browserbase.js.map +1 -0
  254. package/dist/esm/lib/v3/launch/local.d.ts +15 -0
  255. package/dist/esm/lib/v3/launch/local.js +98 -0
  256. package/dist/esm/lib/v3/launch/local.js.map +1 -0
  257. package/dist/esm/lib/v3/llm/AnthropicClient.d.ts +16 -0
  258. package/dist/esm/lib/v3/llm/AnthropicClient.js +239 -0
  259. package/dist/esm/lib/v3/llm/AnthropicClient.js.map +1 -0
  260. package/dist/esm/lib/v3/llm/CerebrasClient.d.ts +17 -0
  261. package/dist/esm/lib/v3/llm/CerebrasClient.js +235 -0
  262. package/dist/esm/lib/v3/llm/CerebrasClient.js.map +1 -0
  263. package/dist/esm/lib/v3/llm/GoogleClient.d.ts +19 -0
  264. package/dist/esm/lib/v3/llm/GoogleClient.js +369 -0
  265. package/dist/esm/lib/v3/llm/GoogleClient.js.map +1 -0
  266. package/dist/esm/lib/v3/llm/GroqClient.d.ts +17 -0
  267. package/dist/esm/lib/v3/llm/GroqClient.js +236 -0
  268. package/dist/esm/lib/v3/llm/GroqClient.js.map +1 -0
  269. package/dist/esm/lib/v3/llm/LLMClient.d.ts +121 -0
  270. package/dist/esm/lib/v3/llm/LLMClient.js +23 -0
  271. package/dist/esm/lib/v3/llm/LLMClient.js.map +1 -0
  272. package/dist/esm/lib/v3/llm/LLMProvider.d.ts +13 -0
  273. package/dist/esm/lib/v3/llm/LLMProvider.js +194 -0
  274. package/dist/esm/lib/v3/llm/LLMProvider.js.map +1 -0
  275. package/dist/esm/lib/v3/llm/OpenAIClient.d.ts +15 -0
  276. package/dist/esm/lib/v3/llm/OpenAIClient.js +329 -0
  277. package/dist/esm/lib/v3/llm/OpenAIClient.js.map +1 -0
  278. package/dist/esm/lib/v3/llm/aisdk.d.ts +15 -0
  279. package/dist/esm/lib/v3/llm/aisdk.js +348 -0
  280. package/dist/esm/lib/v3/llm/aisdk.js.map +1 -0
  281. package/dist/esm/lib/v3/logger.d.ts +9 -0
  282. package/dist/esm/lib/v3/logger.js +96 -0
  283. package/dist/esm/lib/v3/logger.js.map +1 -0
  284. package/dist/esm/lib/v3/mcp/connection.d.ts +11 -0
  285. package/dist/esm/lib/v3/mcp/connection.js +49 -0
  286. package/dist/esm/lib/v3/mcp/connection.js.map +1 -0
  287. package/dist/esm/lib/v3/mcp/utils.d.ts +3 -0
  288. package/dist/esm/lib/v3/mcp/utils.js +36 -0
  289. package/dist/esm/lib/v3/mcp/utils.js.map +1 -0
  290. package/dist/esm/lib/v3/shutdown/cleanupLocal.d.ts +14 -0
  291. package/dist/esm/lib/v3/shutdown/cleanupLocal.js +30 -0
  292. package/dist/esm/lib/v3/shutdown/cleanupLocal.js.map +1 -0
  293. package/dist/esm/lib/v3/shutdown/supervisor.d.ts +9 -0
  294. package/dist/esm/lib/v3/shutdown/supervisor.js +156 -0
  295. package/dist/esm/lib/v3/shutdown/supervisor.js.map +1 -0
  296. package/dist/esm/lib/v3/shutdown/supervisorClient.d.ts +15 -0
  297. package/dist/esm/lib/v3/shutdown/supervisorClient.js +97 -0
  298. package/dist/esm/lib/v3/shutdown/supervisorClient.js.map +1 -0
  299. package/dist/esm/lib/v3/tests/agent-abort-signal.spec.js +113 -0
  300. package/dist/esm/lib/v3/tests/agent-abort-signal.spec.js.map +7 -0
  301. package/dist/esm/lib/v3/tests/agent-cache-self-heal.spec.js +80 -0
  302. package/dist/esm/lib/v3/tests/agent-cache-self-heal.spec.js.map +7 -0
  303. package/dist/esm/lib/v3/tests/agent-callbacks.spec.js +374 -0
  304. package/dist/esm/lib/v3/tests/agent-callbacks.spec.js.map +7 -0
  305. package/dist/esm/lib/v3/tests/agent-experimental-validation.spec.js +357 -0
  306. package/dist/esm/lib/v3/tests/agent-experimental-validation.spec.js.map +7 -0
  307. package/dist/esm/lib/v3/tests/agent-hybrid-mode.spec.js +247 -0
  308. package/dist/esm/lib/v3/tests/agent-hybrid-mode.spec.js.map +7 -0
  309. package/dist/esm/lib/v3/tests/agent-message-continuation.spec.js +105 -0
  310. package/dist/esm/lib/v3/tests/agent-message-continuation.spec.js.map +7 -0
  311. package/dist/esm/lib/v3/tests/agent-streaming.spec.js +126 -0
  312. package/dist/esm/lib/v3/tests/agent-streaming.spec.js.map +7 -0
  313. package/dist/esm/lib/v3/tests/cdp-session-detached.spec.js +44 -0
  314. package/dist/esm/lib/v3/tests/cdp-session-detached.spec.js.map +7 -0
  315. package/dist/esm/lib/v3/tests/click-count.spec.js +112 -0
  316. package/dist/esm/lib/v3/tests/click-count.spec.js.map +7 -0
  317. package/dist/esm/lib/v3/tests/connect-to-existing-browser.spec.js +54 -0
  318. package/dist/esm/lib/v3/tests/connect-to-existing-browser.spec.js.map +7 -0
  319. package/dist/esm/lib/v3/tests/context-addInitScript.spec.js +176 -0
  320. package/dist/esm/lib/v3/tests/context-addInitScript.spec.js.map +7 -0
  321. package/dist/esm/lib/v3/tests/default-page-tracking.spec.js +53 -0
  322. package/dist/esm/lib/v3/tests/default-page-tracking.spec.js.map +7 -0
  323. package/dist/esm/lib/v3/tests/downloads.spec.js +58 -0
  324. package/dist/esm/lib/v3/tests/downloads.spec.js.map +7 -0
  325. package/dist/esm/lib/v3/tests/envReporter.js +57 -0
  326. package/dist/esm/lib/v3/tests/envReporter.js.map +7 -0
  327. package/dist/esm/lib/v3/tests/frame-get-location-and-click.spec.js +53 -0
  328. package/dist/esm/lib/v3/tests/frame-get-location-and-click.spec.js.map +7 -0
  329. package/dist/esm/lib/v3/tests/iframe-ctx-addInitScript.spec.js +447 -0
  330. package/dist/esm/lib/v3/tests/iframe-ctx-addInitScript.spec.js.map +7 -0
  331. package/dist/esm/lib/v3/tests/keep-alive.child.js +92 -0
  332. package/dist/esm/lib/v3/tests/keep-alive.child.js.map +7 -0
  333. package/dist/esm/lib/v3/tests/keep-alive.helpers.js +532 -0
  334. package/dist/esm/lib/v3/tests/keep-alive.helpers.js.map +7 -0
  335. package/dist/esm/lib/v3/tests/keep-alive.spec.js +19 -0
  336. package/dist/esm/lib/v3/tests/keep-alive.spec.js.map +7 -0
  337. package/dist/esm/lib/v3/tests/keyboard.spec.js +296 -0
  338. package/dist/esm/lib/v3/tests/keyboard.spec.js.map +7 -0
  339. package/dist/esm/lib/v3/tests/locator-backend-node-id.spec.js +159 -0
  340. package/dist/esm/lib/v3/tests/locator-backend-node-id.spec.js.map +7 -0
  341. package/dist/esm/lib/v3/tests/locator-content-methods.spec.js +191 -0
  342. package/dist/esm/lib/v3/tests/locator-content-methods.spec.js.map +7 -0
  343. package/dist/esm/lib/v3/tests/locator-count-iframe.spec.js +108 -0
  344. package/dist/esm/lib/v3/tests/locator-count-iframe.spec.js.map +7 -0
  345. package/dist/esm/lib/v3/tests/locator-count.spec.js +71 -0
  346. package/dist/esm/lib/v3/tests/locator-count.spec.js.map +7 -0
  347. package/dist/esm/lib/v3/tests/locator-fill.spec.js +118 -0
  348. package/dist/esm/lib/v3/tests/locator-fill.spec.js.map +7 -0
  349. package/dist/esm/lib/v3/tests/locator-input-methods.spec.js +136 -0
  350. package/dist/esm/lib/v3/tests/locator-input-methods.spec.js.map +7 -0
  351. package/dist/esm/lib/v3/tests/locator-nth.spec.js +157 -0
  352. package/dist/esm/lib/v3/tests/locator-nth.spec.js.map +7 -0
  353. package/dist/esm/lib/v3/tests/locator-select-option.spec.js +242 -0
  354. package/dist/esm/lib/v3/tests/locator-select-option.spec.js.map +7 -0
  355. package/dist/esm/lib/v3/tests/logger-initialization.spec.js +552 -0
  356. package/dist/esm/lib/v3/tests/logger-initialization.spec.js.map +7 -0
  357. package/dist/esm/lib/v3/tests/multi-instance-logger.spec.js +269 -0
  358. package/dist/esm/lib/v3/tests/multi-instance-logger.spec.js.map +7 -0
  359. package/dist/esm/lib/v3/tests/nested-div.spec.js +23 -0
  360. package/dist/esm/lib/v3/tests/nested-div.spec.js.map +7 -0
  361. package/dist/esm/lib/v3/tests/page-addInitScript.spec.js +90 -0
  362. package/dist/esm/lib/v3/tests/page-addInitScript.spec.js.map +7 -0
  363. package/dist/esm/lib/v3/tests/page-console.spec.js +56 -0
  364. package/dist/esm/lib/v3/tests/page-console.spec.js.map +7 -0
  365. package/dist/esm/lib/v3/tests/page-drag-and-drop.spec.js +418 -0
  366. package/dist/esm/lib/v3/tests/page-drag-and-drop.spec.js.map +7 -0
  367. package/dist/esm/lib/v3/tests/page-goto-response.spec.js +35 -0
  368. package/dist/esm/lib/v3/tests/page-goto-response.spec.js.map +7 -0
  369. package/dist/esm/lib/v3/tests/page-hover.spec.js +167 -0
  370. package/dist/esm/lib/v3/tests/page-hover.spec.js.map +7 -0
  371. package/dist/esm/lib/v3/tests/page-screenshot.spec.js +273 -0
  372. package/dist/esm/lib/v3/tests/page-screenshot.spec.js.map +7 -0
  373. package/dist/esm/lib/v3/tests/page-scroll.spec.js +182 -0
  374. package/dist/esm/lib/v3/tests/page-scroll.spec.js.map +7 -0
  375. package/dist/esm/lib/v3/tests/page-send-cdp.spec.js +46 -0
  376. package/dist/esm/lib/v3/tests/page-send-cdp.spec.js.map +7 -0
  377. package/dist/esm/lib/v3/tests/perform-understudy-method.spec.js +98 -0
  378. package/dist/esm/lib/v3/tests/perform-understudy-method.spec.js.map +7 -0
  379. package/dist/esm/lib/v3/tests/setinputfiles.spec.js +126 -0
  380. package/dist/esm/lib/v3/tests/setinputfiles.spec.js.map +7 -0
  381. package/dist/esm/lib/v3/tests/shadow-iframe-oopif.spec.js +134 -0
  382. package/dist/esm/lib/v3/tests/shadow-iframe-oopif.spec.js.map +7 -0
  383. package/dist/esm/lib/v3/tests/shadow-iframe-spif.spec.js +134 -0
  384. package/dist/esm/lib/v3/tests/shadow-iframe-spif.spec.js.map +7 -0
  385. package/dist/esm/lib/v3/tests/testUtils.js +31 -0
  386. package/dist/esm/lib/v3/tests/testUtils.js.map +7 -0
  387. package/dist/esm/lib/v3/tests/text-selector-innermost.spec.js +100 -0
  388. package/dist/esm/lib/v3/tests/text-selector-innermost.spec.js.map +7 -0
  389. package/dist/esm/lib/v3/tests/timeouts.spec.js +32 -0
  390. package/dist/esm/lib/v3/tests/timeouts.spec.js.map +7 -0
  391. package/dist/esm/lib/v3/tests/user-data-dir.spec.js +43 -0
  392. package/dist/esm/lib/v3/tests/user-data-dir.spec.js.map +7 -0
  393. package/dist/esm/lib/v3/tests/v3.config.js +15 -0
  394. package/dist/esm/lib/v3/tests/v3.config.js.map +7 -0
  395. package/dist/esm/lib/v3/tests/v3.dynamic.config.js +43 -0
  396. package/dist/esm/lib/v3/tests/v3.dynamic.config.js.map +7 -0
  397. package/dist/esm/lib/v3/tests/v3.playwright.config.js +98 -0
  398. package/dist/esm/lib/v3/tests/v3.playwright.config.js.map +7 -0
  399. package/dist/esm/lib/v3/tests/wait-for-selector.spec.js +593 -0
  400. package/dist/esm/lib/v3/tests/wait-for-selector.spec.js.map +7 -0
  401. package/dist/esm/lib/v3/tests/wait-for-timeout.spec.js +97 -0
  402. package/dist/esm/lib/v3/tests/wait-for-timeout.spec.js.map +7 -0
  403. package/dist/esm/lib/v3/tests/xpath-for-location-deep.spec.js +77 -0
  404. package/dist/esm/lib/v3/tests/xpath-for-location-deep.spec.js.map +7 -0
  405. package/dist/esm/lib/v3/timeoutConfig.d.ts +2 -0
  406. package/dist/esm/lib/v3/timeoutConfig.js +27 -0
  407. package/dist/esm/lib/v3/timeoutConfig.js.map +1 -0
  408. package/dist/esm/lib/v3/types/private/agent.d.ts +6 -0
  409. package/dist/esm/lib/v3/types/private/agent.js +2 -0
  410. package/dist/esm/lib/v3/types/private/agent.js.map +1 -0
  411. package/dist/esm/lib/v3/types/private/api.d.ts +11 -0
  412. package/dist/esm/lib/v3/types/private/api.js +2 -0
  413. package/dist/esm/lib/v3/types/private/api.js.map +1 -0
  414. package/dist/esm/lib/v3/types/private/cache.d.ts +128 -0
  415. package/dist/esm/lib/v3/types/private/cache.js +2 -0
  416. package/dist/esm/lib/v3/types/private/cache.js.map +1 -0
  417. package/dist/esm/lib/v3/types/private/evaluator.d.ts +40 -0
  418. package/dist/esm/lib/v3/types/private/evaluator.js +2 -0
  419. package/dist/esm/lib/v3/types/private/evaluator.js.map +1 -0
  420. package/dist/esm/lib/v3/types/private/handlers.d.ts +38 -0
  421. package/dist/esm/lib/v3/types/private/handlers.js +16 -0
  422. package/dist/esm/lib/v3/types/private/handlers.js.map +1 -0
  423. package/dist/esm/lib/v3/types/private/index.d.ts +7 -0
  424. package/dist/esm/lib/v3/types/private/index.js +8 -0
  425. package/dist/esm/lib/v3/types/private/index.js.map +1 -0
  426. package/dist/esm/lib/v3/types/private/internal.d.ts +39 -0
  427. package/dist/esm/lib/v3/types/private/internal.js +2 -0
  428. package/dist/esm/lib/v3/types/private/internal.js.map +1 -0
  429. package/dist/esm/lib/v3/types/private/locator.d.ts +9 -0
  430. package/dist/esm/lib/v3/types/private/locator.js +2 -0
  431. package/dist/esm/lib/v3/types/private/locator.js.map +1 -0
  432. package/dist/esm/lib/v3/types/private/network.d.ts +34 -0
  433. package/dist/esm/lib/v3/types/private/network.js +3 -0
  434. package/dist/esm/lib/v3/types/private/network.js.map +1 -0
  435. package/dist/esm/lib/v3/types/private/shutdown.d.ts +31 -0
  436. package/dist/esm/lib/v3/types/private/shutdown.js +5 -0
  437. package/dist/esm/lib/v3/types/private/shutdown.js.map +1 -0
  438. package/dist/esm/lib/v3/types/private/shutdownErrors.d.ts +12 -0
  439. package/dist/esm/lib/v3/types/private/shutdownErrors.js +22 -0
  440. package/dist/esm/lib/v3/types/private/shutdownErrors.js.map +1 -0
  441. package/dist/esm/lib/v3/types/private/snapshot.d.ts +117 -0
  442. package/dist/esm/lib/v3/types/private/snapshot.js +2 -0
  443. package/dist/esm/lib/v3/types/private/snapshot.js.map +1 -0
  444. package/dist/esm/lib/v3/types/public/agent.d.ts +595 -0
  445. package/dist/esm/lib/v3/types/public/agent.js +15 -0
  446. package/dist/esm/lib/v3/types/public/agent.js.map +1 -0
  447. package/dist/esm/lib/v3/types/public/api.d.ts +1211 -0
  448. package/dist/esm/lib/v3/types/public/api.js +915 -0
  449. package/dist/esm/lib/v3/types/public/api.js.map +1 -0
  450. package/dist/esm/lib/v3/types/public/apiErrors.d.ts +18 -0
  451. package/dist/esm/lib/v3/types/public/apiErrors.js +32 -0
  452. package/dist/esm/lib/v3/types/public/apiErrors.js.map +1 -0
  453. package/dist/esm/lib/v3/types/public/index.d.ts +12 -0
  454. package/dist/esm/lib/v3/types/public/index.js +14 -0
  455. package/dist/esm/lib/v3/types/public/index.js.map +1 -0
  456. package/dist/esm/lib/v3/types/public/locator.d.ts +9 -0
  457. package/dist/esm/lib/v3/types/public/locator.js +2 -0
  458. package/dist/esm/lib/v3/types/public/locator.js.map +1 -0
  459. package/dist/esm/lib/v3/types/public/logs.d.ts +23 -0
  460. package/dist/esm/lib/v3/types/public/logs.js +13 -0
  461. package/dist/esm/lib/v3/types/public/logs.js.map +1 -0
  462. package/dist/esm/lib/v3/types/public/methods.d.ts +56 -0
  463. package/dist/esm/lib/v3/types/public/methods.js +15 -0
  464. package/dist/esm/lib/v3/types/public/methods.js.map +1 -0
  465. package/dist/esm/lib/v3/types/public/metrics.d.ts +27 -0
  466. package/dist/esm/lib/v3/types/public/metrics.js +2 -0
  467. package/dist/esm/lib/v3/types/public/metrics.js.map +1 -0
  468. package/dist/esm/lib/v3/types/public/model.d.ts +65 -0
  469. package/dist/esm/lib/v3/types/public/model.js +2 -0
  470. package/dist/esm/lib/v3/types/public/model.js.map +1 -0
  471. package/dist/esm/lib/v3/types/public/options.d.ts +70 -0
  472. package/dist/esm/lib/v3/types/public/options.js +4 -0
  473. package/dist/esm/lib/v3/types/public/options.js.map +1 -0
  474. package/dist/esm/lib/v3/types/public/page.d.ts +18 -0
  475. package/dist/esm/lib/v3/types/public/page.js +3 -0
  476. package/dist/esm/lib/v3/types/public/page.js.map +1 -0
  477. package/dist/esm/lib/v3/types/public/screenshotTypes.d.ts +25 -0
  478. package/dist/esm/lib/v3/types/public/screenshotTypes.js +2 -0
  479. package/dist/esm/lib/v3/types/public/screenshotTypes.js.map +1 -0
  480. package/dist/esm/lib/v3/types/public/sdkErrors.d.ts +152 -0
  481. package/dist/esm/lib/v3/types/public/sdkErrors.js +305 -0
  482. package/dist/esm/lib/v3/types/public/sdkErrors.js.map +1 -0
  483. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.d.ts +15 -0
  484. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js +196 -0
  485. package/dist/esm/lib/v3/understudy/a11y/snapshot/a11yTree.js.map +1 -0
  486. package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.d.ts +8 -0
  487. package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.js +121 -0
  488. package/dist/esm/lib/v3/understudy/a11y/snapshot/activeElement.js.map +1 -0
  489. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.d.ts +77 -0
  490. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js +336 -0
  491. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -0
  492. package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.d.ts +7 -0
  493. package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js +129 -0
  494. package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js.map +1 -0
  495. package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.d.ts +46 -0
  496. package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.js +274 -0
  497. package/dist/esm/lib/v3/understudy/a11y/snapshot/domTree.js.map +1 -0
  498. package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.d.ts +24 -0
  499. package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.js +216 -0
  500. package/dist/esm/lib/v3/understudy/a11y/snapshot/focusSelectors.js.map +1 -0
  501. package/dist/esm/lib/v3/understudy/a11y/snapshot/index.d.ts +4 -0
  502. package/dist/esm/lib/v3/understudy/a11y/snapshot/index.js +5 -0
  503. package/dist/esm/lib/v3/understudy/a11y/snapshot/index.js.map +1 -0
  504. package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.d.ts +16 -0
  505. package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.js +22 -0
  506. package/dist/esm/lib/v3/understudy/a11y/snapshot/sessions.js.map +1 -0
  507. package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.d.ts +28 -0
  508. package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js +135 -0
  509. package/dist/esm/lib/v3/understudy/a11y/snapshot/treeFormatUtils.js.map +1 -0
  510. package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.d.ts +26 -0
  511. package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.js +102 -0
  512. package/dist/esm/lib/v3/understudy/a11y/snapshot/xpathUtils.js.map +1 -0
  513. package/dist/esm/lib/v3/understudy/a11yInvocation.d.ts +8 -0
  514. package/dist/esm/lib/v3/understudy/a11yInvocation.js +12 -0
  515. package/dist/esm/lib/v3/understudy/a11yInvocation.js.map +1 -0
  516. package/dist/esm/lib/v3/understudy/cdp.d.ts +69 -0
  517. package/dist/esm/lib/v3/understudy/cdp.js +251 -0
  518. package/dist/esm/lib/v3/understudy/cdp.js.map +1 -0
  519. package/dist/esm/lib/v3/understudy/consoleMessage.d.ts +22 -0
  520. package/dist/esm/lib/v3/understudy/consoleMessage.js +66 -0
  521. package/dist/esm/lib/v3/understudy/consoleMessage.js.map +1 -0
  522. package/dist/esm/lib/v3/understudy/context.d.ts +132 -0
  523. package/dist/esm/lib/v3/understudy/context.js +687 -0
  524. package/dist/esm/lib/v3/understudy/context.js.map +1 -0
  525. package/dist/esm/lib/v3/understudy/deepLocator.d.ts +87 -0
  526. package/dist/esm/lib/v3/understudy/deepLocator.js +218 -0
  527. package/dist/esm/lib/v3/understudy/deepLocator.js.map +1 -0
  528. package/dist/esm/lib/v3/understudy/executionContextRegistry.d.ts +15 -0
  529. package/dist/esm/lib/v3/understudy/executionContextRegistry.js +83 -0
  530. package/dist/esm/lib/v3/understudy/executionContextRegistry.js.map +1 -0
  531. package/dist/esm/lib/v3/understudy/fileUploadUtils.d.ts +13 -0
  532. package/dist/esm/lib/v3/understudy/fileUploadUtils.js +81 -0
  533. package/dist/esm/lib/v3/understudy/fileUploadUtils.js.map +1 -0
  534. package/dist/esm/lib/v3/understudy/frame.d.ts +69 -0
  535. package/dist/esm/lib/v3/understudy/frame.js +211 -0
  536. package/dist/esm/lib/v3/understudy/frame.js.map +1 -0
  537. package/dist/esm/lib/v3/understudy/frameLocator.d.ts +50 -0
  538. package/dist/esm/lib/v3/understudy/frameLocator.js +255 -0
  539. package/dist/esm/lib/v3/understudy/frameLocator.js.map +1 -0
  540. package/dist/esm/lib/v3/understudy/frameRegistry.d.ts +101 -0
  541. package/dist/esm/lib/v3/understudy/frameRegistry.js +298 -0
  542. package/dist/esm/lib/v3/understudy/frameRegistry.js.map +1 -0
  543. package/dist/esm/lib/v3/understudy/initScripts.d.ts +2 -0
  544. package/dist/esm/lib/v3/understudy/initScripts.js +33 -0
  545. package/dist/esm/lib/v3/understudy/initScripts.js.map +1 -0
  546. package/dist/esm/lib/v3/understudy/lifecycleWatcher.d.ts +64 -0
  547. package/dist/esm/lib/v3/understudy/lifecycleWatcher.js +245 -0
  548. package/dist/esm/lib/v3/understudy/lifecycleWatcher.js.map +1 -0
  549. package/dist/esm/lib/v3/understudy/locator.d.ts +194 -0
  550. package/dist/esm/lib/v3/understudy/locator.js +753 -0
  551. package/dist/esm/lib/v3/understudy/locator.js.map +1 -0
  552. package/dist/esm/lib/v3/understudy/locatorInvocation.d.ts +8 -0
  553. package/dist/esm/lib/v3/understudy/locatorInvocation.js +12 -0
  554. package/dist/esm/lib/v3/understudy/locatorInvocation.js.map +1 -0
  555. package/dist/esm/lib/v3/understudy/navigationResponseTracker.d.ts +84 -0
  556. package/dist/esm/lib/v3/understudy/navigationResponseTracker.js +224 -0
  557. package/dist/esm/lib/v3/understudy/navigationResponseTracker.js.map +1 -0
  558. package/dist/esm/lib/v3/understudy/networkManager.d.ts +53 -0
  559. package/dist/esm/lib/v3/understudy/networkManager.js +306 -0
  560. package/dist/esm/lib/v3/understudy/networkManager.js.map +1 -0
  561. package/dist/esm/lib/v3/understudy/page.d.ts +354 -0
  562. package/dist/esm/lib/v3/understudy/page.js +1941 -0
  563. package/dist/esm/lib/v3/understudy/page.js.map +1 -0
  564. package/dist/esm/lib/v3/understudy/piercer.d.ts +4 -0
  565. package/dist/esm/lib/v3/understudy/piercer.js +61 -0
  566. package/dist/esm/lib/v3/understudy/piercer.js.map +1 -0
  567. package/dist/esm/lib/v3/understudy/response.d.ts +137 -0
  568. package/dist/esm/lib/v3/understudy/response.js +330 -0
  569. package/dist/esm/lib/v3/understudy/response.js.map +1 -0
  570. package/dist/esm/lib/v3/understudy/screenshotUtils.d.ts +16 -0
  571. package/dist/esm/lib/v3/understudy/screenshotUtils.js +352 -0
  572. package/dist/esm/lib/v3/understudy/screenshotUtils.js.map +1 -0
  573. package/dist/esm/lib/v3/understudy/selectorResolver.d.ts +38 -0
  574. package/dist/esm/lib/v3/understudy/selectorResolver.js +296 -0
  575. package/dist/esm/lib/v3/understudy/selectorResolver.js.map +1 -0
  576. package/dist/esm/lib/v3/v3.d.ts +191 -0
  577. package/dist/esm/lib/v3/v3.js +1572 -0
  578. package/dist/esm/lib/v3/v3.js.map +1 -0
  579. package/dist/esm/lib/v3/zodCompat.d.ts +12 -0
  580. package/dist/esm/lib/v3/zodCompat.js +17 -0
  581. package/dist/esm/lib/v3/zodCompat.js.map +1 -0
  582. package/dist/esm/lib/v3Evaluator.d.ts +19 -0
  583. package/dist/esm/lib/v3Evaluator.js +210 -0
  584. package/dist/esm/lib/v3Evaluator.js.map +1 -0
  585. package/dist/esm/lib/version.d.ts +5 -0
  586. package/dist/esm/lib/version.js +6 -0
  587. package/dist/esm/lib/version.js.map +1 -0
  588. package/dist/esm/package.json +3 -0
  589. package/dist/esm/tests/agent-execution-model.test.js +139 -0
  590. package/dist/esm/tests/agent-execution-model.test.js.map +7 -0
  591. package/dist/esm/tests/browserbase-session-accessors.test.js +101 -0
  592. package/dist/esm/tests/browserbase-session-accessors.test.js.map +7 -0
  593. package/dist/esm/tests/cache-llm-resolution.test.js +187 -0
  594. package/dist/esm/tests/cache-llm-resolution.test.js.map +7 -0
  595. package/dist/esm/tests/helpers/mockCDPSession.js +27 -0
  596. package/dist/esm/tests/helpers/mockCDPSession.js.map +7 -0
  597. package/dist/esm/tests/llm-provider.test.js +57 -0
  598. package/dist/esm/tests/llm-provider.test.js.map +7 -0
  599. package/dist/esm/tests/model-deprecation.test.js +135 -0
  600. package/dist/esm/tests/model-deprecation.test.js.map +7 -0
  601. package/dist/esm/tests/model-utils.test.js +43 -0
  602. package/dist/esm/tests/model-utils.test.js.map +7 -0
  603. package/dist/esm/tests/page-snapshot.test.js +36 -0
  604. package/dist/esm/tests/page-snapshot.test.js.map +7 -0
  605. package/dist/esm/tests/public-api/export-surface.test.js +53 -0
  606. package/dist/esm/tests/public-api/export-surface.test.js.map +7 -0
  607. package/dist/esm/tests/public-api/llm-and-agents.test.js +128 -0
  608. package/dist/esm/tests/public-api/llm-and-agents.test.js.map +7 -0
  609. package/dist/esm/tests/public-api/public-error-types.test.js +71 -0
  610. package/dist/esm/tests/public-api/public-error-types.test.js.map +7 -0
  611. package/dist/esm/tests/public-api/public-types.test.js +74 -0
  612. package/dist/esm/tests/public-api/public-types.test.js.map +7 -0
  613. package/dist/esm/tests/public-api/runtime-utils.test.js +31 -0
  614. package/dist/esm/tests/public-api/runtime-utils.test.js.map +7 -0
  615. package/dist/esm/tests/public-api/schema-utils.test.js +78 -0
  616. package/dist/esm/tests/public-api/schema-utils.test.js.map +7 -0
  617. package/dist/esm/tests/public-api/timeout-error-types.test.js +81 -0
  618. package/dist/esm/tests/public-api/timeout-error-types.test.js.map +7 -0
  619. package/dist/esm/tests/public-api/tool-type-export.test.js +25 -0
  620. package/dist/esm/tests/public-api/tool-type-export.test.js.map +7 -0
  621. package/dist/esm/tests/public-api/v3-core.test.js +82 -0
  622. package/dist/esm/tests/public-api/v3-core.test.js.map +7 -0
  623. package/dist/esm/tests/safety-confirmation.test.js +134 -0
  624. package/dist/esm/tests/safety-confirmation.test.js.map +7 -0
  625. package/dist/esm/tests/snapshot-a11y-resolvers.test.js +348 -0
  626. package/dist/esm/tests/snapshot-a11y-resolvers.test.js.map +7 -0
  627. package/dist/esm/tests/snapshot-a11y-tree-utils.test.js +300 -0
  628. package/dist/esm/tests/snapshot-a11y-tree-utils.test.js.map +7 -0
  629. package/dist/esm/tests/snapshot-capture-orchestration.test.js +381 -0
  630. package/dist/esm/tests/snapshot-capture-orchestration.test.js.map +7 -0
  631. package/dist/esm/tests/snapshot-cbor.test.js +197 -0
  632. package/dist/esm/tests/snapshot-cbor.test.js.map +7 -0
  633. package/dist/esm/tests/snapshot-dom-session-builders.test.js +251 -0
  634. package/dist/esm/tests/snapshot-dom-session-builders.test.js.map +7 -0
  635. package/dist/esm/tests/snapshot-dom-tree-utils.test.js +109 -0
  636. package/dist/esm/tests/snapshot-dom-tree-utils.test.js.map +7 -0
  637. package/dist/esm/tests/snapshot-focus-selectors-utils.test.js +49 -0
  638. package/dist/esm/tests/snapshot-focus-selectors-utils.test.js.map +7 -0
  639. package/dist/esm/tests/snapshot-frame-merge.test.js +391 -0
  640. package/dist/esm/tests/snapshot-frame-merge.test.js.map +7 -0
  641. package/dist/esm/tests/snapshot-tree-format-utils.test.js +113 -0
  642. package/dist/esm/tests/snapshot-tree-format-utils.test.js.map +7 -0
  643. package/dist/esm/tests/snapshot-xpath-utils.test.js +79 -0
  644. package/dist/esm/tests/snapshot-xpath-utils.test.js.map +7 -0
  645. package/dist/esm/tests/timeout-handlers.test.js +850 -0
  646. package/dist/esm/tests/timeout-handlers.test.js.map +7 -0
  647. package/dist/esm/tests/xpath-parser.test.js +317 -0
  648. package/dist/esm/tests/xpath-parser.test.js.map +7 -0
  649. package/dist/esm/tests/xpath-resolver.test.js +73 -0
  650. package/dist/esm/tests/xpath-resolver.test.js.map +7 -0
  651. package/dist/esm/tests/zod-enum-compatibility.test.js +97 -0
  652. package/dist/esm/tests/zod-enum-compatibility.test.js.map +7 -0
  653. package/package.json +42 -27
  654. package/dist/index.d.ts +0 -4321
  655. package/dist/index.js +0 -69585
@@ -0,0 +1,770 @@
1
+ import OpenAI from "openai";
2
+ import { AgentClient } from "./AgentClient.js";
3
+ import { AgentScreenshotProviderError } from "../types/public/sdkErrors.js";
4
+ import { mapKeyToPlaywright } from "./utils/cuaKeyMapping.js";
5
+ /**
6
+ * Client for FARA (Function-based Autonomous Research Agent) by Microsoft
7
+ * This implementation uses OpenAI-compatible API with XML-based tool calling
8
+ */
9
+ export class MicrosoftCUAClient extends AgentClient {
10
+ apiKey;
11
+ baseURL;
12
+ client;
13
+ currentViewport = { width: 1288, height: 711 };
14
+ currentUrl;
15
+ screenshotProvider;
16
+ actionHandler;
17
+ // Dual history system
18
+ conversationHistory = []; // Conceptual flow
19
+ actionHistory = []; // Raw model responses
20
+ maxImages = 3;
21
+ temperature = 0;
22
+ facts = [];
23
+ // FARA-specific MLM processor config
24
+ MLM_PROCESSOR_IM_CFG = {
25
+ min_pixels: 3136,
26
+ max_pixels: 12845056,
27
+ patch_size: 14,
28
+ merge_size: 2,
29
+ };
30
+ // Resized dimensions for model input
31
+ resizedViewport = { width: 1288, height: 711 };
32
+ constructor(type, modelName, userProvidedInstructions, clientOptions) {
33
+ super(type, modelName || "fara-7b", userProvidedInstructions);
34
+ // Process client options
35
+ this.apiKey =
36
+ clientOptions?.apiKey ||
37
+ process.env.AZURE_API_KEY ||
38
+ process.env.FIREWORKS_API_KEY ||
39
+ "";
40
+ this.baseURL =
41
+ clientOptions?.baseURL ||
42
+ process.env.AZURE_ENDPOINT ||
43
+ process.env.FIREWORKS_ENDPOINT ||
44
+ "";
45
+ // Store client options for reference
46
+ this.clientOptions = {
47
+ apiKey: this.apiKey,
48
+ baseURL: this.baseURL,
49
+ };
50
+ // Validate API key
51
+ if (!this.apiKey || this.apiKey === "") {
52
+ throw new Error("API key is required. Please provide it via clientOptions.apiKey or AZURE_API_KEY or FIREWORKS_API_KEY environment variables.");
53
+ }
54
+ // Initialize the OpenAI client (FARA uses OpenAI-compatible API)
55
+ this.client = new OpenAI({
56
+ apiKey: this.apiKey,
57
+ baseURL: this.baseURL,
58
+ });
59
+ // Max images to keep in history
60
+ if (clientOptions?.maxImages !== undefined) {
61
+ this.maxImages = clientOptions.maxImages;
62
+ }
63
+ // Temperature
64
+ if (clientOptions?.temperature !== undefined) {
65
+ this.temperature = clientOptions.temperature;
66
+ }
67
+ }
68
+ setViewport(width, height) {
69
+ this.currentViewport = { width, height };
70
+ // Compute resized viewport using smart_resize logic
71
+ this.resizedViewport = this.smartResize(width, height);
72
+ }
73
+ setCurrentUrl(url) {
74
+ this.currentUrl = url;
75
+ }
76
+ setScreenshotProvider(provider) {
77
+ this.screenshotProvider = provider;
78
+ }
79
+ setActionHandler(handler) {
80
+ this.actionHandler = handler;
81
+ }
82
+ /**
83
+ * Smart resize algorithm from FARA
84
+ * Ensures dimensions are divisible by factor and within pixel limits
85
+ */
86
+ smartResize(width, height) {
87
+ const { patch_size, merge_size, min_pixels, max_pixels } = this.MLM_PROCESSOR_IM_CFG;
88
+ const factor = patch_size * merge_size;
89
+ const roundByFactor = (num, f) => Math.round(num / f) * f;
90
+ const ceilByFactor = (num, f) => Math.ceil(num / f) * f;
91
+ const floorByFactor = (num, f) => Math.floor(num / f) * f;
92
+ let h_bar = Math.max(factor, roundByFactor(height, factor));
93
+ let w_bar = Math.max(factor, roundByFactor(width, factor));
94
+ if (h_bar * w_bar > max_pixels) {
95
+ const beta = Math.sqrt((height * width) / max_pixels);
96
+ h_bar = floorByFactor(height / beta, factor);
97
+ w_bar = floorByFactor(width / beta, factor);
98
+ }
99
+ else if (h_bar * w_bar < min_pixels) {
100
+ const beta = Math.sqrt(min_pixels / (height * width));
101
+ h_bar = ceilByFactor(height * beta, factor);
102
+ w_bar = ceilByFactor(width * beta, factor);
103
+ }
104
+ return { width: w_bar, height: h_bar };
105
+ }
106
+ /**
107
+ * Generate system prompt with tool description
108
+ * Simplified to match Python's minimal approach
109
+ */
110
+ generateSystemPrompt() {
111
+ const { width, height } = this.resizedViewport;
112
+ // Base prompt - Minimalist like Python
113
+ let basePrompt = "You are a helpful assistant.";
114
+ // Add user-provided instructions if available
115
+ if (this.userProvidedInstructions) {
116
+ basePrompt = `${basePrompt}\n\n${this.userProvidedInstructions}`;
117
+ }
118
+ // Tool description from FaraComputerUse
119
+ const toolDescription = `Use a mouse and keyboard to interact with a computer, and take screenshots.
120
+ * This is an interface to a desktop GUI. You do not have access to a terminal or applications menu. You must click on desktop icons to start applications.
121
+ * Some applications may take time to start or process actions, so you may need to wait and take successive screenshots to see the results of your actions. E.g. if you click on Firefox and a window doesn't open, try wait and taking another screenshot.
122
+ * The screen's resolution is ${width}x${height}.
123
+ * Whenever you intend to move the cursor to click on an element like an icon, you should consult a screenshot to determine the coordinates of the element before moving the cursor.
124
+ * If you tried clicking on a program or link but it failed to load, even after waiting, try adjusting your cursor position so that the tip of the cursor visually falls on the element that you want to click.
125
+ * Make sure to click any buttons, links, icons, etc with the cursor tip in the center of the element. Don't click boxes on their edges unless asked.
126
+ * When a separate scrollable container prominently overlays the webpage, if you want to scroll within it, you typically need to mouse_move() over it first and then scroll().
127
+ * If a popup window appears that you want to close, if left_click() on the 'X' or close button doesn't work, try key(keys=['Escape']) to close it.
128
+ * On some search bars, when you type(), you may need to press_enter=False and instead separately call left_click() on the search button to submit the search query. This is especially true of search bars that have auto-suggest popups for e.g. locations
129
+ * For calendar widgets, you usually need to left_click() on arrows to move between months and left_click() on dates to select them; type() is not typically used to input dates there.`;
130
+ // Tool parameters description
131
+ const actionsDescription = `The action to perform. The available actions are:
132
+ * \`key\`: Performs key down presses on the arguments passed in order, then performs key releases in reverse order. Includes "Enter", "Alt", "Shift", "Tab", "Control", "Backspace", "Delete", "Escape", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageDown", "PageUp", "Shift", etc.
133
+ * \`type\`: Type a string of text on the keyboard.
134
+ * \`mouse_move\`: Move the cursor to a specified (x, y) pixel coordinate on the screen.
135
+ * \`left_click\`: Click the left mouse button.
136
+ * \`scroll\`: Performs a scroll of the mouse scroll wheel.
137
+ * \`history_back\`: Go back to the previous page in the browser history.
138
+ * \`pause_and_memorize_fact\`: Pause and memorize a fact for future reference.
139
+ * \`visit_url\`: Visit a specified URL.
140
+ * \`web_search\`: Perform a web search with a specified query.
141
+ * \`wait\`: Wait specified seconds for the change to happen.
142
+ * \`terminate\`: Terminate the current task and report its completion status.`;
143
+ // Tool JSON schema
144
+ const toolSchema = {
145
+ name: "computer_use",
146
+ description: toolDescription,
147
+ parameters: {
148
+ type: "object",
149
+ required: ["action"],
150
+ properties: {
151
+ action: {
152
+ type: "string",
153
+ description: actionsDescription,
154
+ enum: [
155
+ "key",
156
+ "type",
157
+ "mouse_move",
158
+ "left_click",
159
+ "scroll",
160
+ "visit_url",
161
+ "web_search",
162
+ "history_back",
163
+ "pause_and_memorize_fact",
164
+ "wait",
165
+ "terminate",
166
+ ],
167
+ },
168
+ keys: {
169
+ type: "array",
170
+ description: "Required only by `action=key`.",
171
+ },
172
+ text: {
173
+ type: "string",
174
+ description: "Required only by `action=type`.",
175
+ },
176
+ press_enter: {
177
+ type: "boolean",
178
+ description: "Whether to press the Enter key after typing. Required only by `action=type`.",
179
+ },
180
+ delete_existing_text: {
181
+ type: "boolean",
182
+ description: "Whether to delete existing text before typing. Required only by `action=type`.",
183
+ },
184
+ coordinate: {
185
+ type: "array",
186
+ description: "(x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=left_click`, `action=mouse_move`, and `action=type`.",
187
+ },
188
+ pixels: {
189
+ type: "number",
190
+ description: "The amount of scrolling to perform. Positive values scroll up, negative values scroll down. Required only by `action=scroll`.",
191
+ },
192
+ fact: {
193
+ type: "string",
194
+ description: "The fact to remember for the future. Required only by `action=pause_and_memorize_fact`.",
195
+ },
196
+ time: {
197
+ type: "number",
198
+ description: "The seconds to wait. Required only by `action=wait`.",
199
+ },
200
+ status: {
201
+ type: "string",
202
+ description: "The status of the task. Required only by `action=terminate`.",
203
+ enum: ["success", "failure"],
204
+ },
205
+ },
206
+ },
207
+ };
208
+ // Format as FARA function calling template (FN_CALL_TEMPLATE format)
209
+ const toolDescs = JSON.stringify(toolSchema, null, 2);
210
+ const functionCallTemplate = `
211
+ You are provided with function signatures within <tools></tools> XML tags:
212
+ <tools>
213
+ ${toolDescs}
214
+ </tools>
215
+
216
+ For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
217
+ <tool_call>
218
+ {{"name": <function-name>, "arguments": <args-json-object>}}
219
+ </tool_call>`;
220
+ return `${basePrompt}\n\n${functionCallTemplate}`;
221
+ }
222
+ /**
223
+ * Parse thoughts and action from model response
224
+ * FARA uses XML-based tool calling: <tool_call>\n{...}\n</tool_call>
225
+ */
226
+ parseThoughtsAndAction(response) {
227
+ try {
228
+ const parts = response.split("<tool_call>\n");
229
+ const thoughts = parts[0].trim();
230
+ const actionText = parts[1].split("\n</tool_call>")[0].trim();
231
+ let parsedAction;
232
+ try {
233
+ parsedAction = JSON.parse(actionText);
234
+ }
235
+ catch (jsonError) {
236
+ // Fix common malformed JSON: double opening brackets {{"name": ...}}
237
+ // This happens when the model adds an extra opening brace
238
+ if (actionText.startsWith("{{") && actionText.endsWith("}")) {
239
+ // Remove the extra opening brace
240
+ const fixedText = actionText.slice(1);
241
+ try {
242
+ parsedAction = JSON.parse(fixedText);
243
+ }
244
+ catch (retryError) {
245
+ throw new Error(`Failed to parse action text even after fixing double brackets. Original: ${actionText}. Fixed: ${fixedText}. Error: ${retryError}`);
246
+ }
247
+ }
248
+ else {
249
+ throw new Error(`Failed to parse action text as JSON: ${actionText}. Error: ${jsonError}`);
250
+ }
251
+ }
252
+ return {
253
+ thoughts,
254
+ functionCall: {
255
+ name: parsedAction.name || "computer_use",
256
+ arguments: {
257
+ ...parsedAction.arguments,
258
+ thoughts,
259
+ },
260
+ },
261
+ };
262
+ }
263
+ catch (error) {
264
+ throw new Error(`Failed to parse FARA tool call from response: ${response}. Error: ${error}`);
265
+ }
266
+ }
267
+ /**
268
+ * Convert FARA function call to Stagehand AgentAction
269
+ */
270
+ convertFunctionCallToAction(functionCall) {
271
+ const args = functionCall.arguments;
272
+ const action = args.action;
273
+ // Transform coordinates from resized to original viewport
274
+ const transformCoordinate = (coord) => {
275
+ if (!coord || coord.length !== 2)
276
+ return coord;
277
+ const [x, y] = coord;
278
+ const scaleX = this.currentViewport.width / this.resizedViewport.width;
279
+ const scaleY = this.currentViewport.height / this.resizedViewport.height;
280
+ return [Math.round(x * scaleX), Math.round(y * scaleY)];
281
+ };
282
+ const baseAction = {
283
+ type: action,
284
+ reasoning: args.thoughts,
285
+ };
286
+ switch (action) {
287
+ case "left_click": {
288
+ const clickCoord = transformCoordinate(args.coordinate);
289
+ return {
290
+ ...baseAction,
291
+ type: "click",
292
+ x: clickCoord[0],
293
+ y: clickCoord[1],
294
+ button: "left",
295
+ };
296
+ }
297
+ case "mouse_move": {
298
+ const moveCoord = transformCoordinate(args.coordinate);
299
+ return {
300
+ ...baseAction,
301
+ type: "move",
302
+ coordinate: moveCoord,
303
+ };
304
+ }
305
+ case "type": {
306
+ const typeCoord = args.coordinate
307
+ ? transformCoordinate(args.coordinate)
308
+ : undefined;
309
+ return {
310
+ ...baseAction,
311
+ text: args.text,
312
+ ...(typeCoord && { x: typeCoord[0], y: typeCoord[1] }),
313
+ press_enter: args.press_enter !== undefined
314
+ ? args.press_enter
315
+ : true,
316
+ ...(args.delete_existing_text !== undefined && {
317
+ delete_existing_text: args.delete_existing_text,
318
+ }),
319
+ };
320
+ }
321
+ case "key":
322
+ case "keypress": {
323
+ const keys = args.keys || [];
324
+ // Normalize keys to Playwright format
325
+ const normalizedKeys = keys.map((k) => mapKeyToPlaywright(k));
326
+ return {
327
+ ...baseAction,
328
+ type: "keypress",
329
+ keys: normalizedKeys,
330
+ };
331
+ }
332
+ case "scroll": {
333
+ const pixels = args.pixels || 0;
334
+ // FARA: positive = scroll up, negative = scroll down
335
+ // Convert to scroll_x/scroll_y
336
+ return {
337
+ ...baseAction,
338
+ scroll_x: 0,
339
+ scroll_y: -pixels, // Invert: negative pixels = scroll down
340
+ };
341
+ }
342
+ case "visit_url": {
343
+ let url = args.url;
344
+ // Enhanced URL processing like Python
345
+ if (!url.startsWith("https://") &&
346
+ !url.startsWith("http://") &&
347
+ !url.startsWith("file://") &&
348
+ !url.startsWith("about:")) {
349
+ // If URL contains space, treat as search query
350
+ if (url.includes(" ")) {
351
+ url = `https://www.bing.com/search?q=${encodeURIComponent(url)}&FORM=QBLH`;
352
+ }
353
+ else {
354
+ // Otherwise prefix with https://
355
+ url = "https://" + url;
356
+ }
357
+ }
358
+ return {
359
+ ...baseAction,
360
+ type: "goto",
361
+ url,
362
+ };
363
+ }
364
+ case "web_search": {
365
+ // Convert web search to visit_url with Bing search
366
+ const query = args.query;
367
+ const searchUrl = `https://www.bing.com/search?q=${encodeURIComponent(query)}&FORM=QBLH`;
368
+ return {
369
+ ...baseAction,
370
+ type: "goto",
371
+ url: searchUrl,
372
+ };
373
+ }
374
+ case "history_back":
375
+ return {
376
+ ...baseAction,
377
+ type: "back",
378
+ };
379
+ case "wait": {
380
+ // Support both 'time' and 'duration' parameters with default (matches Python)
381
+ const durationSeconds = args.time || args.duration || 3.0;
382
+ return {
383
+ ...baseAction,
384
+ timeMs: durationSeconds * 1000, // Convert seconds to ms
385
+ };
386
+ }
387
+ case "pause_and_memorize_fact": {
388
+ // Store the fact for future reference (matches Python)
389
+ const fact = args.fact;
390
+ this.facts.push(fact);
391
+ return {
392
+ ...baseAction,
393
+ fact,
394
+ };
395
+ }
396
+ case "terminate":
397
+ return {
398
+ ...baseAction,
399
+ status: args.status,
400
+ };
401
+ default:
402
+ return {
403
+ ...baseAction,
404
+ ...args,
405
+ };
406
+ }
407
+ }
408
+ /**
409
+ * Capture a screenshot and return as base64 data URL
410
+ */
411
+ async captureScreenshot() {
412
+ if (!this.screenshotProvider) {
413
+ throw new AgentScreenshotProviderError("Screenshot provider not set");
414
+ }
415
+ const base64Screenshot = await this.screenshotProvider();
416
+ return `data:image/png;base64,${base64Screenshot}`;
417
+ }
418
+ /**
419
+ * Remove old screenshots from history
420
+ * Matches Python's maybe_remove_old_screenshots
421
+ */
422
+ maybeRemoveOldScreenshots(history, includesCurrent = false) {
423
+ if (this.maxImages <= 0) {
424
+ return history;
425
+ }
426
+ const maxImages = includesCurrent ? this.maxImages : this.maxImages - 1;
427
+ const newHistory = [];
428
+ let nImages = 0;
429
+ // Iterate backwards
430
+ for (let i = history.length - 1; i >= 0; i--) {
431
+ const msg = history[i];
432
+ // Check if message has image
433
+ let hasImage = false;
434
+ if (Array.isArray(msg.content)) {
435
+ hasImage = msg.content.some((c) => c.type === "image_url");
436
+ }
437
+ if (i === 0 && nImages >= maxImages) {
438
+ // First message (task) - preserve text, remove image
439
+ if (Array.isArray(msg.content)) {
440
+ const newContent = msg.content.filter((c) => c.type !== "image_url");
441
+ // If no content left, skip (unless it's the only message, but Python logic says continue)
442
+ if (newContent.length === 0) {
443
+ continue;
444
+ }
445
+ newHistory.push({ ...msg, content: newContent });
446
+ }
447
+ else {
448
+ newHistory.push(msg);
449
+ }
450
+ continue;
451
+ }
452
+ if (hasImage) {
453
+ if (nImages < maxImages) {
454
+ newHistory.push(msg);
455
+ nImages++;
456
+ }
457
+ else {
458
+ // Remove image, keep text
459
+ if (Array.isArray(msg.content)) {
460
+ const newContent = msg.content.filter((c) => c.type !== "image_url");
461
+ // If content becomes empty, we can skip this message entirely (unless it's meaningful text)
462
+ // Python logic: if msg is None continue.
463
+ if (newContent.length > 0) {
464
+ newHistory.push({ ...msg, content: newContent });
465
+ }
466
+ }
467
+ else {
468
+ newHistory.push(msg);
469
+ }
470
+ }
471
+ }
472
+ else {
473
+ newHistory.push(msg);
474
+ }
475
+ }
476
+ return newHistory.reverse();
477
+ }
478
+ /**
479
+ * Reconstruct history for API call
480
+ * Merges conceptual chat history with raw action history
481
+ */
482
+ reconstructHistory() {
483
+ const history = [];
484
+ let actionTurn = 0;
485
+ for (let i = 0; i < this.conversationHistory.length; i++) {
486
+ const m = this.conversationHistory[i];
487
+ if (m.role === "assistant") {
488
+ if (actionTurn >= this.actionHistory.length) {
489
+ // Should not happen if synced correctly
490
+ console.warn("OUT OF SYNC: Action history shorter than chat history");
491
+ history.push(m);
492
+ }
493
+ else {
494
+ history.push(this.actionHistory[actionTurn]);
495
+ actionTurn++;
496
+ }
497
+ }
498
+ else {
499
+ history.push(m);
500
+ }
501
+ }
502
+ return this.maybeRemoveOldScreenshots(history);
503
+ }
504
+ /**
505
+ * Execute a single step
506
+ */
507
+ async executeStep(logger, isFirstRound = false) {
508
+ // Capture screenshot
509
+ const screenshotDataUrl = await this.captureScreenshot();
510
+ // Update conversation history with new screenshot/message
511
+ if (isFirstRound) {
512
+ // First round: modify the last message (initial user instruction) to include screenshot
513
+ const lastMessage = this.conversationHistory[this.conversationHistory.length - 1];
514
+ if (lastMessage && lastMessage.role === "user") {
515
+ const originalContent = typeof lastMessage.content === "string"
516
+ ? lastMessage.content
517
+ : (lastMessage.content.find((c) => c.type === "text")?.text ??
518
+ "Start task");
519
+ lastMessage.content = [
520
+ {
521
+ type: "image_url",
522
+ image_url: { url: screenshotDataUrl },
523
+ },
524
+ {
525
+ type: "text",
526
+ text: originalContent,
527
+ },
528
+ ];
529
+ }
530
+ }
531
+ else {
532
+ // Subsequent rounds: add new user message with screenshot
533
+ const userContent = [
534
+ {
535
+ type: "image_url",
536
+ image_url: { url: screenshotDataUrl },
537
+ },
538
+ ];
539
+ // Add current URL if available
540
+ let textPrompt = "Here is the next screenshot. Think about what to do next.";
541
+ if (this.currentUrl) {
542
+ const trimmedUrl = this.currentUrl.length > 100
543
+ ? this.currentUrl.slice(0, 100) + "..."
544
+ : this.currentUrl;
545
+ textPrompt = `Current URL: ${trimmedUrl}\n${textPrompt}`;
546
+ }
547
+ userContent.push({
548
+ type: "text",
549
+ text: textPrompt,
550
+ });
551
+ this.conversationHistory.push({
552
+ role: "user",
553
+ content: userContent,
554
+ });
555
+ }
556
+ // Reconstruct history for model call
557
+ let history = this.reconstructHistory();
558
+ // Prepend system prompt (generated fresh)
559
+ const systemMessage = {
560
+ role: "system",
561
+ content: this.generateSystemPrompt(),
562
+ };
563
+ history = [systemMessage, ...history];
564
+ // Make API call
565
+ logger({
566
+ category: "agent",
567
+ message: `Making API call to FARA model with ${history.length} messages`,
568
+ level: 2,
569
+ });
570
+ const startTime = Date.now();
571
+ let response;
572
+ try {
573
+ response = await this.client.chat.completions.create({
574
+ model: this.modelName,
575
+ messages: history,
576
+ temperature: this.temperature,
577
+ });
578
+ }
579
+ catch (apiError) {
580
+ logger({
581
+ category: "agent",
582
+ message: `API call failed: ${apiError instanceof Error ? apiError.message : String(apiError)}`,
583
+ level: 0,
584
+ });
585
+ throw apiError;
586
+ }
587
+ const inferenceTime = Date.now() - startTime;
588
+ logger({
589
+ category: "agent",
590
+ message: `API call completed in ${inferenceTime}ms`,
591
+ level: 2,
592
+ });
593
+ const content = response.choices[0].message.content || "";
594
+ const usage = response.usage || {
595
+ prompt_tokens: 0,
596
+ completion_tokens: 0,
597
+ total_tokens: 0,
598
+ };
599
+ // Add assistant response to both histories
600
+ const assistantMsg = {
601
+ role: "assistant",
602
+ content,
603
+ };
604
+ this.conversationHistory.push(assistantMsg);
605
+ this.actionHistory.push(assistantMsg);
606
+ logger({
607
+ category: "agent",
608
+ message: `Model response: ${content}`,
609
+ level: 2,
610
+ });
611
+ // Parse tool call
612
+ const { thoughts, functionCall } = this.parseThoughtsAndAction(content);
613
+ logger({
614
+ category: "agent",
615
+ message: `Thoughts: ${thoughts}`,
616
+ level: 2,
617
+ });
618
+ logger({
619
+ category: "agent",
620
+ message: `Action: ${JSON.stringify(functionCall.arguments)}`,
621
+ level: 2,
622
+ });
623
+ // Convert to AgentAction
624
+ const agentAction = this.convertFunctionCallToAction(functionCall);
625
+ // Expand type action into multiple actions if it has coordinates
626
+ const actions = [];
627
+ if (agentAction.type === "type" &&
628
+ typeof agentAction.x === "number" &&
629
+ typeof agentAction.y === "number") {
630
+ // First, click at the coordinates to focus the field
631
+ actions.push({
632
+ type: "click",
633
+ x: agentAction.x,
634
+ y: agentAction.y,
635
+ button: "left",
636
+ });
637
+ // If delete_existing_text is true, clear the field first
638
+ if (agentAction.delete_existing_text) {
639
+ actions.push({
640
+ type: "keypress",
641
+ keys: ["Command+A"],
642
+ });
643
+ actions.push({
644
+ type: "keypress",
645
+ keys: ["Backspace"],
646
+ });
647
+ }
648
+ // Add the type action (without coordinates since we already clicked)
649
+ actions.push({
650
+ type: "type",
651
+ text: agentAction.text,
652
+ });
653
+ // If press_enter is true (default), press Enter after typing
654
+ if (agentAction.press_enter !== false) {
655
+ actions.push({
656
+ type: "keypress",
657
+ keys: ["Enter"],
658
+ });
659
+ }
660
+ }
661
+ else {
662
+ // For all other actions, just add as-is
663
+ actions.push(agentAction);
664
+ }
665
+ // Execute all actions if handler is available
666
+ if (this.actionHandler && agentAction.type !== "terminate") {
667
+ for (const action of actions) {
668
+ await this.actionHandler(action);
669
+ }
670
+ }
671
+ // Check if completed
672
+ const completed = functionCall.arguments.action === "terminate";
673
+ return {
674
+ actions,
675
+ completed,
676
+ usage: {
677
+ input_tokens: usage.prompt_tokens,
678
+ output_tokens: usage.completion_tokens,
679
+ inference_time_ms: inferenceTime,
680
+ },
681
+ };
682
+ }
683
+ /**
684
+ * Execute a task with the FARA CUA
685
+ * This is the main entry point for the agent
686
+ * @implements AgentClient.execute
687
+ */
688
+ async execute(executionOptions) {
689
+ const { options, logger } = executionOptions;
690
+ const { instruction } = options;
691
+ const maxSteps = options.maxSteps || 10;
692
+ let currentStep = 0;
693
+ let completed = false;
694
+ const actions = [];
695
+ const messageList = [];
696
+ let finalMessage = "";
697
+ let totalInputTokens = 0;
698
+ let totalOutputTokens = 0;
699
+ let totalInferenceTime = 0;
700
+ // Initialize conversation with user instruction
701
+ // System prompt is NOT added here, it's added dynamically in executeStep
702
+ this.conversationHistory = [
703
+ {
704
+ role: "user",
705
+ content: instruction,
706
+ },
707
+ ];
708
+ this.actionHistory = [];
709
+ try {
710
+ // Execute steps until completion or max steps reached
711
+ while (!completed && currentStep < maxSteps) {
712
+ logger({
713
+ category: "agent",
714
+ message: `Executing step ${currentStep + 1}/${maxSteps}`,
715
+ level: 1,
716
+ });
717
+ const isFirstRound = currentStep === 0;
718
+ const result = await this.executeStep(logger, isFirstRound);
719
+ totalInputTokens += result.usage.input_tokens;
720
+ totalOutputTokens += result.usage.output_tokens;
721
+ totalInferenceTime += result.usage.inference_time_ms;
722
+ // Add actions to the list
723
+ actions.push(...result.actions);
724
+ // Update completion status
725
+ completed = result.completed;
726
+ currentStep++;
727
+ // Record message for this step
728
+ const lastAction = result.actions[result.actions.length - 1];
729
+ if (lastAction?.reasoning) {
730
+ messageList.push(lastAction.reasoning);
731
+ }
732
+ }
733
+ // Generate final message
734
+ if (completed) {
735
+ const lastAction = actions[actions.length - 1];
736
+ finalMessage =
737
+ lastAction?.status === "success"
738
+ ? "Task completed successfully."
739
+ : "Task completed with failures.";
740
+ }
741
+ else {
742
+ finalMessage = `Reached maximum steps (${maxSteps}) without completion.`;
743
+ }
744
+ if (messageList.length > 0) {
745
+ finalMessage = `${messageList.join("\n\n")}\n\n${finalMessage}`;
746
+ }
747
+ return {
748
+ success: completed,
749
+ completed,
750
+ message: finalMessage,
751
+ actions,
752
+ usage: {
753
+ input_tokens: totalInputTokens,
754
+ output_tokens: totalOutputTokens,
755
+ inference_time_ms: totalInferenceTime,
756
+ },
757
+ };
758
+ }
759
+ catch (error) {
760
+ logger({
761
+ category: "agent",
762
+ message: `Error during execution: ${error}`,
763
+ level: 0,
764
+ });
765
+ // Rethrow to allow eval runner's retry logic to handle transient errors
766
+ throw error;
767
+ }
768
+ }
769
+ }
770
+ //# sourceMappingURL=MicrosoftCUAClient.js.map