@browserbasehq/stagehand 2.5.3-alpha-4994eabfa8016347ec001b40ceadb0c905403470 → 4.0.0-alpha-49bc5b68e4fbeb28a120b301b51c31a36db7d922

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 (286) hide show
  1. package/dist/index.d.ts +1367 -751
  2. package/dist/index.js +37087 -22062
  3. package/package.json +54 -78
  4. package/README.md +0 -165
  5. package/dist/evals/args.d.ts +0 -15
  6. package/dist/evals/cli.d.ts +0 -2
  7. package/dist/evals/core/summary.d.ts +0 -2
  8. package/dist/evals/datasets/osworld/adapter.d.ts +0 -22
  9. package/dist/evals/datasets/osworld/index.d.ts +0 -9
  10. package/dist/evals/datasets/osworld/types.d.ts +0 -54
  11. package/dist/evals/deterministic/bb.playwright.config.d.ts +0 -5
  12. package/dist/evals/deterministic/e2e.playwright.config.d.ts +0 -5
  13. package/dist/evals/deterministic/local.playwright.config.d.ts +0 -5
  14. package/dist/evals/deterministic/stagehand.config.d.ts +0 -3
  15. package/dist/evals/deterministic/tests/BrowserContext/addInitScript.test.d.ts +0 -1
  16. package/dist/evals/deterministic/tests/BrowserContext/cookies.test.d.ts +0 -1
  17. package/dist/evals/deterministic/tests/BrowserContext/multiPage.test.d.ts +0 -1
  18. package/dist/evals/deterministic/tests/BrowserContext/page.test.d.ts +0 -1
  19. package/dist/evals/deterministic/tests/BrowserContext/routing.test.d.ts +0 -1
  20. package/dist/evals/deterministic/tests/Errors/apiKeyError.test.d.ts +0 -1
  21. package/dist/evals/deterministic/tests/browserbase/contexts.test.d.ts +0 -1
  22. package/dist/evals/deterministic/tests/browserbase/downloads.test.d.ts +0 -1
  23. package/dist/evals/deterministic/tests/browserbase/sessions.test.d.ts +0 -1
  24. package/dist/evals/deterministic/tests/browserbase/uploads.test.d.ts +0 -1
  25. package/dist/evals/deterministic/tests/local/create.test.d.ts +0 -1
  26. package/dist/evals/deterministic/tests/local/downloads.test.d.ts +0 -1
  27. package/dist/evals/deterministic/tests/page/addInitScript.test.d.ts +0 -1
  28. package/dist/evals/deterministic/tests/page/addRemoveLocatorHandler.test.d.ts +0 -1
  29. package/dist/evals/deterministic/tests/page/addTags.test.d.ts +0 -1
  30. package/dist/evals/deterministic/tests/page/bringToFront.test.d.ts +0 -1
  31. package/dist/evals/deterministic/tests/page/content.test.d.ts +0 -1
  32. package/dist/evals/deterministic/tests/page/evaluate.test.d.ts +0 -1
  33. package/dist/evals/deterministic/tests/page/expose.test.d.ts +0 -1
  34. package/dist/evals/deterministic/tests/page/frames.test.d.ts +0 -1
  35. package/dist/evals/deterministic/tests/page/getBy.test.d.ts +0 -1
  36. package/dist/evals/deterministic/tests/page/livePageProxy.test.d.ts +0 -1
  37. package/dist/evals/deterministic/tests/page/navigation.test.d.ts +0 -1
  38. package/dist/evals/deterministic/tests/page/on.test.d.ts +0 -1
  39. package/dist/evals/deterministic/tests/page/pageContext.test.d.ts +0 -1
  40. package/dist/evals/deterministic/tests/page/reload.test.d.ts +0 -1
  41. package/dist/evals/deterministic/tests/page/waitFor.test.d.ts +0 -1
  42. package/dist/evals/env.d.ts +0 -13
  43. package/dist/evals/evaluator.d.ts +0 -29
  44. package/dist/evals/index.eval.d.ts +0 -1
  45. package/dist/evals/initStagehand.d.ts +0 -37
  46. package/dist/evals/llm_clients/hn_aisdk.d.ts +0 -2
  47. package/dist/evals/llm_clients/hn_customOpenAI.d.ts +0 -2
  48. package/dist/evals/llm_clients/hn_langchain.d.ts +0 -2
  49. package/dist/evals/logger.d.ts +0 -50
  50. package/dist/evals/scoring.d.ts +0 -25
  51. package/dist/evals/suites/gaia.d.ts +0 -2
  52. package/dist/evals/suites/onlineMind2Web.d.ts +0 -2
  53. package/dist/evals/suites/osworld.d.ts +0 -2
  54. package/dist/evals/suites/webbench.d.ts +0 -2
  55. package/dist/evals/suites/webvoyager.d.ts +0 -2
  56. package/dist/evals/taskConfig.d.ts +0 -33
  57. package/dist/evals/tasks/agent/all_recipes.d.ts +0 -2
  58. package/dist/evals/tasks/agent/apple_trade_in.d.ts +0 -2
  59. package/dist/evals/tasks/agent/apple_tv.d.ts +0 -2
  60. package/dist/evals/tasks/agent/arxiv_gpt_report.d.ts +0 -2
  61. package/dist/evals/tasks/agent/gaia.d.ts +0 -9
  62. package/dist/evals/tasks/agent/github.d.ts +0 -2
  63. package/dist/evals/tasks/agent/github_react_version.d.ts +0 -2
  64. package/dist/evals/tasks/agent/google_flights.d.ts +0 -2
  65. package/dist/evals/tasks/agent/google_maps.d.ts +0 -2
  66. package/dist/evals/tasks/agent/google_maps_2.d.ts +0 -2
  67. package/dist/evals/tasks/agent/google_maps_3.d.ts +0 -2
  68. package/dist/evals/tasks/agent/google_shopping.d.ts +0 -2
  69. package/dist/evals/tasks/agent/hotel_booking.d.ts +0 -2
  70. package/dist/evals/tasks/agent/hugging_face.d.ts +0 -2
  71. package/dist/evals/tasks/agent/iframe_form.d.ts +0 -2
  72. package/dist/evals/tasks/agent/iframe_form_multiple.d.ts +0 -2
  73. package/dist/evals/tasks/agent/kayak.d.ts +0 -2
  74. package/dist/evals/tasks/agent/kith.d.ts +0 -2
  75. package/dist/evals/tasks/agent/nba_trades.d.ts +0 -2
  76. package/dist/evals/tasks/agent/onlineMind2Web.d.ts +0 -2
  77. package/dist/evals/tasks/agent/osworld.d.ts +0 -2
  78. package/dist/evals/tasks/agent/sf_library_card.d.ts +0 -2
  79. package/dist/evals/tasks/agent/sf_library_card_multiple.d.ts +0 -2
  80. package/dist/evals/tasks/agent/sign_in.d.ts +0 -2
  81. package/dist/evals/tasks/agent/steam_games.d.ts +0 -2
  82. package/dist/evals/tasks/agent/trivago.d.ts +0 -2
  83. package/dist/evals/tasks/agent/ubereats.d.ts +0 -2
  84. package/dist/evals/tasks/agent/webbench.d.ts +0 -2
  85. package/dist/evals/tasks/agent/webvoyager.d.ts +0 -2
  86. package/dist/evals/tasks/agent/youtube.d.ts +0 -2
  87. package/dist/evals/tasks/allrecipes.d.ts +0 -2
  88. package/dist/evals/tasks/amazon_add_to_cart.d.ts +0 -2
  89. package/dist/evals/tasks/apple.d.ts +0 -2
  90. package/dist/evals/tasks/arxiv.d.ts +0 -2
  91. package/dist/evals/tasks/bidnet.d.ts +0 -2
  92. package/dist/evals/tasks/checkboxes.d.ts +0 -2
  93. package/dist/evals/tasks/combination_sauce.d.ts +0 -2
  94. package/dist/evals/tasks/costar.d.ts +0 -2
  95. package/dist/evals/tasks/csr_in_oopif.d.ts +0 -2
  96. package/dist/evals/tasks/csr_in_spif.d.ts +0 -2
  97. package/dist/evals/tasks/custom_dropdown.d.ts +0 -2
  98. package/dist/evals/tasks/dropdown.d.ts +0 -2
  99. package/dist/evals/tasks/expect_act_timeout.d.ts +0 -2
  100. package/dist/evals/tasks/extract_aigrant_companies.d.ts +0 -2
  101. package/dist/evals/tasks/extract_aigrant_targeted.d.ts +0 -2
  102. package/dist/evals/tasks/extract_aigrant_targeted_2.d.ts +0 -2
  103. package/dist/evals/tasks/extract_apartments.d.ts +0 -2
  104. package/dist/evals/tasks/extract_area_codes.d.ts +0 -2
  105. package/dist/evals/tasks/extract_baptist_health.d.ts +0 -2
  106. package/dist/evals/tasks/extract_capacitor_info.d.ts +0 -2
  107. package/dist/evals/tasks/extract_collaborators.d.ts +0 -2
  108. package/dist/evals/tasks/extract_csa.d.ts +0 -2
  109. package/dist/evals/tasks/extract_geniusee.d.ts +0 -2
  110. package/dist/evals/tasks/extract_geniusee_2.d.ts +0 -2
  111. package/dist/evals/tasks/extract_github_commits.d.ts +0 -2
  112. package/dist/evals/tasks/extract_github_stars.d.ts +0 -2
  113. package/dist/evals/tasks/extract_hamilton_weather.d.ts +0 -2
  114. package/dist/evals/tasks/extract_jfk_links.d.ts +0 -2
  115. package/dist/evals/tasks/extract_jstor_news.d.ts +0 -2
  116. package/dist/evals/tasks/extract_memorial_healthcare.d.ts +0 -2
  117. package/dist/evals/tasks/extract_nhl_stats.d.ts +0 -2
  118. package/dist/evals/tasks/extract_partners.d.ts +0 -2
  119. package/dist/evals/tasks/extract_press_releases.d.ts +0 -2
  120. package/dist/evals/tasks/extract_professional_info.d.ts +0 -2
  121. package/dist/evals/tasks/extract_public_notices.d.ts +0 -2
  122. package/dist/evals/tasks/extract_recipe.d.ts +0 -2
  123. package/dist/evals/tasks/extract_regulations_table.d.ts +0 -2
  124. package/dist/evals/tasks/extract_repo_name.d.ts +0 -2
  125. package/dist/evals/tasks/extract_resistor_info.d.ts +0 -2
  126. package/dist/evals/tasks/extract_rockauto.d.ts +0 -2
  127. package/dist/evals/tasks/extract_single_link.d.ts +0 -2
  128. package/dist/evals/tasks/extract_snowshoeing_destinations.d.ts +0 -2
  129. package/dist/evals/tasks/extract_staff_members.d.ts +0 -2
  130. package/dist/evals/tasks/extract_zillow.d.ts +0 -2
  131. package/dist/evals/tasks/google_flights.d.ts +0 -11
  132. package/dist/evals/tasks/heal_custom_dropdown.d.ts +0 -2
  133. package/dist/evals/tasks/heal_scroll_50.d.ts +0 -2
  134. package/dist/evals/tasks/heal_simple_google_search.d.ts +0 -2
  135. package/dist/evals/tasks/hidden_input_dropdown.d.ts +0 -2
  136. package/dist/evals/tasks/history.d.ts +0 -2
  137. package/dist/evals/tasks/homedepot.d.ts +0 -2
  138. package/dist/evals/tasks/iframe_form_filling.d.ts +0 -2
  139. package/dist/evals/tasks/iframe_hn.d.ts +0 -2
  140. package/dist/evals/tasks/iframe_same_proc.d.ts +0 -2
  141. package/dist/evals/tasks/iframe_scroll.d.ts +0 -2
  142. package/dist/evals/tasks/iframes_nested.d.ts +0 -2
  143. package/dist/evals/tasks/imdb_movie_details.d.ts +0 -2
  144. package/dist/evals/tasks/instructions.d.ts +0 -2
  145. package/dist/evals/tasks/ionwave.d.ts +0 -2
  146. package/dist/evals/tasks/ionwave_observe.d.ts +0 -2
  147. package/dist/evals/tasks/login.d.ts +0 -2
  148. package/dist/evals/tasks/multi_tab.d.ts +0 -2
  149. package/dist/evals/tasks/namespace_xpath.d.ts +0 -2
  150. package/dist/evals/tasks/nested_iframes_2.d.ts +0 -2
  151. package/dist/evals/tasks/nextChunk.d.ts +0 -2
  152. package/dist/evals/tasks/no_js_click.d.ts +0 -2
  153. package/dist/evals/tasks/nonsense_action.d.ts +0 -2
  154. package/dist/evals/tasks/observe_amazon_add_to_cart.d.ts +0 -2
  155. package/dist/evals/tasks/observe_github.d.ts +0 -2
  156. package/dist/evals/tasks/observe_iframes1.d.ts +0 -2
  157. package/dist/evals/tasks/observe_iframes2.d.ts +0 -2
  158. package/dist/evals/tasks/observe_simple_google_search.d.ts +0 -2
  159. package/dist/evals/tasks/observe_taxes.d.ts +0 -2
  160. package/dist/evals/tasks/observe_vantechjournal.d.ts +0 -2
  161. package/dist/evals/tasks/observe_yc_startup.d.ts +0 -2
  162. package/dist/evals/tasks/oopif_in_csr.d.ts +0 -2
  163. package/dist/evals/tasks/oopif_in_osr.d.ts +0 -2
  164. package/dist/evals/tasks/os_dropdown.d.ts +0 -2
  165. package/dist/evals/tasks/osr_in_oopif.d.ts +0 -2
  166. package/dist/evals/tasks/osr_in_spif.d.ts +0 -2
  167. package/dist/evals/tasks/panamcs.d.ts +0 -2
  168. package/dist/evals/tasks/peeler_complex.d.ts +0 -2
  169. package/dist/evals/tasks/peeler_simple.d.ts +0 -2
  170. package/dist/evals/tasks/prevChunk.d.ts +0 -2
  171. package/dist/evals/tasks/radio_btn.d.ts +0 -2
  172. package/dist/evals/tasks/rakuten_jp.d.ts +0 -2
  173. package/dist/evals/tasks/sciquest.d.ts +0 -2
  174. package/dist/evals/tasks/screenshot_cdp_toggle.d.ts +0 -9
  175. package/dist/evals/tasks/scroll_50.d.ts +0 -2
  176. package/dist/evals/tasks/scroll_75.d.ts +0 -2
  177. package/dist/evals/tasks/shadow_dom.d.ts +0 -2
  178. package/dist/evals/tasks/simple_google_search.d.ts +0 -2
  179. package/dist/evals/tasks/spif_in_csr.d.ts +0 -2
  180. package/dist/evals/tasks/spif_in_osr.d.ts +0 -2
  181. package/dist/evals/tasks/stock_x.d.ts +0 -2
  182. package/dist/evals/tasks/tab_handling.d.ts +0 -2
  183. package/dist/evals/tasks/ted_talk.d.ts +0 -2
  184. package/dist/evals/tasks/vanta_h.d.ts +0 -2
  185. package/dist/evals/tasks/vantechjournal.d.ts +0 -2
  186. package/dist/evals/tasks/wichita.d.ts +0 -2
  187. package/dist/evals/tasks/wikipedia.d.ts +0 -2
  188. package/dist/evals/utils/ScreenshotCollector.d.ts +0 -34
  189. package/dist/evals/utils/imageUtils.d.ts +0 -1
  190. package/dist/evals/utils.d.ts +0 -61
  191. package/dist/examples/2048.d.ts +0 -1
  192. package/dist/examples/actionable_observe_example.d.ts +0 -14
  193. package/dist/examples/cua-example.d.ts +0 -1
  194. package/dist/examples/custom_client_aisdk.d.ts +0 -1
  195. package/dist/examples/custom_client_langchain.d.ts +0 -1
  196. package/dist/examples/custom_client_openai.d.ts +0 -1
  197. package/dist/examples/example.d.ts +0 -1
  198. package/dist/examples/external_clients/aisdk.d.ts +0 -20
  199. package/dist/examples/external_clients/customOpenAI.d.ts +0 -18
  200. package/dist/examples/external_clients/langchain.d.ts +0 -9
  201. package/dist/examples/form_filling_sensible.d.ts +0 -1
  202. package/dist/examples/google_enter.d.ts +0 -6
  203. package/dist/examples/instructions.d.ts +0 -1
  204. package/dist/examples/integrations/exa.d.ts +0 -1
  205. package/dist/examples/integrations/supabase.d.ts +0 -1
  206. package/dist/examples/operator-example.d.ts +0 -8
  207. package/dist/examples/parameterizeApiKey.d.ts +0 -1
  208. package/dist/examples/popup.d.ts +0 -6
  209. package/dist/examples/wordle.d.ts +0 -1
  210. package/dist/lib/StagehandContext.d.ts +0 -25
  211. package/dist/lib/StagehandPage.d.ts +0 -103
  212. package/dist/lib/a11y/utils.d.ts +0 -144
  213. package/dist/lib/agent/AgentClient.d.ts +0 -20
  214. package/dist/lib/agent/AgentProvider.d.ts +0 -19
  215. package/dist/lib/agent/AnthropicCUAClient.d.ts +0 -56
  216. package/dist/lib/agent/GoogleCUAClient.d.ts +0 -63
  217. package/dist/lib/agent/OpenAICUAClient.d.ts +0 -65
  218. package/dist/lib/agent/StagehandAgent.d.ts +0 -15
  219. package/dist/lib/agent/tools/act.d.ts +0 -59
  220. package/dist/lib/agent/tools/ariaTree.d.ts +0 -11
  221. package/dist/lib/agent/tools/close.d.ts +0 -22
  222. package/dist/lib/agent/tools/extract.d.ts +0 -38
  223. package/dist/lib/agent/tools/fillform.d.ts +0 -37
  224. package/dist/lib/agent/tools/goto.d.ts +0 -29
  225. package/dist/lib/agent/tools/index.d.ts +0 -257
  226. package/dist/lib/agent/tools/navback.d.ts +0 -17
  227. package/dist/lib/agent/tools/screenshot.d.ts +0 -13
  228. package/dist/lib/agent/tools/scroll.d.ts +0 -23
  229. package/dist/lib/agent/tools/wait.d.ts +0 -18
  230. package/dist/lib/agent/utils/cuaKeyMapping.d.ts +0 -10
  231. package/dist/lib/agent/utils/imageCompression.d.ts +0 -53
  232. package/dist/lib/agent/utils/messageProcessing.d.ts +0 -13
  233. package/dist/lib/api.d.ts +0 -23
  234. package/dist/lib/browserbaseDefaults.d.ts +0 -9
  235. package/dist/lib/cache/ActionCache.d.ts +0 -62
  236. package/dist/lib/cache/BaseCache.d.ts +0 -66
  237. package/dist/lib/cache/LLMCache.d.ts +0 -22
  238. package/dist/lib/cache.d.ts +0 -29
  239. package/dist/lib/dom/build/scriptContent.d.ts +0 -1
  240. package/dist/lib/dom/elementCheckUtils.d.ts +0 -2
  241. package/dist/lib/dom/genDomScripts.d.ts +0 -1
  242. package/dist/lib/dom/index.d.ts +0 -2
  243. package/dist/lib/dom/process.d.ts +0 -17
  244. package/dist/lib/dom/utils.d.ts +0 -7
  245. package/dist/lib/dom/xpathUtils.d.ts +0 -14
  246. package/dist/lib/handlers/actHandler.d.ts +0 -33
  247. package/dist/lib/handlers/cuaAgentHandler.d.ts +0 -58
  248. package/dist/lib/handlers/extractHandler.d.ts +0 -54
  249. package/dist/lib/handlers/handlerUtils/actHandlerUtils.d.ts +0 -21
  250. package/dist/lib/handlers/observeHandler.d.ts +0 -40
  251. package/dist/lib/handlers/stagehandAgentHandler.d.ts +0 -27
  252. package/dist/lib/index.d.ts +0 -94
  253. package/dist/lib/inference.d.ts +0 -61
  254. package/dist/lib/inferenceLogUtils.d.ts +0 -12
  255. package/dist/lib/llm/AnthropicClient.d.ts +0 -21
  256. package/dist/lib/llm/CerebrasClient.d.ts +0 -22
  257. package/dist/lib/llm/GoogleClient.d.ts +0 -24
  258. package/dist/lib/llm/GroqClient.d.ts +0 -22
  259. package/dist/lib/llm/LLMClient.d.ts +0 -99
  260. package/dist/lib/llm/LLMProvider.d.ts +0 -13
  261. package/dist/lib/llm/OpenAIClient.d.ts +0 -20
  262. package/dist/lib/llm/aisdk.d.ts +0 -20
  263. package/dist/lib/logger.d.ts +0 -54
  264. package/dist/lib/mcp/connection.d.ts +0 -11
  265. package/dist/lib/mcp/utils.d.ts +0 -3
  266. package/dist/lib/prompt.d.ts +0 -14
  267. package/dist/lib/utils.d.ts +0 -68
  268. package/dist/lib/version.d.ts +0 -5
  269. package/dist/scripts/gen-version.d.ts +0 -1
  270. package/dist/scripts/run-evals.d.ts +0 -1
  271. package/dist/stagehand.config.d.ts +0 -3
  272. package/dist/types/act.d.ts +0 -50
  273. package/dist/types/agent.d.ts +0 -144
  274. package/dist/types/api.d.ts +0 -40
  275. package/dist/types/browser.d.ts +0 -10
  276. package/dist/types/context.d.ts +0 -117
  277. package/dist/types/evals.d.ts +0 -95
  278. package/dist/types/evaluator.d.ts +0 -40
  279. package/dist/types/llm.d.ts +0 -11
  280. package/dist/types/log.d.ts +0 -23
  281. package/dist/types/model.d.ts +0 -17
  282. package/dist/types/page.d.ts +0 -38
  283. package/dist/types/playwright.d.ts +0 -12
  284. package/dist/types/stagehand.d.ts +0 -330
  285. package/dist/types/stagehandApiErrors.d.ts +0 -18
  286. package/dist/types/stagehandErrors.d.ts +0 -104
@@ -1,144 +0,0 @@
1
- import { AccessibilityNode, TreeResult, BackendIdMaps, CombinedA11yResult, EncodedId } from "../../types/context";
2
- import { StagehandPage } from "../StagehandPage";
3
- import { LogLine } from "../../types/log";
4
- import { Frame } from "playwright";
5
- /**
6
- * Clean a string by removing private-use unicode characters, normalizing whitespace,
7
- * and trimming the result.
8
- *
9
- * @param input - The text to clean, potentially containing PUA and NBSP characters.
10
- * @returns A cleaned string with PUA characters removed, NBSP variants collapsed,
11
- * consecutive spaces merged, and leading/trailing whitespace trimmed.
12
- */
13
- export declare function cleanText(input: string): string;
14
- /**
15
- * Generate a human-readable, indented outline of an accessibility node tree.
16
- *
17
- * @param node - The accessibility node to format, optionally with an encodedId.
18
- * @param level - The current depth level for indentation (used internally).
19
- * @returns A string representation of the node and its descendants, with one node per line.
20
- */
21
- export declare function formatSimplifiedTree(node: AccessibilityNode & {
22
- encodedId?: EncodedId;
23
- }, level?: number): string;
24
- /**
25
- * Build mappings from CDP backendNodeIds to HTML tag names and relative XPaths.
26
- *
27
- * @param experimental - Whether to use experimental behaviour.
28
- * @param sp - The StagehandPage wrapper for Playwright and CDP calls.
29
- * @param targetFrame - Optional Playwright.Frame whose DOM subtree to map; defaults to main frame.
30
- * @returns A Promise resolving to BackendIdMaps containing tagNameMap and xpathMap.
31
- */
32
- export declare function buildBackendIdMaps(experimental: boolean, sp: StagehandPage, targetFrame?: Frame): Promise<BackendIdMaps>;
33
- /**
34
- * Convert a flat array of AccessibilityNodes into a cleaned, hierarchical tree.
35
- * Nodes are pruned, structural wrappers removed, and each kept node is stamped
36
- * with its EncodedId for later lookup or subtree injection.
37
- *
38
- * @param nodes - Raw flat list of AX nodes retrieved via CDP.
39
- * @param tagNameMap - Mapping of EncodedId to HTML tag names for structural decisions.
40
- * @param logger - Optional function for logging diagnostic messages.
41
- * @param xpathMap - Optional mapping of EncodedId to relative XPath for element lookup.
42
- * @returns A Promise resolving to a TreeResult with cleaned tree, simplified text outline,
43
- * iframe list, URL map, and inherited xpathMap.
44
- */
45
- export declare function buildHierarchicalTree(nodes: AccessibilityNode[], tagNameMap: Record<EncodedId, string>, logger?: (l: LogLine) => void, xpathMap?: Record<EncodedId, string>): Promise<TreeResult>;
46
- /**
47
- * Resolve the CDP frame identifier for a Playwright Frame, handling same-process and OOPIF.
48
- *
49
- * @param sp - The StagehandPage instance for issuing CDP commands.
50
- * @param frame - The target Playwright.Frame; undefined or main frame yields undefined.
51
- * @returns A Promise resolving to the CDP frameId string, or undefined for main document.
52
- */
53
- export declare function getCDPFrameId(sp: StagehandPage, frame?: Frame): Promise<string | undefined>;
54
- /**
55
- * Retrieve and build a cleaned accessibility tree for a document or specific iframe.
56
- * Prunes, formats, and optionally filters by XPath, including scrollable role decoration.
57
- *
58
- * @param stagehandPage - The StagehandPage instance for Playwright and CDP interaction.
59
- * @param logger - Logging function for diagnostics and performance metrics.
60
- * @param selector - Optional XPath to filter the AX tree to a specific subtree.
61
- * @param targetFrame - Optional Playwright.Frame to scope the AX tree retrieval.
62
- * @returns A Promise resolving to a TreeResult with the hierarchical AX tree and related metadata.
63
- */
64
- export declare function getAccessibilityTree(experimental: boolean, stagehandPage: StagehandPage, logger: (log: LogLine) => void, selector?: string, targetFrame?: Frame): Promise<TreeResult>;
65
- /**
66
- * Get the backendNodeId of the iframe element that contains a given Playwright.Frame.
67
- *
68
- * @param sp - The StagehandPage instance for issuing CDP commands.
69
- * @param frame - The Playwright.Frame whose host iframe element to locate.
70
- * @returns A Promise resolving to the backendNodeId of the iframe element, or null if not applicable.
71
- */
72
- export declare function getFrameRootBackendNodeId(sp: StagehandPage, frame: Frame | undefined): Promise<number | null>;
73
- /**
74
- * Compute the absolute XPath for the iframe element hosting a given Playwright.Frame.
75
- *
76
- * @param frame - The Playwright.Frame whose iframe element to locate.
77
- * @returns A Promise resolving to the XPath of the iframe element, or "/" if no frame provided.
78
- */
79
- export declare function getFrameRootXpathWithShadow(frame: Frame | undefined): Promise<string>;
80
- export declare function getFrameRootXpath(frame: Frame | undefined): Promise<string>;
81
- /**
82
- * Inject simplified subtree outlines into the main frame outline for nested iframes.
83
- * Walks the main tree text, looks for EncodedId labels, and inserts matching subtrees.
84
- *
85
- * @param tree - The indented AX outline of the main frame.
86
- * @param idToTree - Map of EncodedId to subtree outlines for nested frames.
87
- * @returns A single combined text outline with iframe subtrees injected.
88
- */
89
- export declare function injectSubtrees(tree: string, idToTree: Map<EncodedId, string>): string;
90
- /**
91
- * Retrieve and merge accessibility trees for the main document and nested iframes.
92
- * Walks through frame chains if a root XPath is provided, then stitches subtree outlines.
93
- *
94
- * @param stagehandPage - The StagehandPage instance for Playwright and CDP interaction.
95
- * @param logger - Logging function for diagnostics and performance.
96
- * @param rootXPath - Optional absolute XPath to focus the crawl on a subtree across frames.
97
- * @returns A Promise resolving to CombinedA11yResult with combined tree text, xpath map, and URL map.
98
- */
99
- export declare function getAccessibilityTreeWithFrames(experimental: boolean, stagehandPage: StagehandPage, logger: (l: LogLine) => void, rootXPath?: string): Promise<CombinedA11yResult>;
100
- /**
101
- * `findScrollableElementIds` is a function that identifies elements in
102
- * the browser that are deemed "scrollable". At a high level, it does the
103
- * following:
104
- * - Calls the browser-side `window.getScrollableElementXpaths()` function,
105
- * which returns a list of XPaths for scrollable containers.
106
- * - Iterates over the returned list of XPaths, locating each element in the DOM
107
- * using `stagehandPage.sendCDP(...)`
108
- * - During each iteration, we call `Runtime.evaluate` to run `document.evaluate(...)`
109
- * with each XPath, obtaining a `RemoteObject` reference if it exists.
110
- * - Then, for each valid object reference, we call `DOM.describeNode` to retrieve
111
- * the element’s `backendNodeId`.
112
- * - Collects all resulting `backendNodeId`s in a Set and returns them.
113
- *
114
- * @param stagehandPage - A StagehandPage instance with built-in CDP helpers.
115
- * @returns A Promise that resolves to a Set of unique `backendNodeId`s corresponding
116
- * to scrollable elements in the DOM.
117
- */
118
- export declare function findScrollableElementIds(stagehandPage: StagehandPage, targetFrame?: Frame): Promise<Set<number>>;
119
- /**
120
- * Resolve an XPath to a Chrome-DevTools-Protocol (CDP) remote-object ID.
121
- *
122
- * @param page A StagehandPage (or Playwright.Page with .sendCDP)
123
- * @param xpath An absolute or relative XPath
124
- * @returns The remote objectId for the matched node, or null
125
- */
126
- export declare function resolveObjectIdForXPath(page: StagehandPage, xpath: string, targetFrame?: Frame): Promise<string | null>;
127
- /**
128
- * Resolve a chain of iframe frames from an absolute XPath, returning the frame sequence and inner XPath.
129
- *
130
- * This helper walks an XPath expression containing iframe steps (e.g., '/html/body/iframe[2]/...'),
131
- * descending into each matching iframe element to build a frame chain, and returns the leftover
132
- * XPath segment to evaluate within the context of the last iframe.
133
- *
134
- * @param sp - The StagehandPage instance for evaluating XPath and locating frames.
135
- * @param absPath - An absolute XPath expression starting with '/', potentially including iframe steps.
136
- * @returns An object containing:
137
- * frames: Array of Frame objects representing each iframe in the chain.
138
- * rest: The remaining XPath string to evaluate inside the final iframe.
139
- * @throws Error if an iframe cannot be found or the final XPath cannot be resolved.
140
- */
141
- export declare function resolveFrameChain(sp: StagehandPage, absPath: string): Promise<{
142
- frames: Frame[];
143
- rest: string;
144
- }>;
@@ -1,20 +0,0 @@
1
- import { AgentAction, AgentResult, AgentType, AgentExecutionOptions } from "@/types/agent";
2
- import { ToolSet } from "ai/dist";
3
- /**
4
- * Abstract base class for agent clients
5
- * This provides a common interface for all agent implementations
6
- */
7
- export declare abstract class AgentClient {
8
- type: AgentType;
9
- modelName: string;
10
- clientOptions: Record<string, unknown>;
11
- userProvidedInstructions?: string;
12
- constructor(type: AgentType, modelName: string, userProvidedInstructions?: string);
13
- abstract execute(options: AgentExecutionOptions): Promise<AgentResult>;
14
- abstract captureScreenshot(options?: Record<string, unknown>): Promise<unknown>;
15
- abstract setViewport(width: number, height: number): void;
16
- abstract setCurrentUrl(url: string): void;
17
- abstract setScreenshotProvider(provider: () => Promise<string>): void;
18
- abstract setActionHandler(handler: (action: AgentAction) => Promise<void>): void;
19
- abstract setTools(tools: ToolSet): void;
20
- }
@@ -1,19 +0,0 @@
1
- import { AgentType } from "@/types/agent";
2
- import { LogLine } from "@/types/log";
3
- import { ToolSet } from "ai/dist";
4
- import { AgentClient } from "./AgentClient";
5
- export declare const modelToAgentProviderMap: Record<string, AgentType>;
6
- /**
7
- * Provider for agent clients
8
- * This class is responsible for creating the appropriate agent client
9
- * based on the provider type
10
- */
11
- export declare class AgentProvider {
12
- private logger;
13
- /**
14
- * Create a new agent provider
15
- */
16
- constructor(logger: (message: LogLine) => void);
17
- getClient(modelName: string, clientOptions?: Record<string, unknown>, userProvidedInstructions?: string, tools?: ToolSet): AgentClient;
18
- static getAgentProvider(modelName: string): AgentType;
19
- }
@@ -1,56 +0,0 @@
1
- import { AgentAction, AgentExecutionOptions, AgentResult, AgentType, AnthropicContentBlock, AnthropicMessage, AnthropicToolResult, ToolUseItem } from "@/types/agent";
2
- import { LogLine } from "@/types/log";
3
- import { ToolSet } from "ai";
4
- import { AgentClient } from "./AgentClient";
5
- export type ResponseInputItem = AnthropicMessage | AnthropicToolResult;
6
- /**
7
- * Client for Anthropic's Computer Use API
8
- * This implementation uses the official Anthropic Messages API for Computer Use
9
- */
10
- export declare class AnthropicCUAClient extends AgentClient {
11
- private apiKey;
12
- private baseURL?;
13
- private client;
14
- lastMessageId?: string;
15
- private currentViewport;
16
- private currentUrl?;
17
- private screenshotProvider?;
18
- private actionHandler?;
19
- private thinkingBudget;
20
- private tools?;
21
- constructor(type: AgentType, modelName: string, userProvidedInstructions?: string, clientOptions?: Record<string, unknown>, tools?: ToolSet);
22
- setViewport(width: number, height: number): void;
23
- setCurrentUrl(url: string): void;
24
- setScreenshotProvider(provider: () => Promise<string>): void;
25
- setActionHandler(handler: (action: AgentAction) => Promise<void>): void;
26
- setTools(tools: ToolSet): void;
27
- /**
28
- * Execute a task with the Anthropic CUA
29
- * This is the main entry point for the agent
30
- * @implements AgentClient.execute
31
- */
32
- execute(executionOptions: AgentExecutionOptions): Promise<AgentResult>;
33
- executeStep(inputItems: ResponseInputItem[], logger: (message: LogLine) => void): Promise<{
34
- actions: AgentAction[];
35
- message: string;
36
- completed: boolean;
37
- nextInputItems: ResponseInputItem[];
38
- usage: {
39
- input_tokens: number;
40
- output_tokens: number;
41
- inference_time_ms: number;
42
- };
43
- }>;
44
- private createInitialInputItems;
45
- getAction(inputItems: ResponseInputItem[]): Promise<{
46
- content: AnthropicContentBlock[];
47
- id: string;
48
- usage: Record<string, number>;
49
- }>;
50
- takeAction(toolUseItems: ToolUseItem[], logger: (message: LogLine) => void): Promise<AnthropicToolResult[]>;
51
- private convertToolUseToAction;
52
- captureScreenshot(options?: {
53
- base64Image?: string;
54
- currentUrl?: string;
55
- }): Promise<string>;
56
- }
@@ -1,63 +0,0 @@
1
- import { LogLine } from "../../types/log";
2
- import { AgentAction, AgentResult, AgentType, AgentExecutionOptions } from "@/types/agent";
3
- import { AgentClient } from "./AgentClient";
4
- /**
5
- * Client for Google's Computer Use Assistant API
6
- * This implementation uses the Google Generative AI SDK for Computer Use
7
- */
8
- export declare class GoogleCUAClient extends AgentClient {
9
- private apiKey;
10
- private client;
11
- private currentViewport;
12
- private currentUrl?;
13
- private screenshotProvider?;
14
- private actionHandler?;
15
- private history;
16
- private environment;
17
- private generateContentConfig;
18
- constructor(type: AgentType, modelName: string, userProvidedInstructions?: string, clientOptions?: Record<string, unknown>);
19
- setViewport(width: number, height: number): void;
20
- setCurrentUrl(url: string): void;
21
- setScreenshotProvider(provider: () => Promise<string>): void;
22
- setActionHandler(handler: (action: AgentAction) => Promise<void>): void;
23
- setTools(): void;
24
- /**
25
- * Execute a task with the Google CUA
26
- * This is the main entry point for the agent
27
- * @implements AgentClient.execute
28
- */
29
- execute(executionOptions: AgentExecutionOptions): Promise<AgentResult>;
30
- /**
31
- * Initialize conversation history with the initial instruction
32
- */
33
- private initializeHistory;
34
- /**
35
- * Execute a single step of the agent
36
- */
37
- executeStep(logger: (message: LogLine) => void): Promise<{
38
- actions: AgentAction[];
39
- message: string;
40
- completed: boolean;
41
- usage: {
42
- input_tokens: number;
43
- output_tokens: number;
44
- inference_time_ms: number;
45
- };
46
- }>;
47
- /**
48
- * Process the response from Google's API
49
- */
50
- private processResponse;
51
- /**
52
- * Convert Google function call to Stagehand action
53
- */
54
- private convertFunctionCallToAction;
55
- /**
56
- * Normalize coordinates from Google's 0-1000 range to actual viewport dimensions
57
- */
58
- private normalizeCoordinates;
59
- captureScreenshot(options?: {
60
- base64Image?: string;
61
- currentUrl?: string;
62
- }): Promise<string>;
63
- }
@@ -1,65 +0,0 @@
1
- import { LogLine } from "../../types/log";
2
- import { AgentAction, AgentResult, AgentType, AgentExecutionOptions, ResponseInputItem, ResponseItem } from "@/types/agent";
3
- import { AgentClient } from "./AgentClient";
4
- import { ToolSet } from "ai/dist";
5
- /**
6
- * Client for OpenAI's Computer Use Assistant API
7
- * This implementation uses the official OpenAI Responses API for Computer Use
8
- */
9
- export declare class OpenAICUAClient extends AgentClient {
10
- private apiKey;
11
- private organization?;
12
- private baseURL;
13
- private client;
14
- lastResponseId?: string;
15
- private currentViewport;
16
- private currentUrl?;
17
- private screenshotProvider?;
18
- private actionHandler?;
19
- private reasoningItems;
20
- private environment;
21
- private tools?;
22
- constructor(type: AgentType, modelName: string, userProvidedInstructions?: string, clientOptions?: Record<string, unknown>, tools?: ToolSet);
23
- setViewport(width: number, height: number): void;
24
- setCurrentUrl(url: string): void;
25
- setScreenshotProvider(provider: () => Promise<string>): void;
26
- setActionHandler(handler: (action: AgentAction) => Promise<void>): void;
27
- setTools(tools: ToolSet): void;
28
- /**
29
- * Execute a task with the OpenAI CUA
30
- * This is the main entry point for the agent
31
- * @implements AgentClient.execute
32
- */
33
- execute(executionOptions: AgentExecutionOptions): Promise<AgentResult>;
34
- /**
35
- * Execute a single step of the agent
36
- * This coordinates the flow: Request → Get Action → Execute Action
37
- */
38
- executeStep(inputItems: ResponseInputItem[], previousResponseId: string | undefined, logger: (message: LogLine) => void): Promise<{
39
- actions: AgentAction[];
40
- message: string;
41
- completed: boolean;
42
- nextInputItems: ResponseInputItem[];
43
- responseId: string;
44
- usage: {
45
- input_tokens: number;
46
- output_tokens: number;
47
- inference_time_ms: number;
48
- };
49
- }>;
50
- private isComputerCallItem;
51
- private isFunctionCallItem;
52
- private createInitialInputItems;
53
- getAction(inputItems: ResponseInputItem[], previousResponseId?: string): Promise<{
54
- output: ResponseItem[];
55
- responseId: string;
56
- usage: Record<string, number>;
57
- }>;
58
- takeAction(output: ResponseItem[], logger: (message: LogLine) => void): Promise<ResponseInputItem[]>;
59
- private convertComputerCallToAction;
60
- private convertFunctionCallToAction;
61
- captureScreenshot(options?: {
62
- base64Image?: string;
63
- currentUrl?: string;
64
- }): Promise<string>;
65
- }
@@ -1,15 +0,0 @@
1
- import { LogLine } from "@/types/log";
2
- import { AgentExecuteOptions, AgentResult } from "@/types/agent";
3
- import { AgentClient } from "./AgentClient";
4
- /**
5
- * Main interface for agent operations in Stagehand
6
- * This class provides methods for executing tasks with an agent
7
- */
8
- export declare class StagehandAgent {
9
- private client;
10
- private logger;
11
- constructor(client: AgentClient, logger: (message: LogLine) => void);
12
- execute(optionsOrInstruction: AgentExecuteOptions | string): Promise<AgentResult>;
13
- getModelName(): string;
14
- getAgentType(): string;
15
- }
@@ -1,59 +0,0 @@
1
- import { z } from "zod/v3";
2
- import { Stagehand } from "../../index";
3
- export declare const createActTool: (stagehand: Stagehand, executionModel?: string) => import("ai/dist").Tool<z.ZodObject<{
4
- action: z.ZodString;
5
- }, "strip", z.ZodTypeAny, {
6
- action?: string;
7
- }, {
8
- action?: string;
9
- }>, {
10
- success: boolean;
11
- error: string;
12
- isIframe: boolean;
13
- action?: undefined;
14
- playwrightArguments?: undefined;
15
- } | {
16
- success: boolean;
17
- action: string;
18
- isIframe: boolean;
19
- playwrightArguments: {
20
- description: string;
21
- method: string;
22
- arguments: string[];
23
- selector: string;
24
- };
25
- error?: undefined;
26
- } | {
27
- success: boolean;
28
- error: any;
29
- isIframe?: undefined;
30
- action?: undefined;
31
- playwrightArguments?: undefined;
32
- }> & {
33
- execute: (args: {
34
- action?: string;
35
- }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
36
- success: boolean;
37
- error: string;
38
- isIframe: boolean;
39
- action?: undefined;
40
- playwrightArguments?: undefined;
41
- } | {
42
- success: boolean;
43
- action: string;
44
- isIframe: boolean;
45
- playwrightArguments: {
46
- description: string;
47
- method: string;
48
- arguments: string[];
49
- selector: string;
50
- };
51
- error?: undefined;
52
- } | {
53
- success: boolean;
54
- error: any;
55
- isIframe?: undefined;
56
- action?: undefined;
57
- playwrightArguments?: undefined;
58
- }>;
59
- };
@@ -1,11 +0,0 @@
1
- import { z } from "zod/v3";
2
- import { Stagehand } from "../../index";
3
- export declare const createAriaTreeTool: (stagehand: Stagehand) => import("ai/dist").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {
4
- content: string;
5
- pageUrl: string;
6
- }> & {
7
- execute: (args: {}, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
8
- content: string;
9
- pageUrl: string;
10
- }>;
11
- };
@@ -1,22 +0,0 @@
1
- import { z } from "zod/v3";
2
- export declare const createCloseTool: () => import("ai/dist").Tool<z.ZodObject<{
3
- reasoning: z.ZodString;
4
- success: z.ZodBoolean;
5
- }, "strip", z.ZodTypeAny, {
6
- reasoning?: string;
7
- success?: boolean;
8
- }, {
9
- reasoning?: string;
10
- success?: boolean;
11
- }>, {
12
- success: boolean;
13
- reasoning: string;
14
- }> & {
15
- execute: (args: {
16
- reasoning?: string;
17
- success?: boolean;
18
- }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
19
- success: boolean;
20
- reasoning: string;
21
- }>;
22
- };
@@ -1,38 +0,0 @@
1
- import { z } from "zod/v3";
2
- import { Stagehand } from "../../index";
3
- import { LogLine } from "@/types/log";
4
- export declare const createExtractTool: (stagehand: Stagehand, executionModel?: string, logger?: (message: LogLine) => void) => import("ai/dist").Tool<z.ZodObject<{
5
- instruction: z.ZodString;
6
- schema: z.ZodString;
7
- }, "strip", z.ZodTypeAny, {
8
- schema?: string;
9
- instruction?: string;
10
- }, {
11
- schema?: string;
12
- instruction?: string;
13
- }>, {
14
- success: boolean;
15
- data: any;
16
- timestamp: number;
17
- error?: undefined;
18
- } | {
19
- success: boolean;
20
- error: string;
21
- timestamp: number;
22
- data?: undefined;
23
- }> & {
24
- execute: (args: {
25
- schema?: string;
26
- instruction?: string;
27
- }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
28
- success: boolean;
29
- data: any;
30
- timestamp: number;
31
- error?: undefined;
32
- } | {
33
- success: boolean;
34
- error: string;
35
- timestamp: number;
36
- data?: undefined;
37
- }>;
38
- };
@@ -1,37 +0,0 @@
1
- import { z } from "zod/v3";
2
- import { Stagehand } from "../../index";
3
- export declare const createFillFormTool: (stagehand: Stagehand, executionModel?: string) => import("ai/dist").Tool<z.ZodObject<{
4
- fields: z.ZodArray<z.ZodObject<{
5
- action: z.ZodString;
6
- value: z.ZodString;
7
- }, "strip", z.ZodTypeAny, {
8
- value?: string;
9
- action?: string;
10
- }, {
11
- value?: string;
12
- action?: string;
13
- }>, "many">;
14
- }, "strip", z.ZodTypeAny, {
15
- fields?: {
16
- value?: string;
17
- action?: string;
18
- }[];
19
- }, {
20
- fields?: {
21
- value?: string;
22
- action?: string;
23
- }[];
24
- }>, {
25
- success: boolean;
26
- actions: import("@/types/stagehand").ActResult[];
27
- }> & {
28
- execute: (args: {
29
- fields?: {
30
- value?: string;
31
- action?: string;
32
- }[];
33
- }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
34
- success: boolean;
35
- actions: import("@/types/stagehand").ActResult[];
36
- }>;
37
- };
@@ -1,29 +0,0 @@
1
- import { z } from "zod/v3";
2
- import { Stagehand } from "../../index";
3
- export declare const createGotoTool: (stagehand: Stagehand) => import("ai/dist").Tool<z.ZodObject<{
4
- url: z.ZodString;
5
- }, "strip", z.ZodTypeAny, {
6
- url?: string;
7
- }, {
8
- url?: string;
9
- }>, {
10
- success: boolean;
11
- url: string;
12
- error?: undefined;
13
- } | {
14
- success: boolean;
15
- error: any;
16
- url?: undefined;
17
- }> & {
18
- execute: (args: {
19
- url?: string;
20
- }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
21
- success: boolean;
22
- url: string;
23
- error?: undefined;
24
- } | {
25
- success: boolean;
26
- error: any;
27
- url?: undefined;
28
- }>;
29
- };