Skip to content

Commit 2262f19

Browse files
feat(api): manual updates
1 parent afa389f commit 2262f19

File tree

8 files changed

+261
-725
lines changed

8 files changed

+261
-725
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-09064f4021f94fb1b1bd86ce496d998318276b61bbc24de4728ecdb5763847ef.yml
3-
openapi_spec_hash: 911d0631010b372890f98545a038cfb5
4-
config_hash: bb7561632c1f66c2b9efca06f438f904
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-6a22863a7da4fa45f904657a4cb8fc1a28e236925f03dc94fca25fd8271ca6db.yml
3+
openapi_spec_hash: d5c6108942ad79f39ea4ff1bee9b7996
4+
config_hash: 2f1ec44e7e07906e07bdc6e075763da9

README.md

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +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.apiKey` and `stagehand.baseUrl` system properties
5555
// Or configures using the `STAGEHAND_API_KEY` and `STAGEHAND_BASE_URL` environment variables
5656
StagehandClient client = StagehandOkHttpClient.fromEnv();
5757

58-
SessionStartParams params = SessionStartParams.builder()
59-
.env(SessionStartParams.Env.LOCAL)
58+
SessionActParams params = SessionActParams.builder()
59+
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
60+
.input("click the first link on the page")
6061
.build();
61-
SessionStartResponse response = client.sessions().start(params);
62+
SessionActResponse response = client.sessions().act(params);
6263
```
6364

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

132133
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.
133134

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

136137
## Immutability
137138

@@ -148,37 +149,39 @@ The default client is synchronous. To switch to asynchronous execution, call the
148149
```java
149150
import com.browserbase.api.client.StagehandClient;
150151
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
151-
import com.browserbase.api.models.sessions.SessionStartParams;
152-
import com.browserbase.api.models.sessions.SessionStartResponse;
152+
import com.browserbase.api.models.sessions.SessionActParams;
153+
import com.browserbase.api.models.sessions.SessionActResponse;
153154
import java.util.concurrent.CompletableFuture;
154155

155156
// Configures using the `stagehand.apiKey` and `stagehand.baseUrl` system properties
156157
// Or configures using the `STAGEHAND_API_KEY` and `STAGEHAND_BASE_URL` environment variables
157158
StagehandClient client = StagehandOkHttpClient.fromEnv();
158159

159-
SessionStartParams params = SessionStartParams.builder()
160-
.env(SessionStartParams.Env.LOCAL)
160+
SessionActParams params = SessionActParams.builder()
161+
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
162+
.input("click the first link on the page")
161163
.build();
162-
CompletableFuture<SessionStartResponse> response = client.async().sessions().start(params);
164+
CompletableFuture<SessionActResponse> response = client.async().sessions().act(params);
163165
```
164166

165167
Or create an asynchronous client from the beginning:
166168

167169
```java
168170
import com.browserbase.api.client.StagehandClientAsync;
169171
import com.browserbase.api.client.okhttp.StagehandOkHttpClientAsync;
170-
import com.browserbase.api.models.sessions.SessionStartParams;
171-
import com.browserbase.api.models.sessions.SessionStartResponse;
172+
import com.browserbase.api.models.sessions.SessionActParams;
173+
import com.browserbase.api.models.sessions.SessionActResponse;
172174
import java.util.concurrent.CompletableFuture;
173175

174176
// Configures using the `stagehand.apiKey` and `stagehand.baseUrl` system properties
175177
// Or configures using the `STAGEHAND_API_KEY` and `STAGEHAND_BASE_URL` environment variables
176178
StagehandClientAsync client = StagehandOkHttpClientAsync.fromEnv();
177179

178-
SessionStartParams params = SessionStartParams.builder()
179-
.env(SessionStartParams.Env.LOCAL)
180+
SessionActParams params = SessionActParams.builder()
181+
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
182+
.input("click the first link on the page")
180183
.build();
181-
CompletableFuture<SessionStartResponse> response = client.sessions().start(params);
184+
CompletableFuture<SessionActResponse> response = client.sessions().act(params);
182185
```
183186

184187
The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.
@@ -196,7 +199,8 @@ import com.browserbase.api.models.sessions.SessionStartParams;
196199
import com.browserbase.api.models.sessions.SessionStartResponse;
197200

198201
SessionStartParams params = SessionStartParams.builder()
199-
.env(SessionStartParams.Env.LOCAL)
202+
.browserbaseApiKey("BROWSERBASE_API_KEY")
203+
.browserbaseProjectId("BROWSERBASE_PROJECT_ID")
200204
.build();
201205
HttpResponseFor<SessionStartResponse> response = client.sessions().withRawResponse().start(params);
202206

@@ -427,9 +431,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu
427431

428432
```java
429433
import com.browserbase.api.core.JsonValue;
430-
import com.browserbase.api.models.sessions.SessionStartParams;
434+
import com.browserbase.api.models.sessions.SessionActParams;
431435

432-
SessionStartParams params = SessionStartParams.builder()
436+
SessionActParams params = SessionActParams.builder()
433437
.putAdditionalHeader("Secret-Header", "42")
434438
.putAdditionalQueryParam("secret_query_param", "42")
435439
.putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))
@@ -442,10 +446,10 @@ To set undocumented parameters on _nested_ headers, query params, or body classe
442446

443447
```java
444448
import com.browserbase.api.core.JsonValue;
445-
import com.browserbase.api.models.sessions.SessionStartParams;
449+
import com.browserbase.api.models.sessions.SessionActParams;
446450

447-
SessionStartParams params = SessionStartParams.builder()
448-
.localBrowserLaunchOptions(SessionStartParams.LocalBrowserLaunchOptions.builder()
451+
SessionActParams params = SessionActParams.builder()
452+
.options(SessionActParams.Options.builder()
449453
.putAdditionalProperty("secretProperty", JsonValue.from("42"))
450454
.build())
451455
.build();
@@ -457,10 +461,10 @@ To set a documented parameter or property to an undocumented or not yet supporte
457461

458462
```java
459463
import com.browserbase.api.core.JsonValue;
460-
import com.browserbase.api.models.sessions.SessionStartParams;
464+
import com.browserbase.api.models.sessions.SessionActParams;
461465

462-
SessionStartParams params = SessionStartParams.builder()
463-
.env(JsonValue.from(42))
466+
SessionActParams params = SessionActParams.builder()
467+
.input(JsonValue.from(42))
464468
.build();
465469
```
466470

@@ -509,10 +513,11 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](stagehan
509513

510514
```java
511515
import com.browserbase.api.core.JsonMissing;
512-
import com.browserbase.api.models.sessions.SessionStartParams;
516+
import com.browserbase.api.models.sessions.SessionActParams;
513517

514-
SessionStartParams params = SessionStartParams.builder()
515-
.env(JsonMissing.of())
518+
SessionActParams params = SessionActParams.builder()
519+
.input("click the sign in button")
520+
.sessionId(JsonMissing.of())
516521
.build();
517522
```
518523

@@ -524,7 +529,7 @@ To access undocumented response properties, call the `_additionalProperties()` m
524529
import com.browserbase.api.core.JsonValue;
525530
import java.util.Map;
526531

527-
Map<String, JsonValue> additionalProperties = client.sessions().start(params)._additionalProperties();
532+
Map<String, JsonValue> additionalProperties = client.sessions().act(params)._additionalProperties();
528533
JsonValue secretPropertyValue = additionalProperties.get("secretProperty");
529534

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

553558
```java
554559
import com.browserbase.api.core.JsonField;
555-
import com.browserbase.api.models.sessions.SessionStartParams;
560+
import com.browserbase.api.models.sessions.SessionActParams;
556561
import java.util.Optional;
557562

558-
JsonField<SessionStartParams.Env> env = client.sessions().start(params)._env();
563+
JsonField<SessionActParams.Input> input = client.sessions().act(params)._input();
559564

560-
if (env.isMissing()) {
565+
if (input.isMissing()) {
561566
// The property is absent from the JSON response
562-
} else if (env.isNull()) {
567+
} else if (input.isNull()) {
563568
// The property was set to literal null
564569
} else {
565570
// Check if value was provided as a string
566571
// Other methods include `asNumber()`, `asBoolean()`, etc.
567-
Optional<String> jsonString = env.asString();
572+
Optional<String> jsonString = input.asString();
568573

569574
// Try to deserialize into a custom type
570-
MyClass myObject = env.asUnknown().orElseThrow().convert(MyClass.class);
575+
MyClass myObject = input.asUnknown().orElseThrow().convert(MyClass.class);
571576
}
572577
```
573578

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

582587
```java
583-
import com.browserbase.api.models.sessions.SessionStartResponse;
588+
import com.browserbase.api.models.sessions.SessionActResponse;
584589

585-
SessionStartResponse response = client.sessions().start(params).validate();
590+
SessionActResponse response = client.sessions().act(params).validate();
586591
```
587592

588593
Or configure the method call to validate the response using the `responseValidation` method:
589594

590595
```java
591-
import com.browserbase.api.models.sessions.SessionStartResponse;
596+
import com.browserbase.api.models.sessions.SessionActResponse;
592597

593-
SessionStartResponse response = client.sessions().start(
598+
SessionActResponse response = client.sessions().act(
594599
params, RequestOptions.builder().responseValidation(true).build()
595600
);
596601
```

0 commit comments

Comments
 (0)