Skip to content

Commit 7eb2aab

Browse files
release: 0.7.1 (#13)
* STG-1293: add local server multiregion example * STG-1293: document multiregion example * docs: tweak README wording for release validation * release: 0.7.1 --------- Co-authored-by: monadoid <sam.finton@gmail.com> Co-authored-by: Sam F <43347795+monadoid@users.noreply.github.com> Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent 8d872ab commit 7eb2aab

File tree

5 files changed

+169
-7
lines changed

5 files changed

+169
-7
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.7.0"
2+
".": "0.7.1"
33
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.7.1 (2026-03-04)
4+
5+
Full Changelog: [v0.7.0...v0.7.1](https://github.com/browserbase/stagehand-java/compare/v0.7.0...v0.7.1)
6+
7+
### Documentation
8+
9+
* tweak README wording for release validation ([d60513d](https://github.com/browserbase/stagehand-java/commit/d60513dcbf3b65b64f2e8e86ef965927df74d40d))
10+
311
## 0.7.0 (2026-02-25)
412

513
Full Changelog: [v0.6.1...v0.7.0](https://github.com/browserbase/stagehand-java/compare/v0.6.1...v0.7.0)

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
<!-- x-release-please-start-version -->
44

5-
[![Maven Central](https://img.shields.io/maven-central/v/com.browserbase.api/stagehand-java)](https://central.sonatype.com/artifact/com.browserbase.api/stagehand-java/0.7.0)
6-
[![javadoc](https://javadoc.io/badge2/com.browserbase.api/stagehand-java/0.7.0/javadoc.svg)](https://javadoc.io/doc/com.browserbase.api/stagehand-java/0.7.0)
5+
[![Maven Central](https://img.shields.io/maven-central/v/com.browserbase.api/stagehand-java)](https://central.sonatype.com/artifact/com.browserbase.api/stagehand-java/0.7.1)
6+
[![javadoc](https://javadoc.io/badge2/com.browserbase.api/stagehand-java/0.7.1/javadoc.svg)](https://javadoc.io/doc/com.browserbase.api/stagehand-java/0.7.1)
77

88
<!-- x-release-please-end -->
99

10-
The Stagehand Java SDK provides convenient access to the [Stagehand REST API](https://docs.stagehand.dev) from applications written in Java.
10+
The Stagehand Java SDK provides direct access to the [Stagehand REST API](https://docs.stagehand.dev) from applications written in Java.
1111
<!-- x-stagehand-custom-start -->
1212
<div id="toc" align="center" style="margin-bottom: 0;">
1313
<ul style="list-style: none; margin: 0; padding: 0;">
@@ -85,7 +85,7 @@ Most existing browser automation tools either require you to write low-level cod
8585
### Gradle
8686

8787
```kotlin
88-
implementation("com.browserbase.api:stagehand-java:0.7.0")
88+
implementation("com.browserbase.api:stagehand-java:0.7.1")
8989
```
9090

9191
### Maven
@@ -94,7 +94,7 @@ implementation("com.browserbase.api:stagehand-java:0.7.0")
9494
<dependency>
9595
<groupId>com.browserbase.api</groupId>
9696
<artifactId>stagehand-java</artifactId>
97-
<version>0.7.0</version>
97+
<version>0.7.1</version>
9898
</dependency>
9999
```
100100

@@ -111,6 +111,8 @@ Examples live at:
111111
- `stagehand-java-example/src/main/java/com/stagehand/api/example/RemoteBrowserPlaywrightExample.java`
112112
- `stagehand-java-example/src/main/java/com/stagehand/api/example/LocalBrowserPlaywrightExample.java`
113113

114+
Multiregion support: see `stagehand-java-example/src/main/java/com/stagehand/api/example/LocalServerMultiregionBrowserExample.java`.
115+
114116
Set your environment variables (from `examples/.env.example`):
115117

116118
- `STAGEHAND_API_URL`

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88

99
allprojects {
1010
group = "com.browserbase.api"
11-
version = "0.7.0" // x-release-please-version
11+
version = "0.7.1" // x-release-please-version
1212
}
1313

1414
subprojects {
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package com.stagehand.api.example;
2+
3+
import com.browserbase.api.client.StagehandClient;
4+
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
5+
import com.browserbase.api.core.JsonValue;
6+
import com.browserbase.api.core.RequestOptions;
7+
import com.browserbase.api.core.http.StreamResponse;
8+
import com.browserbase.api.models.sessions.ModelConfig;
9+
import com.browserbase.api.models.sessions.SessionActParams;
10+
import com.browserbase.api.models.sessions.SessionEndParams;
11+
import com.browserbase.api.models.sessions.SessionExecuteParams;
12+
import com.browserbase.api.models.sessions.SessionExtractParams;
13+
import com.browserbase.api.models.sessions.SessionNavigateParams;
14+
import com.browserbase.api.models.sessions.SessionObserveParams;
15+
import com.browserbase.api.models.sessions.SessionStartParams;
16+
import com.browserbase.api.models.sessions.SessionStartResponse;
17+
import com.browserbase.api.models.sessions.StreamEvent;
18+
import java.time.Duration;
19+
import java.util.List;
20+
import java.util.Map;
21+
22+
/**
23+
* Local Stagehand server + multiregion Browserbase example demonstrating SSE streaming.
24+
*
25+
* This example shows the full flow of:
26+
* 1. Starting a Browserbase session in eu-central-1 (via local Stagehand server)
27+
* 2. Navigating to a webpage
28+
* 3. Observing possible actions (streaming)
29+
* 4. Acting on an element (streaming)
30+
* 5. Extracting structured data (streaming)
31+
* 6. Running an autonomous agent (streaming)
32+
* 7. Ending the session
33+
*
34+
* Required environment variables:
35+
* - BROWSERBASE_API_KEY: Your Browserbase API key
36+
* - BROWSERBASE_PROJECT_ID: Your Browserbase project ID
37+
* - MODEL_API_KEY: Your OpenAI API key
38+
* - STAGEHAND_API_URL: Local Stagehand server base URL
39+
*/
40+
public class LocalServerMultiregionBrowserExample {
41+
public static void main(String[] args) {
42+
Env.load();
43+
StagehandClient client = StagehandOkHttpClient.builder().fromEnv().build();
44+
45+
SessionStartResponse startResponse = client.sessions()
46+
.start(SessionStartParams.builder()
47+
.modelName("anthropic/claude-sonnet-4-6")
48+
.browser(SessionStartParams.Browser.builder()
49+
.type(SessionStartParams.Browser.Type.BROWSERBASE)
50+
.build())
51+
.browserbaseSessionCreateParams(SessionStartParams.BrowserbaseSessionCreateParams.builder()
52+
.projectId(System.getProperty("stagehand.browserbaseProjectId"))
53+
.region(SessionStartParams.BrowserbaseSessionCreateParams.Region.EU_CENTRAL_1)
54+
.build())
55+
.build());
56+
57+
String sessionId = startResponse.data().sessionId();
58+
System.out.println("Session started: " + sessionId);
59+
60+
try {
61+
client.sessions()
62+
.navigate(SessionNavigateParams.builder()
63+
.id(sessionId)
64+
.url("https://news.ycombinator.com")
65+
.build());
66+
System.out.println("Navigated to Hacker News");
67+
68+
SessionObserveParams observeParams = SessionObserveParams.builder()
69+
.id(sessionId)
70+
.instruction("find the link to view comments for the top post")
71+
.xStreamResponse(SessionObserveParams.XStreamResponse.TRUE)
72+
.build();
73+
try (StreamResponse<StreamEvent> observeStream = client.sessions().observeStreaming(observeParams)) {
74+
printStreamEvents("observe", observeStream);
75+
}
76+
77+
SessionActParams actParams = SessionActParams.builder()
78+
.id(sessionId)
79+
.input("Click the comments link for the top post")
80+
.xStreamResponse(SessionActParams.XStreamResponse.TRUE)
81+
.build();
82+
try (StreamResponse<StreamEvent> actStream = client.sessions().actStreaming(actParams)) {
83+
printStreamEvents("act", actStream);
84+
}
85+
86+
SessionExtractParams extractParams = SessionExtractParams.builder()
87+
.id(sessionId)
88+
.instruction("extract the text of the top comment on this page")
89+
.schema(SessionExtractParams.Schema.builder()
90+
.putAdditionalProperty("type", JsonValue.from("object"))
91+
.putAdditionalProperty(
92+
"properties",
93+
JsonValue.from(Map.of(
94+
"commentText",
95+
Map.of(
96+
"type",
97+
"string",
98+
"description",
99+
"The text content of the top comment"),
100+
"author",
101+
Map.of(
102+
"type",
103+
"string",
104+
"description",
105+
"The username of the comment author"))))
106+
.putAdditionalProperty("required", JsonValue.from(List.of("commentText")))
107+
.build())
108+
.xStreamResponse(SessionExtractParams.XStreamResponse.TRUE)
109+
.build();
110+
try (StreamResponse<StreamEvent> extractStream = client.sessions().extractStreaming(extractParams)) {
111+
printStreamEvents("extract", extractStream);
112+
}
113+
114+
SessionExecuteParams executeParams = SessionExecuteParams.builder()
115+
.id(sessionId)
116+
.executeOptions(SessionExecuteParams.ExecuteOptions.builder()
117+
.instruction(
118+
"Find any personal website, GitHub, LinkedIn, or other best profile URL for the"
119+
+ " top comment author on this page. Click on the username to go to their"
120+
+ " profile page and look for any links they have shared. Use Google Search"
121+
+ " with their username or other details from their profile if you don't find"
122+
+ " any direct links.")
123+
.maxSteps(15.0)
124+
.build())
125+
.agentConfig(SessionExecuteParams.AgentConfig.builder()
126+
.model(ModelConfig.builder()
127+
.modelName("anthropic/claude-opus-4-6")
128+
.apiKey(System.getProperty("stagehand.modelApiKey"))
129+
.build())
130+
.cua(false)
131+
.build())
132+
.xStreamResponse(SessionExecuteParams.XStreamResponse.TRUE)
133+
.build();
134+
try (StreamResponse<StreamEvent> executeStream = client.sessions()
135+
.executeStreaming(
136+
executeParams,
137+
RequestOptions.builder()
138+
.timeout(Duration.ofMinutes(5))
139+
.build())) {
140+
printStreamEvents("execute", executeStream);
141+
}
142+
} finally {
143+
client.sessions().end(SessionEndParams.builder().id(sessionId).build());
144+
System.out.println("Session ended");
145+
}
146+
}
147+
148+
private static void printStreamEvents(String label, StreamResponse<StreamEvent> stream) {
149+
stream.stream().forEach(event -> System.out.println("[" + label + "] " + event.type() + " " + event.data()));
150+
System.out.println("[" + label + "] stream complete");
151+
}
152+
}

0 commit comments

Comments
 (0)