Skip to content

Commit 067c9e6

Browse files
feat(api): manual updates
1 parent d7aabe3 commit 067c9e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+20977
-1614
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 7
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-c1a6f03afe5d6823c198e5ac476fb688dacc783dae1fefdf6bf142084e298e16.yml
3-
openapi_spec_hash: d20e8f697ce8d5bb80295fc1e8ce02e8
4-
config_hash: e457d704d820df5d25acfd379169f132
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-349e1b0f6291eedd731c1660155a50adcb3424fb8cd9e17bbdc0939ff3bbffcd.yml
3+
openapi_spec_hash: 456b593ea71d72bc31a6338a25363e9f
4+
config_hash: 5f6b5ec6e84fb01932ba87c6a9623d9b

README.md

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@ This library requires Java 8 or later.
4848
```java
4949
import com.browserbase.api.client.StagehandClient;
5050
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
51-
import com.browserbase.api.models.sessions.SessionStartParams;
52-
import com.browserbase.api.models.sessions.SessionStartResponse;
51+
import com.browserbase.api.models.sessions.SessionActParams;
52+
import com.browserbase.api.models.sessions.SessionActResponse;
5353

5454
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
5555
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
5656
StagehandClient client = StagehandOkHttpClient.fromEnv();
5757

58-
SessionStartResponse response = client.sessions().start();
58+
SessionActParams params = SessionActParams.builder()
59+
.id("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
60+
.input("Click the login button")
61+
.build();
62+
SessionActResponse response = client.sessions().act(params);
5963
```
6064

6165
## Client configuration
@@ -132,7 +136,7 @@ The `withOptions()` method does not affect the original client or service.
132136

133137
To send a request to the Stagehand API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.
134138

135-
For example, `client.sessions().start(...)` should be called with an instance of `SessionStartParams`, and it will return an instance of `SessionStartResponse`.
139+
For example, `client.sessions().act(...)` should be called with an instance of `SessionActParams`, and it will return an instance of `SessionActResponse`.
136140

137141
## Immutability
138142

@@ -149,31 +153,39 @@ The default client is synchronous. To switch to asynchronous execution, call the
149153
```java
150154
import com.browserbase.api.client.StagehandClient;
151155
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
152-
import com.browserbase.api.models.sessions.SessionStartParams;
153-
import com.browserbase.api.models.sessions.SessionStartResponse;
156+
import com.browserbase.api.models.sessions.SessionActParams;
157+
import com.browserbase.api.models.sessions.SessionActResponse;
154158
import java.util.concurrent.CompletableFuture;
155159

156160
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
157161
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
158162
StagehandClient client = StagehandOkHttpClient.fromEnv();
159163

160-
CompletableFuture<SessionStartResponse> response = client.async().sessions().start();
164+
SessionActParams params = SessionActParams.builder()
165+
.id("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
166+
.input("Click the login button")
167+
.build();
168+
CompletableFuture<SessionActResponse> response = client.async().sessions().act(params);
161169
```
162170

163171
Or create an asynchronous client from the beginning:
164172

165173
```java
166174
import com.browserbase.api.client.StagehandClientAsync;
167175
import com.browserbase.api.client.okhttp.StagehandOkHttpClientAsync;
168-
import com.browserbase.api.models.sessions.SessionStartParams;
169-
import com.browserbase.api.models.sessions.SessionStartResponse;
176+
import com.browserbase.api.models.sessions.SessionActParams;
177+
import com.browserbase.api.models.sessions.SessionActResponse;
170178
import java.util.concurrent.CompletableFuture;
171179

172180
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
173181
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
174182
StagehandClientAsync client = StagehandOkHttpClientAsync.fromEnv();
175183

176-
CompletableFuture<SessionStartResponse> response = client.sessions().start();
184+
SessionActParams params = SessionActParams.builder()
185+
.id("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
186+
.input("Click the login button")
187+
.build();
188+
CompletableFuture<SessionActResponse> response = client.sessions().act(params);
177189
```
178190

179191
The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.
@@ -187,10 +199,14 @@ To access this data, prefix any HTTP method call on a client or service with `wi
187199
```java
188200
import com.browserbase.api.core.http.Headers;
189201
import com.browserbase.api.core.http.HttpResponseFor;
190-
import com.browserbase.api.models.sessions.SessionStartParams;
191-
import com.browserbase.api.models.sessions.SessionStartResponse;
202+
import com.browserbase.api.models.sessions.SessionActParams;
203+
import com.browserbase.api.models.sessions.SessionActResponse;
192204

193-
HttpResponseFor<SessionStartResponse> response = client.sessions().withRawResponse().start();
205+
SessionActParams params = SessionActParams.builder()
206+
.id("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
207+
.input("Click the login button")
208+
.build();
209+
HttpResponseFor<SessionActResponse> response = client.sessions().withRawResponse().act(params);
194210

195211
int statusCode = response.statusCode();
196212
Headers headers = response.headers();
@@ -199,9 +215,9 @@ Headers headers = response.headers();
199215
You can still deserialize the response into an instance of a Java class if needed:
200216

201217
```java
202-
import com.browserbase.api.models.sessions.SessionStartResponse;
218+
import com.browserbase.api.models.sessions.SessionActResponse;
203219

204-
SessionStartResponse parsedResponse = response.parse();
220+
SessionActResponse parsedResponse = response.parse();
205221
```
206222

207223
## Error handling
@@ -297,9 +313,11 @@ Requests time out after 1 minute by default.
297313
To set a custom timeout, configure the method call using the `timeout` method:
298314

299315
```java
300-
import com.browserbase.api.models.sessions.SessionStartResponse;
316+
import com.browserbase.api.models.sessions.SessionActResponse;
301317

302-
SessionStartResponse response = client.sessions().start(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build());
318+
SessionActResponse response = client.sessions().act(
319+
params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()
320+
);
303321
```
304322

305323
Or configure the default for all method calls at the client level:
@@ -402,9 +420,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu
402420

403421
```java
404422
import com.browserbase.api.core.JsonValue;
405-
import com.browserbase.api.models.sessions.SessionStartParams;
423+
import com.browserbase.api.models.sessions.SessionActParams;
406424

407-
SessionStartParams params = SessionStartParams.builder()
425+
SessionActParams params = SessionActParams.builder()
408426
.putAdditionalHeader("Secret-Header", "42")
409427
.putAdditionalQueryParam("secret_query_param", "42")
410428
.putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))
@@ -413,12 +431,29 @@ SessionStartParams params = SessionStartParams.builder()
413431

414432
These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.
415433

434+
To set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:
435+
436+
```java
437+
import com.browserbase.api.core.JsonValue;
438+
import com.browserbase.api.models.sessions.SessionActParams;
439+
440+
SessionActParams params = SessionActParams.builder()
441+
.options(SessionActParams.Options.builder()
442+
.putAdditionalProperty("secretProperty", JsonValue.from("42"))
443+
.build())
444+
.build();
445+
```
446+
447+
These properties can be accessed on the nested built object later using the `_additionalProperties()` method.
448+
416449
To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](stagehand-java-core/src/main/kotlin/com/browserbase/api/core/Values.kt) object to its setter:
417450

418451
```java
419-
import com.browserbase.api.models.sessions.SessionStartParams;
452+
import com.browserbase.api.models.sessions.SessionActParams;
420453

421-
SessionStartParams params = SessionStartParams.builder().build();
454+
SessionActParams params = SessionActParams.builder()
455+
.input("Click the login button")
456+
.build();
422457
```
423458

424459
The most straightforward way to create a [`JsonValue`](stagehand-java-core/src/main/kotlin/com/browserbase/api/core/Values.kt) is using its `from(...)` method:
@@ -467,9 +502,9 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](stagehan
467502
```java
468503
import com.browserbase.api.core.JsonMissing;
469504
import com.browserbase.api.models.sessions.SessionActParams;
470-
import com.browserbase.api.models.sessions.SessionStartParams;
471505

472-
SessionStartParams params = SessionActParams.builder()
506+
SessionActParams params = SessionActParams.builder()
507+
.input("Click the login button")
473508
.id(JsonMissing.of())
474509
.build();
475510
```
@@ -482,7 +517,7 @@ To access undocumented response properties, call the `_additionalProperties()` m
482517
import com.browserbase.api.core.JsonValue;
483518
import java.util.Map;
484519

485-
Map<String, JsonValue> additionalProperties = client.sessions().start(params)._additionalProperties();
520+
Map<String, JsonValue> additionalProperties = client.sessions().act(params)._additionalProperties();
486521
JsonValue secretPropertyValue = additionalProperties.get("secretProperty");
487522

488523
String result = secretPropertyValue.accept(new JsonValue.Visitor<>() {
@@ -510,21 +545,22 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p
510545

511546
```java
512547
import com.browserbase.api.core.JsonField;
548+
import com.browserbase.api.models.sessions.SessionActParams;
513549
import java.util.Optional;
514550

515-
JsonField<Object> field = client.sessions().start(params)._field();
551+
JsonField<SessionActParams.Input> input = client.sessions().act(params)._input();
516552

517-
if (field.isMissing()) {
553+
if (input.isMissing()) {
518554
// The property is absent from the JSON response
519-
} else if (field.isNull()) {
555+
} else if (input.isNull()) {
520556
// The property was set to literal null
521557
} else {
522558
// Check if value was provided as a string
523559
// Other methods include `asNumber()`, `asBoolean()`, etc.
524-
Optional<String> jsonString = field.asString();
560+
Optional<String> jsonString = input.asString();
525561

526562
// Try to deserialize into a custom type
527-
MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class);
563+
MyClass myObject = input.asUnknown().orElseThrow().convert(MyClass.class);
528564
}
529565
```
530566

@@ -537,17 +573,19 @@ By default, the SDK will not throw an exception in this case. It will throw [`St
537573
If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:
538574

539575
```java
540-
import com.browserbase.api.models.sessions.SessionStartResponse;
576+
import com.browserbase.api.models.sessions.SessionActResponse;
541577

542-
SessionStartResponse response = client.sessions().start(params).validate();
578+
SessionActResponse response = client.sessions().act(params).validate();
543579
```
544580

545581
Or configure the method call to validate the response using the `responseValidation` method:
546582

547583
```java
548-
import com.browserbase.api.models.sessions.SessionStartResponse;
584+
import com.browserbase.api.models.sessions.SessionActResponse;
549585

550-
SessionStartResponse response = client.sessions().start(RequestOptions.builder().responseValidation(true).build());
586+
SessionActResponse response = client.sessions().act(
587+
params, RequestOptions.builder().responseValidation(true).build()
588+
);
551589
```
552590

553591
Or configure the default for all method calls at the client level:

buildSrc/src/main/kotlin/stagehand.publish.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ configure<PublishingExtension> {
1010

1111
pom {
1212
name.set("Stagehand API")
13-
description.set("Stagehand SDK for AI browser automation [ALPHA]. This API allows clients to\nexecute browser automation tasks remotely on the Browserbase cloud.\n\nAll endpoints except /sessions/start require an active session ID. Responses are\nstreamed using Server-Sent Events (SSE) when the `x-stream-response: true`\nheader is provided.\n\nThis SDK is currently ALPHA software and is not production ready! Please try it\nand give us your feedback, stay tuned for upcoming release announcements!")
13+
description.set("Stagehand SDK for AI browser automation [ALPHA].")
1414
url.set("https://docs.stagehand.dev")
1515

1616
licenses {

0 commit comments

Comments
 (0)