You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -131,22 +130,49 @@ This constructor is used to create an instance of Stagehand.
131
130
132
131
-**Arguments:**
133
132
134
-
-`env`: `'LOCAL'` or `'BROWSERBASE'`.
133
+
-`env`: `'LOCAL'` or `'BROWSERBASE'`. Defaults to `'BROWSERBASE'`.
134
+
-`modelName`: (optional) an `AvailableModel` string to specify the default model to use.
135
+
-`modelClientOptions`: (optional) configuration options for the model client.
136
+
-`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`.
137
+
-`headless`: a `boolean` that determines if the browser runs in headless mode. Defaults to `false`. When the env is set to `BROWSERBASE`, this will be ignored.
138
+
-`domSettleTimeoutMs`: an `integer` that specifies the timeout in milliseconds for waiting for the DOM to settle. Defaults to 30000 (30 seconds).
139
+
-`apiKey`: (optional) your Browserbase API key. Defaults to `BROWSERBASE_API_KEY` environment variable.
140
+
-`projectId`: (optional) your Browserbase project ID. Defaults to `BROWSERBASE_PROJECT_ID` environment variable.
141
+
-`browserBaseSessionCreateParams`: configuration options for creating new Browserbase sessions.
142
+
-`browserbaseResumeSessionID`: ID of an existing Browserbase session to resume.
143
+
-`logger`: a function that handles log messages. Useful for custom logging implementations.
135
144
-`verbose`: an `integer` that enables several levels of logging during automation:
136
145
-`0`: limited to no logging
137
146
-`1`: SDK-level logging
138
147
-`2`: LLM-client level logging (most granular)
139
148
-`debugDom`: a `boolean` that draws bounding boxes around elements presented to the LLM during automation.
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`.
142
149
143
150
-**Returns:**
144
151
145
152
- An instance of the `Stagehand` class configured with the specified options.
@@ -157,7 +183,9 @@ This constructor is used to create an instance of Stagehand.
157
183
158
184
-**Arguments:**
159
185
160
-
-`modelName`: (optional) an `AvailableModel` string to specify the model to use. This will be used for all other methods unless overridden. Defaults to `"gpt-4o"`.
186
+
-`modelName`: (optional) an `AvailableModel` string to specify the model to use. This will be used for all other methods unless overridden.
187
+
-`modelClientOptions`: (optional) configuration options for the model client
188
+
-`domSettleTimeoutMs`: (optional) timeout in milliseconds for waiting for the DOM to settle
161
189
162
190
-**Returns:**
163
191
@@ -176,10 +204,12 @@ This constructor is used to create an instance of Stagehand.
176
204
177
205
-**Arguments:**
178
206
179
-
-`action`: a `string` describing the action to perform, e.g., `"search for 'x'"`.
180
-
-`modelName`: (optional) an `AvailableModel` string to specify the model to use.
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.
207
+
-`action`: a `string` describing the action to perform
208
+
-`modelName`: (optional) an `AvailableModel` string to specify the model to use
209
+
-`modelClientOptions`: (optional) configuration options for the model client
210
+
-`useVision`: (optional) a `boolean` or `"fallback"` to determine if vision-based processing should be used. Defaults to `"fallback"`
211
+
-`variables`: (optional) a `Record<string, string>` of variables to use in the action. Variables in the action string are referenced using `%variable_name%`
212
+
-`domSettleTimeoutMs`: (optional) timeout in milliseconds for waiting for the DOM to settle
183
213
184
214
-**Returns:**
185
215
@@ -189,8 +219,27 @@ This constructor is used to create an instance of Stagehand.
189
219
-`action`: a `string` describing the action performed.
190
220
191
221
-**Example:**
222
+
192
223
```javascript
224
+
// Basic usage
193
225
awaitstagehand.act({ action:"click on add to cart" });
226
+
227
+
// Using variables
228
+
awaitstagehand.act({
229
+
action:"enter %username% into the username field",
action:"fill in the form with %username% and %password%",
238
+
variables: {
239
+
username:"john.doe",
240
+
password:"secretpass123",
241
+
},
242
+
});
194
243
```
195
244
196
245
#### `extract()`
@@ -199,10 +248,11 @@ This constructor is used to create an instance of Stagehand.
199
248
200
249
-**Arguments:**
201
250
202
-
-`instruction`: a `string` providing instructions for extraction.
203
-
-`schema`: a `z.AnyZodObject` defining the structure of the data to extract.
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.
251
+
-`instruction`: a `string` providing instructions for extraction
252
+
-`schema`: a `z.AnyZodObject` defining the structure of the data to extract
253
+
-`modelName`: (optional) an `AvailableModel` string to specify the model to use
254
+
-`modelClientOptions`: (optional) configuration options for the model client
255
+
-`domSettleTimeoutMs`: (optional) timeout in milliseconds for waiting for the DOM to settle
206
256
207
257
-**Returns:**
208
258
@@ -229,13 +279,17 @@ If you are looking for a specific element, you can also pass in an instruction t
229
279
230
280
-**Arguments:**
231
281
232
-
-`instruction`: a `string` providing instructions for the observation.
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.
282
+
-`instruction`: (optional) a `string` providing instructions for the observation. Defaults to "Find actions that can be performed on this page."
283
+
-`modelName`: (optional) an `AvailableModel` string to specify the model to use
284
+
-`modelClientOptions`: (optional) configuration options for the model client
285
+
-`useVision`: (optional) a `boolean` to determine if vision-based processing should be used. Defaults to `false`
286
+
-`domSettleTimeoutMs`: (optional) timeout in milliseconds for waiting for the DOM to settle
235
287
236
288
-**Returns:**
237
289
238
-
- A `Promise` that resolves to an array of `string`s representing the actions that can be taken on the current page.
290
+
- A `Promise` that resolves to an array of objects containing:
291
+
-`selector`: a `string` representing the element selector
292
+
-`description`: a `string` describing the possible action
0 commit comments