Skip to content

Commit 13074f1

Browse files
feat(api): manual updates
1 parent 4431f69 commit 13074f1

Some content is hidden

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

41 files changed

+738
-11567
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 7
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-705638ac8966569986bd9ebb7c9761bf0016909e9f2753e77ceabb12c8049511.yml
3-
openapi_spec_hash: a8fbbcaa38e91c7f97313620b42d8d62
1+
configured_endpoints: 1
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-516862e7e90968bc55ac44ce7ffe2d5c1f738c11757471c2b9e0e4cff9384f2c.yml
3+
openapi_spec_hash: 19bbe52a6ae0eec7fc3f6698e831ee55
44
config_hash: a35b56eb05306a0f02e83c11d57f975f

README.md

Lines changed: 26 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,14 @@ 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.SessionActParams;
52-
import com.browserbase.api.models.sessions.SessionActResponse;
51+
import com.browserbase.api.models.sessions.SessionStartParams;
52+
import com.browserbase.api.models.sessions.SessionStartResponse;
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-
SessionActParams params = SessionActParams.builder()
59-
.sessionId("00000000-your-session-id-000000000000")
60-
.input("click the first link on the page")
61-
.build();
62-
SessionActResponse response = client.sessions().act(params);
58+
SessionStartResponse response = client.sessions().start();
6359
```
6460

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

137133
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.
138134

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

141137
## Immutability
142138

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

160156
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
161157
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
162158
StagehandClient client = StagehandOkHttpClient.fromEnv();
163159

164-
SessionActParams params = SessionActParams.builder()
165-
.sessionId("00000000-your-session-id-000000000000")
166-
.input("click the first link on the page")
167-
.build();
168-
CompletableFuture<SessionActResponse> response = client.async().sessions().act(params);
160+
CompletableFuture<SessionStartResponse> response = client.async().sessions().start();
169161
```
170162

171163
Or create an asynchronous client from the beginning:
172164

173165
```java
174166
import com.browserbase.api.client.StagehandClientAsync;
175167
import com.browserbase.api.client.okhttp.StagehandOkHttpClientAsync;
176-
import com.browserbase.api.models.sessions.SessionActParams;
177-
import com.browserbase.api.models.sessions.SessionActResponse;
168+
import com.browserbase.api.models.sessions.SessionStartParams;
169+
import com.browserbase.api.models.sessions.SessionStartResponse;
178170
import java.util.concurrent.CompletableFuture;
179171

180172
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
181173
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
182174
StagehandClientAsync client = StagehandOkHttpClientAsync.fromEnv();
183175

184-
SessionActParams params = SessionActParams.builder()
185-
.sessionId("00000000-your-session-id-000000000000")
186-
.input("click the first link on the page")
187-
.build();
188-
CompletableFuture<SessionActResponse> response = client.sessions().act(params);
176+
CompletableFuture<SessionStartResponse> response = client.sessions().start();
189177
```
190178

191179
The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.
@@ -202,11 +190,7 @@ import com.browserbase.api.core.http.HttpResponseFor;
202190
import com.browserbase.api.models.sessions.SessionStartParams;
203191
import com.browserbase.api.models.sessions.SessionStartResponse;
204192

205-
SessionStartParams params = SessionStartParams.builder()
206-
.browserbaseApiKey("your Browserbase API key")
207-
.browserbaseProjectId("your Browserbase Project ID")
208-
.build();
209-
HttpResponseFor<SessionStartResponse> response = client.sessions().withRawResponse().start(params);
193+
HttpResponseFor<SessionStartResponse> response = client.sessions().withRawResponse().start();
210194

211195
int statusCode = response.statusCode();
212196
Headers headers = response.headers();
@@ -315,9 +299,7 @@ To set a custom timeout, configure the method call using the `timeout` method:
315299
```java
316300
import com.browserbase.api.models.sessions.SessionStartResponse;
317301

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

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

421403
```java
422404
import com.browserbase.api.core.JsonValue;
423-
import com.browserbase.api.models.sessions.SessionActParams;
405+
import com.browserbase.api.models.sessions.SessionStartParams;
424406

425-
SessionActParams params = SessionActParams.builder()
407+
SessionStartParams params = SessionStartParams.builder()
426408
.putAdditionalHeader("Secret-Header", "42")
427409
.putAdditionalQueryParam("secret_query_param", "42")
428410
.putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))
@@ -431,30 +413,12 @@ SessionActParams params = SessionActParams.builder()
431413

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

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-
449416
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:
450417

451418
```java
452-
import com.browserbase.api.core.JsonValue;
453-
import com.browserbase.api.models.sessions.SessionActParams;
419+
import com.browserbase.api.models.sessions.SessionStartParams;
454420

455-
SessionActParams params = SessionActParams.builder()
456-
.input(JsonValue.from(42))
457-
.build();
421+
SessionStartParams params = SessionStartParams.builder().build();
458422
```
459423

460424
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:
@@ -496,20 +460,6 @@ JsonValue complexValue = JsonValue.from(Map.of(
496460
));
497461
```
498462

499-
Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.
500-
501-
To forcibly omit a required parameter or property, pass [`JsonMissing`](stagehand-java-core/src/main/kotlin/com/browserbase/api/core/Values.kt):
502-
503-
```java
504-
import com.browserbase.api.core.JsonMissing;
505-
import com.browserbase.api.models.sessions.SessionActParams;
506-
507-
SessionActParams params = SessionActParams.builder()
508-
.input("click the sign in button")
509-
.sessionId(JsonMissing.of())
510-
.build();
511-
```
512-
513463
### Response properties
514464

515465
To access undocumented response properties, call the `_additionalProperties()` method:
@@ -518,7 +468,7 @@ To access undocumented response properties, call the `_additionalProperties()` m
518468
import com.browserbase.api.core.JsonValue;
519469
import java.util.Map;
520470

521-
Map<String, JsonValue> additionalProperties = client.sessions().act(params)._additionalProperties();
471+
Map<String, JsonValue> additionalProperties = client.sessions().start(params)._additionalProperties();
522472
JsonValue secretPropertyValue = additionalProperties.get("secretProperty");
523473

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

547497
```java
548498
import com.browserbase.api.core.JsonField;
549-
import com.browserbase.api.models.sessions.SessionActParams;
550499
import java.util.Optional;
551500

552-
JsonField<SessionActParams.Input> input = client.sessions().act(params)._input();
501+
JsonField<Object> field = client.sessions().start(params)._field();
553502

554-
if (input.isMissing()) {
503+
if (field.isMissing()) {
555504
// The property is absent from the JSON response
556-
} else if (input.isNull()) {
505+
} else if (field.isNull()) {
557506
// The property was set to literal null
558507
} else {
559508
// Check if value was provided as a string
560509
// Other methods include `asNumber()`, `asBoolean()`, etc.
561-
Optional<String> jsonString = input.asString();
510+
Optional<String> jsonString = field.asString();
562511

563512
// Try to deserialize into a custom type
564-
MyClass myObject = input.asUnknown().orElseThrow().convert(MyClass.class);
513+
MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class);
565514
}
566515
```
567516

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

576525
```java
577-
import com.browserbase.api.models.sessions.SessionActResponse;
526+
import com.browserbase.api.models.sessions.SessionStartResponse;
578527

579-
SessionActResponse response = client.sessions().act(params).validate();
528+
SessionStartResponse response = client.sessions().start(params).validate();
580529
```
581530

582531
Or configure the method call to validate the response using the `responseValidation` method:
583532

584533
```java
585-
import com.browserbase.api.models.sessions.SessionActResponse;
534+
import com.browserbase.api.models.sessions.SessionStartResponse;
586535

587-
SessionActResponse response = client.sessions().act(
588-
params, RequestOptions.builder().responseValidation(true).build()
589-
);
536+
SessionStartResponse response = client.sessions().start(RequestOptions.builder().responseValidation(true).build());
590537
```
591538

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

0 commit comments

Comments
 (0)