Skip to content

Commit 2628417

Browse files
feat: Add executionModel serialization to api client
1 parent 65820a9 commit 2628417

12 files changed

Lines changed: 394 additions & 67 deletions

File tree

.github/workflows/publish-sonatype.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
export -- GPG_SIGNING_KEY_ID
3434
printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD"
3535
GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')"
36-
./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache
36+
./gradlew publish --no-configuration-cache
3737
env:
3838
SONATYPE_USERNAME: ${{ secrets.STAGEHAND_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
3939
SONATYPE_PASSWORD: ${{ secrets.STAGEHAND_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-43e6dd4ce19381de488d296e9036fea15bfea9a6f946cf8ccf4e02aecc8fb765.yml
3-
openapi_spec_hash: f736e7a8acea0d73e1031c86ea803246
4-
config_hash: b375728ccf7d33287335852f4f59c293
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-8fbb3fa8f3a37c1c7408de427fe125aadec49f705e8e30d191601a9b69c4cc41.yml
3+
openapi_spec_hash: 48b4dfac35a842d7fb0d228caf87544e
4+
config_hash: 242651c4871c2869ba3c2e3d337505b9

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ If you're looking for other languages, you can find them
6262
## What is Stagehand?
6363
The Stagehand Java SDK is similar to the Stagehand Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions.
6464

65-
The Stagehand Java SDK is similar to the Stagehand Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions.
66-
6765
It is generated with [Stainless](https://www.stainless.com/).
6866

6967
Stagehand is a browser automation framework used to control web browsers with natural language and code. By combining the power of AI with the precision of code, Stagehand makes web automation flexible, maintainable, and actually reliable.

build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
23
id("org.jetbrains.dokka") version "2.0.0"
34
}
45

@@ -34,3 +35,15 @@ tasks.named("dokkaJavadocCollector").configure {
3435
.filter { it.project.name != "stagehand-java" && it.name == "dokkaJavadocJar" }
3536
.forEach { mustRunAfter(it) }
3637
}
38+
39+
nexusPublishing {
40+
repositories {
41+
sonatype {
42+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
43+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
44+
45+
username.set(System.getenv("SONATYPE_USERNAME"))
46+
password.set(System.getenv("SONATYPE_PASSWORD"))
47+
}
48+
}
49+
}

buildSrc/build.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
plugins {
22
`kotlin-dsl`
33
kotlin("jvm") version "1.9.20"
4-
id("com.vanniktech.maven.publish") version "0.28.0"
54
}
65

76
repositories {
87
gradlePluginPortal()
9-
mavenCentral()
108
}
119

1210
dependencies {
1311
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
14-
implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0")
1512
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ repositories {
88
mavenCentral()
99
}
1010

11+
configure<JavaPluginExtension> {
12+
withJavadocJar()
13+
withSourcesJar()
14+
}
15+
1116
java {
1217
toolchain {
1318
languageVersion.set(JavaLanguageVersion.of(21))
@@ -22,6 +27,10 @@ tasks.withType<JavaCompile>().configureEach {
2227
options.release.set(8)
2328
}
2429

30+
tasks.named<Jar>("javadocJar") {
31+
setZip64(true)
32+
}
33+
2534
tasks.named<Jar>("jar") {
2635
manifest {
2736
attributes(mapOf(
Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,68 @@
1-
import com.vanniktech.maven.publish.JavadocJar
2-
import com.vanniktech.maven.publish.KotlinJvm
3-
import com.vanniktech.maven.publish.MavenPublishBaseExtension
4-
import com.vanniktech.maven.publish.SonatypeHost
5-
61
plugins {
7-
id("com.vanniktech.maven.publish")
8-
}
9-
10-
publishing {
11-
repositories {
12-
if (project.hasProperty("publishLocal")) {
13-
maven {
14-
name = "LocalFileSystem"
15-
url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo")
16-
}
17-
}
18-
}
2+
`maven-publish`
3+
signing
194
}
205

21-
repositories {
22-
gradlePluginPortal()
23-
mavenCentral()
24-
}
6+
configure<PublishingExtension> {
7+
publications {
8+
register<MavenPublication>("maven") {
9+
from(components["java"])
2510

26-
extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY")
27-
extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID")
28-
extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD")
11+
pom {
12+
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!")
14+
url.set("https://docs.stagehand.dev")
2915

30-
configure<MavenPublishBaseExtension> {
31-
if (!project.hasProperty("publishLocal")) {
32-
signAllPublications()
33-
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
34-
}
16+
licenses {
17+
license {
18+
name.set("MIT")
19+
}
20+
}
3521

36-
coordinates(project.group.toString(), project.name, project.version.toString())
37-
configure(
38-
KotlinJvm(
39-
javadocJar = JavadocJar.Dokka("dokkaJavadoc"),
40-
sourcesJar = true,
41-
)
42-
)
22+
developers {
23+
developer {
24+
name.set("Stagehand")
25+
}
26+
}
4327

44-
pom {
45-
name.set("Stagehand API")
46-
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!")
47-
url.set("https://docs.stagehand.dev")
28+
scm {
29+
connection.set("scm:git:git://github.com/browserbase/stagehand-java.git")
30+
developerConnection.set("scm:git:git://github.com/browserbase/stagehand-java.git")
31+
url.set("https://github.com/browserbase/stagehand-java")
32+
}
4833

49-
licenses {
50-
license {
51-
name.set("MIT")
34+
versionMapping {
35+
allVariants {
36+
fromResolutionResult()
37+
}
38+
}
5239
}
5340
}
54-
55-
developers {
56-
developer {
57-
name.set("Stagehand")
41+
}
42+
repositories {
43+
if (project.hasProperty("publishLocal")) {
44+
maven {
45+
name = "LocalFileSystem"
46+
url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo")
5847
}
5948
}
49+
}
50+
}
6051

61-
scm {
62-
connection.set("scm:git:git://github.com/browserbase/stagehand-java.git")
63-
developerConnection.set("scm:git:git://github.com/browserbase/stagehand-java.git")
64-
url.set("https://github.com/browserbase/stagehand-java")
65-
}
52+
signing {
53+
val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null }
54+
val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null }
55+
val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null }
56+
if (signingKey != null && signingPassword != null) {
57+
useInMemoryPgpKeys(
58+
signingKeyId,
59+
signingKey,
60+
signingPassword,
61+
)
62+
sign(publishing.publications["maven"])
6663
}
6764
}
6865

69-
tasks.withType<Zip>().configureEach {
70-
isZip64 = true
66+
tasks.named("publish") {
67+
dependsOn(":closeAndReleaseSonatypeStagingRepository")
7168
}

stagehand-java-core/src/main/kotlin/com/browserbase/api/core/handlers/SseHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal fun sseHandler(jsonMapper: JsonMapper): Handler<StreamResponse<SseMessa
2828
val message = state.decode(line) ?: continue
2929

3030
when {
31-
message.data.startsWith("{\"data\":{\"status\":\"finished\"") -> {
31+
message.data.startsWith("finished") -> {
3232
// In this case we don't break because we still want to iterate through the full
3333
// stream.
3434
done = true

0 commit comments

Comments
 (0)