@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,20 +0,0 @@
1
- import { ClientOptions } from "openai";
2
- import { LogLine } from "../../types/log";
3
- import { AvailableModel } from "../../types/model";
4
- import { LLMCache } from "../cache/LLMCache";
5
- import { CreateChatCompletionOptions, LLMClient, LLMResponse } from "./LLMClient";
6
- export declare class OpenAIClient extends LLMClient {
7
- type: "openai";
8
- private client;
9
- private cache;
10
- private enableCaching;
11
- clientOptions: ClientOptions;
12
- constructor({ enableCaching, cache, modelName, clientOptions, }: {
13
- logger: (message: LogLine) => void;
14
- enableCaching?: boolean;
15
- cache?: LLMCache;
16
- modelName: AvailableModel;
17
- clientOptions?: ClientOptions;
18
- });
19
- createChatCompletion<T = LLMResponse>({ options: optionsInitial, logger, retries, }: CreateChatCompletionOptions): Promise<T>;
20
- }
@@ -1,20 +0,0 @@
1
- import { LanguageModel } from "ai";
2
- import { ChatCompletion } from "openai/resources";
3
- import { LogLine } from "../../types/log";
4
- import { LLMCache } from "../cache/LLMCache";
5
- import { CreateChatCompletionOptions, LLMClient } from "./LLMClient";
6
- export declare class AISdkClient extends LLMClient {
7
- type: "aisdk";
8
- private model;
9
- private logger?;
10
- private cache;
11
- private enableCaching;
12
- constructor({ model, logger, enableCaching, cache, }: {
13
- model: LanguageModel;
14
- logger?: (message: LogLine) => void;
15
- enableCaching?: boolean;
16
- cache?: LLMCache;
17
- });
18
- getLanguageModel(): LanguageModel;
19
- createChatCompletion<T = ChatCompletion>({ options, }: CreateChatCompletionOptions): Promise<T>;
20
- }
@@ -1,54 +0,0 @@
1
- import pino from "pino";
2
- import { LogLine } from "../types/log";
3
- export interface LoggerOptions {
4
- pretty?: boolean;
5
- level?: pino.Level;
6
- destination?: pino.DestinationStream;
7
- usePino?: boolean;
8
- }
9
- /**
10
- * Creates a configured Pino logger instance
11
- */
12
- export declare function createLogger(options?: LoggerOptions): pino.Logger<never, boolean>;
13
- /**
14
- * StagehandLogger class that wraps Pino for our specific needs
15
- */
16
- export declare class StagehandLogger {
17
- /**
18
- * We maintain a single shared Pino instance when `usePino` is enabled.
19
- * This prevents spawning a new worker thread for every Stagehand instance
20
- * (which happens when `pino-pretty` transport is used), eliminating the
21
- * memory/RSS growth observed when many Stagehand objects are created and
22
- * disposed within the same process (e.g. a request-per-instance API).
23
- */
24
- private static sharedPinoLogger;
25
- private logger?;
26
- private verbose;
27
- private externalLogger?;
28
- private usePino;
29
- private isTest;
30
- constructor(options?: LoggerOptions, externalLogger?: (logLine: LogLine) => void);
31
- /**
32
- * Set the verbosity level
33
- */
34
- setVerbosity(level: 0 | 1 | 2): void;
35
- /**
36
- * Log a message using our LogLine format
37
- */
38
- log(logLine: LogLine): void;
39
- /**
40
- * Helper to format auxiliary data for structured logging
41
- */
42
- private formatAuxiliaryData;
43
- /**
44
- * Convenience methods for different log levels
45
- */
46
- error(message: string, data?: Record<string, unknown>): void;
47
- warn(message: string, data?: Record<string, unknown>): void;
48
- info(message: string, data?: Record<string, unknown>): void;
49
- debug(message: string, data?: Record<string, unknown>): void;
50
- /**
51
- * Convert a plain object to our auxiliary format
52
- */
53
- private convertToAuxiliary;
54
- }
@@ -1,11 +0,0 @@
1
- import { Client, ClientOptions } from "@modelcontextprotocol/sdk/client/index.js";
2
- export interface ConnectToMCPServerOptions {
3
- serverUrl: string | URL;
4
- clientOptions?: ClientOptions;
5
- }
6
- export interface StdioServerConfig {
7
- command: string;
8
- args?: string[];
9
- env?: Record<string, string>;
10
- }
11
- export declare const connectToMCPServer: (serverConfig: string | URL | StdioServerConfig | ConnectToMCPServerOptions) => Promise<Client>;
@@ -1,3 +0,0 @@
1
- import { Client } from "@modelcontextprotocol/sdk/dist/esm/client";
2
- import { ToolSet } from "ai/dist";
3
- export declare const resolveTools: (clients: (Client | string)[], userTools: ToolSet) => Promise<ToolSet>;
@@ -1,14 +0,0 @@
1
- import { ChatMessage } from "./llm/LLMClient";
2
- export declare function buildUserInstructionsString(userProvidedInstructions?: string): string;
3
- export declare function buildExtractSystemPrompt(isUsingPrintExtractedDataTool?: boolean, userProvidedInstructions?: string): ChatMessage;
4
- export declare function buildExtractUserPrompt(instruction: string, domElements: string, isUsingPrintExtractedDataTool?: boolean): ChatMessage;
5
- export declare function buildMetadataSystemPrompt(): ChatMessage;
6
- export declare function buildMetadataPrompt(instruction: string, extractionResponse: object, chunksSeen: number, chunksTotal: number): ChatMessage;
7
- export declare function buildObserveSystemPrompt(userProvidedInstructions?: string): ChatMessage;
8
- export declare function buildObserveUserMessage(instruction: string, domElements: string): ChatMessage;
9
- /**
10
- * Builds the instruction for the observeAct method to find the most relevant element for an action
11
- */
12
- export declare function buildActObservePrompt(action: string, supportedActions: string[], variables?: Record<string, string>): string;
13
- export declare function buildOperatorSystemPrompt(goal: string): ChatMessage;
14
- export declare function buildGoogleCUASystemPrompt(): ChatMessage;
@@ -1,68 +0,0 @@
1
- import { Schema } from "@google/genai";
2
- import { z, ZodTypeAny } from "zod/v3";
3
- import { ObserveResult, Page } from ".";
4
- import { LogLine } from "../types/log";
5
- import { ModelProvider } from "../types/model";
6
- import { ZodPathSegments } from "../types/stagehand";
7
- export declare function validateZodSchema(schema: z.ZodTypeAny, data: unknown): boolean;
8
- export declare function drawObserveOverlay(page: Page, results: ObserveResult[]): Promise<void>;
9
- export declare function clearOverlays(page: Page): Promise<void>;
10
- /**
11
- * Detects if the code is running in the Bun runtime environment.
12
- * @returns {boolean} True if running in Bun, false otherwise.
13
- */
14
- export declare function isRunningInBun(): boolean;
15
- export declare function toGeminiSchema(zodSchema: z.ZodTypeAny): Schema;
16
- export declare function getZodType(schema: z.ZodTypeAny): string;
17
- /**
18
- * Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`.
19
- * For each such field, it replaces the `z.string().url()` with `z.number()`.
20
- *
21
- * This function is used internally by higher-level utilities (e.g., transforming entire object schemas)
22
- * and handles nested objects, arrays, unions, intersections, optionals.
23
- *
24
- * @param schema - The Zod schema to transform.
25
- * @param currentPath - An array of string/number keys representing the current schema path (used internally for recursion).
26
- * @returns A two-element tuple:
27
- * 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`.
28
- * 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments.
29
- */
30
- export declare function transformSchema(schema: z.ZodTypeAny, currentPath: Array<string | number>): [z.ZodTypeAny, ZodPathSegments[]];
31
- /**
32
- * Once we get the final extracted object that has numeric IDs in place of URLs,
33
- * use `injectUrls` to walk the object and replace numeric IDs
34
- * with the real URL strings from idToUrlMapping. The `path` may include `*`
35
- * for array indices (indicating "all items in the array").
36
- */
37
- export declare function injectUrls(obj: unknown, path: Array<string | number>, idToUrlMapping: Record<string, string>): void;
38
- /**
39
- * Mapping from LLM provider names to their corresponding environment variable names for API keys.
40
- */
41
- export declare const providerEnvVarMap: Partial<Record<ModelProvider | string, string>>;
42
- /**
43
- * Loads an API key for a provider, checking environment variables.
44
- * @param provider The name of the provider (e.g., 'openai', 'anthropic')
45
- * @param logger Optional logger for info/error messages
46
- * @returns The API key if found, undefined otherwise
47
- */
48
- export declare function loadApiKeyFromEnv(provider: string | undefined, logger: (logLine: LogLine) => void): string | undefined;
49
- export declare function trimTrailingTextNode(path: string | undefined): string | undefined;
50
- export interface JsonSchemaProperty {
51
- type: string;
52
- enum?: unknown[];
53
- items?: JsonSchemaProperty;
54
- properties?: Record<string, JsonSchemaProperty>;
55
- required?: string[];
56
- minimum?: number;
57
- maximum?: number;
58
- description?: string;
59
- }
60
- export interface JsonSchema extends JsonSchemaProperty {
61
- type: string;
62
- }
63
- /**
64
- * Converts a JSON Schema object to a Zod schema
65
- * @param schema The JSON Schema object to convert
66
- * @returns A Zod schema equivalent to the input JSON Schema
67
- */
68
- export declare function jsonSchemaToZod(schema: JsonSchema): ZodTypeAny;
@@ -1,5 +0,0 @@
1
- /**
2
- * AUTO-GENERATED — DO NOT EDIT BY HAND
3
- * Run `pnpm run gen-version` to refresh.
4
- */
5
- export declare const STAGEHAND_VERSION: "2.5.3-alpha-4994eabfa8016347ec001b40ceadb0c905403470";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import type { ConstructorParams } from "@/dist";
2
- declare const StagehandConfig: ConstructorParams;
3
- export default StagehandConfig;
@@ -1,50 +0,0 @@
1
- import { LLMClient } from "../lib/llm/LLMClient";
2
- import { Locator } from "playwright";
3
- import { Logger } from "@/types/log";
4
- import { StagehandPage } from "@/lib/StagehandPage";
5
- export interface ActCommandParams {
6
- action: string;
7
- steps?: string;
8
- domElements: string;
9
- llmClient: LLMClient;
10
- retries?: number;
11
- logger: (message: {
12
- category?: string;
13
- message: string;
14
- }) => void;
15
- requestId: string;
16
- variables?: Record<string, string>;
17
- userProvidedInstructions?: string;
18
- }
19
- export interface ActCommandResult {
20
- method: string;
21
- element: number;
22
- args: unknown[];
23
- completed: boolean;
24
- step: string;
25
- why?: string;
26
- }
27
- export declare enum SupportedPlaywrightAction {
28
- CLICK = "click",
29
- FILL = "fill",
30
- TYPE = "type",
31
- PRESS = "press",
32
- SCROLL = "scrollTo",
33
- NEXT_CHUNK = "nextChunk",
34
- PREV_CHUNK = "prevChunk",
35
- SELECT_OPTION_FROM_DROPDOWN = "selectOptionFromDropdown"
36
- }
37
- /**
38
- * A context object to hold all parameters that might be needed by
39
- * any of the methods in the `methodHandlerMap`
40
- */
41
- export interface MethodHandlerContext {
42
- method: string;
43
- locator: Locator;
44
- xpath: string;
45
- args: unknown[];
46
- logger: Logger;
47
- stagehandPage: StagehandPage;
48
- initialUrl: string;
49
- domSettleTimeoutMs?: number;
50
- }
@@ -1,144 +0,0 @@
1
- import { LogLine } from "./log";
2
- import { ObserveResult } from "./stagehand";
3
- export interface ActToolResult {
4
- success: boolean;
5
- action?: string;
6
- error?: string;
7
- isIframe?: boolean;
8
- playwrightArguments?: ObserveResult | null;
9
- }
10
- export interface AgentAction {
11
- type: string;
12
- reasoning?: string;
13
- taskCompleted?: boolean;
14
- action?: string;
15
- timeMs?: number;
16
- pageText?: string;
17
- timestamp?: number;
18
- pageUrl?: string;
19
- instruction?: string;
20
- playwrightArguments?: ObserveResult | null;
21
- [key: string]: unknown;
22
- }
23
- export interface AgentResult {
24
- success: boolean;
25
- message: string;
26
- actions: AgentAction[];
27
- completed: boolean;
28
- metadata?: Record<string, unknown>;
29
- usage?: {
30
- input_tokens: number;
31
- output_tokens: number;
32
- inference_time_ms: number;
33
- };
34
- }
35
- export interface AgentOptions {
36
- maxSteps?: number;
37
- autoScreenshot?: boolean;
38
- waitBetweenActions?: number;
39
- context?: string;
40
- highlightCursor?: boolean;
41
- }
42
- export interface AgentExecuteOptions extends AgentOptions {
43
- instruction: string;
44
- }
45
- export type AgentProviderType = "openai" | "anthropic" | "google";
46
- export interface AgentClientOptions {
47
- apiKey: string;
48
- organization?: string;
49
- baseURL?: string;
50
- defaultMaxSteps?: number;
51
- [key: string]: unknown;
52
- }
53
- export type AgentType = "openai" | "anthropic" | "google";
54
- export interface AgentExecutionOptions {
55
- options: AgentExecuteOptions;
56
- logger: (message: LogLine) => void;
57
- retries?: number;
58
- }
59
- export interface AgentHandlerOptions {
60
- modelName: string;
61
- clientOptions?: Record<string, unknown>;
62
- userProvidedInstructions?: string;
63
- agentType: AgentType;
64
- experimental?: boolean;
65
- }
66
- export interface ActionExecutionResult {
67
- success: boolean;
68
- error?: string;
69
- data?: unknown;
70
- }
71
- export interface ToolUseItem extends ResponseItem {
72
- type: "tool_use";
73
- id: string;
74
- name: string;
75
- input: Record<string, unknown>;
76
- }
77
- export interface AnthropicMessage {
78
- role: string;
79
- content: string | Array<AnthropicContentBlock>;
80
- }
81
- export interface AnthropicContentBlock {
82
- type: string;
83
- [key: string]: unknown;
84
- }
85
- export interface AnthropicTextBlock extends AnthropicContentBlock {
86
- type: "text";
87
- text: string;
88
- }
89
- export interface AnthropicToolResult {
90
- type: "tool_result";
91
- tool_use_id: string;
92
- content: string | Array<AnthropicContentBlock>;
93
- }
94
- export interface ResponseItem {
95
- type: string;
96
- id: string;
97
- [key: string]: unknown;
98
- }
99
- export interface ComputerCallItem extends ResponseItem {
100
- type: "computer_call";
101
- call_id: string;
102
- action: {
103
- type: string;
104
- [key: string]: unknown;
105
- };
106
- pending_safety_checks?: Array<{
107
- id: string;
108
- code: string;
109
- message: string;
110
- }>;
111
- }
112
- export interface FunctionCallItem extends ResponseItem {
113
- type: "function_call";
114
- call_id: string;
115
- name: string;
116
- arguments: string;
117
- }
118
- export type ResponseInputItem = {
119
- role: string;
120
- content: string;
121
- } | {
122
- type: "computer_call_output";
123
- call_id: string;
124
- output: {
125
- type: "input_image";
126
- image_url: string;
127
- current_url?: string;
128
- error?: string;
129
- [key: string]: unknown;
130
- } | string;
131
- acknowledged_safety_checks?: Array<{
132
- id: string;
133
- code: string;
134
- message: string;
135
- }>;
136
- } | {
137
- type: "function_call_output";
138
- call_id: string;
139
- output: string;
140
- };
141
- export interface AgentInstance {
142
- execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
143
- setScreenshotCollector?: (collector: unknown) => void;
144
- }
@@ -1,40 +0,0 @@
1
- import Browserbase from "@browserbasehq/sdk";
2
- import { LogLine } from "./log";
3
- export interface StagehandAPIConstructorParams {
4
- apiKey: string;
5
- projectId: string;
6
- logger: (message: LogLine) => void;
7
- }
8
- export interface ExecuteActionParams {
9
- method: "act" | "extract" | "observe" | "navigate" | "end" | "agentExecute";
10
- args?: unknown;
11
- params?: unknown;
12
- }
13
- export interface StartSessionParams {
14
- modelName: string;
15
- modelApiKey: string;
16
- domSettleTimeoutMs: number;
17
- verbose: number;
18
- debugDom: boolean;
19
- systemPrompt?: string;
20
- browserbaseSessionCreateParams?: Omit<Browserbase.Sessions.SessionCreateParams, "projectId"> & {
21
- projectId?: string;
22
- };
23
- selfHeal?: boolean;
24
- waitForCaptchaSolves?: boolean;
25
- actionTimeoutMs?: number;
26
- browserbaseSessionID?: string;
27
- }
28
- export interface StartSessionResult {
29
- sessionId: string;
30
- available?: boolean;
31
- }
32
- export interface SuccessResponse<T> {
33
- success: true;
34
- data: T;
35
- }
36
- export interface ErrorResponse {
37
- success: false;
38
- message: string;
39
- }
40
- export type ApiResponse<T> = SuccessResponse<T> | ErrorResponse;
@@ -1,10 +0,0 @@
1
- import { Browser, BrowserContext } from "./page";
2
- export interface BrowserResult {
3
- env: "LOCAL" | "BROWSERBASE";
4
- browser?: Browser;
5
- context: BrowserContext;
6
- debugUrl?: string;
7
- sessionUrl?: string;
8
- contextPath?: string;
9
- sessionId?: string;
10
- }
@@ -1,117 +0,0 @@
1
- import type { BrowserContext as PlaywrightContext, Frame } from "playwright";
2
- import { Page } from "../types/page";
3
- export interface AXNode {
4
- role?: {
5
- value: string;
6
- };
7
- name?: {
8
- value: string;
9
- };
10
- description?: {
11
- value: string;
12
- };
13
- value?: {
14
- value: string;
15
- };
16
- nodeId: string;
17
- backendDOMNodeId?: number;
18
- parentId?: string;
19
- childIds?: string[];
20
- properties?: {
21
- name: string;
22
- value: {
23
- type: string;
24
- value?: string;
25
- };
26
- }[];
27
- }
28
- export type AccessibilityNode = {
29
- role: string;
30
- name?: string;
31
- description?: string;
32
- value?: string;
33
- children?: AccessibilityNode[];
34
- childIds?: string[];
35
- parentId?: string;
36
- nodeId?: string;
37
- backendDOMNodeId?: number;
38
- properties?: {
39
- name: string;
40
- value: {
41
- type: string;
42
- value?: string;
43
- };
44
- }[];
45
- };
46
- export interface TreeResult {
47
- tree: AccessibilityNode[];
48
- simplified: string;
49
- iframes?: AccessibilityNode[];
50
- idToUrl: Record<EncodedId, string>;
51
- xpathMap: Record<EncodedId, string>;
52
- }
53
- export type DOMNode = {
54
- backendNodeId?: number;
55
- nodeName?: string;
56
- children?: DOMNode[];
57
- shadowRoots?: DOMNode[];
58
- contentDocument?: DOMNode;
59
- nodeType: number;
60
- frameId?: string;
61
- };
62
- export type BackendIdMaps = {
63
- tagNameMap: Record<number, string>;
64
- xpathMap: Record<number, string>;
65
- iframeXPath?: string;
66
- };
67
- export interface EnhancedContext extends Omit<PlaywrightContext, "newPage" | "pages"> {
68
- newPage(): Promise<Page>;
69
- pages(): Page[];
70
- }
71
- export type FrameId = string;
72
- export type LoaderId = string;
73
- export interface CdpFrame {
74
- id: FrameId;
75
- parentId?: FrameId;
76
- loaderId: LoaderId;
77
- name?: string;
78
- url: string;
79
- urlFragment?: string;
80
- domainAndRegistry?: string;
81
- securityOrigin: string;
82
- securityOriginDetails?: Record<string, unknown>;
83
- mimeType: string;
84
- unreachableUrl?: string;
85
- adFrameStatus?: string;
86
- secureContextType?: string;
87
- crossOriginIsolatedContextType?: string;
88
- gatedAPIFeatures?: string[];
89
- }
90
- export interface CdpFrameTree {
91
- frame: CdpFrame;
92
- childFrames?: CdpFrameTree[];
93
- }
94
- export interface FrameOwnerResult {
95
- backendNodeId?: number;
96
- }
97
- export interface CombinedA11yResult {
98
- combinedTree: string;
99
- combinedXpathMap: Record<EncodedId, string>;
100
- combinedUrlMap: Record<EncodedId, string>;
101
- }
102
- export interface FrameSnapshot {
103
- frame: Frame;
104
- tree: string;
105
- xpathMap: Record<EncodedId, string>;
106
- urlMap: Record<EncodedId, string>;
107
- frameXpath: string;
108
- backendNodeId: number | null;
109
- parentFrame?: Frame;
110
- /** CDP frame identifier for this snapshot; used to generate stable EncodedIds. */
111
- frameId?: string;
112
- }
113
- export type EncodedId = `${number}-${number}`;
114
- export interface RichNode extends AccessibilityNode {
115
- encodedId?: EncodedId;
116
- }
117
- export declare const ID_PATTERN: RegExp;
@@ -1,95 +0,0 @@
1
- import { z } from "zod/v3";
2
- import type { AvailableModel } from "../types/model";
3
- import type { LogLine } from "../types/log";
4
- import type { AgentInstance } from "../types/agent";
5
- import type { EvalCase } from "braintrust";
6
- import { Stagehand } from "@/dist";
7
- import { ConstructorParams } from "@/dist";
8
- import { EvalLogger } from "@/evals/logger";
9
- export type StagehandInitResult = {
10
- stagehand: Stagehand;
11
- logger: EvalLogger;
12
- debugUrl: string;
13
- sessionUrl: string;
14
- stagehandConfig: ConstructorParams;
15
- modelName: AvailableModel;
16
- agent: AgentInstance;
17
- };
18
- export declare enum ErrorType {
19
- TIMEOUT = "timeout",
20
- NETWORK = "network",
21
- AGENT_FAILURE = "agent_failure",
22
- EVALUATION_ERROR = "evaluation_error",
23
- SETUP_ERROR = "setup_error",
24
- PARSING_ERROR = "parsing_error",
25
- PROXY_ERROR = "proxy_error",
26
- ANTIBOT = "bot_detected",
27
- UNKNOWN = "unknown"
28
- }
29
- export interface EvalOutput {
30
- _success: boolean;
31
- logs: LogLine[];
32
- debugUrl: string;
33
- sessionUrl: string;
34
- error?: unknown;
35
- error_type?: ErrorType;
36
- error_message?: string;
37
- error_stack?: string;
38
- execution_time?: number;
39
- agent_steps?: number;
40
- final_answer?: string;
41
- reasoning?: string;
42
- observations?: string | unknown;
43
- [key: string]: unknown;
44
- }
45
- export type EvalFunction = (taskInput: StagehandInitResult & {
46
- input: EvalInput;
47
- }) => Promise<EvalOutput>;
48
- export declare const EvalCategorySchema: z.ZodEnum<["observe", "act", "combination", "extract", "experimental", "targeted_extract", "regression", "regression_llm_providers", "llm_clients", "agent", "external_agent_benchmarks"]>;
49
- export type EvalCategory = z.infer<typeof EvalCategorySchema>;
50
- export interface EvalInput {
51
- name: string;
52
- modelName: AvailableModel;
53
- params?: Record<string, unknown>;
54
- }
55
- export interface TestcaseMetadata {
56
- model: AvailableModel;
57
- test: string;
58
- category?: string;
59
- dataset?: string;
60
- dataset_id?: string;
61
- dataset_level?: string | number;
62
- dataset_category?: string;
63
- [key: string]: unknown;
64
- }
65
- export interface Testcase extends EvalCase<EvalInput, unknown, TestcaseMetadata> {
66
- input: EvalInput;
67
- name: string;
68
- tags: string[];
69
- metadata: TestcaseMetadata;
70
- expected: unknown;
71
- }
72
- export interface SummaryResult {
73
- input: EvalInput;
74
- output: {
75
- _success: boolean;
76
- };
77
- name: string;
78
- score: number;
79
- }
80
- export interface EvalArgs<TInput, TOutput, TExpected> {
81
- input: TInput;
82
- output: TOutput;
83
- expected: TExpected;
84
- metadata?: {
85
- model: AvailableModel;
86
- test: string;
87
- };
88
- }
89
- export interface EvalResult {
90
- name: string;
91
- score: number;
92
- }
93
- export type LogLineEval = LogLine & {
94
- parsedAuxiliary?: string | object;
95
- };