@browserbasehq/stagehand 1.0.3 → 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.
- package/README.md +10 -5
- package/dist/evals/index.eval.js +1075 -0
- package/dist/evals/index.eval.js.map +1 -0
- package/dist/evals/playground.js +112 -0
- package/dist/evals/playground.js.map +1 -0
- package/dist/evals/utils.js +52 -0
- package/dist/evals/utils.js.map +1 -0
- package/dist/examples/2048.js +108 -0
- package/dist/examples/2048.js.map +1 -0
- package/dist/examples/debugUrl.js +35 -0
- package/dist/examples/debugUrl.js.map +1 -0
- package/dist/examples/example.js +37 -0
- package/dist/examples/example.js.map +1 -0
- package/dist/index.d.ts +22 -6
- package/dist/index.js +629 -152
- package/dist/lib/browserbase.js +56 -0
- package/dist/lib/browserbase.js.map +1 -0
- package/dist/lib/cache.js +78 -0
- package/dist/lib/cache.js.map +1 -0
- package/dist/lib/dom/debug.js +119 -0
- package/dist/lib/dom/debug.js.map +1 -0
- package/dist/lib/dom/index.js +20 -0
- package/dist/lib/dom/index.js.map +1 -0
- package/dist/lib/dom/process.js +396 -0
- package/dist/lib/dom/process.js.map +1 -0
- package/dist/lib/dom/utils.js +28 -0
- package/dist/lib/dom/utils.js.map +1 -0
- package/dist/lib/index.js +978 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/inference.js +226 -0
- package/dist/lib/inference.js.map +1 -0
- package/dist/lib/llm/AnthropicClient.js +150 -0
- package/dist/lib/llm/AnthropicClient.js.map +1 -0
- package/dist/lib/llm/LLMClient.js +12 -0
- package/dist/lib/llm/LLMClient.js.map +1 -0
- package/dist/lib/llm/LLMProvider.js +34 -0
- package/dist/lib/llm/LLMProvider.js.map +1 -0
- package/dist/lib/llm/OpenAIClient.js +69 -0
- package/dist/lib/llm/OpenAIClient.js.map +1 -0
- package/dist/lib/prompt.js +288 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/vision.js +194 -0
- package/dist/lib/vision.js.map +1 -0
- 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
|
|