Skip to content

Commit 058cf38

Browse files
feat: /end endpoint returns empty object
1 parent 7135947 commit 058cf38

9 files changed

Lines changed: 99 additions & 104 deletions

File tree

.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-ed52466945f2f8dfd3814a29e948d7bf30af7b76a7a7689079c03b8baf64e26f.yml
3-
openapi_spec_hash: 5d57aaf2362b0d882372dbf76477ba23
4-
config_hash: 8ec9eaf59304f664cf79f73de1488671
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-2c6c017cc9ca1fcfe7b3902edfa64fb0420bdb46b1740c7c862e81e2132d4f7c.yml
3+
openapi_spec_hash: 220daf7e8f5897909a6c10e3385386e3
4+
config_hash: 1f709f8775e13029dc60064ef3a94355

stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionEndParams.kt

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import com.browserbase.api.core.Enum
66
import com.browserbase.api.core.JsonField
77
import com.browserbase.api.core.JsonValue
88
import com.browserbase.api.core.Params
9+
import com.browserbase.api.core.checkRequired
910
import com.browserbase.api.core.http.Headers
1011
import com.browserbase.api.core.http.QueryParams
11-
import com.browserbase.api.core.toImmutable
1212
import com.browserbase.api.errors.StagehandInvalidDataException
1313
import com.fasterxml.jackson.annotation.JsonCreator
1414
import java.time.OffsetDateTime
@@ -25,9 +25,9 @@ private constructor(
2525
private val xSdkVersion: String?,
2626
private val xSentAt: OffsetDateTime?,
2727
private val xStreamResponse: XStreamResponse?,
28+
private val body: JsonValue,
2829
private val additionalHeaders: Headers,
2930
private val additionalQueryParams: QueryParams,
30-
private val additionalBodyProperties: Map<String, JsonValue>,
3131
) : Params {
3232

3333
/** Unique session identifier */
@@ -45,8 +45,7 @@ private constructor(
4545
/** Whether to stream the response via SSE */
4646
fun xStreamResponse(): Optional<XStreamResponse> = Optional.ofNullable(xStreamResponse)
4747

48-
/** Additional body properties to send with the request. */
49-
fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties
48+
fun body(): JsonValue = body
5049

5150
/** Additional headers to send with the request. */
5251
fun _additionalHeaders(): Headers = additionalHeaders
@@ -58,9 +57,14 @@ private constructor(
5857

5958
companion object {
6059

61-
@JvmStatic fun none(): SessionEndParams = builder().build()
62-
63-
/** Returns a mutable builder for constructing an instance of [SessionEndParams]. */
60+
/**
61+
* Returns a mutable builder for constructing an instance of [SessionEndParams].
62+
*
63+
* The following fields are required:
64+
* ```java
65+
* .body()
66+
* ```
67+
*/
6468
@JvmStatic fun builder() = Builder()
6569
}
6670

@@ -72,9 +76,9 @@ private constructor(
7276
private var xSdkVersion: String? = null
7377
private var xSentAt: OffsetDateTime? = null
7478
private var xStreamResponse: XStreamResponse? = null
79+
private var body: JsonValue? = null
7580
private var additionalHeaders: Headers.Builder = Headers.builder()
7681
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
77-
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()
7882

7983
@JvmSynthetic
8084
internal fun from(sessionEndParams: SessionEndParams) = apply {
@@ -83,9 +87,9 @@ private constructor(
8387
xSdkVersion = sessionEndParams.xSdkVersion
8488
xSentAt = sessionEndParams.xSentAt
8589
xStreamResponse = sessionEndParams.xStreamResponse
90+
body = sessionEndParams.body
8691
additionalHeaders = sessionEndParams.additionalHeaders.toBuilder()
8792
additionalQueryParams = sessionEndParams.additionalQueryParams.toBuilder()
88-
additionalBodyProperties = sessionEndParams.additionalBodyProperties.toMutableMap()
8993
}
9094

9195
/** Unique session identifier */
@@ -121,6 +125,8 @@ private constructor(
121125
fun xStreamResponse(xStreamResponse: Optional<XStreamResponse>) =
122126
xStreamResponse(xStreamResponse.getOrNull())
123127

128+
fun body(body: JsonValue) = apply { this.body = body }
129+
124130
fun additionalHeaders(additionalHeaders: Headers) = apply {
125131
this.additionalHeaders.clear()
126132
putAllAdditionalHeaders(additionalHeaders)
@@ -219,32 +225,17 @@ private constructor(
219225
additionalQueryParams.removeAll(keys)
220226
}
221227

222-
fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply {
223-
this.additionalBodyProperties.clear()
224-
putAllAdditionalBodyProperties(additionalBodyProperties)
225-
}
226-
227-
fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
228-
additionalBodyProperties.put(key, value)
229-
}
230-
231-
fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) =
232-
apply {
233-
this.additionalBodyProperties.putAll(additionalBodyProperties)
234-
}
235-
236-
fun removeAdditionalBodyProperty(key: String) = apply {
237-
additionalBodyProperties.remove(key)
238-
}
239-
240-
fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply {
241-
keys.forEach(::removeAdditionalBodyProperty)
242-
}
243-
244228
/**
245229
* Returns an immutable instance of [SessionEndParams].
246230
*
247231
* Further updates to this [Builder] will not mutate the returned instance.
232+
*
233+
* The following fields are required:
234+
* ```java
235+
* .body()
236+
* ```
237+
*
238+
* @throws IllegalStateException if any required field is unset.
248239
*/
249240
fun build(): SessionEndParams =
250241
SessionEndParams(
@@ -253,14 +244,13 @@ private constructor(
253244
xSdkVersion,
254245
xSentAt,
255246
xStreamResponse,
247+
checkRequired("body", body),
256248
additionalHeaders.build(),
257249
additionalQueryParams.build(),
258-
additionalBodyProperties.toImmutable(),
259250
)
260251
}
261252

262-
fun _body(): Optional<Map<String, JsonValue>> =
263-
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
253+
fun _body(): JsonValue = body
264254

265255
fun _pathParam(index: Int): String =
266256
when (index) {
@@ -560,9 +550,9 @@ private constructor(
560550
xSdkVersion == other.xSdkVersion &&
561551
xSentAt == other.xSentAt &&
562552
xStreamResponse == other.xStreamResponse &&
553+
body == other.body &&
563554
additionalHeaders == other.additionalHeaders &&
564-
additionalQueryParams == other.additionalQueryParams &&
565-
additionalBodyProperties == other.additionalBodyProperties
555+
additionalQueryParams == other.additionalQueryParams
566556
}
567557

568558
override fun hashCode(): Int =
@@ -572,11 +562,11 @@ private constructor(
572562
xSdkVersion,
573563
xSentAt,
574564
xStreamResponse,
565+
body,
575566
additionalHeaders,
576567
additionalQueryParams,
577-
additionalBodyProperties,
578568
)
579569

580570
override fun toString() =
581-
"SessionEndParams{id=$id, xLanguage=$xLanguage, xSdkVersion=$xSdkVersion, xSentAt=$xSentAt, xStreamResponse=$xStreamResponse, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}"
571+
"SessionEndParams{id=$id, xLanguage=$xLanguage, xSdkVersion=$xSdkVersion, xSentAt=$xSentAt, xStreamResponse=$xStreamResponse, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
582572
}

stagehand-java-core/src/main/kotlin/com/browserbase/api/services/async/SessionServiceAsync.kt

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -89,36 +89,27 @@ interface SessionServiceAsync {
8989
): AsyncStreamResponse<StreamEvent>
9090

9191
/** Terminates the browser session and releases all associated resources. */
92-
fun end(id: String): CompletableFuture<SessionEndResponse> = end(id, SessionEndParams.none())
92+
fun end(id: String, params: SessionEndParams): CompletableFuture<SessionEndResponse> =
93+
end(id, params, RequestOptions.none())
9394

9495
/** @see end */
9596
fun end(
9697
id: String,
97-
params: SessionEndParams = SessionEndParams.none(),
98+
params: SessionEndParams,
9899
requestOptions: RequestOptions = RequestOptions.none(),
99100
): CompletableFuture<SessionEndResponse> =
100101
end(params.toBuilder().id(id).build(), requestOptions)
101102

102103
/** @see end */
103-
fun end(
104-
id: String,
105-
params: SessionEndParams = SessionEndParams.none(),
106-
): CompletableFuture<SessionEndResponse> = end(id, params, RequestOptions.none())
104+
fun end(params: SessionEndParams): CompletableFuture<SessionEndResponse> =
105+
end(params, RequestOptions.none())
107106

108107
/** @see end */
109108
fun end(
110109
params: SessionEndParams,
111110
requestOptions: RequestOptions = RequestOptions.none(),
112111
): CompletableFuture<SessionEndResponse>
113112

114-
/** @see end */
115-
fun end(params: SessionEndParams): CompletableFuture<SessionEndResponse> =
116-
end(params, RequestOptions.none())
117-
118-
/** @see end */
119-
fun end(id: String, requestOptions: RequestOptions): CompletableFuture<SessionEndResponse> =
120-
end(id, SessionEndParams.none(), requestOptions)
121-
122113
/** Runs an autonomous AI agent that can perform complex multi-step browser tasks. */
123114
fun execute(
124115
id: String,
@@ -430,40 +421,29 @@ interface SessionServiceAsync {
430421
* Returns a raw HTTP response for `post /v1/sessions/{id}/end`, but is otherwise the same
431422
* as [SessionServiceAsync.end].
432423
*/
433-
fun end(id: String): CompletableFuture<HttpResponseFor<SessionEndResponse>> =
434-
end(id, SessionEndParams.none())
435-
436-
/** @see end */
437424
fun end(
438425
id: String,
439-
params: SessionEndParams = SessionEndParams.none(),
440-
requestOptions: RequestOptions = RequestOptions.none(),
441-
): CompletableFuture<HttpResponseFor<SessionEndResponse>> =
442-
end(params.toBuilder().id(id).build(), requestOptions)
443-
444-
/** @see end */
445-
fun end(
446-
id: String,
447-
params: SessionEndParams = SessionEndParams.none(),
426+
params: SessionEndParams,
448427
): CompletableFuture<HttpResponseFor<SessionEndResponse>> =
449428
end(id, params, RequestOptions.none())
450429

451430
/** @see end */
452431
fun end(
432+
id: String,
453433
params: SessionEndParams,
454434
requestOptions: RequestOptions = RequestOptions.none(),
455-
): CompletableFuture<HttpResponseFor<SessionEndResponse>>
435+
): CompletableFuture<HttpResponseFor<SessionEndResponse>> =
436+
end(params.toBuilder().id(id).build(), requestOptions)
456437

457438
/** @see end */
458439
fun end(params: SessionEndParams): CompletableFuture<HttpResponseFor<SessionEndResponse>> =
459440
end(params, RequestOptions.none())
460441

461442
/** @see end */
462443
fun end(
463-
id: String,
464-
requestOptions: RequestOptions,
465-
): CompletableFuture<HttpResponseFor<SessionEndResponse>> =
466-
end(id, SessionEndParams.none(), requestOptions)
444+
params: SessionEndParams,
445+
requestOptions: RequestOptions = RequestOptions.none(),
446+
): CompletableFuture<HttpResponseFor<SessionEndResponse>>
467447

468448
/**
469449
* Returns a raw HTTP response for `post /v1/sessions/{id}/agentExecute`, but is otherwise

stagehand-java-core/src/main/kotlin/com/browserbase/api/services/async/SessionServiceAsyncImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl
250250
.method(HttpMethod.POST)
251251
.baseUrl(clientOptions.baseUrl())
252252
.addPathSegments("v1", "sessions", params._pathParam(0), "end")
253-
.apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } }
253+
.body(json(clientOptions.jsonMapper, params._body()))
254254
.build()
255255
.prepareAsync(clientOptions, params)
256256
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))

stagehand-java-core/src/main/kotlin/com/browserbase/api/services/blocking/SessionService.kt

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,25 @@ interface SessionService {
8888
): StreamResponse<StreamEvent>
8989

9090
/** Terminates the browser session and releases all associated resources. */
91-
fun end(id: String): SessionEndResponse = end(id, SessionEndParams.none())
91+
fun end(id: String, params: SessionEndParams): SessionEndResponse =
92+
end(id, params, RequestOptions.none())
9293

9394
/** @see end */
9495
fun end(
9596
id: String,
96-
params: SessionEndParams = SessionEndParams.none(),
97+
params: SessionEndParams,
9798
requestOptions: RequestOptions = RequestOptions.none(),
9899
): SessionEndResponse = end(params.toBuilder().id(id).build(), requestOptions)
99100

100101
/** @see end */
101-
fun end(id: String, params: SessionEndParams = SessionEndParams.none()): SessionEndResponse =
102-
end(id, params, RequestOptions.none())
102+
fun end(params: SessionEndParams): SessionEndResponse = end(params, RequestOptions.none())
103103

104104
/** @see end */
105105
fun end(
106106
params: SessionEndParams,
107107
requestOptions: RequestOptions = RequestOptions.none(),
108108
): SessionEndResponse
109109

110-
/** @see end */
111-
fun end(params: SessionEndParams): SessionEndResponse = end(params, RequestOptions.none())
112-
113-
/** @see end */
114-
fun end(id: String, requestOptions: RequestOptions): SessionEndResponse =
115-
end(id, SessionEndParams.none(), requestOptions)
116-
117110
/** Runs an autonomous AI agent that can perform complex multi-step browser tasks. */
118111
fun execute(id: String, params: SessionExecuteParams): SessionExecuteResponse =
119112
execute(id, params, RequestOptions.none())
@@ -413,23 +406,22 @@ interface SessionService {
413406
* as [SessionService.end].
414407
*/
415408
@MustBeClosed
416-
fun end(id: String): HttpResponseFor<SessionEndResponse> = end(id, SessionEndParams.none())
409+
fun end(id: String, params: SessionEndParams): HttpResponseFor<SessionEndResponse> =
410+
end(id, params, RequestOptions.none())
417411

418412
/** @see end */
419413
@MustBeClosed
420414
fun end(
421415
id: String,
422-
params: SessionEndParams = SessionEndParams.none(),
416+
params: SessionEndParams,
423417
requestOptions: RequestOptions = RequestOptions.none(),
424418
): HttpResponseFor<SessionEndResponse> =
425419
end(params.toBuilder().id(id).build(), requestOptions)
426420

427421
/** @see end */
428422
@MustBeClosed
429-
fun end(
430-
id: String,
431-
params: SessionEndParams = SessionEndParams.none(),
432-
): HttpResponseFor<SessionEndResponse> = end(id, params, RequestOptions.none())
423+
fun end(params: SessionEndParams): HttpResponseFor<SessionEndResponse> =
424+
end(params, RequestOptions.none())
433425

434426
/** @see end */
435427
@MustBeClosed
@@ -438,16 +430,6 @@ interface SessionService {
438430
requestOptions: RequestOptions = RequestOptions.none(),
439431
): HttpResponseFor<SessionEndResponse>
440432

441-
/** @see end */
442-
@MustBeClosed
443-
fun end(params: SessionEndParams): HttpResponseFor<SessionEndResponse> =
444-
end(params, RequestOptions.none())
445-
446-
/** @see end */
447-
@MustBeClosed
448-
fun end(id: String, requestOptions: RequestOptions): HttpResponseFor<SessionEndResponse> =
449-
end(id, SessionEndParams.none(), requestOptions)
450-
451433
/**
452434
* Returns a raw HTTP response for `post /v1/sessions/{id}/agentExecute`, but is otherwise
453435
* the same as [SessionService.execute].

stagehand-java-core/src/main/kotlin/com/browserbase/api/services/blocking/SessionServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO
223223
.method(HttpMethod.POST)
224224
.baseUrl(clientOptions.baseUrl())
225225
.addPathSegments("v1", "sessions", params._pathParam(0), "end")
226-
.apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } }
226+
.body(json(clientOptions.jsonMapper, params._body()))
227227
.build()
228228
.prepare(clientOptions, params)
229229
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))

0 commit comments

Comments
 (0)