@browserbasehq/stagehand 1.0.3-alpha.2 → 1.1.0-alpha.1

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 (45) hide show
  1. package/README.md +10 -5
  2. package/dist/dom/build/types.js +2 -0
  3. package/dist/evals/index.eval.js +1075 -0
  4. package/dist/evals/index.eval.js.map +1 -0
  5. package/dist/evals/playground.js +112 -0
  6. package/dist/evals/playground.js.map +1 -0
  7. package/dist/evals/utils.js +52 -0
  8. package/dist/evals/utils.js.map +1 -0
  9. package/dist/examples/2048.js +108 -0
  10. package/dist/examples/2048.js.map +1 -0
  11. package/dist/examples/debugUrl.js +35 -0
  12. package/dist/examples/debugUrl.js.map +1 -0
  13. package/dist/examples/example.js +37 -0
  14. package/dist/examples/example.js.map +1 -0
  15. package/dist/index.d.ts +25 -6
  16. package/dist/index.js +666 -151
  17. package/dist/lib/browserbase.js +56 -0
  18. package/dist/lib/browserbase.js.map +1 -0
  19. package/dist/lib/cache.js +78 -0
  20. package/dist/lib/cache.js.map +1 -0
  21. package/dist/lib/dom/debug.js +119 -0
  22. package/dist/lib/dom/debug.js.map +1 -0
  23. package/dist/lib/dom/index.js +20 -0
  24. package/dist/lib/dom/index.js.map +1 -0
  25. package/dist/lib/dom/process.js +396 -0
  26. package/dist/lib/dom/process.js.map +1 -0
  27. package/dist/lib/dom/utils.js +28 -0
  28. package/dist/lib/dom/utils.js.map +1 -0
  29. package/dist/lib/index.js +978 -0
  30. package/dist/lib/index.js.map +1 -0
  31. package/dist/lib/inference.js +226 -0
  32. package/dist/lib/inference.js.map +1 -0
  33. package/dist/lib/llm/AnthropicClient.js +150 -0
  34. package/dist/lib/llm/AnthropicClient.js.map +1 -0
  35. package/dist/lib/llm/LLMClient.js +12 -0
  36. package/dist/lib/llm/LLMClient.js.map +1 -0
  37. package/dist/lib/llm/LLMProvider.js +34 -0
  38. package/dist/lib/llm/LLMProvider.js.map +1 -0
  39. package/dist/lib/llm/OpenAIClient.js +69 -0
  40. package/dist/lib/llm/OpenAIClient.js.map +1 -0
  41. package/dist/lib/prompt.js +288 -0
  42. package/dist/lib/prompt.js.map +1 -0
  43. package/dist/lib/vision.js +194 -0
  44. package/dist/lib/vision.js.map +1 -0
  45. package/package.json +2 -1
package/README.md CHANGED
@@ -101,6 +101,7 @@ import { z } from "zod";
101
101
 
102
102
  const stagehand = new Stagehand({
103
103
  env: "BROWSERBASE",
104
+ enableCaching: true,
104
105
  });
105
106
  ```
106
107
 
@@ -136,7 +137,8 @@ This constructor is used to create an instance of Stagehand.
136
137
  - `1`: SDK-level logging
137
138
  - `2`: LLM-client level logging (most granular)
138
139
  - `debugDom`: a `boolean` that draws bounding boxes around elements presented to the LLM during automation.
139
- - `domSettleTimeoutMs`: an `integer` that specifies the timeout in milliseconds for waiting for the DOM to settle. Defaults to 30000 (30 seconds).
140
+ - `domSettleTimeoutMs`: an `integer` that specifies the timeout in milliseconds for waiting for the DOM to settle. It can be overriden in individual function calls if needed. Defaults to 30000 (30 seconds).
141
+ - `enableCaching`: a `boolean` that enables caching of LLM responses. When set to `true`, the LLM requests will be cached on disk and reused for identical requests. Defaults to `false`.
140
142
 
141
143
  - **Returns:**
142
144
 
@@ -177,6 +179,7 @@ This constructor is used to create an instance of Stagehand.
177
179
  - `action`: a `string` describing the action to perform, e.g., `"search for 'x'"`.
178
180
  - `modelName`: (optional) an `AvailableModel` string to specify the model to use.
179
181
  - `useVision`: (optional) a `boolean` or `"fallback"` to determine if vision-based processing should be used. Defaults to `"fallback"`.
182
+ - `domSettleTimeoutMs`: (optional) an `integer` that specifies the timeout in milliseconds for waiting for the DOM to settle. If not set, defaults to the timeout value specified during initialization.
180
183
 
181
184
  - **Returns:**
182
185
 
@@ -199,6 +202,7 @@ This constructor is used to create an instance of Stagehand.
199
202
  - `instruction`: a `string` providing instructions for extraction.
200
203
  - `schema`: a `z.AnyZodObject` defining the structure of the data to extract.
201
204
  - `modelName`: (optional) an `AvailableModel` string to specify the model to use.
205
+ - `domSettleTimeoutMs`: (optional) an `integer` that specifies the timeout in milliseconds for waiting for the DOM to settle. If not set, defaults to the timeout value specified during initialization.
202
206
 
203
207
  - **Returns:**
204
208
 
@@ -227,6 +231,7 @@ If you are looking for a specific element, you can also pass in an instruction t
227
231
 
228
232
  - `instruction`: a `string` providing instructions for the observation.
229
233
  - `useVision`: (optional) a `boolean` or `"fallback"` to determine if vision-based processing should be used. Defaults to `"fallback"`.
234
+ - `domSettleTimeoutMs`: (optional) an `integer` that specifies the timeout in milliseconds for waiting for the DOM to settle. If not set, defaults to the timeout value specified during initialization.
230
235
 
231
236
  - **Returns:**
232
237
 
@@ -278,7 +283,6 @@ Stagehand currently supports the following models from OpenAI and Anthropic:
278
283
 
279
284
  These models can be specified when initializing the `Stagehand` instance or when calling methods like `act()` and `extract()`.
280
285
 
281
-
282
286
  ## How It Works
283
287
 
284
288
  The SDK has two major phases:
@@ -342,12 +346,14 @@ const productInfo = await stagehand.extract({
342
346
  - **Break down complex tasks into smaller, atomic steps**
343
347
 
344
348
  Instead of combining actions:
349
+
345
350
  ```javascript
346
351
  // Avoid this
347
352
  await stagehand.act({ action: "log in and purchase the first item" });
348
353
  ```
349
354
 
350
355
  Split them into individual steps:
356
+
351
357
  ```javascript
352
358
  await stagehand.act({ action: "click the login button" });
353
359
  // ...additional steps to log in...
@@ -385,11 +391,10 @@ await stagehand.act({ action: "fill out the form and submit it" });
385
391
  await stagehand.act({ action: "book the cheapest flight available" });
386
392
  ```
387
393
 
388
- By following these guidelines, you'll increase the reliability and effectiveness of your web automations with Stagehand. Remember, Stagehand excels at executing precise, well-defined actions so keeping your instructions atomic will lead to the best outcomes.
394
+ By following these guidelines, you'll increase the reliability and effectiveness of your web automations with Stagehand. Remember, Stagehand excels at executing precise, well-defined actions so keeping your instructions atomic will lead to the best outcomes.
389
395
 
390
396
  We leave the agentic behaviour to higher-level agentic systems which can use Stagehand as a tool.
391
397
 
392
-
393
398
  ## Roadmap
394
399
 
395
400
  At a high level, we're focused on improving reliability, speed, and cost in that order of priority.
@@ -464,7 +469,7 @@ Stagehand uses [tsup](https://github.com/egoist/tsup) to build the SDK and vanil
464
469
 
465
470
  ## Acknowledgements
466
471
 
467
- This project heavily relies on [Playwright](https://playwright.dev/) as a resilient backbone to automate the web. It also would not be possible without the awesome techniques and discoveries made by [tarsier](https://github.com/reworkd/tarsier), and [fuji-web](https://github.com/fuji-web).
472
+ This project heavily relies on [Playwright](https://playwright.dev/) as a resilient backbone to automate the web. It also would not be possible without the awesome techniques and discoveries made by [tarsier](https://github.com/reworkd/tarsier), and [fuji-web](https://github.com/normal-computing/fuji-web).
468
473
 
469
474
  [Jeremy Press](https://x.com/jeremypress) wrote the original MVP of Stagehand and continues to be a major ally to the project.
470
475
 
@@ -0,0 +1,2 @@
1
+ (() => {
2
+ })();