From 84fc60f6b75cd49758a4e898482bc9651927aad3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Apr 2026 19:38:43 +0000 Subject: [PATCH 1/5] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ac9e78a..ade26eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-b969ce378479c79ee64c05127c0ed6c6ce2edbee017ecd037242fb618a5ebc9f.yml openapi_spec_hash: a24aabaa5214effb679808b7f2be0ad4 -config_hash: a962ae71493deb11a1c903256fb25386 +config_hash: 0cc516caf1432087f40654336e0fa8cd From 7d5037abacedbee829f0fe238565ed81c211eba9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 18:22:46 +0000 Subject: [PATCH 2/5] feat: Bedrock auth passthrough --- .stats.yml | 4 +- .../api/models/sessions/ModelConfig.kt | 1987 +++++++- .../models/sessions/SessionExecuteParams.kt | 97 +- .../api/models/sessions/SessionStartParams.kt | 4089 ++++++++++++++++- .../api/models/sessions/StreamEvent.kt | 4 +- .../api/models/sessions/ModelConfigTest.kt | 33 +- .../models/sessions/SessionActParamsTest.kt | 54 +- .../sessions/SessionExecuteParamsTest.kt | 116 +- .../sessions/SessionExtractParamsTest.kt | 54 +- .../sessions/SessionObserveParamsTest.kt | 54 +- .../models/sessions/SessionStartParamsTest.kt | 87 + .../api/services/ErrorHandlingTest.kt | 459 ++ .../api/services/ServiceParamsTest.kt | 35 +- .../services/async/SessionServiceAsyncTest.kt | 171 +- .../services/blocking/SessionServiceTest.kt | 171 +- 15 files changed, 7207 insertions(+), 208 deletions(-) diff --git a/.stats.yml b/.stats.yml index ade26eb..f1d6429 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-b969ce378479c79ee64c05127c0ed6c6ce2edbee017ecd037242fb618a5ebc9f.yml -openapi_spec_hash: a24aabaa5214effb679808b7f2be0ad4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-7773ef4ca29c983daafb787ee918cfa6b5b12c5bbdc088308653f2737c26e51f.yml +openapi_spec_hash: 47fc8f2540be0b6374e4230c021072d9 config_hash: 0cc516caf1432087f40654336e0fa8cd diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt index 4e46131..c397bfa 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt @@ -2,18 +2,29 @@ package com.browserbase.api.models.sessions +import com.browserbase.api.core.BaseDeserializer +import com.browserbase.api.core.BaseSerializer import com.browserbase.api.core.Enum import com.browserbase.api.core.ExcludeMissing import com.browserbase.api.core.JsonField import com.browserbase.api.core.JsonMissing import com.browserbase.api.core.JsonValue +import com.browserbase.api.core.allMaxBy import com.browserbase.api.core.checkRequired +import com.browserbase.api.core.getOrThrow import com.browserbase.api.core.toImmutable import com.browserbase.api.errors.StagehandInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Collections import java.util.Objects import java.util.Optional @@ -27,6 +38,8 @@ private constructor( private val baseUrl: JsonField, private val headers: JsonField, private val provider: JsonField, + private val providerOptions: JsonField, + private val skipApiKeyFallback: JsonField, private val additionalProperties: MutableMap, ) { @@ -37,7 +50,22 @@ private constructor( @JsonProperty("baseURL") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(), @JsonProperty("provider") @ExcludeMissing provider: JsonField = JsonMissing.of(), - ) : this(modelName, apiKey, baseUrl, headers, provider, mutableMapOf()) + @JsonProperty("providerOptions") + @ExcludeMissing + providerOptions: JsonField = JsonMissing.of(), + @JsonProperty("skipApiKeyFallback") + @ExcludeMissing + skipApiKeyFallback: JsonField = JsonMissing.of(), + ) : this( + modelName, + apiKey, + baseUrl, + headers, + provider, + providerOptions, + skipApiKeyFallback, + mutableMapOf(), + ) /** * Model name string with provider prefix (e.g., 'openai/gpt-5-nano') @@ -64,7 +92,7 @@ private constructor( fun baseUrl(): Optional = baseUrl.getOptional("baseURL") /** - * Custom headers sent with every request to the model provider + * Custom headers for the model provider * * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -79,6 +107,27 @@ private constructor( */ fun provider(): Optional = provider.getOptional("provider") + /** + * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { + * region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, + * googleAuthOptions }. + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun providerOptions(): Optional = + providerOptions.getOptional("providerOptions") + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when + * auth is carried through providerOptions instead of an API key. + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun skipApiKeyFallback(): Optional = + skipApiKeyFallback.getOptional("skipApiKeyFallback") + /** * Returns the raw JSON value of [modelName]. * @@ -114,6 +163,25 @@ private constructor( */ @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider + /** + * Returns the raw JSON value of [providerOptions]. + * + * Unlike [providerOptions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("providerOptions") + @ExcludeMissing + fun _providerOptions(): JsonField = providerOptions + + /** + * Returns the raw JSON value of [skipApiKeyFallback]. + * + * Unlike [skipApiKeyFallback], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("skipApiKeyFallback") + @ExcludeMissing + fun _skipApiKeyFallback(): JsonField = skipApiKeyFallback + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -147,6 +215,8 @@ private constructor( private var baseUrl: JsonField = JsonMissing.of() private var headers: JsonField = JsonMissing.of() private var provider: JsonField = JsonMissing.of() + private var providerOptions: JsonField = JsonMissing.of() + private var skipApiKeyFallback: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -156,6 +226,8 @@ private constructor( baseUrl = modelConfig.baseUrl headers = modelConfig.headers provider = modelConfig.provider + providerOptions = modelConfig.providerOptions + skipApiKeyFallback = modelConfig.skipApiKeyFallback additionalProperties = modelConfig.additionalProperties.toMutableMap() } @@ -193,7 +265,7 @@ private constructor( */ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Custom headers sent with every request to the model provider */ + /** Custom headers for the model provider */ fun headers(headers: Headers) = headers(JsonField.of(headers)) /** @@ -216,6 +288,64 @@ private constructor( */ fun provider(provider: JsonField) = apply { this.provider = provider } + /** + * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: + * { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, + * googleAuthOptions }. + */ + fun providerOptions(providerOptions: ProviderOptions) = + providerOptions(JsonField.of(providerOptions)) + + /** + * Sets [Builder.providerOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.providerOptions] with a well-typed [ProviderOptions] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun providerOptions(providerOptions: JsonField) = apply { + this.providerOptions = providerOptions + } + + /** + * Alias for calling [providerOptions] with + * `ProviderOptions.ofBedrockApiKey(bedrockApiKey)`. + */ + fun providerOptions(bedrockApiKey: ProviderOptions.BedrockApiKeyProviderOptions) = + providerOptions(ProviderOptions.ofBedrockApiKey(bedrockApiKey)) + + /** + * Alias for calling [providerOptions] with + * `ProviderOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)`. + */ + fun providerOptions( + bedrockAwsCredentials: ProviderOptions.BedrockAwsCredentialsProviderOptions + ) = providerOptions(ProviderOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)) + + /** + * Alias for calling [providerOptions] with `ProviderOptions.ofGoogleVertex(googleVertex)`. + */ + fun providerOptions(googleVertex: ProviderOptions.GoogleVertexProviderOptions) = + providerOptions(ProviderOptions.ofGoogleVertex(googleVertex)) + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when + * auth is carried through providerOptions instead of an API key. + */ + fun skipApiKeyFallback(skipApiKeyFallback: Boolean) = + skipApiKeyFallback(JsonField.of(skipApiKeyFallback)) + + /** + * Sets [Builder.skipApiKeyFallback] to an arbitrary JSON value. + * + * You should usually call [Builder.skipApiKeyFallback] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipApiKeyFallback(skipApiKeyFallback: JsonField) = apply { + this.skipApiKeyFallback = skipApiKeyFallback + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -254,6 +384,8 @@ private constructor( baseUrl, headers, provider, + providerOptions, + skipApiKeyFallback, additionalProperties.toMutableMap(), ) } @@ -270,6 +402,8 @@ private constructor( baseUrl() headers().ifPresent { it.validate() } provider().ifPresent { it.validate() } + providerOptions().ifPresent { it.validate() } + skipApiKeyFallback() validated = true } @@ -292,9 +426,11 @@ private constructor( (if (apiKey.asKnown().isPresent) 1 else 0) + (if (baseUrl.asKnown().isPresent) 1 else 0) + (headers.asKnown().getOrNull()?.validity() ?: 0) + - (provider.asKnown().getOrNull()?.validity() ?: 0) + (provider.asKnown().getOrNull()?.validity() ?: 0) + + (providerOptions.asKnown().getOrNull()?.validity() ?: 0) + + (if (skipApiKeyFallback.asKnown().isPresent) 1 else 0) - /** Custom headers sent with every request to the model provider */ + /** Custom headers for the model provider */ class Headers @JsonCreator private constructor( @@ -540,6 +676,1832 @@ private constructor( override fun toString() = value.toString() } + /** + * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { + * region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, + * googleAuthOptions }. + */ + @JsonDeserialize(using = ProviderOptions.Deserializer::class) + @JsonSerialize(using = ProviderOptions.Serializer::class) + class ProviderOptions + private constructor( + private val bedrockApiKey: BedrockApiKeyProviderOptions? = null, + private val bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions? = null, + private val googleVertex: GoogleVertexProviderOptions? = null, + private val _json: JsonValue? = null, + ) { + + fun bedrockApiKey(): Optional = + Optional.ofNullable(bedrockApiKey) + + fun bedrockAwsCredentials(): Optional = + Optional.ofNullable(bedrockAwsCredentials) + + fun googleVertex(): Optional = + Optional.ofNullable(googleVertex) + + fun isBedrockApiKey(): Boolean = bedrockApiKey != null + + fun isBedrockAwsCredentials(): Boolean = bedrockAwsCredentials != null + + fun isGoogleVertex(): Boolean = googleVertex != null + + fun asBedrockApiKey(): BedrockApiKeyProviderOptions = + bedrockApiKey.getOrThrow("bedrockApiKey") + + fun asBedrockAwsCredentials(): BedrockAwsCredentialsProviderOptions = + bedrockAwsCredentials.getOrThrow("bedrockAwsCredentials") + + fun asGoogleVertex(): GoogleVertexProviderOptions = googleVertex.getOrThrow("googleVertex") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + bedrockApiKey != null -> visitor.visitBedrockApiKey(bedrockApiKey) + bedrockAwsCredentials != null -> + visitor.visitBedrockAwsCredentials(bedrockAwsCredentials) + googleVertex != null -> visitor.visitGoogleVertex(googleVertex) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ProviderOptions = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions) { + bedrockApiKey.validate() + } + + override fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions + ) { + bedrockAwsCredentials.validate() + } + + override fun visitGoogleVertex(googleVertex: GoogleVertexProviderOptions) { + googleVertex.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions) = + bedrockApiKey.validity() + + override fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions + ) = bedrockAwsCredentials.validity() + + override fun visitGoogleVertex(googleVertex: GoogleVertexProviderOptions) = + googleVertex.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderOptions && + bedrockApiKey == other.bedrockApiKey && + bedrockAwsCredentials == other.bedrockAwsCredentials && + googleVertex == other.googleVertex + } + + override fun hashCode(): Int = + Objects.hash(bedrockApiKey, bedrockAwsCredentials, googleVertex) + + override fun toString(): String = + when { + bedrockApiKey != null -> "ProviderOptions{bedrockApiKey=$bedrockApiKey}" + bedrockAwsCredentials != null -> + "ProviderOptions{bedrockAwsCredentials=$bedrockAwsCredentials}" + googleVertex != null -> "ProviderOptions{googleVertex=$googleVertex}" + _json != null -> "ProviderOptions{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ProviderOptions") + } + + companion object { + + @JvmStatic + fun ofBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions) = + ProviderOptions(bedrockApiKey = bedrockApiKey) + + @JvmStatic + fun ofBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions + ) = ProviderOptions(bedrockAwsCredentials = bedrockAwsCredentials) + + @JvmStatic + fun ofGoogleVertex(googleVertex: GoogleVertexProviderOptions) = + ProviderOptions(googleVertex = googleVertex) + } + + /** + * An interface that defines how to map each variant of [ProviderOptions] to a value of type + * [T]. + */ + interface Visitor { + + fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions): T + + fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions + ): T + + fun visitGoogleVertex(googleVertex: GoogleVertexProviderOptions): T + + /** + * Maps an unknown variant of [ProviderOptions] to a value of type [T]. + * + * An instance of [ProviderOptions] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws StagehandInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw StagehandInvalidDataException("Unknown ProviderOptions: $json") + } + } + + internal class Deserializer : BaseDeserializer(ProviderOptions::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ProviderOptions { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { ProviderOptions(bedrockApiKey = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { ProviderOptions(bedrockAwsCredentials = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ProviderOptions(googleVertex = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> ProviderOptions(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ProviderOptions::class) { + + override fun serialize( + value: ProviderOptions, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bedrockApiKey != null -> generator.writeObject(value.bedrockApiKey) + value.bedrockAwsCredentials != null -> + generator.writeObject(value.bedrockAwsCredentials) + value.googleVertex != null -> generator.writeObject(value.googleVertex) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ProviderOptions") + } + } + } + + class BedrockApiKeyProviderOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val region: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("region") @ExcludeMissing region: JsonField = JsonMissing.of() + ) : this(region, mutableMapOf()) + + /** + * AWS region for Amazon Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun region(): String = region.getRequired("region") + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BedrockApiKeyProviderOptions]. + * + * The following fields are required: + * ```java + * .region() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BedrockApiKeyProviderOptions]. */ + class Builder internal constructor() { + + private var region: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bedrockApiKeyProviderOptions: BedrockApiKeyProviderOptions) = + apply { + region = bedrockApiKeyProviderOptions.region + additionalProperties = + bedrockApiKeyProviderOptions.additionalProperties.toMutableMap() + } + + /** AWS region for Amazon Bedrock */ + fun region(region: String) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun region(region: JsonField) = apply { this.region = region } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BedrockApiKeyProviderOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .region() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BedrockApiKeyProviderOptions = + BedrockApiKeyProviderOptions( + checkRequired("region", region), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BedrockApiKeyProviderOptions = apply { + if (validated) { + return@apply + } + + region() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (region.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BedrockApiKeyProviderOptions && + region == other.region && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(region, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BedrockApiKeyProviderOptions{region=$region, additionalProperties=$additionalProperties}" + } + + class BedrockAwsCredentialsProviderOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessKeyId: JsonField, + private val region: JsonField, + private val secretAccessKey: JsonField, + private val sessionToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accessKeyId") + @ExcludeMissing + accessKeyId: JsonField = JsonMissing.of(), + @JsonProperty("region") + @ExcludeMissing + region: JsonField = JsonMissing.of(), + @JsonProperty("secretAccessKey") + @ExcludeMissing + secretAccessKey: JsonField = JsonMissing.of(), + @JsonProperty("sessionToken") + @ExcludeMissing + sessionToken: JsonField = JsonMissing.of(), + ) : this(accessKeyId, region, secretAccessKey, sessionToken, mutableMapOf()) + + /** + * AWS access key ID for Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun accessKeyId(): String = accessKeyId.getRequired("accessKeyId") + + /** + * AWS region for Amazon Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun region(): String = region.getRequired("region") + + /** + * AWS secret access key for Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun secretAccessKey(): String = secretAccessKey.getRequired("secretAccessKey") + + /** + * Optional AWS session token for temporary credentials + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionToken(): Optional = sessionToken.getOptional("sessionToken") + + /** + * Returns the raw JSON value of [accessKeyId]. + * + * Unlike [accessKeyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("accessKeyId") + @ExcludeMissing + fun _accessKeyId(): JsonField = accessKeyId + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region + + /** + * Returns the raw JSON value of [secretAccessKey]. + * + * Unlike [secretAccessKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("secretAccessKey") + @ExcludeMissing + fun _secretAccessKey(): JsonField = secretAccessKey + + /** + * Returns the raw JSON value of [sessionToken]. + * + * Unlike [sessionToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sessionToken") + @ExcludeMissing + fun _sessionToken(): JsonField = sessionToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BedrockAwsCredentialsProviderOptions]. + * + * The following fields are required: + * ```java + * .accessKeyId() + * .region() + * .secretAccessKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BedrockAwsCredentialsProviderOptions]. */ + class Builder internal constructor() { + + private var accessKeyId: JsonField? = null + private var region: JsonField? = null + private var secretAccessKey: JsonField? = null + private var sessionToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + bedrockAwsCredentialsProviderOptions: BedrockAwsCredentialsProviderOptions + ) = apply { + accessKeyId = bedrockAwsCredentialsProviderOptions.accessKeyId + region = bedrockAwsCredentialsProviderOptions.region + secretAccessKey = bedrockAwsCredentialsProviderOptions.secretAccessKey + sessionToken = bedrockAwsCredentialsProviderOptions.sessionToken + additionalProperties = + bedrockAwsCredentialsProviderOptions.additionalProperties.toMutableMap() + } + + /** AWS access key ID for Bedrock */ + fun accessKeyId(accessKeyId: String) = accessKeyId(JsonField.of(accessKeyId)) + + /** + * Sets [Builder.accessKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.accessKeyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun accessKeyId(accessKeyId: JsonField) = apply { + this.accessKeyId = accessKeyId + } + + /** AWS region for Amazon Bedrock */ + fun region(region: String) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun region(region: JsonField) = apply { this.region = region } + + /** AWS secret access key for Bedrock */ + fun secretAccessKey(secretAccessKey: String) = + secretAccessKey(JsonField.of(secretAccessKey)) + + /** + * Sets [Builder.secretAccessKey] to an arbitrary JSON value. + * + * You should usually call [Builder.secretAccessKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secretAccessKey(secretAccessKey: JsonField) = apply { + this.secretAccessKey = secretAccessKey + } + + /** Optional AWS session token for temporary credentials */ + fun sessionToken(sessionToken: String) = sessionToken(JsonField.of(sessionToken)) + + /** + * Sets [Builder.sessionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sessionToken(sessionToken: JsonField) = apply { + this.sessionToken = sessionToken + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BedrockAwsCredentialsProviderOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessKeyId() + * .region() + * .secretAccessKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BedrockAwsCredentialsProviderOptions = + BedrockAwsCredentialsProviderOptions( + checkRequired("accessKeyId", accessKeyId), + checkRequired("region", region), + checkRequired("secretAccessKey", secretAccessKey), + sessionToken, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BedrockAwsCredentialsProviderOptions = apply { + if (validated) { + return@apply + } + + accessKeyId() + region() + secretAccessKey() + sessionToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessKeyId.asKnown().isPresent) 1 else 0) + + (if (region.asKnown().isPresent) 1 else 0) + + (if (secretAccessKey.asKnown().isPresent) 1 else 0) + + (if (sessionToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BedrockAwsCredentialsProviderOptions && + accessKeyId == other.accessKeyId && + region == other.region && + secretAccessKey == other.secretAccessKey && + sessionToken == other.sessionToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessKeyId, + region, + secretAccessKey, + sessionToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BedrockAwsCredentialsProviderOptions{accessKeyId=$accessKeyId, region=$region, secretAccessKey=$secretAccessKey, sessionToken=$sessionToken, additionalProperties=$additionalProperties}" + } + + class GoogleVertexProviderOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val googleAuthOptions: JsonField, + private val headers: JsonField, + private val location: JsonField, + private val project: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("googleAuthOptions") + @ExcludeMissing + googleAuthOptions: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + location: JsonField = JsonMissing.of(), + @JsonProperty("project") + @ExcludeMissing + project: JsonField = JsonMissing.of(), + ) : this(googleAuthOptions, headers, location, project, mutableMapOf()) + + /** + * Optional Google auth options for Vertex AI + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun googleAuthOptions(): Optional = + googleAuthOptions.getOptional("googleAuthOptions") + + /** + * Custom headers for Vertex AI requests + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * Google Cloud location for Vertex AI + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun location(): Optional = location.getOptional("location") + + /** + * Google Cloud project ID for Vertex AI + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun project(): Optional = project.getOptional("project") + + /** + * Returns the raw JSON value of [googleAuthOptions]. + * + * Unlike [googleAuthOptions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("googleAuthOptions") + @ExcludeMissing + fun _googleAuthOptions(): JsonField = googleAuthOptions + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + + /** + * Returns the raw JSON value of [project]. + * + * Unlike [project], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project") @ExcludeMissing fun _project(): JsonField = project + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GoogleVertexProviderOptions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleVertexProviderOptions]. */ + class Builder internal constructor() { + + private var googleAuthOptions: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var project: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(googleVertexProviderOptions: GoogleVertexProviderOptions) = + apply { + googleAuthOptions = googleVertexProviderOptions.googleAuthOptions + headers = googleVertexProviderOptions.headers + location = googleVertexProviderOptions.location + project = googleVertexProviderOptions.project + additionalProperties = + googleVertexProviderOptions.additionalProperties.toMutableMap() + } + + /** Optional Google auth options for Vertex AI */ + fun googleAuthOptions(googleAuthOptions: GoogleAuthOptions) = + googleAuthOptions(JsonField.of(googleAuthOptions)) + + /** + * Sets [Builder.googleAuthOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.googleAuthOptions] with a well-typed + * [GoogleAuthOptions] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun googleAuthOptions(googleAuthOptions: JsonField) = apply { + this.googleAuthOptions = googleAuthOptions + } + + /** Custom headers for Vertex AI requests */ + fun headers(headers: Headers) = headers(JsonField.of(headers)) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + /** Google Cloud location for Vertex AI */ + fun location(location: String) = location(JsonField.of(location)) + + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun location(location: JsonField) = apply { this.location = location } + + /** Google Cloud project ID for Vertex AI */ + fun project(project: String) = project(JsonField.of(project)) + + /** + * Sets [Builder.project] to an arbitrary JSON value. + * + * You should usually call [Builder.project] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun project(project: JsonField) = apply { this.project = project } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GoogleVertexProviderOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GoogleVertexProviderOptions = + GoogleVertexProviderOptions( + googleAuthOptions, + headers, + location, + project, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GoogleVertexProviderOptions = apply { + if (validated) { + return@apply + } + + googleAuthOptions().ifPresent { it.validate() } + headers().ifPresent { it.validate() } + location() + project() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (googleAuthOptions.asKnown().getOrNull()?.validity() ?: 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (if (location.asKnown().isPresent) 1 else 0) + + (if (project.asKnown().isPresent) 1 else 0) + + /** Optional Google auth options for Vertex AI */ + class GoogleAuthOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credentials: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credentials") + @ExcludeMissing + credentials: JsonField = JsonMissing.of() + ) : this(credentials, mutableMapOf()) + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun credentials(): Optional = credentials.getOptional("credentials") + + /** + * Returns the raw JSON value of [credentials]. + * + * Unlike [credentials], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credentials") + @ExcludeMissing + fun _credentials(): JsonField = credentials + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GoogleAuthOptions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleAuthOptions]. */ + class Builder internal constructor() { + + private var credentials: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(googleAuthOptions: GoogleAuthOptions) = apply { + credentials = googleAuthOptions.credentials + additionalProperties = googleAuthOptions.additionalProperties.toMutableMap() + } + + fun credentials(credentials: Credentials) = + credentials(JsonField.of(credentials)) + + /** + * Sets [Builder.credentials] to an arbitrary JSON value. + * + * You should usually call [Builder.credentials] with a well-typed [Credentials] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun credentials(credentials: JsonField) = apply { + this.credentials = credentials + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GoogleAuthOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GoogleAuthOptions = + GoogleAuthOptions(credentials, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GoogleAuthOptions = apply { + if (validated) { + return@apply + } + + credentials().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (credentials.asKnown().getOrNull()?.validity() ?: 0) + + class Credentials + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val authProviderX509CertUrl: JsonField, + private val authUri: JsonField, + private val clientEmail: JsonField, + private val clientId: JsonField, + private val clientX509CertUrl: JsonField, + private val privateKey: JsonField, + private val privateKeyId: JsonField, + private val projectId: JsonField, + private val tokenUri: JsonField, + private val type: JsonField, + private val universeDomain: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("auth_provider_x509_cert_url") + @ExcludeMissing + authProviderX509CertUrl: JsonField = JsonMissing.of(), + @JsonProperty("auth_uri") + @ExcludeMissing + authUri: JsonField = JsonMissing.of(), + @JsonProperty("client_email") + @ExcludeMissing + clientEmail: JsonField = JsonMissing.of(), + @JsonProperty("client_id") + @ExcludeMissing + clientId: JsonField = JsonMissing.of(), + @JsonProperty("client_x509_cert_url") + @ExcludeMissing + clientX509CertUrl: JsonField = JsonMissing.of(), + @JsonProperty("private_key") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), + @JsonProperty("private_key_id") + @ExcludeMissing + privateKeyId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("token_uri") + @ExcludeMissing + tokenUri: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("universe_domain") + @ExcludeMissing + universeDomain: JsonField = JsonMissing.of(), + ) : this( + authProviderX509CertUrl, + authUri, + clientEmail, + clientId, + clientX509CertUrl, + privateKey, + privateKeyId, + projectId, + tokenUri, + type, + universeDomain, + mutableMapOf(), + ) + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun authProviderX509CertUrl(): Optional = + authProviderX509CertUrl.getOptional("auth_provider_x509_cert_url") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun authUri(): Optional = authUri.getOptional("auth_uri") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun clientEmail(): Optional = clientEmail.getOptional("client_email") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun clientId(): Optional = clientId.getOptional("client_id") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun clientX509CertUrl(): Optional = + clientX509CertUrl.getOptional("client_x509_cert_url") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun privateKey(): Optional = privateKey.getOptional("private_key") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun privateKeyId(): Optional = + privateKeyId.getOptional("private_key_id") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun projectId(): Optional = projectId.getOptional("project_id") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tokenUri(): Optional = tokenUri.getOptional("token_uri") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun universeDomain(): Optional = + universeDomain.getOptional("universe_domain") + + /** + * Returns the raw JSON value of [authProviderX509CertUrl]. + * + * Unlike [authProviderX509CertUrl], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("auth_provider_x509_cert_url") + @ExcludeMissing + fun _authProviderX509CertUrl(): JsonField = authProviderX509CertUrl + + /** + * Returns the raw JSON value of [authUri]. + * + * Unlike [authUri], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("auth_uri") + @ExcludeMissing + fun _authUri(): JsonField = authUri + + /** + * Returns the raw JSON value of [clientEmail]. + * + * Unlike [clientEmail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("client_email") + @ExcludeMissing + fun _clientEmail(): JsonField = clientEmail + + /** + * Returns the raw JSON value of [clientId]. + * + * Unlike [clientId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("client_id") + @ExcludeMissing + fun _clientId(): JsonField = clientId + + /** + * Returns the raw JSON value of [clientX509CertUrl]. + * + * Unlike [clientX509CertUrl], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("client_x509_cert_url") + @ExcludeMissing + fun _clientX509CertUrl(): JsonField = clientX509CertUrl + + /** + * Returns the raw JSON value of [privateKey]. + * + * Unlike [privateKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("private_key") + @ExcludeMissing + fun _privateKey(): JsonField = privateKey + + /** + * Returns the raw JSON value of [privateKeyId]. + * + * Unlike [privateKeyId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("private_key_id") + @ExcludeMissing + fun _privateKeyId(): JsonField = privateKeyId + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [tokenUri]. + * + * Unlike [tokenUri], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("token_uri") + @ExcludeMissing + fun _tokenUri(): JsonField = tokenUri + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [universeDomain]. + * + * Unlike [universeDomain], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("universe_domain") + @ExcludeMissing + fun _universeDomain(): JsonField = universeDomain + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Credentials]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Credentials]. */ + class Builder internal constructor() { + + private var authProviderX509CertUrl: JsonField = JsonMissing.of() + private var authUri: JsonField = JsonMissing.of() + private var clientEmail: JsonField = JsonMissing.of() + private var clientId: JsonField = JsonMissing.of() + private var clientX509CertUrl: JsonField = JsonMissing.of() + private var privateKey: JsonField = JsonMissing.of() + private var privateKeyId: JsonField = JsonMissing.of() + private var projectId: JsonField = JsonMissing.of() + private var tokenUri: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var universeDomain: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(credentials: Credentials) = apply { + authProviderX509CertUrl = credentials.authProviderX509CertUrl + authUri = credentials.authUri + clientEmail = credentials.clientEmail + clientId = credentials.clientId + clientX509CertUrl = credentials.clientX509CertUrl + privateKey = credentials.privateKey + privateKeyId = credentials.privateKeyId + projectId = credentials.projectId + tokenUri = credentials.tokenUri + type = credentials.type + universeDomain = credentials.universeDomain + additionalProperties = credentials.additionalProperties.toMutableMap() + } + + fun authProviderX509CertUrl(authProviderX509CertUrl: String) = + authProviderX509CertUrl(JsonField.of(authProviderX509CertUrl)) + + /** + * Sets [Builder.authProviderX509CertUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.authProviderX509CertUrl] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun authProviderX509CertUrl(authProviderX509CertUrl: JsonField) = + apply { + this.authProviderX509CertUrl = authProviderX509CertUrl + } + + fun authUri(authUri: String) = authUri(JsonField.of(authUri)) + + /** + * Sets [Builder.authUri] to an arbitrary JSON value. + * + * You should usually call [Builder.authUri] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun authUri(authUri: JsonField) = apply { this.authUri = authUri } + + fun clientEmail(clientEmail: String) = + clientEmail(JsonField.of(clientEmail)) + + /** + * Sets [Builder.clientEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.clientEmail] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun clientEmail(clientEmail: JsonField) = apply { + this.clientEmail = clientEmail + } + + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + + /** + * Sets [Builder.clientId] to an arbitrary JSON value. + * + * You should usually call [Builder.clientId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun clientId(clientId: JsonField) = apply { + this.clientId = clientId + } + + fun clientX509CertUrl(clientX509CertUrl: String) = + clientX509CertUrl(JsonField.of(clientX509CertUrl)) + + /** + * Sets [Builder.clientX509CertUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.clientX509CertUrl] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun clientX509CertUrl(clientX509CertUrl: JsonField) = apply { + this.clientX509CertUrl = clientX509CertUrl + } + + fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + + /** + * Sets [Builder.privateKey] to an arbitrary JSON value. + * + * You should usually call [Builder.privateKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun privateKey(privateKey: JsonField) = apply { + this.privateKey = privateKey + } + + fun privateKeyId(privateKeyId: String) = + privateKeyId(JsonField.of(privateKeyId)) + + /** + * Sets [Builder.privateKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.privateKeyId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun privateKeyId(privateKeyId: JsonField) = apply { + this.privateKeyId = privateKeyId + } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } + + fun tokenUri(tokenUri: String) = tokenUri(JsonField.of(tokenUri)) + + /** + * Sets [Builder.tokenUri] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenUri] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenUri(tokenUri: JsonField) = apply { + this.tokenUri = tokenUri + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun universeDomain(universeDomain: String) = + universeDomain(JsonField.of(universeDomain)) + + /** + * Sets [Builder.universeDomain] to an arbitrary JSON value. + * + * You should usually call [Builder.universeDomain] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun universeDomain(universeDomain: JsonField) = apply { + this.universeDomain = universeDomain + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Credentials]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Credentials = + Credentials( + authProviderX509CertUrl, + authUri, + clientEmail, + clientId, + clientX509CertUrl, + privateKey, + privateKeyId, + projectId, + tokenUri, + type, + universeDomain, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Credentials = apply { + if (validated) { + return@apply + } + + authProviderX509CertUrl() + authUri() + clientEmail() + clientId() + clientX509CertUrl() + privateKey() + privateKeyId() + projectId() + tokenUri() + type() + universeDomain() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (authProviderX509CertUrl.asKnown().isPresent) 1 else 0) + + (if (authUri.asKnown().isPresent) 1 else 0) + + (if (clientEmail.asKnown().isPresent) 1 else 0) + + (if (clientId.asKnown().isPresent) 1 else 0) + + (if (clientX509CertUrl.asKnown().isPresent) 1 else 0) + + (if (privateKey.asKnown().isPresent) 1 else 0) + + (if (privateKeyId.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (tokenUri.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (universeDomain.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Credentials && + authProviderX509CertUrl == other.authProviderX509CertUrl && + authUri == other.authUri && + clientEmail == other.clientEmail && + clientId == other.clientId && + clientX509CertUrl == other.clientX509CertUrl && + privateKey == other.privateKey && + privateKeyId == other.privateKeyId && + projectId == other.projectId && + tokenUri == other.tokenUri && + type == other.type && + universeDomain == other.universeDomain && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + authProviderX509CertUrl, + authUri, + clientEmail, + clientId, + clientX509CertUrl, + privateKey, + privateKeyId, + projectId, + tokenUri, + type, + universeDomain, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Credentials{authProviderX509CertUrl=$authProviderX509CertUrl, authUri=$authUri, clientEmail=$clientEmail, clientId=$clientId, clientX509CertUrl=$clientX509CertUrl, privateKey=$privateKey, privateKeyId=$privateKeyId, projectId=$projectId, tokenUri=$tokenUri, type=$type, universeDomain=$universeDomain, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleAuthOptions && + credentials == other.credentials && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(credentials, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GoogleAuthOptions{credentials=$credentials, additionalProperties=$additionalProperties}" + } + + /** Custom headers for Vertex AI requests */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleVertexProviderOptions && + googleAuthOptions == other.googleAuthOptions && + headers == other.headers && + location == other.location && + project == other.project && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(googleAuthOptions, headers, location, project, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GoogleVertexProviderOptions{googleAuthOptions=$googleAuthOptions, headers=$headers, location=$location, project=$project, additionalProperties=$additionalProperties}" + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -551,15 +2513,26 @@ private constructor( baseUrl == other.baseUrl && headers == other.headers && provider == other.provider && + providerOptions == other.providerOptions && + skipApiKeyFallback == other.skipApiKeyFallback && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(modelName, apiKey, baseUrl, headers, provider, additionalProperties) + Objects.hash( + modelName, + apiKey, + baseUrl, + headers, + provider, + providerOptions, + skipApiKeyFallback, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ModelConfig{modelName=$modelName, apiKey=$apiKey, baseUrl=$baseUrl, headers=$headers, provider=$provider, additionalProperties=$additionalProperties}" + "ModelConfig{modelName=$modelName, apiKey=$apiKey, baseUrl=$baseUrl, headers=$headers, provider=$provider, providerOptions=$providerOptions, skipApiKeyFallback=$skipApiKeyFallback, additionalProperties=$additionalProperties}" } diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionExecuteParams.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionExecuteParams.kt index f68232a..65fd5a6 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionExecuteParams.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionExecuteParams.kt @@ -1686,8 +1686,6 @@ private constructor( private val instruction: JsonField, private val highlightCursor: JsonField, private val maxSteps: JsonField, - private val toolTimeout: JsonField, - private val useSearch: JsonField, private val additionalProperties: MutableMap, ) { @@ -1699,16 +1697,8 @@ private constructor( @JsonProperty("highlightCursor") @ExcludeMissing highlightCursor: JsonField = JsonMissing.of(), - @JsonProperty("maxSteps") - @ExcludeMissing - maxSteps: JsonField = JsonMissing.of(), - @JsonProperty("toolTimeout") - @ExcludeMissing - toolTimeout: JsonField = JsonMissing.of(), - @JsonProperty("useSearch") - @ExcludeMissing - useSearch: JsonField = JsonMissing.of(), - ) : this(instruction, highlightCursor, maxSteps, toolTimeout, useSearch, mutableMapOf()) + @JsonProperty("maxSteps") @ExcludeMissing maxSteps: JsonField = JsonMissing.of(), + ) : this(instruction, highlightCursor, maxSteps, mutableMapOf()) /** * Natural language instruction for the agent @@ -1734,22 +1724,6 @@ private constructor( */ fun maxSteps(): Optional = maxSteps.getOptional("maxSteps") - /** - * Timeout in milliseconds for each agent tool call - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun toolTimeout(): Optional = toolTimeout.getOptional("toolTimeout") - - /** - * Whether to enable the web search tool powered by Browserbase Search API - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun useSearch(): Optional = useSearch.getOptional("useSearch") - /** * Returns the raw JSON value of [instruction]. * @@ -1776,22 +1750,6 @@ private constructor( */ @JsonProperty("maxSteps") @ExcludeMissing fun _maxSteps(): JsonField = maxSteps - /** - * Returns the raw JSON value of [toolTimeout]. - * - * Unlike [toolTimeout], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("toolTimeout") - @ExcludeMissing - fun _toolTimeout(): JsonField = toolTimeout - - /** - * Returns the raw JSON value of [useSearch]. - * - * Unlike [useSearch], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("useSearch") @ExcludeMissing fun _useSearch(): JsonField = useSearch - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1823,8 +1781,6 @@ private constructor( private var instruction: JsonField? = null private var highlightCursor: JsonField = JsonMissing.of() private var maxSteps: JsonField = JsonMissing.of() - private var toolTimeout: JsonField = JsonMissing.of() - private var useSearch: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1832,8 +1788,6 @@ private constructor( instruction = executeOptions.instruction highlightCursor = executeOptions.highlightCursor maxSteps = executeOptions.maxSteps - toolTimeout = executeOptions.toolTimeout - useSearch = executeOptions.useSearch additionalProperties = executeOptions.additionalProperties.toMutableMap() } @@ -1878,32 +1832,6 @@ private constructor( */ fun maxSteps(maxSteps: JsonField) = apply { this.maxSteps = maxSteps } - /** Timeout in milliseconds for each agent tool call */ - fun toolTimeout(toolTimeout: Double) = toolTimeout(JsonField.of(toolTimeout)) - - /** - * Sets [Builder.toolTimeout] to an arbitrary JSON value. - * - * You should usually call [Builder.toolTimeout] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun toolTimeout(toolTimeout: JsonField) = apply { - this.toolTimeout = toolTimeout - } - - /** Whether to enable the web search tool powered by Browserbase Search API */ - fun useSearch(useSearch: Boolean) = useSearch(JsonField.of(useSearch)) - - /** - * Sets [Builder.useSearch] to an arbitrary JSON value. - * - * You should usually call [Builder.useSearch] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun useSearch(useSearch: JsonField) = apply { this.useSearch = useSearch } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1940,8 +1868,6 @@ private constructor( checkRequired("instruction", instruction), highlightCursor, maxSteps, - toolTimeout, - useSearch, additionalProperties.toMutableMap(), ) } @@ -1956,8 +1882,6 @@ private constructor( instruction() highlightCursor() maxSteps() - toolTimeout() - useSearch() validated = true } @@ -1979,9 +1903,7 @@ private constructor( internal fun validity(): Int = (if (instruction.asKnown().isPresent) 1 else 0) + (if (highlightCursor.asKnown().isPresent) 1 else 0) + - (if (maxSteps.asKnown().isPresent) 1 else 0) + - (if (toolTimeout.asKnown().isPresent) 1 else 0) + - (if (useSearch.asKnown().isPresent) 1 else 0) + (if (maxSteps.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1992,26 +1914,17 @@ private constructor( instruction == other.instruction && highlightCursor == other.highlightCursor && maxSteps == other.maxSteps && - toolTimeout == other.toolTimeout && - useSearch == other.useSearch && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - instruction, - highlightCursor, - maxSteps, - toolTimeout, - useSearch, - additionalProperties, - ) + Objects.hash(instruction, highlightCursor, maxSteps, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ExecuteOptions{instruction=$instruction, highlightCursor=$highlightCursor, maxSteps=$maxSteps, toolTimeout=$toolTimeout, useSearch=$useSearch, additionalProperties=$additionalProperties}" + "ExecuteOptions{instruction=$instruction, highlightCursor=$highlightCursor, maxSteps=$maxSteps, additionalProperties=$additionalProperties}" } /** Whether to stream the response via SSE */ diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt index 5e09071..3b2547c 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt @@ -100,6 +100,15 @@ private constructor( */ fun experimental(): Optional = body.experimental() + /** + * Optional provider-specific configuration for the session model (for example Bedrock region + * and credentials) + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelClientOptions(): Optional = body.modelClientOptions() + /** * Enable self-healing for failed actions * @@ -185,6 +194,14 @@ private constructor( */ fun _experimental(): JsonField = body._experimental() + /** + * Returns the raw JSON value of [modelClientOptions]. + * + * Unlike [modelClientOptions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _modelClientOptions(): JsonField = body._modelClientOptions() + /** * Returns the raw JSON value of [selfHeal]. * @@ -372,6 +389,47 @@ private constructor( body.experimental(experimental) } + /** + * Optional provider-specific configuration for the session model (for example Bedrock + * region and credentials) + */ + fun modelClientOptions(modelClientOptions: ModelClientOptions) = apply { + body.modelClientOptions(modelClientOptions) + } + + /** + * Sets [Builder.modelClientOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.modelClientOptions] with a well-typed + * [ModelClientOptions] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun modelClientOptions(modelClientOptions: JsonField) = apply { + body.modelClientOptions(modelClientOptions) + } + + /** + * Alias for calling [modelClientOptions] with + * `ModelClientOptions.ofBedrockApiKey(bedrockApiKey)`. + */ + fun modelClientOptions(bedrockApiKey: ModelClientOptions.BedrockApiKeyModelClientOptions) = + apply { + body.modelClientOptions(bedrockApiKey) + } + + /** + * Alias for calling [modelClientOptions] with + * `ModelClientOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)`. + */ + fun modelClientOptions( + bedrockAwsCredentials: ModelClientOptions.BedrockAwsCredentialsModelClientOptions + ) = apply { body.modelClientOptions(bedrockAwsCredentials) } + + /** Alias for calling [modelClientOptions] with `ModelClientOptions.ofGeneric(generic)`. */ + fun modelClientOptions(generic: ModelClientOptions.GenericModelClientOptions) = apply { + body.modelClientOptions(generic) + } + /** Enable self-healing for failed actions */ fun selfHeal(selfHeal: Boolean) = apply { body.selfHeal(selfHeal) } @@ -585,6 +643,7 @@ private constructor( private val browserbaseSessionId: JsonField, private val domSettleTimeoutMs: JsonField, private val experimental: JsonField, + private val modelClientOptions: JsonField, private val selfHeal: JsonField, private val systemPrompt: JsonField, private val verbose: JsonField, @@ -614,6 +673,9 @@ private constructor( @JsonProperty("experimental") @ExcludeMissing experimental: JsonField = JsonMissing.of(), + @JsonProperty("modelClientOptions") + @ExcludeMissing + modelClientOptions: JsonField = JsonMissing.of(), @JsonProperty("selfHeal") @ExcludeMissing selfHeal: JsonField = JsonMissing.of(), @@ -632,6 +694,7 @@ private constructor( browserbaseSessionId, domSettleTimeoutMs, experimental, + modelClientOptions, selfHeal, systemPrompt, verbose, @@ -692,6 +755,16 @@ private constructor( */ fun experimental(): Optional = experimental.getOptional("experimental") + /** + * Optional provider-specific configuration for the session model (for example Bedrock + * region and credentials) + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelClientOptions(): Optional = + modelClientOptions.getOptional("modelClientOptions") + /** * Enable self-healing for failed actions * @@ -790,6 +863,16 @@ private constructor( @ExcludeMissing fun _experimental(): JsonField = experimental + /** + * Returns the raw JSON value of [modelClientOptions]. + * + * Unlike [modelClientOptions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("modelClientOptions") + @ExcludeMissing + fun _modelClientOptions(): JsonField = modelClientOptions + /** * Returns the raw JSON value of [selfHeal]. * @@ -860,6 +943,7 @@ private constructor( private var browserbaseSessionId: JsonField = JsonMissing.of() private var domSettleTimeoutMs: JsonField = JsonMissing.of() private var experimental: JsonField = JsonMissing.of() + private var modelClientOptions: JsonField = JsonMissing.of() private var selfHeal: JsonField = JsonMissing.of() private var systemPrompt: JsonField = JsonMissing.of() private var verbose: JsonField = JsonMissing.of() @@ -875,6 +959,7 @@ private constructor( browserbaseSessionId = body.browserbaseSessionId domSettleTimeoutMs = body.domSettleTimeoutMs experimental = body.experimental + modelClientOptions = body.modelClientOptions selfHeal = body.selfHeal systemPrompt = body.systemPrompt verbose = body.verbose @@ -977,6 +1062,49 @@ private constructor( this.experimental = experimental } + /** + * Optional provider-specific configuration for the session model (for example Bedrock + * region and credentials) + */ + fun modelClientOptions(modelClientOptions: ModelClientOptions) = + modelClientOptions(JsonField.of(modelClientOptions)) + + /** + * Sets [Builder.modelClientOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.modelClientOptions] with a well-typed + * [ModelClientOptions] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun modelClientOptions(modelClientOptions: JsonField) = apply { + this.modelClientOptions = modelClientOptions + } + + /** + * Alias for calling [modelClientOptions] with + * `ModelClientOptions.ofBedrockApiKey(bedrockApiKey)`. + */ + fun modelClientOptions( + bedrockApiKey: ModelClientOptions.BedrockApiKeyModelClientOptions + ) = modelClientOptions(ModelClientOptions.ofBedrockApiKey(bedrockApiKey)) + + /** + * Alias for calling [modelClientOptions] with + * `ModelClientOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)`. + */ + fun modelClientOptions( + bedrockAwsCredentials: ModelClientOptions.BedrockAwsCredentialsModelClientOptions + ) = + modelClientOptions( + ModelClientOptions.ofBedrockAwsCredentials(bedrockAwsCredentials) + ) + + /** + * Alias for calling [modelClientOptions] with `ModelClientOptions.ofGeneric(generic)`. + */ + fun modelClientOptions(generic: ModelClientOptions.GenericModelClientOptions) = + modelClientOptions(ModelClientOptions.ofGeneric(generic)) + /** Enable self-healing for failed actions */ fun selfHeal(selfHeal: Boolean) = selfHeal(JsonField.of(selfHeal)) @@ -1070,6 +1198,7 @@ private constructor( browserbaseSessionId, domSettleTimeoutMs, experimental, + modelClientOptions, selfHeal, systemPrompt, verbose, @@ -1092,6 +1221,7 @@ private constructor( browserbaseSessionId() domSettleTimeoutMs() experimental() + modelClientOptions().ifPresent { it.validate() } selfHeal() systemPrompt() verbose().ifPresent { it.validate() } @@ -1122,6 +1252,7 @@ private constructor( (if (browserbaseSessionId.asKnown().isPresent) 1 else 0) + (if (domSettleTimeoutMs.asKnown().isPresent) 1 else 0) + (if (experimental.asKnown().isPresent) 1 else 0) + + (modelClientOptions.asKnown().getOrNull()?.validity() ?: 0) + (if (selfHeal.asKnown().isPresent) 1 else 0) + (if (systemPrompt.asKnown().isPresent) 1 else 0) + (verbose.asKnown().getOrNull()?.validity() ?: 0) + @@ -1140,6 +1271,7 @@ private constructor( browserbaseSessionId == other.browserbaseSessionId && domSettleTimeoutMs == other.domSettleTimeoutMs && experimental == other.experimental && + modelClientOptions == other.modelClientOptions && selfHeal == other.selfHeal && systemPrompt == other.systemPrompt && verbose == other.verbose && @@ -1156,6 +1288,7 @@ private constructor( browserbaseSessionId, domSettleTimeoutMs, experimental, + modelClientOptions, selfHeal, systemPrompt, verbose, @@ -1167,7 +1300,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{modelName=$modelName, actTimeoutMs=$actTimeoutMs, browser=$browser, browserbaseSessionCreateParams=$browserbaseSessionCreateParams, browserbaseSessionId=$browserbaseSessionId, domSettleTimeoutMs=$domSettleTimeoutMs, experimental=$experimental, selfHeal=$selfHeal, systemPrompt=$systemPrompt, verbose=$verbose, waitForCaptchaSolves=$waitForCaptchaSolves, additionalProperties=$additionalProperties}" + "Body{modelName=$modelName, actTimeoutMs=$actTimeoutMs, browser=$browser, browserbaseSessionCreateParams=$browserbaseSessionCreateParams, browserbaseSessionId=$browserbaseSessionId, domSettleTimeoutMs=$domSettleTimeoutMs, experimental=$experimental, modelClientOptions=$modelClientOptions, selfHeal=$selfHeal, systemPrompt=$systemPrompt, verbose=$verbose, waitForCaptchaSolves=$waitForCaptchaSolves, additionalProperties=$additionalProperties}" } class Browser @@ -7195,6 +7328,3960 @@ private constructor( "BrowserbaseSessionCreateParams{browserSettings=$browserSettings, extensionId=$extensionId, keepAlive=$keepAlive, projectId=$projectId, proxies=$proxies, region=$region, timeout=$timeout, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" } + /** + * Optional provider-specific configuration for the session model (for example Bedrock region + * and credentials) + */ + @JsonDeserialize(using = ModelClientOptions.Deserializer::class) + @JsonSerialize(using = ModelClientOptions.Serializer::class) + class ModelClientOptions + private constructor( + private val bedrockApiKey: BedrockApiKeyModelClientOptions? = null, + private val bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions? = null, + private val generic: GenericModelClientOptions? = null, + private val _json: JsonValue? = null, + ) { + + fun bedrockApiKey(): Optional = + Optional.ofNullable(bedrockApiKey) + + fun bedrockAwsCredentials(): Optional = + Optional.ofNullable(bedrockAwsCredentials) + + fun generic(): Optional = Optional.ofNullable(generic) + + fun isBedrockApiKey(): Boolean = bedrockApiKey != null + + fun isBedrockAwsCredentials(): Boolean = bedrockAwsCredentials != null + + fun isGeneric(): Boolean = generic != null + + fun asBedrockApiKey(): BedrockApiKeyModelClientOptions = + bedrockApiKey.getOrThrow("bedrockApiKey") + + fun asBedrockAwsCredentials(): BedrockAwsCredentialsModelClientOptions = + bedrockAwsCredentials.getOrThrow("bedrockAwsCredentials") + + fun asGeneric(): GenericModelClientOptions = generic.getOrThrow("generic") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + bedrockApiKey != null -> visitor.visitBedrockApiKey(bedrockApiKey) + bedrockAwsCredentials != null -> + visitor.visitBedrockAwsCredentials(bedrockAwsCredentials) + generic != null -> visitor.visitGeneric(generic) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ModelClientOptions = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitBedrockApiKey( + bedrockApiKey: BedrockApiKeyModelClientOptions + ) { + bedrockApiKey.validate() + } + + override fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions + ) { + bedrockAwsCredentials.validate() + } + + override fun visitGeneric(generic: GenericModelClientOptions) { + generic.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitBedrockApiKey( + bedrockApiKey: BedrockApiKeyModelClientOptions + ) = bedrockApiKey.validity() + + override fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions + ) = bedrockAwsCredentials.validity() + + override fun visitGeneric(generic: GenericModelClientOptions) = + generic.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelClientOptions && + bedrockApiKey == other.bedrockApiKey && + bedrockAwsCredentials == other.bedrockAwsCredentials && + generic == other.generic + } + + override fun hashCode(): Int = Objects.hash(bedrockApiKey, bedrockAwsCredentials, generic) + + override fun toString(): String = + when { + bedrockApiKey != null -> "ModelClientOptions{bedrockApiKey=$bedrockApiKey}" + bedrockAwsCredentials != null -> + "ModelClientOptions{bedrockAwsCredentials=$bedrockAwsCredentials}" + generic != null -> "ModelClientOptions{generic=$generic}" + _json != null -> "ModelClientOptions{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ModelClientOptions") + } + + companion object { + + @JvmStatic + fun ofBedrockApiKey(bedrockApiKey: BedrockApiKeyModelClientOptions) = + ModelClientOptions(bedrockApiKey = bedrockApiKey) + + @JvmStatic + fun ofBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions + ) = ModelClientOptions(bedrockAwsCredentials = bedrockAwsCredentials) + + @JvmStatic + fun ofGeneric(generic: GenericModelClientOptions) = + ModelClientOptions(generic = generic) + } + + /** + * An interface that defines how to map each variant of [ModelClientOptions] to a value of + * type [T]. + */ + interface Visitor { + + fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyModelClientOptions): T + + fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions + ): T + + fun visitGeneric(generic: GenericModelClientOptions): T + + /** + * Maps an unknown variant of [ModelClientOptions] to a value of type [T]. + * + * An instance of [ModelClientOptions] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws StagehandInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw StagehandInvalidDataException("Unknown ModelClientOptions: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ModelClientOptions::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ModelClientOptions { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { ModelClientOptions(bedrockApiKey = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ModelClientOptions(bedrockAwsCredentials = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ModelClientOptions(generic = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> ModelClientOptions(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ModelClientOptions::class) { + + override fun serialize( + value: ModelClientOptions, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bedrockApiKey != null -> generator.writeObject(value.bedrockApiKey) + value.bedrockAwsCredentials != null -> + generator.writeObject(value.bedrockAwsCredentials) + value.generic != null -> generator.writeObject(value.generic) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ModelClientOptions") + } + } + } + + class BedrockApiKeyModelClientOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val apiKey: JsonField, + private val providerOptions: JsonField, + private val baseUrl: JsonField, + private val headers: JsonField, + private val skipApiKeyFallback: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("apiKey") + @ExcludeMissing + apiKey: JsonField = JsonMissing.of(), + @JsonProperty("providerOptions") + @ExcludeMissing + providerOptions: JsonField = JsonMissing.of(), + @JsonProperty("baseURL") + @ExcludeMissing + baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + @JsonProperty("skipApiKeyFallback") + @ExcludeMissing + skipApiKeyFallback: JsonField = JsonMissing.of(), + ) : this(apiKey, providerOptions, baseUrl, headers, skipApiKeyFallback, mutableMapOf()) + + /** + * Short-term Bedrock API key for bearer-token auth + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun apiKey(): String = apiKey.getRequired("apiKey") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun providerOptions(): ProviderOptions = providerOptions.getRequired("providerOptions") + + /** + * Base URL for the model provider + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseUrl(): Optional = baseUrl.getOptional("baseURL") + + /** + * Custom headers for the model provider + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this + * when auth is carried through providerOptions instead of an API key. + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun skipApiKeyFallback(): Optional = + skipApiKeyFallback.getOptional("skipApiKeyFallback") + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("apiKey") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [providerOptions]. + * + * Unlike [providerOptions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("providerOptions") + @ExcludeMissing + fun _providerOptions(): JsonField = providerOptions + + /** + * Returns the raw JSON value of [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [skipApiKeyFallback]. + * + * Unlike [skipApiKeyFallback], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("skipApiKeyFallback") + @ExcludeMissing + fun _skipApiKeyFallback(): JsonField = skipApiKeyFallback + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BedrockApiKeyModelClientOptions]. + * + * The following fields are required: + * ```java + * .apiKey() + * .providerOptions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BedrockApiKeyModelClientOptions]. */ + class Builder internal constructor() { + + private var apiKey: JsonField? = null + private var providerOptions: JsonField? = null + private var baseUrl: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var skipApiKeyFallback: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + bedrockApiKeyModelClientOptions: BedrockApiKeyModelClientOptions + ) = apply { + apiKey = bedrockApiKeyModelClientOptions.apiKey + providerOptions = bedrockApiKeyModelClientOptions.providerOptions + baseUrl = bedrockApiKeyModelClientOptions.baseUrl + headers = bedrockApiKeyModelClientOptions.headers + skipApiKeyFallback = bedrockApiKeyModelClientOptions.skipApiKeyFallback + additionalProperties = + bedrockApiKeyModelClientOptions.additionalProperties.toMutableMap() + } + + /** Short-term Bedrock API key for bearer-token auth */ + fun apiKey(apiKey: String) = apiKey(JsonField.of(apiKey)) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + + fun providerOptions(providerOptions: ProviderOptions) = + providerOptions(JsonField.of(providerOptions)) + + /** + * Sets [Builder.providerOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.providerOptions] with a well-typed + * [ProviderOptions] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun providerOptions(providerOptions: JsonField) = apply { + this.providerOptions = providerOptions + } + + /** Base URL for the model provider */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + + /** + * Sets [Builder.baseUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + + /** Custom headers for the model provider */ + fun headers(headers: Headers) = headers(JsonField.of(headers)) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use + * this when auth is carried through providerOptions instead of an API key. + */ + fun skipApiKeyFallback(skipApiKeyFallback: Boolean) = + skipApiKeyFallback(JsonField.of(skipApiKeyFallback)) + + /** + * Sets [Builder.skipApiKeyFallback] to an arbitrary JSON value. + * + * You should usually call [Builder.skipApiKeyFallback] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun skipApiKeyFallback(skipApiKeyFallback: JsonField) = apply { + this.skipApiKeyFallback = skipApiKeyFallback + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BedrockApiKeyModelClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .apiKey() + * .providerOptions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BedrockApiKeyModelClientOptions = + BedrockApiKeyModelClientOptions( + checkRequired("apiKey", apiKey), + checkRequired("providerOptions", providerOptions), + baseUrl, + headers, + skipApiKeyFallback, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BedrockApiKeyModelClientOptions = apply { + if (validated) { + return@apply + } + + apiKey() + providerOptions().validate() + baseUrl() + headers().ifPresent { it.validate() } + skipApiKeyFallback() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (apiKey.asKnown().isPresent) 1 else 0) + + (providerOptions.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrl.asKnown().isPresent) 1 else 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (if (skipApiKeyFallback.asKnown().isPresent) 1 else 0) + + class ProviderOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val region: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("region") + @ExcludeMissing + region: JsonField = JsonMissing.of() + ) : this(region, mutableMapOf()) + + /** + * AWS region for Amazon Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun region(): String = region.getRequired("region") + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProviderOptions]. + * + * The following fields are required: + * ```java + * .region() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProviderOptions]. */ + class Builder internal constructor() { + + private var region: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(providerOptions: ProviderOptions) = apply { + region = providerOptions.region + additionalProperties = providerOptions.additionalProperties.toMutableMap() + } + + /** AWS region for Amazon Bedrock */ + fun region(region: String) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun region(region: JsonField) = apply { this.region = region } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProviderOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .region() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProviderOptions = + ProviderOptions( + checkRequired("region", region), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProviderOptions = apply { + if (validated) { + return@apply + } + + region() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (region.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderOptions && + region == other.region && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(region, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProviderOptions{region=$region, additionalProperties=$additionalProperties}" + } + + /** Custom headers for the model provider */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BedrockApiKeyModelClientOptions && + apiKey == other.apiKey && + providerOptions == other.providerOptions && + baseUrl == other.baseUrl && + headers == other.headers && + skipApiKeyFallback == other.skipApiKeyFallback && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + apiKey, + providerOptions, + baseUrl, + headers, + skipApiKeyFallback, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BedrockApiKeyModelClientOptions{apiKey=$apiKey, providerOptions=$providerOptions, baseUrl=$baseUrl, headers=$headers, skipApiKeyFallback=$skipApiKeyFallback, additionalProperties=$additionalProperties}" + } + + class BedrockAwsCredentialsModelClientOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val providerOptions: JsonField, + private val baseUrl: JsonField, + private val headers: JsonField, + private val skipApiKeyFallback: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("providerOptions") + @ExcludeMissing + providerOptions: JsonField = JsonMissing.of(), + @JsonProperty("baseURL") + @ExcludeMissing + baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + @JsonProperty("skipApiKeyFallback") + @ExcludeMissing + skipApiKeyFallback: JsonField = JsonMissing.of(), + ) : this(providerOptions, baseUrl, headers, skipApiKeyFallback, mutableMapOf()) + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun providerOptions(): ProviderOptions = providerOptions.getRequired("providerOptions") + + /** + * Base URL for the model provider + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseUrl(): Optional = baseUrl.getOptional("baseURL") + + /** + * Custom headers for the model provider + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this + * when auth is carried through providerOptions instead of an API key. + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun skipApiKeyFallback(): Optional = + skipApiKeyFallback.getOptional("skipApiKeyFallback") + + /** + * Returns the raw JSON value of [providerOptions]. + * + * Unlike [providerOptions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("providerOptions") + @ExcludeMissing + fun _providerOptions(): JsonField = providerOptions + + /** + * Returns the raw JSON value of [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [skipApiKeyFallback]. + * + * Unlike [skipApiKeyFallback], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("skipApiKeyFallback") + @ExcludeMissing + fun _skipApiKeyFallback(): JsonField = skipApiKeyFallback + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BedrockAwsCredentialsModelClientOptions]. + * + * The following fields are required: + * ```java + * .providerOptions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BedrockAwsCredentialsModelClientOptions]. */ + class Builder internal constructor() { + + private var providerOptions: JsonField? = null + private var baseUrl: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var skipApiKeyFallback: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + bedrockAwsCredentialsModelClientOptions: BedrockAwsCredentialsModelClientOptions + ) = apply { + providerOptions = bedrockAwsCredentialsModelClientOptions.providerOptions + baseUrl = bedrockAwsCredentialsModelClientOptions.baseUrl + headers = bedrockAwsCredentialsModelClientOptions.headers + skipApiKeyFallback = bedrockAwsCredentialsModelClientOptions.skipApiKeyFallback + additionalProperties = + bedrockAwsCredentialsModelClientOptions.additionalProperties.toMutableMap() + } + + fun providerOptions(providerOptions: ProviderOptions) = + providerOptions(JsonField.of(providerOptions)) + + /** + * Sets [Builder.providerOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.providerOptions] with a well-typed + * [ProviderOptions] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun providerOptions(providerOptions: JsonField) = apply { + this.providerOptions = providerOptions + } + + /** Base URL for the model provider */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + + /** + * Sets [Builder.baseUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + + /** Custom headers for the model provider */ + fun headers(headers: Headers) = headers(JsonField.of(headers)) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use + * this when auth is carried through providerOptions instead of an API key. + */ + fun skipApiKeyFallback(skipApiKeyFallback: Boolean) = + skipApiKeyFallback(JsonField.of(skipApiKeyFallback)) + + /** + * Sets [Builder.skipApiKeyFallback] to an arbitrary JSON value. + * + * You should usually call [Builder.skipApiKeyFallback] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun skipApiKeyFallback(skipApiKeyFallback: JsonField) = apply { + this.skipApiKeyFallback = skipApiKeyFallback + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BedrockAwsCredentialsModelClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .providerOptions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BedrockAwsCredentialsModelClientOptions = + BedrockAwsCredentialsModelClientOptions( + checkRequired("providerOptions", providerOptions), + baseUrl, + headers, + skipApiKeyFallback, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BedrockAwsCredentialsModelClientOptions = apply { + if (validated) { + return@apply + } + + providerOptions().validate() + baseUrl() + headers().ifPresent { it.validate() } + skipApiKeyFallback() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (providerOptions.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrl.asKnown().isPresent) 1 else 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (if (skipApiKeyFallback.asKnown().isPresent) 1 else 0) + + class ProviderOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessKeyId: JsonField, + private val region: JsonField, + private val secretAccessKey: JsonField, + private val sessionToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accessKeyId") + @ExcludeMissing + accessKeyId: JsonField = JsonMissing.of(), + @JsonProperty("region") + @ExcludeMissing + region: JsonField = JsonMissing.of(), + @JsonProperty("secretAccessKey") + @ExcludeMissing + secretAccessKey: JsonField = JsonMissing.of(), + @JsonProperty("sessionToken") + @ExcludeMissing + sessionToken: JsonField = JsonMissing.of(), + ) : this(accessKeyId, region, secretAccessKey, sessionToken, mutableMapOf()) + + /** + * AWS access key ID for Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accessKeyId(): String = accessKeyId.getRequired("accessKeyId") + + /** + * AWS region for Amazon Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun region(): String = region.getRequired("region") + + /** + * AWS secret access key for Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun secretAccessKey(): String = secretAccessKey.getRequired("secretAccessKey") + + /** + * Optional AWS session token for temporary credentials + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun sessionToken(): Optional = sessionToken.getOptional("sessionToken") + + /** + * Returns the raw JSON value of [accessKeyId]. + * + * Unlike [accessKeyId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("accessKeyId") + @ExcludeMissing + fun _accessKeyId(): JsonField = accessKeyId + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region + + /** + * Returns the raw JSON value of [secretAccessKey]. + * + * Unlike [secretAccessKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("secretAccessKey") + @ExcludeMissing + fun _secretAccessKey(): JsonField = secretAccessKey + + /** + * Returns the raw JSON value of [sessionToken]. + * + * Unlike [sessionToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sessionToken") + @ExcludeMissing + fun _sessionToken(): JsonField = sessionToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProviderOptions]. + * + * The following fields are required: + * ```java + * .accessKeyId() + * .region() + * .secretAccessKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProviderOptions]. */ + class Builder internal constructor() { + + private var accessKeyId: JsonField? = null + private var region: JsonField? = null + private var secretAccessKey: JsonField? = null + private var sessionToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(providerOptions: ProviderOptions) = apply { + accessKeyId = providerOptions.accessKeyId + region = providerOptions.region + secretAccessKey = providerOptions.secretAccessKey + sessionToken = providerOptions.sessionToken + additionalProperties = providerOptions.additionalProperties.toMutableMap() + } + + /** AWS access key ID for Bedrock */ + fun accessKeyId(accessKeyId: String) = accessKeyId(JsonField.of(accessKeyId)) + + /** + * Sets [Builder.accessKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.accessKeyId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accessKeyId(accessKeyId: JsonField) = apply { + this.accessKeyId = accessKeyId + } + + /** AWS region for Amazon Bedrock */ + fun region(region: String) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun region(region: JsonField) = apply { this.region = region } + + /** AWS secret access key for Bedrock */ + fun secretAccessKey(secretAccessKey: String) = + secretAccessKey(JsonField.of(secretAccessKey)) + + /** + * Sets [Builder.secretAccessKey] to an arbitrary JSON value. + * + * You should usually call [Builder.secretAccessKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun secretAccessKey(secretAccessKey: JsonField) = apply { + this.secretAccessKey = secretAccessKey + } + + /** Optional AWS session token for temporary credentials */ + fun sessionToken(sessionToken: String) = + sessionToken(JsonField.of(sessionToken)) + + /** + * Sets [Builder.sessionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun sessionToken(sessionToken: JsonField) = apply { + this.sessionToken = sessionToken + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProviderOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessKeyId() + * .region() + * .secretAccessKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProviderOptions = + ProviderOptions( + checkRequired("accessKeyId", accessKeyId), + checkRequired("region", region), + checkRequired("secretAccessKey", secretAccessKey), + sessionToken, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProviderOptions = apply { + if (validated) { + return@apply + } + + accessKeyId() + region() + secretAccessKey() + sessionToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessKeyId.asKnown().isPresent) 1 else 0) + + (if (region.asKnown().isPresent) 1 else 0) + + (if (secretAccessKey.asKnown().isPresent) 1 else 0) + + (if (sessionToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderOptions && + accessKeyId == other.accessKeyId && + region == other.region && + secretAccessKey == other.secretAccessKey && + sessionToken == other.sessionToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessKeyId, + region, + secretAccessKey, + sessionToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProviderOptions{accessKeyId=$accessKeyId, region=$region, secretAccessKey=$secretAccessKey, sessionToken=$sessionToken, additionalProperties=$additionalProperties}" + } + + /** Custom headers for the model provider */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BedrockAwsCredentialsModelClientOptions && + providerOptions == other.providerOptions && + baseUrl == other.baseUrl && + headers == other.headers && + skipApiKeyFallback == other.skipApiKeyFallback && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + providerOptions, + baseUrl, + headers, + skipApiKeyFallback, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BedrockAwsCredentialsModelClientOptions{providerOptions=$providerOptions, baseUrl=$baseUrl, headers=$headers, skipApiKeyFallback=$skipApiKeyFallback, additionalProperties=$additionalProperties}" + } + + class GenericModelClientOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val apiKey: JsonField, + private val baseUrl: JsonField, + private val headers: JsonField, + private val providerOptions: JsonField, + private val skipApiKeyFallback: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("apiKey") + @ExcludeMissing + apiKey: JsonField = JsonMissing.of(), + @JsonProperty("baseURL") + @ExcludeMissing + baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + @JsonProperty("providerOptions") + @ExcludeMissing + providerOptions: JsonField = JsonMissing.of(), + @JsonProperty("skipApiKeyFallback") + @ExcludeMissing + skipApiKeyFallback: JsonField = JsonMissing.of(), + ) : this(apiKey, baseUrl, headers, providerOptions, skipApiKeyFallback, mutableMapOf()) + + /** + * API key for the model provider + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun apiKey(): Optional = apiKey.getOptional("apiKey") + + /** + * Base URL for the model provider + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseUrl(): Optional = baseUrl.getOptional("baseURL") + + /** + * Custom headers for the model provider + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * Provider-specific options passed through to the AI SDK provider constructor. For + * Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { + * project, location, googleAuthOptions }. + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun providerOptions(): Optional = + providerOptions.getOptional("providerOptions") + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this + * when auth is carried through providerOptions instead of an API key. + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun skipApiKeyFallback(): Optional = + skipApiKeyFallback.getOptional("skipApiKeyFallback") + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("apiKey") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [providerOptions]. + * + * Unlike [providerOptions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("providerOptions") + @ExcludeMissing + fun _providerOptions(): JsonField = providerOptions + + /** + * Returns the raw JSON value of [skipApiKeyFallback]. + * + * Unlike [skipApiKeyFallback], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("skipApiKeyFallback") + @ExcludeMissing + fun _skipApiKeyFallback(): JsonField = skipApiKeyFallback + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GenericModelClientOptions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GenericModelClientOptions]. */ + class Builder internal constructor() { + + private var apiKey: JsonField = JsonMissing.of() + private var baseUrl: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var providerOptions: JsonField = JsonMissing.of() + private var skipApiKeyFallback: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(genericModelClientOptions: GenericModelClientOptions) = apply { + apiKey = genericModelClientOptions.apiKey + baseUrl = genericModelClientOptions.baseUrl + headers = genericModelClientOptions.headers + providerOptions = genericModelClientOptions.providerOptions + skipApiKeyFallback = genericModelClientOptions.skipApiKeyFallback + additionalProperties = + genericModelClientOptions.additionalProperties.toMutableMap() + } + + /** API key for the model provider */ + fun apiKey(apiKey: String) = apiKey(JsonField.of(apiKey)) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + + /** Base URL for the model provider */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + + /** + * Sets [Builder.baseUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + + /** Custom headers for the model provider */ + fun headers(headers: Headers) = headers(JsonField.of(headers)) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + /** + * Provider-specific options passed through to the AI SDK provider constructor. For + * Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { + * project, location, googleAuthOptions }. + */ + fun providerOptions(providerOptions: ProviderOptions) = + providerOptions(JsonField.of(providerOptions)) + + /** + * Sets [Builder.providerOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.providerOptions] with a well-typed + * [ProviderOptions] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun providerOptions(providerOptions: JsonField) = apply { + this.providerOptions = providerOptions + } + + /** + * Alias for calling [providerOptions] with + * `ProviderOptions.ofBedrockApiKey(bedrockApiKey)`. + */ + fun providerOptions(bedrockApiKey: ProviderOptions.BedrockApiKeyProviderOptions) = + providerOptions(ProviderOptions.ofBedrockApiKey(bedrockApiKey)) + + /** + * Alias for calling [providerOptions] with + * `ProviderOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)`. + */ + fun providerOptions( + bedrockAwsCredentials: ProviderOptions.BedrockAwsCredentialsProviderOptions + ) = providerOptions(ProviderOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)) + + /** + * Alias for calling [providerOptions] with + * `ProviderOptions.ofGoogleVertex(googleVertex)`. + */ + fun providerOptions(googleVertex: ProviderOptions.GoogleVertexProviderOptions) = + providerOptions(ProviderOptions.ofGoogleVertex(googleVertex)) + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use + * this when auth is carried through providerOptions instead of an API key. + */ + fun skipApiKeyFallback(skipApiKeyFallback: Boolean) = + skipApiKeyFallback(JsonField.of(skipApiKeyFallback)) + + /** + * Sets [Builder.skipApiKeyFallback] to an arbitrary JSON value. + * + * You should usually call [Builder.skipApiKeyFallback] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun skipApiKeyFallback(skipApiKeyFallback: JsonField) = apply { + this.skipApiKeyFallback = skipApiKeyFallback + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GenericModelClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GenericModelClientOptions = + GenericModelClientOptions( + apiKey, + baseUrl, + headers, + providerOptions, + skipApiKeyFallback, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GenericModelClientOptions = apply { + if (validated) { + return@apply + } + + apiKey() + baseUrl() + headers().ifPresent { it.validate() } + providerOptions().ifPresent { it.validate() } + skipApiKeyFallback() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (apiKey.asKnown().isPresent) 1 else 0) + + (if (baseUrl.asKnown().isPresent) 1 else 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (providerOptions.asKnown().getOrNull()?.validity() ?: 0) + + (if (skipApiKeyFallback.asKnown().isPresent) 1 else 0) + + /** Custom headers for the model provider */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + /** + * Provider-specific options passed through to the AI SDK provider constructor. For + * Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { + * project, location, googleAuthOptions }. + */ + @JsonDeserialize(using = ProviderOptions.Deserializer::class) + @JsonSerialize(using = ProviderOptions.Serializer::class) + class ProviderOptions + private constructor( + private val bedrockApiKey: BedrockApiKeyProviderOptions? = null, + private val bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions? = null, + private val googleVertex: GoogleVertexProviderOptions? = null, + private val _json: JsonValue? = null, + ) { + + fun bedrockApiKey(): Optional = + Optional.ofNullable(bedrockApiKey) + + fun bedrockAwsCredentials(): Optional = + Optional.ofNullable(bedrockAwsCredentials) + + fun googleVertex(): Optional = + Optional.ofNullable(googleVertex) + + fun isBedrockApiKey(): Boolean = bedrockApiKey != null + + fun isBedrockAwsCredentials(): Boolean = bedrockAwsCredentials != null + + fun isGoogleVertex(): Boolean = googleVertex != null + + fun asBedrockApiKey(): BedrockApiKeyProviderOptions = + bedrockApiKey.getOrThrow("bedrockApiKey") + + fun asBedrockAwsCredentials(): BedrockAwsCredentialsProviderOptions = + bedrockAwsCredentials.getOrThrow("bedrockAwsCredentials") + + fun asGoogleVertex(): GoogleVertexProviderOptions = + googleVertex.getOrThrow("googleVertex") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + bedrockApiKey != null -> visitor.visitBedrockApiKey(bedrockApiKey) + bedrockAwsCredentials != null -> + visitor.visitBedrockAwsCredentials(bedrockAwsCredentials) + googleVertex != null -> visitor.visitGoogleVertex(googleVertex) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ProviderOptions = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitBedrockApiKey( + bedrockApiKey: BedrockApiKeyProviderOptions + ) { + bedrockApiKey.validate() + } + + override fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions + ) { + bedrockAwsCredentials.validate() + } + + override fun visitGoogleVertex( + googleVertex: GoogleVertexProviderOptions + ) { + googleVertex.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitBedrockApiKey( + bedrockApiKey: BedrockApiKeyProviderOptions + ) = bedrockApiKey.validity() + + override fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions + ) = bedrockAwsCredentials.validity() + + override fun visitGoogleVertex( + googleVertex: GoogleVertexProviderOptions + ) = googleVertex.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderOptions && + bedrockApiKey == other.bedrockApiKey && + bedrockAwsCredentials == other.bedrockAwsCredentials && + googleVertex == other.googleVertex + } + + override fun hashCode(): Int = + Objects.hash(bedrockApiKey, bedrockAwsCredentials, googleVertex) + + override fun toString(): String = + when { + bedrockApiKey != null -> "ProviderOptions{bedrockApiKey=$bedrockApiKey}" + bedrockAwsCredentials != null -> + "ProviderOptions{bedrockAwsCredentials=$bedrockAwsCredentials}" + googleVertex != null -> "ProviderOptions{googleVertex=$googleVertex}" + _json != null -> "ProviderOptions{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ProviderOptions") + } + + companion object { + + @JvmStatic + fun ofBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions) = + ProviderOptions(bedrockApiKey = bedrockApiKey) + + @JvmStatic + fun ofBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions + ) = ProviderOptions(bedrockAwsCredentials = bedrockAwsCredentials) + + @JvmStatic + fun ofGoogleVertex(googleVertex: GoogleVertexProviderOptions) = + ProviderOptions(googleVertex = googleVertex) + } + + /** + * An interface that defines how to map each variant of [ProviderOptions] to a value + * of type [T]. + */ + interface Visitor { + + fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions): T + + fun visitBedrockAwsCredentials( + bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions + ): T + + fun visitGoogleVertex(googleVertex: GoogleVertexProviderOptions): T + + /** + * Maps an unknown variant of [ProviderOptions] to a value of type [T]. + * + * An instance of [ProviderOptions] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws StagehandInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw StagehandInvalidDataException("Unknown ProviderOptions: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ProviderOptions::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ProviderOptions { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { ProviderOptions(bedrockApiKey = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ProviderOptions( + bedrockAwsCredentials = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { ProviderOptions(googleVertex = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> ProviderOptions(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(ProviderOptions::class) { + + override fun serialize( + value: ProviderOptions, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bedrockApiKey != null -> + generator.writeObject(value.bedrockApiKey) + value.bedrockAwsCredentials != null -> + generator.writeObject(value.bedrockAwsCredentials) + value.googleVertex != null -> generator.writeObject(value.googleVertex) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ProviderOptions") + } + } + } + + class BedrockApiKeyProviderOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val region: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("region") + @ExcludeMissing + region: JsonField = JsonMissing.of() + ) : this(region, mutableMapOf()) + + /** + * AWS region for Amazon Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun region(): String = region.getRequired("region") + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("region") + @ExcludeMissing + fun _region(): JsonField = region + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BedrockApiKeyProviderOptions]. + * + * The following fields are required: + * ```java + * .region() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BedrockApiKeyProviderOptions]. */ + class Builder internal constructor() { + + private var region: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + bedrockApiKeyProviderOptions: BedrockApiKeyProviderOptions + ) = apply { + region = bedrockApiKeyProviderOptions.region + additionalProperties = + bedrockApiKeyProviderOptions.additionalProperties.toMutableMap() + } + + /** AWS region for Amazon Bedrock */ + fun region(region: String) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun region(region: JsonField) = apply { this.region = region } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BedrockApiKeyProviderOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .region() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BedrockApiKeyProviderOptions = + BedrockApiKeyProviderOptions( + checkRequired("region", region), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BedrockApiKeyProviderOptions = apply { + if (validated) { + return@apply + } + + region() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (region.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BedrockApiKeyProviderOptions && + region == other.region && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(region, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BedrockApiKeyProviderOptions{region=$region, additionalProperties=$additionalProperties}" + } + + class BedrockAwsCredentialsProviderOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessKeyId: JsonField, + private val region: JsonField, + private val secretAccessKey: JsonField, + private val sessionToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accessKeyId") + @ExcludeMissing + accessKeyId: JsonField = JsonMissing.of(), + @JsonProperty("region") + @ExcludeMissing + region: JsonField = JsonMissing.of(), + @JsonProperty("secretAccessKey") + @ExcludeMissing + secretAccessKey: JsonField = JsonMissing.of(), + @JsonProperty("sessionToken") + @ExcludeMissing + sessionToken: JsonField = JsonMissing.of(), + ) : this(accessKeyId, region, secretAccessKey, sessionToken, mutableMapOf()) + + /** + * AWS access key ID for Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun accessKeyId(): String = accessKeyId.getRequired("accessKeyId") + + /** + * AWS region for Amazon Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun region(): String = region.getRequired("region") + + /** + * AWS secret access key for Bedrock + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun secretAccessKey(): String = secretAccessKey.getRequired("secretAccessKey") + + /** + * Optional AWS session token for temporary credentials + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun sessionToken(): Optional = sessionToken.getOptional("sessionToken") + + /** + * Returns the raw JSON value of [accessKeyId]. + * + * Unlike [accessKeyId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("accessKeyId") + @ExcludeMissing + fun _accessKeyId(): JsonField = accessKeyId + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("region") + @ExcludeMissing + fun _region(): JsonField = region + + /** + * Returns the raw JSON value of [secretAccessKey]. + * + * Unlike [secretAccessKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("secretAccessKey") + @ExcludeMissing + fun _secretAccessKey(): JsonField = secretAccessKey + + /** + * Returns the raw JSON value of [sessionToken]. + * + * Unlike [sessionToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sessionToken") + @ExcludeMissing + fun _sessionToken(): JsonField = sessionToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BedrockAwsCredentialsProviderOptions]. + * + * The following fields are required: + * ```java + * .accessKeyId() + * .region() + * .secretAccessKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BedrockAwsCredentialsProviderOptions]. */ + class Builder internal constructor() { + + private var accessKeyId: JsonField? = null + private var region: JsonField? = null + private var secretAccessKey: JsonField? = null + private var sessionToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + bedrockAwsCredentialsProviderOptions: + BedrockAwsCredentialsProviderOptions + ) = apply { + accessKeyId = bedrockAwsCredentialsProviderOptions.accessKeyId + region = bedrockAwsCredentialsProviderOptions.region + secretAccessKey = bedrockAwsCredentialsProviderOptions.secretAccessKey + sessionToken = bedrockAwsCredentialsProviderOptions.sessionToken + additionalProperties = + bedrockAwsCredentialsProviderOptions.additionalProperties + .toMutableMap() + } + + /** AWS access key ID for Bedrock */ + fun accessKeyId(accessKeyId: String) = + accessKeyId(JsonField.of(accessKeyId)) + + /** + * Sets [Builder.accessKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.accessKeyId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accessKeyId(accessKeyId: JsonField) = apply { + this.accessKeyId = accessKeyId + } + + /** AWS region for Amazon Bedrock */ + fun region(region: String) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun region(region: JsonField) = apply { this.region = region } + + /** AWS secret access key for Bedrock */ + fun secretAccessKey(secretAccessKey: String) = + secretAccessKey(JsonField.of(secretAccessKey)) + + /** + * Sets [Builder.secretAccessKey] to an arbitrary JSON value. + * + * You should usually call [Builder.secretAccessKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secretAccessKey(secretAccessKey: JsonField) = apply { + this.secretAccessKey = secretAccessKey + } + + /** Optional AWS session token for temporary credentials */ + fun sessionToken(sessionToken: String) = + sessionToken(JsonField.of(sessionToken)) + + /** + * Sets [Builder.sessionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun sessionToken(sessionToken: JsonField) = apply { + this.sessionToken = sessionToken + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BedrockAwsCredentialsProviderOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessKeyId() + * .region() + * .secretAccessKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BedrockAwsCredentialsProviderOptions = + BedrockAwsCredentialsProviderOptions( + checkRequired("accessKeyId", accessKeyId), + checkRequired("region", region), + checkRequired("secretAccessKey", secretAccessKey), + sessionToken, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BedrockAwsCredentialsProviderOptions = apply { + if (validated) { + return@apply + } + + accessKeyId() + region() + secretAccessKey() + sessionToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessKeyId.asKnown().isPresent) 1 else 0) + + (if (region.asKnown().isPresent) 1 else 0) + + (if (secretAccessKey.asKnown().isPresent) 1 else 0) + + (if (sessionToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BedrockAwsCredentialsProviderOptions && + accessKeyId == other.accessKeyId && + region == other.region && + secretAccessKey == other.secretAccessKey && + sessionToken == other.sessionToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessKeyId, + region, + secretAccessKey, + sessionToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BedrockAwsCredentialsProviderOptions{accessKeyId=$accessKeyId, region=$region, secretAccessKey=$secretAccessKey, sessionToken=$sessionToken, additionalProperties=$additionalProperties}" + } + + class GoogleVertexProviderOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val googleAuthOptions: JsonField, + private val headers: JsonField, + private val location: JsonField, + private val project: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("googleAuthOptions") + @ExcludeMissing + googleAuthOptions: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + location: JsonField = JsonMissing.of(), + @JsonProperty("project") + @ExcludeMissing + project: JsonField = JsonMissing.of(), + ) : this(googleAuthOptions, headers, location, project, mutableMapOf()) + + /** + * Optional Google auth options for Vertex AI + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun googleAuthOptions(): Optional = + googleAuthOptions.getOptional("googleAuthOptions") + + /** + * Custom headers for Vertex AI requests + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * Google Cloud location for Vertex AI + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun location(): Optional = location.getOptional("location") + + /** + * Google Cloud project ID for Vertex AI + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun project(): Optional = project.getOptional("project") + + /** + * Returns the raw JSON value of [googleAuthOptions]. + * + * Unlike [googleAuthOptions], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("googleAuthOptions") + @ExcludeMissing + fun _googleAuthOptions(): JsonField = googleAuthOptions + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("headers") + @ExcludeMissing + fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location + + /** + * Returns the raw JSON value of [project]. + * + * Unlike [project], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("project") + @ExcludeMissing + fun _project(): JsonField = project + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GoogleVertexProviderOptions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleVertexProviderOptions]. */ + class Builder internal constructor() { + + private var googleAuthOptions: JsonField = + JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var project: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + googleVertexProviderOptions: GoogleVertexProviderOptions + ) = apply { + googleAuthOptions = googleVertexProviderOptions.googleAuthOptions + headers = googleVertexProviderOptions.headers + location = googleVertexProviderOptions.location + project = googleVertexProviderOptions.project + additionalProperties = + googleVertexProviderOptions.additionalProperties.toMutableMap() + } + + /** Optional Google auth options for Vertex AI */ + fun googleAuthOptions(googleAuthOptions: GoogleAuthOptions) = + googleAuthOptions(JsonField.of(googleAuthOptions)) + + /** + * Sets [Builder.googleAuthOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.googleAuthOptions] with a well-typed + * [GoogleAuthOptions] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun googleAuthOptions(googleAuthOptions: JsonField) = + apply { + this.googleAuthOptions = googleAuthOptions + } + + /** Custom headers for Vertex AI requests */ + fun headers(headers: Headers) = headers(JsonField.of(headers)) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + /** Google Cloud location for Vertex AI */ + fun location(location: String) = location(JsonField.of(location)) + + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun location(location: JsonField) = apply { + this.location = location + } + + /** Google Cloud project ID for Vertex AI */ + fun project(project: String) = project(JsonField.of(project)) + + /** + * Sets [Builder.project] to an arbitrary JSON value. + * + * You should usually call [Builder.project] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun project(project: JsonField) = apply { this.project = project } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GoogleVertexProviderOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GoogleVertexProviderOptions = + GoogleVertexProviderOptions( + googleAuthOptions, + headers, + location, + project, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GoogleVertexProviderOptions = apply { + if (validated) { + return@apply + } + + googleAuthOptions().ifPresent { it.validate() } + headers().ifPresent { it.validate() } + location() + project() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (googleAuthOptions.asKnown().getOrNull()?.validity() ?: 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (if (location.asKnown().isPresent) 1 else 0) + + (if (project.asKnown().isPresent) 1 else 0) + + /** Optional Google auth options for Vertex AI */ + class GoogleAuthOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credentials: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credentials") + @ExcludeMissing + credentials: JsonField = JsonMissing.of() + ) : this(credentials, mutableMapOf()) + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun credentials(): Optional = + credentials.getOptional("credentials") + + /** + * Returns the raw JSON value of [credentials]. + * + * Unlike [credentials], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credentials") + @ExcludeMissing + fun _credentials(): JsonField = credentials + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GoogleAuthOptions]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleAuthOptions]. */ + class Builder internal constructor() { + + private var credentials: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(googleAuthOptions: GoogleAuthOptions) = apply { + credentials = googleAuthOptions.credentials + additionalProperties = + googleAuthOptions.additionalProperties.toMutableMap() + } + + fun credentials(credentials: Credentials) = + credentials(JsonField.of(credentials)) + + /** + * Sets [Builder.credentials] to an arbitrary JSON value. + * + * You should usually call [Builder.credentials] with a well-typed + * [Credentials] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun credentials(credentials: JsonField) = apply { + this.credentials = credentials + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GoogleAuthOptions]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): GoogleAuthOptions = + GoogleAuthOptions(credentials, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GoogleAuthOptions = apply { + if (validated) { + return@apply + } + + credentials().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (credentials.asKnown().getOrNull()?.validity() ?: 0) + + class Credentials + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val authProviderX509CertUrl: JsonField, + private val authUri: JsonField, + private val clientEmail: JsonField, + private val clientId: JsonField, + private val clientX509CertUrl: JsonField, + private val privateKey: JsonField, + private val privateKeyId: JsonField, + private val projectId: JsonField, + private val tokenUri: JsonField, + private val type: JsonField, + private val universeDomain: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("auth_provider_x509_cert_url") + @ExcludeMissing + authProviderX509CertUrl: JsonField = JsonMissing.of(), + @JsonProperty("auth_uri") + @ExcludeMissing + authUri: JsonField = JsonMissing.of(), + @JsonProperty("client_email") + @ExcludeMissing + clientEmail: JsonField = JsonMissing.of(), + @JsonProperty("client_id") + @ExcludeMissing + clientId: JsonField = JsonMissing.of(), + @JsonProperty("client_x509_cert_url") + @ExcludeMissing + clientX509CertUrl: JsonField = JsonMissing.of(), + @JsonProperty("private_key") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), + @JsonProperty("private_key_id") + @ExcludeMissing + privateKeyId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("token_uri") + @ExcludeMissing + tokenUri: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("universe_domain") + @ExcludeMissing + universeDomain: JsonField = JsonMissing.of(), + ) : this( + authProviderX509CertUrl, + authUri, + clientEmail, + clientId, + clientX509CertUrl, + privateKey, + privateKeyId, + projectId, + tokenUri, + type, + universeDomain, + mutableMapOf(), + ) + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun authProviderX509CertUrl(): Optional = + authProviderX509CertUrl.getOptional("auth_provider_x509_cert_url") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun authUri(): Optional = authUri.getOptional("auth_uri") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun clientEmail(): Optional = + clientEmail.getOptional("client_email") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun clientId(): Optional = clientId.getOptional("client_id") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun clientX509CertUrl(): Optional = + clientX509CertUrl.getOptional("client_x509_cert_url") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun privateKey(): Optional = + privateKey.getOptional("private_key") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun privateKeyId(): Optional = + privateKeyId.getOptional("private_key_id") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun projectId(): Optional = projectId.getOptional("project_id") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun tokenUri(): Optional = tokenUri.getOptional("token_uri") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * @throws StagehandInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun universeDomain(): Optional = + universeDomain.getOptional("universe_domain") + + /** + * Returns the raw JSON value of [authProviderX509CertUrl]. + * + * Unlike [authProviderX509CertUrl], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("auth_provider_x509_cert_url") + @ExcludeMissing + fun _authProviderX509CertUrl(): JsonField = + authProviderX509CertUrl + + /** + * Returns the raw JSON value of [authUri]. + * + * Unlike [authUri], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("auth_uri") + @ExcludeMissing + fun _authUri(): JsonField = authUri + + /** + * Returns the raw JSON value of [clientEmail]. + * + * Unlike [clientEmail], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("client_email") + @ExcludeMissing + fun _clientEmail(): JsonField = clientEmail + + /** + * Returns the raw JSON value of [clientId]. + * + * Unlike [clientId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("client_id") + @ExcludeMissing + fun _clientId(): JsonField = clientId + + /** + * Returns the raw JSON value of [clientX509CertUrl]. + * + * Unlike [clientX509CertUrl], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("client_x509_cert_url") + @ExcludeMissing + fun _clientX509CertUrl(): JsonField = clientX509CertUrl + + /** + * Returns the raw JSON value of [privateKey]. + * + * Unlike [privateKey], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("private_key") + @ExcludeMissing + fun _privateKey(): JsonField = privateKey + + /** + * Returns the raw JSON value of [privateKeyId]. + * + * Unlike [privateKeyId], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("private_key_id") + @ExcludeMissing + fun _privateKeyId(): JsonField = privateKeyId + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [tokenUri]. + * + * Unlike [tokenUri], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("token_uri") + @ExcludeMissing + fun _tokenUri(): JsonField = tokenUri + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [universeDomain]. + * + * Unlike [universeDomain], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("universe_domain") + @ExcludeMissing + fun _universeDomain(): JsonField = universeDomain + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [Credentials]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Credentials]. */ + class Builder internal constructor() { + + private var authProviderX509CertUrl: JsonField = + JsonMissing.of() + private var authUri: JsonField = JsonMissing.of() + private var clientEmail: JsonField = JsonMissing.of() + private var clientId: JsonField = JsonMissing.of() + private var clientX509CertUrl: JsonField = JsonMissing.of() + private var privateKey: JsonField = JsonMissing.of() + private var privateKeyId: JsonField = JsonMissing.of() + private var projectId: JsonField = JsonMissing.of() + private var tokenUri: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var universeDomain: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(credentials: Credentials) = apply { + authProviderX509CertUrl = credentials.authProviderX509CertUrl + authUri = credentials.authUri + clientEmail = credentials.clientEmail + clientId = credentials.clientId + clientX509CertUrl = credentials.clientX509CertUrl + privateKey = credentials.privateKey + privateKeyId = credentials.privateKeyId + projectId = credentials.projectId + tokenUri = credentials.tokenUri + type = credentials.type + universeDomain = credentials.universeDomain + additionalProperties = + credentials.additionalProperties.toMutableMap() + } + + fun authProviderX509CertUrl(authProviderX509CertUrl: String) = + authProviderX509CertUrl(JsonField.of(authProviderX509CertUrl)) + + /** + * Sets [Builder.authProviderX509CertUrl] to an arbitrary JSON + * value. + * + * You should usually call [Builder.authProviderX509CertUrl] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun authProviderX509CertUrl( + authProviderX509CertUrl: JsonField + ) = apply { this.authProviderX509CertUrl = authProviderX509CertUrl } + + fun authUri(authUri: String) = authUri(JsonField.of(authUri)) + + /** + * Sets [Builder.authUri] to an arbitrary JSON value. + * + * You should usually call [Builder.authUri] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun authUri(authUri: JsonField) = apply { + this.authUri = authUri + } + + fun clientEmail(clientEmail: String) = + clientEmail(JsonField.of(clientEmail)) + + /** + * Sets [Builder.clientEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.clientEmail] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun clientEmail(clientEmail: JsonField) = apply { + this.clientEmail = clientEmail + } + + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + + /** + * Sets [Builder.clientId] to an arbitrary JSON value. + * + * You should usually call [Builder.clientId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun clientId(clientId: JsonField) = apply { + this.clientId = clientId + } + + fun clientX509CertUrl(clientX509CertUrl: String) = + clientX509CertUrl(JsonField.of(clientX509CertUrl)) + + /** + * Sets [Builder.clientX509CertUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.clientX509CertUrl] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun clientX509CertUrl(clientX509CertUrl: JsonField) = + apply { + this.clientX509CertUrl = clientX509CertUrl + } + + fun privateKey(privateKey: String) = + privateKey(JsonField.of(privateKey)) + + /** + * Sets [Builder.privateKey] to an arbitrary JSON value. + * + * You should usually call [Builder.privateKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun privateKey(privateKey: JsonField) = apply { + this.privateKey = privateKey + } + + fun privateKeyId(privateKeyId: String) = + privateKeyId(JsonField.of(privateKeyId)) + + /** + * Sets [Builder.privateKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.privateKeyId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun privateKeyId(privateKeyId: JsonField) = apply { + this.privateKeyId = privateKeyId + } + + fun projectId(projectId: String) = + projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } + + fun tokenUri(tokenUri: String) = tokenUri(JsonField.of(tokenUri)) + + /** + * Sets [Builder.tokenUri] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenUri] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tokenUri(tokenUri: JsonField) = apply { + this.tokenUri = tokenUri + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun universeDomain(universeDomain: String) = + universeDomain(JsonField.of(universeDomain)) + + /** + * Sets [Builder.universeDomain] to an arbitrary JSON value. + * + * You should usually call [Builder.universeDomain] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun universeDomain(universeDomain: JsonField) = apply { + this.universeDomain = universeDomain + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Credentials]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Credentials = + Credentials( + authProviderX509CertUrl, + authUri, + clientEmail, + clientId, + clientX509CertUrl, + privateKey, + privateKeyId, + projectId, + tokenUri, + type, + universeDomain, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Credentials = apply { + if (validated) { + return@apply + } + + authProviderX509CertUrl() + authUri() + clientEmail() + clientId() + clientX509CertUrl() + privateKey() + privateKeyId() + projectId() + tokenUri() + type() + universeDomain() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (authProviderX509CertUrl.asKnown().isPresent) 1 else 0) + + (if (authUri.asKnown().isPresent) 1 else 0) + + (if (clientEmail.asKnown().isPresent) 1 else 0) + + (if (clientId.asKnown().isPresent) 1 else 0) + + (if (clientX509CertUrl.asKnown().isPresent) 1 else 0) + + (if (privateKey.asKnown().isPresent) 1 else 0) + + (if (privateKeyId.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (tokenUri.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (universeDomain.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Credentials && + authProviderX509CertUrl == other.authProviderX509CertUrl && + authUri == other.authUri && + clientEmail == other.clientEmail && + clientId == other.clientId && + clientX509CertUrl == other.clientX509CertUrl && + privateKey == other.privateKey && + privateKeyId == other.privateKeyId && + projectId == other.projectId && + tokenUri == other.tokenUri && + type == other.type && + universeDomain == other.universeDomain && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + authProviderX509CertUrl, + authUri, + clientEmail, + clientId, + clientX509CertUrl, + privateKey, + privateKeyId, + projectId, + tokenUri, + type, + universeDomain, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Credentials{authProviderX509CertUrl=$authProviderX509CertUrl, authUri=$authUri, clientEmail=$clientEmail, clientId=$clientId, clientX509CertUrl=$clientX509CertUrl, privateKey=$privateKey, privateKeyId=$privateKeyId, projectId=$projectId, tokenUri=$tokenUri, type=$type, universeDomain=$universeDomain, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleAuthOptions && + credentials == other.credentials && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(credentials, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GoogleAuthOptions{credentials=$credentials, additionalProperties=$additionalProperties}" + } + + /** Custom headers for Vertex AI requests */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Headers]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Headers{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleVertexProviderOptions && + googleAuthOptions == other.googleAuthOptions && + headers == other.headers && + location == other.location && + project == other.project && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + googleAuthOptions, + headers, + location, + project, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GoogleVertexProviderOptions{googleAuthOptions=$googleAuthOptions, headers=$headers, location=$location, project=$project, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GenericModelClientOptions && + apiKey == other.apiKey && + baseUrl == other.baseUrl && + headers == other.headers && + providerOptions == other.providerOptions && + skipApiKeyFallback == other.skipApiKeyFallback && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + apiKey, + baseUrl, + headers, + providerOptions, + skipApiKeyFallback, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GenericModelClientOptions{apiKey=$apiKey, baseUrl=$baseUrl, headers=$headers, providerOptions=$providerOptions, skipApiKeyFallback=$skipApiKeyFallback, additionalProperties=$additionalProperties}" + } + } + /** Logging verbosity level (0=quiet, 1=normal, 2=debug) */ class Verbose @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/StreamEvent.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/StreamEvent.kt index 4584374..443104b 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/StreamEvent.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/StreamEvent.kt @@ -30,8 +30,8 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Server-Sent Event emitted during streaming responses. Events are sent as `event: \ndata: - * \n\n`, where the JSON payload has the shape `{ data, type, id }`. + * Server-Sent Event emitted during streaming responses. Events are sent as `data: \n\n`. Key + * order: data (with status first), type, id. */ class StreamEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/ModelConfigTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/ModelConfigTest.kt index 6e3b3d0..1326d37 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/ModelConfigTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/ModelConfigTest.kt @@ -14,27 +14,42 @@ internal class ModelConfigTest { fun create() { val modelConfig = ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() - assertThat(modelConfig.modelName()).isEqualTo("openai/gpt-5.4-mini") + assertThat(modelConfig.modelName()).isEqualTo("openai/gpt-5-nano") assertThat(modelConfig.apiKey()).contains("sk-some-openai-api-key") assertThat(modelConfig.baseUrl()).contains("https://api.openai.com/v1") assertThat(modelConfig.headers()) .contains( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) .build() ) assertThat(modelConfig.provider()).contains(ModelConfig.Provider.OPENAI) + assertThat(modelConfig.providerOptions()) + .contains( + ModelConfig.ProviderOptions.ofBedrockApiKey( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + ) + assertThat(modelConfig.skipApiKeyFallback()).contains(true) } @Test @@ -42,15 +57,21 @@ internal class ModelConfigTest { val jsonMapper = jsonMapper() val modelConfig = ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() val roundtrippedModelConfig = diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionActParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionActParamsTest.kt index 31ef59b..ac1315c 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionActParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionActParamsTest.kt @@ -20,15 +20,24 @@ internal class SessionActParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -76,15 +85,25 @@ internal class SessionActParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -136,15 +155,25 @@ internal class SessionActParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -176,15 +205,24 @@ internal class SessionActParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExecuteParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExecuteParamsTest.kt index f040cad..e2c6f96 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExecuteParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExecuteParamsTest.kt @@ -19,29 +19,47 @@ internal class SessionExecuteParamsTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -55,8 +73,6 @@ internal class SessionExecuteParamsTest { ) .highlightCursor(true) .maxSteps(20.0) - .toolTimeout(30000.0) - .useSearch(true) .build() ) .frameId("frameId") @@ -95,29 +111,49 @@ internal class SessionExecuteParamsTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -131,8 +167,6 @@ internal class SessionExecuteParamsTest { ) .highlightCursor(true) .maxSteps(20.0) - .toolTimeout(30000.0) - .useSearch(true) .build() ) .frameId("frameId") @@ -175,29 +209,49 @@ internal class SessionExecuteParamsTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -211,8 +265,6 @@ internal class SessionExecuteParamsTest { ) .highlightCursor(true) .maxSteps(20.0) - .toolTimeout(30000.0) - .useSearch(true) .build() ) .frameId("frameId") @@ -227,29 +279,47 @@ internal class SessionExecuteParamsTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -264,8 +334,6 @@ internal class SessionExecuteParamsTest { ) .highlightCursor(true) .maxSteps(20.0) - .toolTimeout(30000.0) - .useSearch(true) .build() ) assertThat(body.frameId()).contains("frameId") diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExtractParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExtractParamsTest.kt index d84a3f9..f14f0a4 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExtractParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExtractParamsTest.kt @@ -20,15 +20,24 @@ internal class SessionExtractParamsTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -65,15 +74,25 @@ internal class SessionExtractParamsTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -114,15 +133,25 @@ internal class SessionExtractParamsTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -146,15 +175,24 @@ internal class SessionExtractParamsTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("#main-content") diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionObserveParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionObserveParamsTest.kt index 08f0c13..fc07b50 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionObserveParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionObserveParamsTest.kt @@ -20,15 +20,24 @@ internal class SessionObserveParamsTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -74,15 +83,25 @@ internal class SessionObserveParamsTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -132,15 +151,25 @@ internal class SessionObserveParamsTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -172,15 +201,24 @@ internal class SessionObserveParamsTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("nav") diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt index 7ebe44e..eef7a55 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt @@ -152,6 +152,27 @@ internal class SessionStartParamsTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -307,6 +328,27 @@ internal class SessionStartParamsTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -475,6 +517,27 @@ internal class SessionStartParamsTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -624,6 +687,30 @@ internal class SessionStartParamsTest { assertThat(body.browserbaseSessionId()).contains("browserbaseSessionID") assertThat(body.domSettleTimeoutMs()).contains(5000.0) assertThat(body.experimental()).contains(true) + assertThat(body.modelClientOptions()) + .contains( + SessionStartParams.ModelClientOptions.ofBedrockApiKey( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) + ) assertThat(body.selfHeal()).contains(true) assertThat(body.systemPrompt()).contains("systemPrompt") assertThat(body.verbose()).contains(SessionStartParams.Verbose._1) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt index a3bc8a0..194631c 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt @@ -233,6 +233,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -419,6 +446,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -605,6 +659,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -791,6 +872,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -977,6 +1085,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1163,6 +1298,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1349,6 +1511,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1535,6 +1724,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1721,6 +1937,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1907,6 +2150,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2093,6 +2363,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2279,6 +2576,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2465,6 +2789,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2651,6 +3002,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2837,6 +3215,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -3023,6 +3428,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -3207,6 +3639,33 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt index f423bd2..233fdfd 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt @@ -192,6 +192,27 @@ internal class ServiceParamsTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -226,15 +247,25 @@ internal class ServiceParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt index 3635e44..0d1d6b0 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt @@ -40,15 +40,25 @@ internal class SessionServiceAsyncTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -97,15 +107,25 @@ internal class SessionServiceAsyncTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -177,29 +197,49 @@ internal class SessionServiceAsyncTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -213,8 +253,6 @@ internal class SessionServiceAsyncTest { ) .highlightCursor(true) .maxSteps(20.0) - .toolTimeout(30000.0) - .useSearch(true) .build() ) .frameId("frameId") @@ -247,29 +285,49 @@ internal class SessionServiceAsyncTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -283,8 +341,6 @@ internal class SessionServiceAsyncTest { ) .highlightCursor(true) .maxSteps(20.0) - .toolTimeout(30000.0) - .useSearch(true) .build() ) .frameId("frameId") @@ -319,15 +375,25 @@ internal class SessionServiceAsyncTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -368,15 +434,25 @@ internal class SessionServiceAsyncTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -451,15 +527,25 @@ internal class SessionServiceAsyncTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -509,15 +595,25 @@ internal class SessionServiceAsyncTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -731,6 +827,33 @@ internal class SessionServiceAsyncTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt index 15ae6c4..cf8b728 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt @@ -40,15 +40,25 @@ internal class SessionServiceTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -96,15 +106,25 @@ internal class SessionServiceTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -175,29 +195,49 @@ internal class SessionServiceTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -211,8 +251,6 @@ internal class SessionServiceTest { ) .highlightCursor(true) .maxSteps(20.0) - .toolTimeout(30000.0) - .useSearch(true) .build() ) .frameId("frameId") @@ -244,29 +282,49 @@ internal class SessionServiceTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -280,8 +338,6 @@ internal class SessionServiceTest { ) .highlightCursor(true) .maxSteps(20.0) - .toolTimeout(30000.0) - .useSearch(true) .build() ) .frameId("frameId") @@ -316,15 +372,25 @@ internal class SessionServiceTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -364,15 +430,25 @@ internal class SessionServiceTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -446,15 +522,25 @@ internal class SessionServiceTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -503,15 +589,25 @@ internal class SessionServiceTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5.4-mini") + .modelName("openai/gpt-5-nano") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) .build() ) .provider(ModelConfig.Provider.OPENAI) + .providerOptions( + ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -724,6 +820,33 @@ internal class SessionServiceTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) + .modelClientOptions( + SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions + .builder() + .apiKey("bedrock-short-term-api-key") + .providerOptions( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .ProviderOptions + .builder() + .region("us-east-1") + .build() + ) + .baseUrl("https://api.openai.com/v1") + .headers( + SessionStartParams.ModelClientOptions + .BedrockApiKeyModelClientOptions + .Headers + .builder() + .putAdditionalProperty( + "X-Custom-Header", + JsonValue.from("value"), + ) + .build() + ) + .skipApiKeyFallback(true) + .build() + ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) From 59ee1516eb17d6b8474b12d2722ff4627fa2557c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 23:32:49 +0000 Subject: [PATCH 3/5] feat: [STG-1798] feat: support Browserbase verified sessions --- .stats.yml | 6 +- .../api/models/sessions/SessionStartParams.kt | 306 +++++++++++++++++- .../models/sessions/SessionStartParamsTest.kt | 32 ++ .../api/services/ErrorHandlingTest.kt | 153 +++++++++ .../api/services/ServiceParamsTest.kt | 9 + .../services/async/SessionServiceAsyncTest.kt | 9 + .../services/blocking/SessionServiceTest.kt | 9 + 7 files changed, 520 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index f1d6429..6bde59e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-7773ef4ca29c983daafb787ee918cfa6b5b12c5bbdc088308653f2737c26e51f.yml -openapi_spec_hash: 47fc8f2540be0b6374e4230c021072d9 -config_hash: 0cc516caf1432087f40654336e0fa8cd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-a8db51c6460b3daff67b35262517848a0d4e783c6805c2edd531b155a5db71dd.yml +openapi_spec_hash: c6e7127f211f946673d6389e1d8db1ba +config_hash: a962ae71493deb11a1c903256fb25386 diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt index 3b2547c..a2fba41 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt @@ -3747,12 +3747,16 @@ private constructor( private constructor( private val advancedStealth: JsonField, private val blockAds: JsonField, + private val captchaImageSelector: JsonField, + private val captchaInputSelector: JsonField, private val context: JsonField, private val extensionId: JsonField, private val fingerprint: JsonField, private val logSession: JsonField, + private val os: JsonField, private val recordSession: JsonField, private val solveCaptchas: JsonField, + private val verified: JsonField, private val viewport: JsonField, private val additionalProperties: MutableMap, ) { @@ -3765,6 +3769,12 @@ private constructor( @JsonProperty("blockAds") @ExcludeMissing blockAds: JsonField = JsonMissing.of(), + @JsonProperty("captchaImageSelector") + @ExcludeMissing + captchaImageSelector: JsonField = JsonMissing.of(), + @JsonProperty("captchaInputSelector") + @ExcludeMissing + captchaInputSelector: JsonField = JsonMissing.of(), @JsonProperty("context") @ExcludeMissing context: JsonField = JsonMissing.of(), @@ -3777,24 +3787,32 @@ private constructor( @JsonProperty("logSession") @ExcludeMissing logSession: JsonField = JsonMissing.of(), + @JsonProperty("os") @ExcludeMissing os: JsonField = JsonMissing.of(), @JsonProperty("recordSession") @ExcludeMissing recordSession: JsonField = JsonMissing.of(), @JsonProperty("solveCaptchas") @ExcludeMissing solveCaptchas: JsonField = JsonMissing.of(), + @JsonProperty("verified") + @ExcludeMissing + verified: JsonField = JsonMissing.of(), @JsonProperty("viewport") @ExcludeMissing viewport: JsonField = JsonMissing.of(), ) : this( advancedStealth, blockAds, + captchaImageSelector, + captchaInputSelector, context, extensionId, fingerprint, logSession, + os, recordSession, solveCaptchas, + verified, viewport, mutableMapOf(), ) @@ -3812,6 +3830,20 @@ private constructor( */ fun blockAds(): Optional = blockAds.getOptional("blockAds") + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun captchaImageSelector(): Optional = + captchaImageSelector.getOptional("captchaImageSelector") + + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun captchaInputSelector(): Optional = + captchaInputSelector.getOptional("captchaInputSelector") + /** * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -3836,6 +3868,12 @@ private constructor( */ fun logSession(): Optional = logSession.getOptional("logSession") + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun os(): Optional = os.getOptional("os") + /** * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -3848,6 +3886,12 @@ private constructor( */ fun solveCaptchas(): Optional = solveCaptchas.getOptional("solveCaptchas") + /** + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun verified(): Optional = verified.getOptional("verified") + /** * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -3872,6 +3916,26 @@ private constructor( */ @JsonProperty("blockAds") @ExcludeMissing fun _blockAds(): JsonField = blockAds + /** + * Returns the raw JSON value of [captchaImageSelector]. + * + * Unlike [captchaImageSelector], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("captchaImageSelector") + @ExcludeMissing + fun _captchaImageSelector(): JsonField = captchaImageSelector + + /** + * Returns the raw JSON value of [captchaInputSelector]. + * + * Unlike [captchaInputSelector], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("captchaInputSelector") + @ExcludeMissing + fun _captchaInputSelector(): JsonField = captchaInputSelector + /** * Returns the raw JSON value of [context]. * @@ -3909,6 +3973,13 @@ private constructor( @ExcludeMissing fun _logSession(): JsonField = logSession + /** + * Returns the raw JSON value of [os]. + * + * Unlike [os], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("os") @ExcludeMissing fun _os(): JsonField = os + /** * Returns the raw JSON value of [recordSession]. * @@ -3929,6 +4000,14 @@ private constructor( @ExcludeMissing fun _solveCaptchas(): JsonField = solveCaptchas + /** + * Returns the raw JSON value of [verified]. + * + * Unlike [verified], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("verified") @ExcludeMissing fun _verified(): JsonField = verified + /** * Returns the raw JSON value of [viewport]. * @@ -3962,12 +4041,16 @@ private constructor( private var advancedStealth: JsonField = JsonMissing.of() private var blockAds: JsonField = JsonMissing.of() + private var captchaImageSelector: JsonField = JsonMissing.of() + private var captchaInputSelector: JsonField = JsonMissing.of() private var context: JsonField = JsonMissing.of() private var extensionId: JsonField = JsonMissing.of() private var fingerprint: JsonField = JsonMissing.of() private var logSession: JsonField = JsonMissing.of() + private var os: JsonField = JsonMissing.of() private var recordSession: JsonField = JsonMissing.of() private var solveCaptchas: JsonField = JsonMissing.of() + private var verified: JsonField = JsonMissing.of() private var viewport: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3975,12 +4058,16 @@ private constructor( internal fun from(browserSettings: BrowserSettings) = apply { advancedStealth = browserSettings.advancedStealth blockAds = browserSettings.blockAds + captchaImageSelector = browserSettings.captchaImageSelector + captchaInputSelector = browserSettings.captchaInputSelector context = browserSettings.context extensionId = browserSettings.extensionId fingerprint = browserSettings.fingerprint logSession = browserSettings.logSession + os = browserSettings.os recordSession = browserSettings.recordSession solveCaptchas = browserSettings.solveCaptchas + verified = browserSettings.verified viewport = browserSettings.viewport additionalProperties = browserSettings.additionalProperties.toMutableMap() } @@ -4010,6 +4097,34 @@ private constructor( */ fun blockAds(blockAds: JsonField) = apply { this.blockAds = blockAds } + fun captchaImageSelector(captchaImageSelector: String) = + captchaImageSelector(JsonField.of(captchaImageSelector)) + + /** + * Sets [Builder.captchaImageSelector] to an arbitrary JSON value. + * + * You should usually call [Builder.captchaImageSelector] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun captchaImageSelector(captchaImageSelector: JsonField) = apply { + this.captchaImageSelector = captchaImageSelector + } + + fun captchaInputSelector(captchaInputSelector: String) = + captchaInputSelector(JsonField.of(captchaInputSelector)) + + /** + * Sets [Builder.captchaInputSelector] to an arbitrary JSON value. + * + * You should usually call [Builder.captchaInputSelector] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun captchaInputSelector(captchaInputSelector: JsonField) = apply { + this.captchaInputSelector = captchaInputSelector + } + fun context(context: Context) = context(JsonField.of(context)) /** @@ -4060,6 +4175,17 @@ private constructor( this.logSession = logSession } + fun os(os: Os) = os(JsonField.of(os)) + + /** + * Sets [Builder.os] to an arbitrary JSON value. + * + * You should usually call [Builder.os] with a well-typed [Os] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun os(os: JsonField) = apply { this.os = os } + fun recordSession(recordSession: Boolean) = recordSession(JsonField.of(recordSession)) @@ -4088,6 +4214,17 @@ private constructor( this.solveCaptchas = solveCaptchas } + fun verified(verified: Boolean) = verified(JsonField.of(verified)) + + /** + * Sets [Builder.verified] to an arbitrary JSON value. + * + * You should usually call [Builder.verified] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun verified(verified: JsonField) = apply { this.verified = verified } + fun viewport(viewport: Viewport) = viewport(JsonField.of(viewport)) /** @@ -4130,12 +4267,16 @@ private constructor( BrowserSettings( advancedStealth, blockAds, + captchaImageSelector, + captchaInputSelector, context, extensionId, fingerprint, logSession, + os, recordSession, solveCaptchas, + verified, viewport, additionalProperties.toMutableMap(), ) @@ -4150,12 +4291,16 @@ private constructor( advancedStealth() blockAds() + captchaImageSelector() + captchaInputSelector() context().ifPresent { it.validate() } extensionId() fingerprint().ifPresent { it.validate() } logSession() + os().ifPresent { it.validate() } recordSession() solveCaptchas() + verified() viewport().ifPresent { it.validate() } validated = true } @@ -4178,12 +4323,16 @@ private constructor( internal fun validity(): Int = (if (advancedStealth.asKnown().isPresent) 1 else 0) + (if (blockAds.asKnown().isPresent) 1 else 0) + + (if (captchaImageSelector.asKnown().isPresent) 1 else 0) + + (if (captchaInputSelector.asKnown().isPresent) 1 else 0) + (context.asKnown().getOrNull()?.validity() ?: 0) + (if (extensionId.asKnown().isPresent) 1 else 0) + (fingerprint.asKnown().getOrNull()?.validity() ?: 0) + (if (logSession.asKnown().isPresent) 1 else 0) + + (os.asKnown().getOrNull()?.validity() ?: 0) + (if (recordSession.asKnown().isPresent) 1 else 0) + (if (solveCaptchas.asKnown().isPresent) 1 else 0) + + (if (verified.asKnown().isPresent) 1 else 0) + (viewport.asKnown().getOrNull()?.validity() ?: 0) class Context @@ -5651,6 +5800,153 @@ private constructor( "Fingerprint{browsers=$browsers, devices=$devices, httpVersion=$httpVersion, locales=$locales, operatingSystems=$operatingSystems, screen=$screen, additionalProperties=$additionalProperties}" } + class Os @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val WINDOWS = of("windows") + + @JvmField val MAC = of("mac") + + @JvmField val LINUX = of("linux") + + @JvmField val MOBILE = of("mobile") + + @JvmField val TABLET = of("tablet") + + @JvmStatic fun of(value: String) = Os(JsonField.of(value)) + } + + /** An enum containing [Os]'s known values. */ + enum class Known { + WINDOWS, + MAC, + LINUX, + MOBILE, + TABLET, + } + + /** + * An enum containing [Os]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Os] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + WINDOWS, + MAC, + LINUX, + MOBILE, + TABLET, + /** + * An enum member indicating that [Os] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + WINDOWS -> Value.WINDOWS + MAC -> Value.MAC + LINUX -> Value.LINUX + MOBILE -> Value.MOBILE + TABLET -> Value.TABLET + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws StagehandInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + WINDOWS -> Known.WINDOWS + MAC -> Known.MAC + LINUX -> Known.LINUX + MOBILE -> Known.MOBILE + TABLET -> Known.TABLET + else -> throw StagehandInvalidDataException("Unknown Os: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws StagehandInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + StagehandInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Os = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StagehandInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Os && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class Viewport @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -5842,12 +6138,16 @@ private constructor( return other is BrowserSettings && advancedStealth == other.advancedStealth && blockAds == other.blockAds && + captchaImageSelector == other.captchaImageSelector && + captchaInputSelector == other.captchaInputSelector && context == other.context && extensionId == other.extensionId && fingerprint == other.fingerprint && logSession == other.logSession && + os == other.os && recordSession == other.recordSession && solveCaptchas == other.solveCaptchas && + verified == other.verified && viewport == other.viewport && additionalProperties == other.additionalProperties } @@ -5856,12 +6156,16 @@ private constructor( Objects.hash( advancedStealth, blockAds, + captchaImageSelector, + captchaInputSelector, context, extensionId, fingerprint, logSession, + os, recordSession, solveCaptchas, + verified, viewport, additionalProperties, ) @@ -5870,7 +6174,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BrowserSettings{advancedStealth=$advancedStealth, blockAds=$blockAds, context=$context, extensionId=$extensionId, fingerprint=$fingerprint, logSession=$logSession, recordSession=$recordSession, solveCaptchas=$solveCaptchas, viewport=$viewport, additionalProperties=$additionalProperties}" + "BrowserSettings{advancedStealth=$advancedStealth, blockAds=$blockAds, captchaImageSelector=$captchaImageSelector, captchaInputSelector=$captchaInputSelector, context=$context, extensionId=$extensionId, fingerprint=$fingerprint, logSession=$logSession, os=$os, recordSession=$recordSession, solveCaptchas=$solveCaptchas, verified=$verified, viewport=$viewport, additionalProperties=$additionalProperties}" } @JsonDeserialize(using = Proxies.Deserializer::class) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt index eef7a55..0d05eca 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt @@ -67,6 +67,8 @@ internal class SessionStartParamsTest { SessionStartParams.BrowserbaseSessionCreateParams.BrowserSettings.builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams.BrowserSettings .Context @@ -124,8 +126,13 @@ internal class SessionStartParamsTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams.BrowserSettings.Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams.BrowserSettings .Viewport @@ -240,6 +247,8 @@ internal class SessionStartParamsTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -299,8 +308,15 @@ internal class SessionStartParamsTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -429,6 +445,8 @@ internal class SessionStartParamsTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -488,8 +506,15 @@ internal class SessionStartParamsTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -602,6 +627,8 @@ internal class SessionStartParamsTest { SessionStartParams.BrowserbaseSessionCreateParams.BrowserSettings.builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams.BrowserSettings .Context @@ -659,8 +686,13 @@ internal class SessionStartParamsTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams.BrowserSettings.Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams.BrowserSettings .Viewport diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt index 194631c..fce6e48 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt @@ -136,6 +136,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -200,8 +202,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -349,6 +358,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -413,8 +424,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -562,6 +580,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -626,8 +646,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -775,6 +802,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -839,8 +868,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -988,6 +1024,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1052,8 +1090,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1201,6 +1246,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1265,8 +1312,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1414,6 +1468,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1478,8 +1534,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1627,6 +1690,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1691,8 +1756,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1840,6 +1912,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -1904,8 +1978,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2053,6 +2134,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2117,8 +2200,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2266,6 +2356,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2330,8 +2422,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2479,6 +2578,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2543,8 +2644,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2692,6 +2800,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2756,8 +2866,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2905,6 +3022,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -2969,8 +3088,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -3118,6 +3244,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -3182,8 +3310,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -3331,6 +3466,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -3395,8 +3532,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -3542,6 +3686,8 @@ internal class ErrorHandlingTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -3606,8 +3752,15 @@ internal class ErrorHandlingTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt index 233fdfd..b67f63c 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt @@ -104,6 +104,8 @@ internal class ServiceParamsTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -163,8 +165,15 @@ internal class ServiceParamsTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt index 0d1d6b0..78f3def 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt @@ -736,6 +736,8 @@ internal class SessionServiceAsyncTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -795,8 +797,15 @@ internal class SessionServiceAsyncTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt index cf8b728..7d7349d 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt @@ -729,6 +729,8 @@ internal class SessionServiceTest { .builder() .advancedStealth(true) .blockAds(true) + .captchaImageSelector("captchaImageSelector") + .captchaInputSelector("captchaInputSelector") .context( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings @@ -788,8 +790,15 @@ internal class SessionServiceTest { .build() ) .logSession(true) + .os( + SessionStartParams.BrowserbaseSessionCreateParams + .BrowserSettings + .Os + .WINDOWS + ) .recordSession(true) .solveCaptchas(true) + .verified(true) .viewport( SessionStartParams.BrowserbaseSessionCreateParams .BrowserSettings From c337e61dd9b2cc366bceec0e7119874acdc3b069 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2026 20:32:12 +0000 Subject: [PATCH 4/5] feat: Revert "[STG-1573] Add providerOptions for extensible model auth (#1822)" --- .stats.yml | 4 +- .../api/models/sessions/ModelConfig.kt | 1987 +------- .../models/sessions/SessionExecuteParams.kt | 97 +- .../api/models/sessions/SessionStartParams.kt | 4089 +---------------- .../api/models/sessions/StreamEvent.kt | 4 +- .../api/models/sessions/ModelConfigTest.kt | 33 +- .../models/sessions/SessionActParamsTest.kt | 54 +- .../sessions/SessionExecuteParamsTest.kt | 116 +- .../sessions/SessionExtractParamsTest.kt | 54 +- .../sessions/SessionObserveParamsTest.kt | 54 +- .../models/sessions/SessionStartParamsTest.kt | 87 - .../api/services/ErrorHandlingTest.kt | 459 -- .../api/services/ServiceParamsTest.kt | 35 +- .../services/async/SessionServiceAsyncTest.kt | 171 +- .../services/blocking/SessionServiceTest.kt | 171 +- 15 files changed, 208 insertions(+), 7207 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6bde59e..d8428d4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-a8db51c6460b3daff67b35262517848a0d4e783c6805c2edd531b155a5db71dd.yml -openapi_spec_hash: c6e7127f211f946673d6389e1d8db1ba +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-1c6caa2891a7f3bdfc0caab143f285badc9145220c9b29cd5e4cf1a9b3ac11cf.yml +openapi_spec_hash: 28c4b734a5309067c39bb4c4b709b9ab config_hash: a962ae71493deb11a1c903256fb25386 diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt index c397bfa..4e46131 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/ModelConfig.kt @@ -2,29 +2,18 @@ package com.browserbase.api.models.sessions -import com.browserbase.api.core.BaseDeserializer -import com.browserbase.api.core.BaseSerializer import com.browserbase.api.core.Enum import com.browserbase.api.core.ExcludeMissing import com.browserbase.api.core.JsonField import com.browserbase.api.core.JsonMissing import com.browserbase.api.core.JsonValue -import com.browserbase.api.core.allMaxBy import com.browserbase.api.core.checkRequired -import com.browserbase.api.core.getOrThrow import com.browserbase.api.core.toImmutable import com.browserbase.api.errors.StagehandInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Collections import java.util.Objects import java.util.Optional @@ -38,8 +27,6 @@ private constructor( private val baseUrl: JsonField, private val headers: JsonField, private val provider: JsonField, - private val providerOptions: JsonField, - private val skipApiKeyFallback: JsonField, private val additionalProperties: MutableMap, ) { @@ -50,22 +37,7 @@ private constructor( @JsonProperty("baseURL") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(), @JsonProperty("provider") @ExcludeMissing provider: JsonField = JsonMissing.of(), - @JsonProperty("providerOptions") - @ExcludeMissing - providerOptions: JsonField = JsonMissing.of(), - @JsonProperty("skipApiKeyFallback") - @ExcludeMissing - skipApiKeyFallback: JsonField = JsonMissing.of(), - ) : this( - modelName, - apiKey, - baseUrl, - headers, - provider, - providerOptions, - skipApiKeyFallback, - mutableMapOf(), - ) + ) : this(modelName, apiKey, baseUrl, headers, provider, mutableMapOf()) /** * Model name string with provider prefix (e.g., 'openai/gpt-5-nano') @@ -92,7 +64,7 @@ private constructor( fun baseUrl(): Optional = baseUrl.getOptional("baseURL") /** - * Custom headers for the model provider + * Custom headers sent with every request to the model provider * * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -107,27 +79,6 @@ private constructor( */ fun provider(): Optional = provider.getOptional("provider") - /** - * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { - * region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, - * googleAuthOptions }. - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun providerOptions(): Optional = - providerOptions.getOptional("providerOptions") - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when - * auth is carried through providerOptions instead of an API key. - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun skipApiKeyFallback(): Optional = - skipApiKeyFallback.getOptional("skipApiKeyFallback") - /** * Returns the raw JSON value of [modelName]. * @@ -163,25 +114,6 @@ private constructor( */ @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider - /** - * Returns the raw JSON value of [providerOptions]. - * - * Unlike [providerOptions], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("providerOptions") - @ExcludeMissing - fun _providerOptions(): JsonField = providerOptions - - /** - * Returns the raw JSON value of [skipApiKeyFallback]. - * - * Unlike [skipApiKeyFallback], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("skipApiKeyFallback") - @ExcludeMissing - fun _skipApiKeyFallback(): JsonField = skipApiKeyFallback - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -215,8 +147,6 @@ private constructor( private var baseUrl: JsonField = JsonMissing.of() private var headers: JsonField = JsonMissing.of() private var provider: JsonField = JsonMissing.of() - private var providerOptions: JsonField = JsonMissing.of() - private var skipApiKeyFallback: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -226,8 +156,6 @@ private constructor( baseUrl = modelConfig.baseUrl headers = modelConfig.headers provider = modelConfig.provider - providerOptions = modelConfig.providerOptions - skipApiKeyFallback = modelConfig.skipApiKeyFallback additionalProperties = modelConfig.additionalProperties.toMutableMap() } @@ -265,7 +193,7 @@ private constructor( */ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Custom headers for the model provider */ + /** Custom headers sent with every request to the model provider */ fun headers(headers: Headers) = headers(JsonField.of(headers)) /** @@ -288,64 +216,6 @@ private constructor( */ fun provider(provider: JsonField) = apply { this.provider = provider } - /** - * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: - * { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, - * googleAuthOptions }. - */ - fun providerOptions(providerOptions: ProviderOptions) = - providerOptions(JsonField.of(providerOptions)) - - /** - * Sets [Builder.providerOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.providerOptions] with a well-typed [ProviderOptions] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun providerOptions(providerOptions: JsonField) = apply { - this.providerOptions = providerOptions - } - - /** - * Alias for calling [providerOptions] with - * `ProviderOptions.ofBedrockApiKey(bedrockApiKey)`. - */ - fun providerOptions(bedrockApiKey: ProviderOptions.BedrockApiKeyProviderOptions) = - providerOptions(ProviderOptions.ofBedrockApiKey(bedrockApiKey)) - - /** - * Alias for calling [providerOptions] with - * `ProviderOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)`. - */ - fun providerOptions( - bedrockAwsCredentials: ProviderOptions.BedrockAwsCredentialsProviderOptions - ) = providerOptions(ProviderOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)) - - /** - * Alias for calling [providerOptions] with `ProviderOptions.ofGoogleVertex(googleVertex)`. - */ - fun providerOptions(googleVertex: ProviderOptions.GoogleVertexProviderOptions) = - providerOptions(ProviderOptions.ofGoogleVertex(googleVertex)) - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when - * auth is carried through providerOptions instead of an API key. - */ - fun skipApiKeyFallback(skipApiKeyFallback: Boolean) = - skipApiKeyFallback(JsonField.of(skipApiKeyFallback)) - - /** - * Sets [Builder.skipApiKeyFallback] to an arbitrary JSON value. - * - * You should usually call [Builder.skipApiKeyFallback] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun skipApiKeyFallback(skipApiKeyFallback: JsonField) = apply { - this.skipApiKeyFallback = skipApiKeyFallback - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -384,8 +254,6 @@ private constructor( baseUrl, headers, provider, - providerOptions, - skipApiKeyFallback, additionalProperties.toMutableMap(), ) } @@ -402,8 +270,6 @@ private constructor( baseUrl() headers().ifPresent { it.validate() } provider().ifPresent { it.validate() } - providerOptions().ifPresent { it.validate() } - skipApiKeyFallback() validated = true } @@ -426,11 +292,9 @@ private constructor( (if (apiKey.asKnown().isPresent) 1 else 0) + (if (baseUrl.asKnown().isPresent) 1 else 0) + (headers.asKnown().getOrNull()?.validity() ?: 0) + - (provider.asKnown().getOrNull()?.validity() ?: 0) + - (providerOptions.asKnown().getOrNull()?.validity() ?: 0) + - (if (skipApiKeyFallback.asKnown().isPresent) 1 else 0) + (provider.asKnown().getOrNull()?.validity() ?: 0) - /** Custom headers for the model provider */ + /** Custom headers sent with every request to the model provider */ class Headers @JsonCreator private constructor( @@ -676,1832 +540,6 @@ private constructor( override fun toString() = value.toString() } - /** - * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { - * region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, - * googleAuthOptions }. - */ - @JsonDeserialize(using = ProviderOptions.Deserializer::class) - @JsonSerialize(using = ProviderOptions.Serializer::class) - class ProviderOptions - private constructor( - private val bedrockApiKey: BedrockApiKeyProviderOptions? = null, - private val bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions? = null, - private val googleVertex: GoogleVertexProviderOptions? = null, - private val _json: JsonValue? = null, - ) { - - fun bedrockApiKey(): Optional = - Optional.ofNullable(bedrockApiKey) - - fun bedrockAwsCredentials(): Optional = - Optional.ofNullable(bedrockAwsCredentials) - - fun googleVertex(): Optional = - Optional.ofNullable(googleVertex) - - fun isBedrockApiKey(): Boolean = bedrockApiKey != null - - fun isBedrockAwsCredentials(): Boolean = bedrockAwsCredentials != null - - fun isGoogleVertex(): Boolean = googleVertex != null - - fun asBedrockApiKey(): BedrockApiKeyProviderOptions = - bedrockApiKey.getOrThrow("bedrockApiKey") - - fun asBedrockAwsCredentials(): BedrockAwsCredentialsProviderOptions = - bedrockAwsCredentials.getOrThrow("bedrockAwsCredentials") - - fun asGoogleVertex(): GoogleVertexProviderOptions = googleVertex.getOrThrow("googleVertex") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - bedrockApiKey != null -> visitor.visitBedrockApiKey(bedrockApiKey) - bedrockAwsCredentials != null -> - visitor.visitBedrockAwsCredentials(bedrockAwsCredentials) - googleVertex != null -> visitor.visitGoogleVertex(googleVertex) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ProviderOptions = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions) { - bedrockApiKey.validate() - } - - override fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions - ) { - bedrockAwsCredentials.validate() - } - - override fun visitGoogleVertex(googleVertex: GoogleVertexProviderOptions) { - googleVertex.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions) = - bedrockApiKey.validity() - - override fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions - ) = bedrockAwsCredentials.validity() - - override fun visitGoogleVertex(googleVertex: GoogleVertexProviderOptions) = - googleVertex.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProviderOptions && - bedrockApiKey == other.bedrockApiKey && - bedrockAwsCredentials == other.bedrockAwsCredentials && - googleVertex == other.googleVertex - } - - override fun hashCode(): Int = - Objects.hash(bedrockApiKey, bedrockAwsCredentials, googleVertex) - - override fun toString(): String = - when { - bedrockApiKey != null -> "ProviderOptions{bedrockApiKey=$bedrockApiKey}" - bedrockAwsCredentials != null -> - "ProviderOptions{bedrockAwsCredentials=$bedrockAwsCredentials}" - googleVertex != null -> "ProviderOptions{googleVertex=$googleVertex}" - _json != null -> "ProviderOptions{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ProviderOptions") - } - - companion object { - - @JvmStatic - fun ofBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions) = - ProviderOptions(bedrockApiKey = bedrockApiKey) - - @JvmStatic - fun ofBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions - ) = ProviderOptions(bedrockAwsCredentials = bedrockAwsCredentials) - - @JvmStatic - fun ofGoogleVertex(googleVertex: GoogleVertexProviderOptions) = - ProviderOptions(googleVertex = googleVertex) - } - - /** - * An interface that defines how to map each variant of [ProviderOptions] to a value of type - * [T]. - */ - interface Visitor { - - fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions): T - - fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions - ): T - - fun visitGoogleVertex(googleVertex: GoogleVertexProviderOptions): T - - /** - * Maps an unknown variant of [ProviderOptions] to a value of type [T]. - * - * An instance of [ProviderOptions] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws StagehandInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw StagehandInvalidDataException("Unknown ProviderOptions: $json") - } - } - - internal class Deserializer : BaseDeserializer(ProviderOptions::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ProviderOptions { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { ProviderOptions(bedrockApiKey = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ProviderOptions(bedrockAwsCredentials = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { ProviderOptions(googleVertex = it, _json = json) }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> ProviderOptions(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(ProviderOptions::class) { - - override fun serialize( - value: ProviderOptions, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bedrockApiKey != null -> generator.writeObject(value.bedrockApiKey) - value.bedrockAwsCredentials != null -> - generator.writeObject(value.bedrockAwsCredentials) - value.googleVertex != null -> generator.writeObject(value.googleVertex) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ProviderOptions") - } - } - } - - class BedrockApiKeyProviderOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val region: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("region") @ExcludeMissing region: JsonField = JsonMissing.of() - ) : this(region, mutableMapOf()) - - /** - * AWS region for Amazon Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun region(): String = region.getRequired("region") - - /** - * Returns the raw JSON value of [region]. - * - * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BedrockApiKeyProviderOptions]. - * - * The following fields are required: - * ```java - * .region() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BedrockApiKeyProviderOptions]. */ - class Builder internal constructor() { - - private var region: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bedrockApiKeyProviderOptions: BedrockApiKeyProviderOptions) = - apply { - region = bedrockApiKeyProviderOptions.region - additionalProperties = - bedrockApiKeyProviderOptions.additionalProperties.toMutableMap() - } - - /** AWS region for Amazon Bedrock */ - fun region(region: String) = region(JsonField.of(region)) - - /** - * Sets [Builder.region] to an arbitrary JSON value. - * - * You should usually call [Builder.region] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun region(region: JsonField) = apply { this.region = region } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BedrockApiKeyProviderOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .region() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BedrockApiKeyProviderOptions = - BedrockApiKeyProviderOptions( - checkRequired("region", region), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BedrockApiKeyProviderOptions = apply { - if (validated) { - return@apply - } - - region() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (region.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BedrockApiKeyProviderOptions && - region == other.region && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(region, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BedrockApiKeyProviderOptions{region=$region, additionalProperties=$additionalProperties}" - } - - class BedrockAwsCredentialsProviderOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessKeyId: JsonField, - private val region: JsonField, - private val secretAccessKey: JsonField, - private val sessionToken: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("accessKeyId") - @ExcludeMissing - accessKeyId: JsonField = JsonMissing.of(), - @JsonProperty("region") - @ExcludeMissing - region: JsonField = JsonMissing.of(), - @JsonProperty("secretAccessKey") - @ExcludeMissing - secretAccessKey: JsonField = JsonMissing.of(), - @JsonProperty("sessionToken") - @ExcludeMissing - sessionToken: JsonField = JsonMissing.of(), - ) : this(accessKeyId, region, secretAccessKey, sessionToken, mutableMapOf()) - - /** - * AWS access key ID for Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun accessKeyId(): String = accessKeyId.getRequired("accessKeyId") - - /** - * AWS region for Amazon Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun region(): String = region.getRequired("region") - - /** - * AWS secret access key for Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun secretAccessKey(): String = secretAccessKey.getRequired("secretAccessKey") - - /** - * Optional AWS session token for temporary credentials - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun sessionToken(): Optional = sessionToken.getOptional("sessionToken") - - /** - * Returns the raw JSON value of [accessKeyId]. - * - * Unlike [accessKeyId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("accessKeyId") - @ExcludeMissing - fun _accessKeyId(): JsonField = accessKeyId - - /** - * Returns the raw JSON value of [region]. - * - * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region - - /** - * Returns the raw JSON value of [secretAccessKey]. - * - * Unlike [secretAccessKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("secretAccessKey") - @ExcludeMissing - fun _secretAccessKey(): JsonField = secretAccessKey - - /** - * Returns the raw JSON value of [sessionToken]. - * - * Unlike [sessionToken], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("sessionToken") - @ExcludeMissing - fun _sessionToken(): JsonField = sessionToken - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BedrockAwsCredentialsProviderOptions]. - * - * The following fields are required: - * ```java - * .accessKeyId() - * .region() - * .secretAccessKey() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BedrockAwsCredentialsProviderOptions]. */ - class Builder internal constructor() { - - private var accessKeyId: JsonField? = null - private var region: JsonField? = null - private var secretAccessKey: JsonField? = null - private var sessionToken: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - bedrockAwsCredentialsProviderOptions: BedrockAwsCredentialsProviderOptions - ) = apply { - accessKeyId = bedrockAwsCredentialsProviderOptions.accessKeyId - region = bedrockAwsCredentialsProviderOptions.region - secretAccessKey = bedrockAwsCredentialsProviderOptions.secretAccessKey - sessionToken = bedrockAwsCredentialsProviderOptions.sessionToken - additionalProperties = - bedrockAwsCredentialsProviderOptions.additionalProperties.toMutableMap() - } - - /** AWS access key ID for Bedrock */ - fun accessKeyId(accessKeyId: String) = accessKeyId(JsonField.of(accessKeyId)) - - /** - * Sets [Builder.accessKeyId] to an arbitrary JSON value. - * - * You should usually call [Builder.accessKeyId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun accessKeyId(accessKeyId: JsonField) = apply { - this.accessKeyId = accessKeyId - } - - /** AWS region for Amazon Bedrock */ - fun region(region: String) = region(JsonField.of(region)) - - /** - * Sets [Builder.region] to an arbitrary JSON value. - * - * You should usually call [Builder.region] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun region(region: JsonField) = apply { this.region = region } - - /** AWS secret access key for Bedrock */ - fun secretAccessKey(secretAccessKey: String) = - secretAccessKey(JsonField.of(secretAccessKey)) - - /** - * Sets [Builder.secretAccessKey] to an arbitrary JSON value. - * - * You should usually call [Builder.secretAccessKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun secretAccessKey(secretAccessKey: JsonField) = apply { - this.secretAccessKey = secretAccessKey - } - - /** Optional AWS session token for temporary credentials */ - fun sessionToken(sessionToken: String) = sessionToken(JsonField.of(sessionToken)) - - /** - * Sets [Builder.sessionToken] to an arbitrary JSON value. - * - * You should usually call [Builder.sessionToken] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun sessionToken(sessionToken: JsonField) = apply { - this.sessionToken = sessionToken - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BedrockAwsCredentialsProviderOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKeyId() - * .region() - * .secretAccessKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BedrockAwsCredentialsProviderOptions = - BedrockAwsCredentialsProviderOptions( - checkRequired("accessKeyId", accessKeyId), - checkRequired("region", region), - checkRequired("secretAccessKey", secretAccessKey), - sessionToken, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BedrockAwsCredentialsProviderOptions = apply { - if (validated) { - return@apply - } - - accessKeyId() - region() - secretAccessKey() - sessionToken() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessKeyId.asKnown().isPresent) 1 else 0) + - (if (region.asKnown().isPresent) 1 else 0) + - (if (secretAccessKey.asKnown().isPresent) 1 else 0) + - (if (sessionToken.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BedrockAwsCredentialsProviderOptions && - accessKeyId == other.accessKeyId && - region == other.region && - secretAccessKey == other.secretAccessKey && - sessionToken == other.sessionToken && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - accessKeyId, - region, - secretAccessKey, - sessionToken, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BedrockAwsCredentialsProviderOptions{accessKeyId=$accessKeyId, region=$region, secretAccessKey=$secretAccessKey, sessionToken=$sessionToken, additionalProperties=$additionalProperties}" - } - - class GoogleVertexProviderOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val googleAuthOptions: JsonField, - private val headers: JsonField, - private val location: JsonField, - private val project: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("googleAuthOptions") - @ExcludeMissing - googleAuthOptions: JsonField = JsonMissing.of(), - @JsonProperty("headers") - @ExcludeMissing - headers: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - location: JsonField = JsonMissing.of(), - @JsonProperty("project") - @ExcludeMissing - project: JsonField = JsonMissing.of(), - ) : this(googleAuthOptions, headers, location, project, mutableMapOf()) - - /** - * Optional Google auth options for Vertex AI - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun googleAuthOptions(): Optional = - googleAuthOptions.getOptional("googleAuthOptions") - - /** - * Custom headers for Vertex AI requests - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun headers(): Optional = headers.getOptional("headers") - - /** - * Google Cloud location for Vertex AI - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun location(): Optional = location.getOptional("location") - - /** - * Google Cloud project ID for Vertex AI - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun project(): Optional = project.getOptional("project") - - /** - * Returns the raw JSON value of [googleAuthOptions]. - * - * Unlike [googleAuthOptions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("googleAuthOptions") - @ExcludeMissing - fun _googleAuthOptions(): JsonField = googleAuthOptions - - /** - * Returns the raw JSON value of [headers]. - * - * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers - - /** - * Returns the raw JSON value of [location]. - * - * Unlike [location], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location - - /** - * Returns the raw JSON value of [project]. - * - * Unlike [project], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("project") @ExcludeMissing fun _project(): JsonField = project - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GoogleVertexProviderOptions]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GoogleVertexProviderOptions]. */ - class Builder internal constructor() { - - private var googleAuthOptions: JsonField = JsonMissing.of() - private var headers: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var project: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(googleVertexProviderOptions: GoogleVertexProviderOptions) = - apply { - googleAuthOptions = googleVertexProviderOptions.googleAuthOptions - headers = googleVertexProviderOptions.headers - location = googleVertexProviderOptions.location - project = googleVertexProviderOptions.project - additionalProperties = - googleVertexProviderOptions.additionalProperties.toMutableMap() - } - - /** Optional Google auth options for Vertex AI */ - fun googleAuthOptions(googleAuthOptions: GoogleAuthOptions) = - googleAuthOptions(JsonField.of(googleAuthOptions)) - - /** - * Sets [Builder.googleAuthOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.googleAuthOptions] with a well-typed - * [GoogleAuthOptions] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun googleAuthOptions(googleAuthOptions: JsonField) = apply { - this.googleAuthOptions = googleAuthOptions - } - - /** Custom headers for Vertex AI requests */ - fun headers(headers: Headers) = headers(JsonField.of(headers)) - - /** - * Sets [Builder.headers] to an arbitrary JSON value. - * - * You should usually call [Builder.headers] with a well-typed [Headers] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun headers(headers: JsonField) = apply { this.headers = headers } - - /** Google Cloud location for Vertex AI */ - fun location(location: String) = location(JsonField.of(location)) - - /** - * Sets [Builder.location] to an arbitrary JSON value. - * - * You should usually call [Builder.location] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun location(location: JsonField) = apply { this.location = location } - - /** Google Cloud project ID for Vertex AI */ - fun project(project: String) = project(JsonField.of(project)) - - /** - * Sets [Builder.project] to an arbitrary JSON value. - * - * You should usually call [Builder.project] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun project(project: JsonField) = apply { this.project = project } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GoogleVertexProviderOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GoogleVertexProviderOptions = - GoogleVertexProviderOptions( - googleAuthOptions, - headers, - location, - project, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GoogleVertexProviderOptions = apply { - if (validated) { - return@apply - } - - googleAuthOptions().ifPresent { it.validate() } - headers().ifPresent { it.validate() } - location() - project() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (googleAuthOptions.asKnown().getOrNull()?.validity() ?: 0) + - (headers.asKnown().getOrNull()?.validity() ?: 0) + - (if (location.asKnown().isPresent) 1 else 0) + - (if (project.asKnown().isPresent) 1 else 0) - - /** Optional Google auth options for Vertex AI */ - class GoogleAuthOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val credentials: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("credentials") - @ExcludeMissing - credentials: JsonField = JsonMissing.of() - ) : this(credentials, mutableMapOf()) - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun credentials(): Optional = credentials.getOptional("credentials") - - /** - * Returns the raw JSON value of [credentials]. - * - * Unlike [credentials], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credentials") - @ExcludeMissing - fun _credentials(): JsonField = credentials - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GoogleAuthOptions]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GoogleAuthOptions]. */ - class Builder internal constructor() { - - private var credentials: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(googleAuthOptions: GoogleAuthOptions) = apply { - credentials = googleAuthOptions.credentials - additionalProperties = googleAuthOptions.additionalProperties.toMutableMap() - } - - fun credentials(credentials: Credentials) = - credentials(JsonField.of(credentials)) - - /** - * Sets [Builder.credentials] to an arbitrary JSON value. - * - * You should usually call [Builder.credentials] with a well-typed [Credentials] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun credentials(credentials: JsonField) = apply { - this.credentials = credentials - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GoogleAuthOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GoogleAuthOptions = - GoogleAuthOptions(credentials, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): GoogleAuthOptions = apply { - if (validated) { - return@apply - } - - credentials().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (credentials.asKnown().getOrNull()?.validity() ?: 0) - - class Credentials - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val authProviderX509CertUrl: JsonField, - private val authUri: JsonField, - private val clientEmail: JsonField, - private val clientId: JsonField, - private val clientX509CertUrl: JsonField, - private val privateKey: JsonField, - private val privateKeyId: JsonField, - private val projectId: JsonField, - private val tokenUri: JsonField, - private val type: JsonField, - private val universeDomain: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("auth_provider_x509_cert_url") - @ExcludeMissing - authProviderX509CertUrl: JsonField = JsonMissing.of(), - @JsonProperty("auth_uri") - @ExcludeMissing - authUri: JsonField = JsonMissing.of(), - @JsonProperty("client_email") - @ExcludeMissing - clientEmail: JsonField = JsonMissing.of(), - @JsonProperty("client_id") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("client_x509_cert_url") - @ExcludeMissing - clientX509CertUrl: JsonField = JsonMissing.of(), - @JsonProperty("private_key") - @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), - @JsonProperty("private_key_id") - @ExcludeMissing - privateKeyId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - projectId: JsonField = JsonMissing.of(), - @JsonProperty("token_uri") - @ExcludeMissing - tokenUri: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("universe_domain") - @ExcludeMissing - universeDomain: JsonField = JsonMissing.of(), - ) : this( - authProviderX509CertUrl, - authUri, - clientEmail, - clientId, - clientX509CertUrl, - privateKey, - privateKeyId, - projectId, - tokenUri, - type, - universeDomain, - mutableMapOf(), - ) - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun authProviderX509CertUrl(): Optional = - authProviderX509CertUrl.getOptional("auth_provider_x509_cert_url") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun authUri(): Optional = authUri.getOptional("auth_uri") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun clientEmail(): Optional = clientEmail.getOptional("client_email") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun clientId(): Optional = clientId.getOptional("client_id") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun clientX509CertUrl(): Optional = - clientX509CertUrl.getOptional("client_x509_cert_url") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun privateKey(): Optional = privateKey.getOptional("private_key") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun privateKeyId(): Optional = - privateKeyId.getOptional("private_key_id") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun projectId(): Optional = projectId.getOptional("project_id") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun tokenUri(): Optional = tokenUri.getOptional("token_uri") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun universeDomain(): Optional = - universeDomain.getOptional("universe_domain") - - /** - * Returns the raw JSON value of [authProviderX509CertUrl]. - * - * Unlike [authProviderX509CertUrl], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("auth_provider_x509_cert_url") - @ExcludeMissing - fun _authProviderX509CertUrl(): JsonField = authProviderX509CertUrl - - /** - * Returns the raw JSON value of [authUri]. - * - * Unlike [authUri], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("auth_uri") - @ExcludeMissing - fun _authUri(): JsonField = authUri - - /** - * Returns the raw JSON value of [clientEmail]. - * - * Unlike [clientEmail], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("client_email") - @ExcludeMissing - fun _clientEmail(): JsonField = clientEmail - - /** - * Returns the raw JSON value of [clientId]. - * - * Unlike [clientId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("client_id") - @ExcludeMissing - fun _clientId(): JsonField = clientId - - /** - * Returns the raw JSON value of [clientX509CertUrl]. - * - * Unlike [clientX509CertUrl], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("client_x509_cert_url") - @ExcludeMissing - fun _clientX509CertUrl(): JsonField = clientX509CertUrl - - /** - * Returns the raw JSON value of [privateKey]. - * - * Unlike [privateKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("private_key") - @ExcludeMissing - fun _privateKey(): JsonField = privateKey - - /** - * Returns the raw JSON value of [privateKeyId]. - * - * Unlike [privateKeyId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("private_key_id") - @ExcludeMissing - fun _privateKeyId(): JsonField = privateKeyId - - /** - * Returns the raw JSON value of [projectId]. - * - * Unlike [projectId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId - - /** - * Returns the raw JSON value of [tokenUri]. - * - * Unlike [tokenUri], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("token_uri") - @ExcludeMissing - fun _tokenUri(): JsonField = tokenUri - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [universeDomain]. - * - * Unlike [universeDomain], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("universe_domain") - @ExcludeMissing - fun _universeDomain(): JsonField = universeDomain - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Credentials]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Credentials]. */ - class Builder internal constructor() { - - private var authProviderX509CertUrl: JsonField = JsonMissing.of() - private var authUri: JsonField = JsonMissing.of() - private var clientEmail: JsonField = JsonMissing.of() - private var clientId: JsonField = JsonMissing.of() - private var clientX509CertUrl: JsonField = JsonMissing.of() - private var privateKey: JsonField = JsonMissing.of() - private var privateKeyId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var tokenUri: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var universeDomain: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(credentials: Credentials) = apply { - authProviderX509CertUrl = credentials.authProviderX509CertUrl - authUri = credentials.authUri - clientEmail = credentials.clientEmail - clientId = credentials.clientId - clientX509CertUrl = credentials.clientX509CertUrl - privateKey = credentials.privateKey - privateKeyId = credentials.privateKeyId - projectId = credentials.projectId - tokenUri = credentials.tokenUri - type = credentials.type - universeDomain = credentials.universeDomain - additionalProperties = credentials.additionalProperties.toMutableMap() - } - - fun authProviderX509CertUrl(authProviderX509CertUrl: String) = - authProviderX509CertUrl(JsonField.of(authProviderX509CertUrl)) - - /** - * Sets [Builder.authProviderX509CertUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.authProviderX509CertUrl] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun authProviderX509CertUrl(authProviderX509CertUrl: JsonField) = - apply { - this.authProviderX509CertUrl = authProviderX509CertUrl - } - - fun authUri(authUri: String) = authUri(JsonField.of(authUri)) - - /** - * Sets [Builder.authUri] to an arbitrary JSON value. - * - * You should usually call [Builder.authUri] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun authUri(authUri: JsonField) = apply { this.authUri = authUri } - - fun clientEmail(clientEmail: String) = - clientEmail(JsonField.of(clientEmail)) - - /** - * Sets [Builder.clientEmail] to an arbitrary JSON value. - * - * You should usually call [Builder.clientEmail] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun clientEmail(clientEmail: JsonField) = apply { - this.clientEmail = clientEmail - } - - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) - - /** - * Sets [Builder.clientId] to an arbitrary JSON value. - * - * You should usually call [Builder.clientId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun clientId(clientId: JsonField) = apply { - this.clientId = clientId - } - - fun clientX509CertUrl(clientX509CertUrl: String) = - clientX509CertUrl(JsonField.of(clientX509CertUrl)) - - /** - * Sets [Builder.clientX509CertUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.clientX509CertUrl] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun clientX509CertUrl(clientX509CertUrl: JsonField) = apply { - this.clientX509CertUrl = clientX509CertUrl - } - - fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) - - /** - * Sets [Builder.privateKey] to an arbitrary JSON value. - * - * You should usually call [Builder.privateKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun privateKey(privateKey: JsonField) = apply { - this.privateKey = privateKey - } - - fun privateKeyId(privateKeyId: String) = - privateKeyId(JsonField.of(privateKeyId)) - - /** - * Sets [Builder.privateKeyId] to an arbitrary JSON value. - * - * You should usually call [Builder.privateKeyId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun privateKeyId(privateKeyId: JsonField) = apply { - this.privateKeyId = privateKeyId - } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** - * Sets [Builder.projectId] to an arbitrary JSON value. - * - * You should usually call [Builder.projectId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } - - fun tokenUri(tokenUri: String) = tokenUri(JsonField.of(tokenUri)) - - /** - * Sets [Builder.tokenUri] to an arbitrary JSON value. - * - * You should usually call [Builder.tokenUri] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tokenUri(tokenUri: JsonField) = apply { - this.tokenUri = tokenUri - } - - fun type(type: String) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun universeDomain(universeDomain: String) = - universeDomain(JsonField.of(universeDomain)) - - /** - * Sets [Builder.universeDomain] to an arbitrary JSON value. - * - * You should usually call [Builder.universeDomain] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun universeDomain(universeDomain: JsonField) = apply { - this.universeDomain = universeDomain - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Credentials]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Credentials = - Credentials( - authProviderX509CertUrl, - authUri, - clientEmail, - clientId, - clientX509CertUrl, - privateKey, - privateKeyId, - projectId, - tokenUri, - type, - universeDomain, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Credentials = apply { - if (validated) { - return@apply - } - - authProviderX509CertUrl() - authUri() - clientEmail() - clientId() - clientX509CertUrl() - privateKey() - privateKeyId() - projectId() - tokenUri() - type() - universeDomain() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (authProviderX509CertUrl.asKnown().isPresent) 1 else 0) + - (if (authUri.asKnown().isPresent) 1 else 0) + - (if (clientEmail.asKnown().isPresent) 1 else 0) + - (if (clientId.asKnown().isPresent) 1 else 0) + - (if (clientX509CertUrl.asKnown().isPresent) 1 else 0) + - (if (privateKey.asKnown().isPresent) 1 else 0) + - (if (privateKeyId.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (tokenUri.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) + - (if (universeDomain.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Credentials && - authProviderX509CertUrl == other.authProviderX509CertUrl && - authUri == other.authUri && - clientEmail == other.clientEmail && - clientId == other.clientId && - clientX509CertUrl == other.clientX509CertUrl && - privateKey == other.privateKey && - privateKeyId == other.privateKeyId && - projectId == other.projectId && - tokenUri == other.tokenUri && - type == other.type && - universeDomain == other.universeDomain && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - authProviderX509CertUrl, - authUri, - clientEmail, - clientId, - clientX509CertUrl, - privateKey, - privateKeyId, - projectId, - tokenUri, - type, - universeDomain, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Credentials{authProviderX509CertUrl=$authProviderX509CertUrl, authUri=$authUri, clientEmail=$clientEmail, clientId=$clientId, clientX509CertUrl=$clientX509CertUrl, privateKey=$privateKey, privateKeyId=$privateKeyId, projectId=$projectId, tokenUri=$tokenUri, type=$type, universeDomain=$universeDomain, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GoogleAuthOptions && - credentials == other.credentials && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(credentials, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GoogleAuthOptions{credentials=$credentials, additionalProperties=$additionalProperties}" - } - - /** Custom headers for Vertex AI requests */ - class Headers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Headers]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Headers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(headers: Headers) = apply { - additionalProperties = headers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Headers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Headers = Headers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Headers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Headers && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Headers{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GoogleVertexProviderOptions && - googleAuthOptions == other.googleAuthOptions && - headers == other.headers && - location == other.location && - project == other.project && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(googleAuthOptions, headers, location, project, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GoogleVertexProviderOptions{googleAuthOptions=$googleAuthOptions, headers=$headers, location=$location, project=$project, additionalProperties=$additionalProperties}" - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2513,26 +551,15 @@ private constructor( baseUrl == other.baseUrl && headers == other.headers && provider == other.provider && - providerOptions == other.providerOptions && - skipApiKeyFallback == other.skipApiKeyFallback && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - modelName, - apiKey, - baseUrl, - headers, - provider, - providerOptions, - skipApiKeyFallback, - additionalProperties, - ) + Objects.hash(modelName, apiKey, baseUrl, headers, provider, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ModelConfig{modelName=$modelName, apiKey=$apiKey, baseUrl=$baseUrl, headers=$headers, provider=$provider, providerOptions=$providerOptions, skipApiKeyFallback=$skipApiKeyFallback, additionalProperties=$additionalProperties}" + "ModelConfig{modelName=$modelName, apiKey=$apiKey, baseUrl=$baseUrl, headers=$headers, provider=$provider, additionalProperties=$additionalProperties}" } diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionExecuteParams.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionExecuteParams.kt index 65fd5a6..f68232a 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionExecuteParams.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionExecuteParams.kt @@ -1686,6 +1686,8 @@ private constructor( private val instruction: JsonField, private val highlightCursor: JsonField, private val maxSteps: JsonField, + private val toolTimeout: JsonField, + private val useSearch: JsonField, private val additionalProperties: MutableMap, ) { @@ -1697,8 +1699,16 @@ private constructor( @JsonProperty("highlightCursor") @ExcludeMissing highlightCursor: JsonField = JsonMissing.of(), - @JsonProperty("maxSteps") @ExcludeMissing maxSteps: JsonField = JsonMissing.of(), - ) : this(instruction, highlightCursor, maxSteps, mutableMapOf()) + @JsonProperty("maxSteps") + @ExcludeMissing + maxSteps: JsonField = JsonMissing.of(), + @JsonProperty("toolTimeout") + @ExcludeMissing + toolTimeout: JsonField = JsonMissing.of(), + @JsonProperty("useSearch") + @ExcludeMissing + useSearch: JsonField = JsonMissing.of(), + ) : this(instruction, highlightCursor, maxSteps, toolTimeout, useSearch, mutableMapOf()) /** * Natural language instruction for the agent @@ -1724,6 +1734,22 @@ private constructor( */ fun maxSteps(): Optional = maxSteps.getOptional("maxSteps") + /** + * Timeout in milliseconds for each agent tool call + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun toolTimeout(): Optional = toolTimeout.getOptional("toolTimeout") + + /** + * Whether to enable the web search tool powered by Browserbase Search API + * + * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useSearch(): Optional = useSearch.getOptional("useSearch") + /** * Returns the raw JSON value of [instruction]. * @@ -1750,6 +1776,22 @@ private constructor( */ @JsonProperty("maxSteps") @ExcludeMissing fun _maxSteps(): JsonField = maxSteps + /** + * Returns the raw JSON value of [toolTimeout]. + * + * Unlike [toolTimeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("toolTimeout") + @ExcludeMissing + fun _toolTimeout(): JsonField = toolTimeout + + /** + * Returns the raw JSON value of [useSearch]. + * + * Unlike [useSearch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("useSearch") @ExcludeMissing fun _useSearch(): JsonField = useSearch + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1781,6 +1823,8 @@ private constructor( private var instruction: JsonField? = null private var highlightCursor: JsonField = JsonMissing.of() private var maxSteps: JsonField = JsonMissing.of() + private var toolTimeout: JsonField = JsonMissing.of() + private var useSearch: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1788,6 +1832,8 @@ private constructor( instruction = executeOptions.instruction highlightCursor = executeOptions.highlightCursor maxSteps = executeOptions.maxSteps + toolTimeout = executeOptions.toolTimeout + useSearch = executeOptions.useSearch additionalProperties = executeOptions.additionalProperties.toMutableMap() } @@ -1832,6 +1878,32 @@ private constructor( */ fun maxSteps(maxSteps: JsonField) = apply { this.maxSteps = maxSteps } + /** Timeout in milliseconds for each agent tool call */ + fun toolTimeout(toolTimeout: Double) = toolTimeout(JsonField.of(toolTimeout)) + + /** + * Sets [Builder.toolTimeout] to an arbitrary JSON value. + * + * You should usually call [Builder.toolTimeout] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toolTimeout(toolTimeout: JsonField) = apply { + this.toolTimeout = toolTimeout + } + + /** Whether to enable the web search tool powered by Browserbase Search API */ + fun useSearch(useSearch: Boolean) = useSearch(JsonField.of(useSearch)) + + /** + * Sets [Builder.useSearch] to an arbitrary JSON value. + * + * You should usually call [Builder.useSearch] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useSearch(useSearch: JsonField) = apply { this.useSearch = useSearch } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1868,6 +1940,8 @@ private constructor( checkRequired("instruction", instruction), highlightCursor, maxSteps, + toolTimeout, + useSearch, additionalProperties.toMutableMap(), ) } @@ -1882,6 +1956,8 @@ private constructor( instruction() highlightCursor() maxSteps() + toolTimeout() + useSearch() validated = true } @@ -1903,7 +1979,9 @@ private constructor( internal fun validity(): Int = (if (instruction.asKnown().isPresent) 1 else 0) + (if (highlightCursor.asKnown().isPresent) 1 else 0) + - (if (maxSteps.asKnown().isPresent) 1 else 0) + (if (maxSteps.asKnown().isPresent) 1 else 0) + + (if (toolTimeout.asKnown().isPresent) 1 else 0) + + (if (useSearch.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1914,17 +1992,26 @@ private constructor( instruction == other.instruction && highlightCursor == other.highlightCursor && maxSteps == other.maxSteps && + toolTimeout == other.toolTimeout && + useSearch == other.useSearch && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(instruction, highlightCursor, maxSteps, additionalProperties) + Objects.hash( + instruction, + highlightCursor, + maxSteps, + toolTimeout, + useSearch, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ExecuteOptions{instruction=$instruction, highlightCursor=$highlightCursor, maxSteps=$maxSteps, additionalProperties=$additionalProperties}" + "ExecuteOptions{instruction=$instruction, highlightCursor=$highlightCursor, maxSteps=$maxSteps, toolTimeout=$toolTimeout, useSearch=$useSearch, additionalProperties=$additionalProperties}" } /** Whether to stream the response via SSE */ diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt index a2fba41..994401f 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/SessionStartParams.kt @@ -100,15 +100,6 @@ private constructor( */ fun experimental(): Optional = body.experimental() - /** - * Optional provider-specific configuration for the session model (for example Bedrock region - * and credentials) - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun modelClientOptions(): Optional = body.modelClientOptions() - /** * Enable self-healing for failed actions * @@ -194,14 +185,6 @@ private constructor( */ fun _experimental(): JsonField = body._experimental() - /** - * Returns the raw JSON value of [modelClientOptions]. - * - * Unlike [modelClientOptions], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _modelClientOptions(): JsonField = body._modelClientOptions() - /** * Returns the raw JSON value of [selfHeal]. * @@ -389,47 +372,6 @@ private constructor( body.experimental(experimental) } - /** - * Optional provider-specific configuration for the session model (for example Bedrock - * region and credentials) - */ - fun modelClientOptions(modelClientOptions: ModelClientOptions) = apply { - body.modelClientOptions(modelClientOptions) - } - - /** - * Sets [Builder.modelClientOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.modelClientOptions] with a well-typed - * [ModelClientOptions] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun modelClientOptions(modelClientOptions: JsonField) = apply { - body.modelClientOptions(modelClientOptions) - } - - /** - * Alias for calling [modelClientOptions] with - * `ModelClientOptions.ofBedrockApiKey(bedrockApiKey)`. - */ - fun modelClientOptions(bedrockApiKey: ModelClientOptions.BedrockApiKeyModelClientOptions) = - apply { - body.modelClientOptions(bedrockApiKey) - } - - /** - * Alias for calling [modelClientOptions] with - * `ModelClientOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)`. - */ - fun modelClientOptions( - bedrockAwsCredentials: ModelClientOptions.BedrockAwsCredentialsModelClientOptions - ) = apply { body.modelClientOptions(bedrockAwsCredentials) } - - /** Alias for calling [modelClientOptions] with `ModelClientOptions.ofGeneric(generic)`. */ - fun modelClientOptions(generic: ModelClientOptions.GenericModelClientOptions) = apply { - body.modelClientOptions(generic) - } - /** Enable self-healing for failed actions */ fun selfHeal(selfHeal: Boolean) = apply { body.selfHeal(selfHeal) } @@ -643,7 +585,6 @@ private constructor( private val browserbaseSessionId: JsonField, private val domSettleTimeoutMs: JsonField, private val experimental: JsonField, - private val modelClientOptions: JsonField, private val selfHeal: JsonField, private val systemPrompt: JsonField, private val verbose: JsonField, @@ -673,9 +614,6 @@ private constructor( @JsonProperty("experimental") @ExcludeMissing experimental: JsonField = JsonMissing.of(), - @JsonProperty("modelClientOptions") - @ExcludeMissing - modelClientOptions: JsonField = JsonMissing.of(), @JsonProperty("selfHeal") @ExcludeMissing selfHeal: JsonField = JsonMissing.of(), @@ -694,7 +632,6 @@ private constructor( browserbaseSessionId, domSettleTimeoutMs, experimental, - modelClientOptions, selfHeal, systemPrompt, verbose, @@ -755,16 +692,6 @@ private constructor( */ fun experimental(): Optional = experimental.getOptional("experimental") - /** - * Optional provider-specific configuration for the session model (for example Bedrock - * region and credentials) - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun modelClientOptions(): Optional = - modelClientOptions.getOptional("modelClientOptions") - /** * Enable self-healing for failed actions * @@ -863,16 +790,6 @@ private constructor( @ExcludeMissing fun _experimental(): JsonField = experimental - /** - * Returns the raw JSON value of [modelClientOptions]. - * - * Unlike [modelClientOptions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("modelClientOptions") - @ExcludeMissing - fun _modelClientOptions(): JsonField = modelClientOptions - /** * Returns the raw JSON value of [selfHeal]. * @@ -943,7 +860,6 @@ private constructor( private var browserbaseSessionId: JsonField = JsonMissing.of() private var domSettleTimeoutMs: JsonField = JsonMissing.of() private var experimental: JsonField = JsonMissing.of() - private var modelClientOptions: JsonField = JsonMissing.of() private var selfHeal: JsonField = JsonMissing.of() private var systemPrompt: JsonField = JsonMissing.of() private var verbose: JsonField = JsonMissing.of() @@ -959,7 +875,6 @@ private constructor( browserbaseSessionId = body.browserbaseSessionId domSettleTimeoutMs = body.domSettleTimeoutMs experimental = body.experimental - modelClientOptions = body.modelClientOptions selfHeal = body.selfHeal systemPrompt = body.systemPrompt verbose = body.verbose @@ -1062,49 +977,6 @@ private constructor( this.experimental = experimental } - /** - * Optional provider-specific configuration for the session model (for example Bedrock - * region and credentials) - */ - fun modelClientOptions(modelClientOptions: ModelClientOptions) = - modelClientOptions(JsonField.of(modelClientOptions)) - - /** - * Sets [Builder.modelClientOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.modelClientOptions] with a well-typed - * [ModelClientOptions] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun modelClientOptions(modelClientOptions: JsonField) = apply { - this.modelClientOptions = modelClientOptions - } - - /** - * Alias for calling [modelClientOptions] with - * `ModelClientOptions.ofBedrockApiKey(bedrockApiKey)`. - */ - fun modelClientOptions( - bedrockApiKey: ModelClientOptions.BedrockApiKeyModelClientOptions - ) = modelClientOptions(ModelClientOptions.ofBedrockApiKey(bedrockApiKey)) - - /** - * Alias for calling [modelClientOptions] with - * `ModelClientOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)`. - */ - fun modelClientOptions( - bedrockAwsCredentials: ModelClientOptions.BedrockAwsCredentialsModelClientOptions - ) = - modelClientOptions( - ModelClientOptions.ofBedrockAwsCredentials(bedrockAwsCredentials) - ) - - /** - * Alias for calling [modelClientOptions] with `ModelClientOptions.ofGeneric(generic)`. - */ - fun modelClientOptions(generic: ModelClientOptions.GenericModelClientOptions) = - modelClientOptions(ModelClientOptions.ofGeneric(generic)) - /** Enable self-healing for failed actions */ fun selfHeal(selfHeal: Boolean) = selfHeal(JsonField.of(selfHeal)) @@ -1198,7 +1070,6 @@ private constructor( browserbaseSessionId, domSettleTimeoutMs, experimental, - modelClientOptions, selfHeal, systemPrompt, verbose, @@ -1221,7 +1092,6 @@ private constructor( browserbaseSessionId() domSettleTimeoutMs() experimental() - modelClientOptions().ifPresent { it.validate() } selfHeal() systemPrompt() verbose().ifPresent { it.validate() } @@ -1252,7 +1122,6 @@ private constructor( (if (browserbaseSessionId.asKnown().isPresent) 1 else 0) + (if (domSettleTimeoutMs.asKnown().isPresent) 1 else 0) + (if (experimental.asKnown().isPresent) 1 else 0) + - (modelClientOptions.asKnown().getOrNull()?.validity() ?: 0) + (if (selfHeal.asKnown().isPresent) 1 else 0) + (if (systemPrompt.asKnown().isPresent) 1 else 0) + (verbose.asKnown().getOrNull()?.validity() ?: 0) + @@ -1271,7 +1140,6 @@ private constructor( browserbaseSessionId == other.browserbaseSessionId && domSettleTimeoutMs == other.domSettleTimeoutMs && experimental == other.experimental && - modelClientOptions == other.modelClientOptions && selfHeal == other.selfHeal && systemPrompt == other.systemPrompt && verbose == other.verbose && @@ -1288,7 +1156,6 @@ private constructor( browserbaseSessionId, domSettleTimeoutMs, experimental, - modelClientOptions, selfHeal, systemPrompt, verbose, @@ -1300,7 +1167,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{modelName=$modelName, actTimeoutMs=$actTimeoutMs, browser=$browser, browserbaseSessionCreateParams=$browserbaseSessionCreateParams, browserbaseSessionId=$browserbaseSessionId, domSettleTimeoutMs=$domSettleTimeoutMs, experimental=$experimental, modelClientOptions=$modelClientOptions, selfHeal=$selfHeal, systemPrompt=$systemPrompt, verbose=$verbose, waitForCaptchaSolves=$waitForCaptchaSolves, additionalProperties=$additionalProperties}" + "Body{modelName=$modelName, actTimeoutMs=$actTimeoutMs, browser=$browser, browserbaseSessionCreateParams=$browserbaseSessionCreateParams, browserbaseSessionId=$browserbaseSessionId, domSettleTimeoutMs=$domSettleTimeoutMs, experimental=$experimental, selfHeal=$selfHeal, systemPrompt=$systemPrompt, verbose=$verbose, waitForCaptchaSolves=$waitForCaptchaSolves, additionalProperties=$additionalProperties}" } class Browser @@ -7632,3960 +7499,6 @@ private constructor( "BrowserbaseSessionCreateParams{browserSettings=$browserSettings, extensionId=$extensionId, keepAlive=$keepAlive, projectId=$projectId, proxies=$proxies, region=$region, timeout=$timeout, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" } - /** - * Optional provider-specific configuration for the session model (for example Bedrock region - * and credentials) - */ - @JsonDeserialize(using = ModelClientOptions.Deserializer::class) - @JsonSerialize(using = ModelClientOptions.Serializer::class) - class ModelClientOptions - private constructor( - private val bedrockApiKey: BedrockApiKeyModelClientOptions? = null, - private val bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions? = null, - private val generic: GenericModelClientOptions? = null, - private val _json: JsonValue? = null, - ) { - - fun bedrockApiKey(): Optional = - Optional.ofNullable(bedrockApiKey) - - fun bedrockAwsCredentials(): Optional = - Optional.ofNullable(bedrockAwsCredentials) - - fun generic(): Optional = Optional.ofNullable(generic) - - fun isBedrockApiKey(): Boolean = bedrockApiKey != null - - fun isBedrockAwsCredentials(): Boolean = bedrockAwsCredentials != null - - fun isGeneric(): Boolean = generic != null - - fun asBedrockApiKey(): BedrockApiKeyModelClientOptions = - bedrockApiKey.getOrThrow("bedrockApiKey") - - fun asBedrockAwsCredentials(): BedrockAwsCredentialsModelClientOptions = - bedrockAwsCredentials.getOrThrow("bedrockAwsCredentials") - - fun asGeneric(): GenericModelClientOptions = generic.getOrThrow("generic") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - bedrockApiKey != null -> visitor.visitBedrockApiKey(bedrockApiKey) - bedrockAwsCredentials != null -> - visitor.visitBedrockAwsCredentials(bedrockAwsCredentials) - generic != null -> visitor.visitGeneric(generic) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ModelClientOptions = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitBedrockApiKey( - bedrockApiKey: BedrockApiKeyModelClientOptions - ) { - bedrockApiKey.validate() - } - - override fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions - ) { - bedrockAwsCredentials.validate() - } - - override fun visitGeneric(generic: GenericModelClientOptions) { - generic.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitBedrockApiKey( - bedrockApiKey: BedrockApiKeyModelClientOptions - ) = bedrockApiKey.validity() - - override fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions - ) = bedrockAwsCredentials.validity() - - override fun visitGeneric(generic: GenericModelClientOptions) = - generic.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ModelClientOptions && - bedrockApiKey == other.bedrockApiKey && - bedrockAwsCredentials == other.bedrockAwsCredentials && - generic == other.generic - } - - override fun hashCode(): Int = Objects.hash(bedrockApiKey, bedrockAwsCredentials, generic) - - override fun toString(): String = - when { - bedrockApiKey != null -> "ModelClientOptions{bedrockApiKey=$bedrockApiKey}" - bedrockAwsCredentials != null -> - "ModelClientOptions{bedrockAwsCredentials=$bedrockAwsCredentials}" - generic != null -> "ModelClientOptions{generic=$generic}" - _json != null -> "ModelClientOptions{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ModelClientOptions") - } - - companion object { - - @JvmStatic - fun ofBedrockApiKey(bedrockApiKey: BedrockApiKeyModelClientOptions) = - ModelClientOptions(bedrockApiKey = bedrockApiKey) - - @JvmStatic - fun ofBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions - ) = ModelClientOptions(bedrockAwsCredentials = bedrockAwsCredentials) - - @JvmStatic - fun ofGeneric(generic: GenericModelClientOptions) = - ModelClientOptions(generic = generic) - } - - /** - * An interface that defines how to map each variant of [ModelClientOptions] to a value of - * type [T]. - */ - interface Visitor { - - fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyModelClientOptions): T - - fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsModelClientOptions - ): T - - fun visitGeneric(generic: GenericModelClientOptions): T - - /** - * Maps an unknown variant of [ModelClientOptions] to a value of type [T]. - * - * An instance of [ModelClientOptions] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws StagehandInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw StagehandInvalidDataException("Unknown ModelClientOptions: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ModelClientOptions::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ModelClientOptions { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { ModelClientOptions(bedrockApiKey = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - ModelClientOptions(bedrockAwsCredentials = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ModelClientOptions(generic = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> ModelClientOptions(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(ModelClientOptions::class) { - - override fun serialize( - value: ModelClientOptions, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bedrockApiKey != null -> generator.writeObject(value.bedrockApiKey) - value.bedrockAwsCredentials != null -> - generator.writeObject(value.bedrockAwsCredentials) - value.generic != null -> generator.writeObject(value.generic) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ModelClientOptions") - } - } - } - - class BedrockApiKeyModelClientOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val apiKey: JsonField, - private val providerOptions: JsonField, - private val baseUrl: JsonField, - private val headers: JsonField, - private val skipApiKeyFallback: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("apiKey") - @ExcludeMissing - apiKey: JsonField = JsonMissing.of(), - @JsonProperty("providerOptions") - @ExcludeMissing - providerOptions: JsonField = JsonMissing.of(), - @JsonProperty("baseURL") - @ExcludeMissing - baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("headers") - @ExcludeMissing - headers: JsonField = JsonMissing.of(), - @JsonProperty("skipApiKeyFallback") - @ExcludeMissing - skipApiKeyFallback: JsonField = JsonMissing.of(), - ) : this(apiKey, providerOptions, baseUrl, headers, skipApiKeyFallback, mutableMapOf()) - - /** - * Short-term Bedrock API key for bearer-token auth - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun apiKey(): String = apiKey.getRequired("apiKey") - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun providerOptions(): ProviderOptions = providerOptions.getRequired("providerOptions") - - /** - * Base URL for the model provider - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun baseUrl(): Optional = baseUrl.getOptional("baseURL") - - /** - * Custom headers for the model provider - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun headers(): Optional = headers.getOptional("headers") - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this - * when auth is carried through providerOptions instead of an API key. - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun skipApiKeyFallback(): Optional = - skipApiKeyFallback.getOptional("skipApiKeyFallback") - - /** - * Returns the raw JSON value of [apiKey]. - * - * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("apiKey") @ExcludeMissing fun _apiKey(): JsonField = apiKey - - /** - * Returns the raw JSON value of [providerOptions]. - * - * Unlike [providerOptions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("providerOptions") - @ExcludeMissing - fun _providerOptions(): JsonField = providerOptions - - /** - * Returns the raw JSON value of [baseUrl]. - * - * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl - - /** - * Returns the raw JSON value of [headers]. - * - * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers - - /** - * Returns the raw JSON value of [skipApiKeyFallback]. - * - * Unlike [skipApiKeyFallback], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("skipApiKeyFallback") - @ExcludeMissing - fun _skipApiKeyFallback(): JsonField = skipApiKeyFallback - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BedrockApiKeyModelClientOptions]. - * - * The following fields are required: - * ```java - * .apiKey() - * .providerOptions() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BedrockApiKeyModelClientOptions]. */ - class Builder internal constructor() { - - private var apiKey: JsonField? = null - private var providerOptions: JsonField? = null - private var baseUrl: JsonField = JsonMissing.of() - private var headers: JsonField = JsonMissing.of() - private var skipApiKeyFallback: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - bedrockApiKeyModelClientOptions: BedrockApiKeyModelClientOptions - ) = apply { - apiKey = bedrockApiKeyModelClientOptions.apiKey - providerOptions = bedrockApiKeyModelClientOptions.providerOptions - baseUrl = bedrockApiKeyModelClientOptions.baseUrl - headers = bedrockApiKeyModelClientOptions.headers - skipApiKeyFallback = bedrockApiKeyModelClientOptions.skipApiKeyFallback - additionalProperties = - bedrockApiKeyModelClientOptions.additionalProperties.toMutableMap() - } - - /** Short-term Bedrock API key for bearer-token auth */ - fun apiKey(apiKey: String) = apiKey(JsonField.of(apiKey)) - - /** - * Sets [Builder.apiKey] to an arbitrary JSON value. - * - * You should usually call [Builder.apiKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } - - fun providerOptions(providerOptions: ProviderOptions) = - providerOptions(JsonField.of(providerOptions)) - - /** - * Sets [Builder.providerOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.providerOptions] with a well-typed - * [ProviderOptions] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun providerOptions(providerOptions: JsonField) = apply { - this.providerOptions = providerOptions - } - - /** Base URL for the model provider */ - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) - - /** - * Sets [Builder.baseUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.baseUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - - /** Custom headers for the model provider */ - fun headers(headers: Headers) = headers(JsonField.of(headers)) - - /** - * Sets [Builder.headers] to an arbitrary JSON value. - * - * You should usually call [Builder.headers] with a well-typed [Headers] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun headers(headers: JsonField) = apply { this.headers = headers } - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use - * this when auth is carried through providerOptions instead of an API key. - */ - fun skipApiKeyFallback(skipApiKeyFallback: Boolean) = - skipApiKeyFallback(JsonField.of(skipApiKeyFallback)) - - /** - * Sets [Builder.skipApiKeyFallback] to an arbitrary JSON value. - * - * You should usually call [Builder.skipApiKeyFallback] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun skipApiKeyFallback(skipApiKeyFallback: JsonField) = apply { - this.skipApiKeyFallback = skipApiKeyFallback - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BedrockApiKeyModelClientOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .apiKey() - * .providerOptions() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BedrockApiKeyModelClientOptions = - BedrockApiKeyModelClientOptions( - checkRequired("apiKey", apiKey), - checkRequired("providerOptions", providerOptions), - baseUrl, - headers, - skipApiKeyFallback, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BedrockApiKeyModelClientOptions = apply { - if (validated) { - return@apply - } - - apiKey() - providerOptions().validate() - baseUrl() - headers().ifPresent { it.validate() } - skipApiKeyFallback() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (apiKey.asKnown().isPresent) 1 else 0) + - (providerOptions.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrl.asKnown().isPresent) 1 else 0) + - (headers.asKnown().getOrNull()?.validity() ?: 0) + - (if (skipApiKeyFallback.asKnown().isPresent) 1 else 0) - - class ProviderOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val region: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("region") - @ExcludeMissing - region: JsonField = JsonMissing.of() - ) : this(region, mutableMapOf()) - - /** - * AWS region for Amazon Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun region(): String = region.getRequired("region") - - /** - * Returns the raw JSON value of [region]. - * - * Unlike [region], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ProviderOptions]. - * - * The following fields are required: - * ```java - * .region() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProviderOptions]. */ - class Builder internal constructor() { - - private var region: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(providerOptions: ProviderOptions) = apply { - region = providerOptions.region - additionalProperties = providerOptions.additionalProperties.toMutableMap() - } - - /** AWS region for Amazon Bedrock */ - fun region(region: String) = region(JsonField.of(region)) - - /** - * Sets [Builder.region] to an arbitrary JSON value. - * - * You should usually call [Builder.region] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun region(region: JsonField) = apply { this.region = region } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ProviderOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .region() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProviderOptions = - ProviderOptions( - checkRequired("region", region), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ProviderOptions = apply { - if (validated) { - return@apply - } - - region() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (region.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProviderOptions && - region == other.region && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(region, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProviderOptions{region=$region, additionalProperties=$additionalProperties}" - } - - /** Custom headers for the model provider */ - class Headers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Headers]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Headers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(headers: Headers) = apply { - additionalProperties = headers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Headers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Headers = Headers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Headers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Headers && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Headers{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BedrockApiKeyModelClientOptions && - apiKey == other.apiKey && - providerOptions == other.providerOptions && - baseUrl == other.baseUrl && - headers == other.headers && - skipApiKeyFallback == other.skipApiKeyFallback && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - apiKey, - providerOptions, - baseUrl, - headers, - skipApiKeyFallback, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BedrockApiKeyModelClientOptions{apiKey=$apiKey, providerOptions=$providerOptions, baseUrl=$baseUrl, headers=$headers, skipApiKeyFallback=$skipApiKeyFallback, additionalProperties=$additionalProperties}" - } - - class BedrockAwsCredentialsModelClientOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val providerOptions: JsonField, - private val baseUrl: JsonField, - private val headers: JsonField, - private val skipApiKeyFallback: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("providerOptions") - @ExcludeMissing - providerOptions: JsonField = JsonMissing.of(), - @JsonProperty("baseURL") - @ExcludeMissing - baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("headers") - @ExcludeMissing - headers: JsonField = JsonMissing.of(), - @JsonProperty("skipApiKeyFallback") - @ExcludeMissing - skipApiKeyFallback: JsonField = JsonMissing.of(), - ) : this(providerOptions, baseUrl, headers, skipApiKeyFallback, mutableMapOf()) - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun providerOptions(): ProviderOptions = providerOptions.getRequired("providerOptions") - - /** - * Base URL for the model provider - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun baseUrl(): Optional = baseUrl.getOptional("baseURL") - - /** - * Custom headers for the model provider - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun headers(): Optional = headers.getOptional("headers") - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this - * when auth is carried through providerOptions instead of an API key. - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun skipApiKeyFallback(): Optional = - skipApiKeyFallback.getOptional("skipApiKeyFallback") - - /** - * Returns the raw JSON value of [providerOptions]. - * - * Unlike [providerOptions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("providerOptions") - @ExcludeMissing - fun _providerOptions(): JsonField = providerOptions - - /** - * Returns the raw JSON value of [baseUrl]. - * - * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl - - /** - * Returns the raw JSON value of [headers]. - * - * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers - - /** - * Returns the raw JSON value of [skipApiKeyFallback]. - * - * Unlike [skipApiKeyFallback], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("skipApiKeyFallback") - @ExcludeMissing - fun _skipApiKeyFallback(): JsonField = skipApiKeyFallback - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BedrockAwsCredentialsModelClientOptions]. - * - * The following fields are required: - * ```java - * .providerOptions() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BedrockAwsCredentialsModelClientOptions]. */ - class Builder internal constructor() { - - private var providerOptions: JsonField? = null - private var baseUrl: JsonField = JsonMissing.of() - private var headers: JsonField = JsonMissing.of() - private var skipApiKeyFallback: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - bedrockAwsCredentialsModelClientOptions: BedrockAwsCredentialsModelClientOptions - ) = apply { - providerOptions = bedrockAwsCredentialsModelClientOptions.providerOptions - baseUrl = bedrockAwsCredentialsModelClientOptions.baseUrl - headers = bedrockAwsCredentialsModelClientOptions.headers - skipApiKeyFallback = bedrockAwsCredentialsModelClientOptions.skipApiKeyFallback - additionalProperties = - bedrockAwsCredentialsModelClientOptions.additionalProperties.toMutableMap() - } - - fun providerOptions(providerOptions: ProviderOptions) = - providerOptions(JsonField.of(providerOptions)) - - /** - * Sets [Builder.providerOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.providerOptions] with a well-typed - * [ProviderOptions] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun providerOptions(providerOptions: JsonField) = apply { - this.providerOptions = providerOptions - } - - /** Base URL for the model provider */ - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) - - /** - * Sets [Builder.baseUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.baseUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - - /** Custom headers for the model provider */ - fun headers(headers: Headers) = headers(JsonField.of(headers)) - - /** - * Sets [Builder.headers] to an arbitrary JSON value. - * - * You should usually call [Builder.headers] with a well-typed [Headers] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun headers(headers: JsonField) = apply { this.headers = headers } - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use - * this when auth is carried through providerOptions instead of an API key. - */ - fun skipApiKeyFallback(skipApiKeyFallback: Boolean) = - skipApiKeyFallback(JsonField.of(skipApiKeyFallback)) - - /** - * Sets [Builder.skipApiKeyFallback] to an arbitrary JSON value. - * - * You should usually call [Builder.skipApiKeyFallback] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun skipApiKeyFallback(skipApiKeyFallback: JsonField) = apply { - this.skipApiKeyFallback = skipApiKeyFallback - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BedrockAwsCredentialsModelClientOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .providerOptions() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BedrockAwsCredentialsModelClientOptions = - BedrockAwsCredentialsModelClientOptions( - checkRequired("providerOptions", providerOptions), - baseUrl, - headers, - skipApiKeyFallback, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BedrockAwsCredentialsModelClientOptions = apply { - if (validated) { - return@apply - } - - providerOptions().validate() - baseUrl() - headers().ifPresent { it.validate() } - skipApiKeyFallback() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (providerOptions.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrl.asKnown().isPresent) 1 else 0) + - (headers.asKnown().getOrNull()?.validity() ?: 0) + - (if (skipApiKeyFallback.asKnown().isPresent) 1 else 0) - - class ProviderOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessKeyId: JsonField, - private val region: JsonField, - private val secretAccessKey: JsonField, - private val sessionToken: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("accessKeyId") - @ExcludeMissing - accessKeyId: JsonField = JsonMissing.of(), - @JsonProperty("region") - @ExcludeMissing - region: JsonField = JsonMissing.of(), - @JsonProperty("secretAccessKey") - @ExcludeMissing - secretAccessKey: JsonField = JsonMissing.of(), - @JsonProperty("sessionToken") - @ExcludeMissing - sessionToken: JsonField = JsonMissing.of(), - ) : this(accessKeyId, region, secretAccessKey, sessionToken, mutableMapOf()) - - /** - * AWS access key ID for Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun accessKeyId(): String = accessKeyId.getRequired("accessKeyId") - - /** - * AWS region for Amazon Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun region(): String = region.getRequired("region") - - /** - * AWS secret access key for Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun secretAccessKey(): String = secretAccessKey.getRequired("secretAccessKey") - - /** - * Optional AWS session token for temporary credentials - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun sessionToken(): Optional = sessionToken.getOptional("sessionToken") - - /** - * Returns the raw JSON value of [accessKeyId]. - * - * Unlike [accessKeyId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("accessKeyId") - @ExcludeMissing - fun _accessKeyId(): JsonField = accessKeyId - - /** - * Returns the raw JSON value of [region]. - * - * Unlike [region], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region - - /** - * Returns the raw JSON value of [secretAccessKey]. - * - * Unlike [secretAccessKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("secretAccessKey") - @ExcludeMissing - fun _secretAccessKey(): JsonField = secretAccessKey - - /** - * Returns the raw JSON value of [sessionToken]. - * - * Unlike [sessionToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("sessionToken") - @ExcludeMissing - fun _sessionToken(): JsonField = sessionToken - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ProviderOptions]. - * - * The following fields are required: - * ```java - * .accessKeyId() - * .region() - * .secretAccessKey() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProviderOptions]. */ - class Builder internal constructor() { - - private var accessKeyId: JsonField? = null - private var region: JsonField? = null - private var secretAccessKey: JsonField? = null - private var sessionToken: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(providerOptions: ProviderOptions) = apply { - accessKeyId = providerOptions.accessKeyId - region = providerOptions.region - secretAccessKey = providerOptions.secretAccessKey - sessionToken = providerOptions.sessionToken - additionalProperties = providerOptions.additionalProperties.toMutableMap() - } - - /** AWS access key ID for Bedrock */ - fun accessKeyId(accessKeyId: String) = accessKeyId(JsonField.of(accessKeyId)) - - /** - * Sets [Builder.accessKeyId] to an arbitrary JSON value. - * - * You should usually call [Builder.accessKeyId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accessKeyId(accessKeyId: JsonField) = apply { - this.accessKeyId = accessKeyId - } - - /** AWS region for Amazon Bedrock */ - fun region(region: String) = region(JsonField.of(region)) - - /** - * Sets [Builder.region] to an arbitrary JSON value. - * - * You should usually call [Builder.region] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun region(region: JsonField) = apply { this.region = region } - - /** AWS secret access key for Bedrock */ - fun secretAccessKey(secretAccessKey: String) = - secretAccessKey(JsonField.of(secretAccessKey)) - - /** - * Sets [Builder.secretAccessKey] to an arbitrary JSON value. - * - * You should usually call [Builder.secretAccessKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun secretAccessKey(secretAccessKey: JsonField) = apply { - this.secretAccessKey = secretAccessKey - } - - /** Optional AWS session token for temporary credentials */ - fun sessionToken(sessionToken: String) = - sessionToken(JsonField.of(sessionToken)) - - /** - * Sets [Builder.sessionToken] to an arbitrary JSON value. - * - * You should usually call [Builder.sessionToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun sessionToken(sessionToken: JsonField) = apply { - this.sessionToken = sessionToken - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ProviderOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKeyId() - * .region() - * .secretAccessKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProviderOptions = - ProviderOptions( - checkRequired("accessKeyId", accessKeyId), - checkRequired("region", region), - checkRequired("secretAccessKey", secretAccessKey), - sessionToken, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ProviderOptions = apply { - if (validated) { - return@apply - } - - accessKeyId() - region() - secretAccessKey() - sessionToken() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessKeyId.asKnown().isPresent) 1 else 0) + - (if (region.asKnown().isPresent) 1 else 0) + - (if (secretAccessKey.asKnown().isPresent) 1 else 0) + - (if (sessionToken.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProviderOptions && - accessKeyId == other.accessKeyId && - region == other.region && - secretAccessKey == other.secretAccessKey && - sessionToken == other.sessionToken && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - accessKeyId, - region, - secretAccessKey, - sessionToken, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProviderOptions{accessKeyId=$accessKeyId, region=$region, secretAccessKey=$secretAccessKey, sessionToken=$sessionToken, additionalProperties=$additionalProperties}" - } - - /** Custom headers for the model provider */ - class Headers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Headers]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Headers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(headers: Headers) = apply { - additionalProperties = headers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Headers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Headers = Headers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Headers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Headers && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Headers{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BedrockAwsCredentialsModelClientOptions && - providerOptions == other.providerOptions && - baseUrl == other.baseUrl && - headers == other.headers && - skipApiKeyFallback == other.skipApiKeyFallback && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - providerOptions, - baseUrl, - headers, - skipApiKeyFallback, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BedrockAwsCredentialsModelClientOptions{providerOptions=$providerOptions, baseUrl=$baseUrl, headers=$headers, skipApiKeyFallback=$skipApiKeyFallback, additionalProperties=$additionalProperties}" - } - - class GenericModelClientOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val apiKey: JsonField, - private val baseUrl: JsonField, - private val headers: JsonField, - private val providerOptions: JsonField, - private val skipApiKeyFallback: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("apiKey") - @ExcludeMissing - apiKey: JsonField = JsonMissing.of(), - @JsonProperty("baseURL") - @ExcludeMissing - baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("headers") - @ExcludeMissing - headers: JsonField = JsonMissing.of(), - @JsonProperty("providerOptions") - @ExcludeMissing - providerOptions: JsonField = JsonMissing.of(), - @JsonProperty("skipApiKeyFallback") - @ExcludeMissing - skipApiKeyFallback: JsonField = JsonMissing.of(), - ) : this(apiKey, baseUrl, headers, providerOptions, skipApiKeyFallback, mutableMapOf()) - - /** - * API key for the model provider - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun apiKey(): Optional = apiKey.getOptional("apiKey") - - /** - * Base URL for the model provider - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun baseUrl(): Optional = baseUrl.getOptional("baseURL") - - /** - * Custom headers for the model provider - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun headers(): Optional = headers.getOptional("headers") - - /** - * Provider-specific options passed through to the AI SDK provider constructor. For - * Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { - * project, location, googleAuthOptions }. - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun providerOptions(): Optional = - providerOptions.getOptional("providerOptions") - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this - * when auth is carried through providerOptions instead of an API key. - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun skipApiKeyFallback(): Optional = - skipApiKeyFallback.getOptional("skipApiKeyFallback") - - /** - * Returns the raw JSON value of [apiKey]. - * - * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("apiKey") @ExcludeMissing fun _apiKey(): JsonField = apiKey - - /** - * Returns the raw JSON value of [baseUrl]. - * - * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("baseURL") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl - - /** - * Returns the raw JSON value of [headers]. - * - * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers - - /** - * Returns the raw JSON value of [providerOptions]. - * - * Unlike [providerOptions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("providerOptions") - @ExcludeMissing - fun _providerOptions(): JsonField = providerOptions - - /** - * Returns the raw JSON value of [skipApiKeyFallback]. - * - * Unlike [skipApiKeyFallback], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("skipApiKeyFallback") - @ExcludeMissing - fun _skipApiKeyFallback(): JsonField = skipApiKeyFallback - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GenericModelClientOptions]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GenericModelClientOptions]. */ - class Builder internal constructor() { - - private var apiKey: JsonField = JsonMissing.of() - private var baseUrl: JsonField = JsonMissing.of() - private var headers: JsonField = JsonMissing.of() - private var providerOptions: JsonField = JsonMissing.of() - private var skipApiKeyFallback: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(genericModelClientOptions: GenericModelClientOptions) = apply { - apiKey = genericModelClientOptions.apiKey - baseUrl = genericModelClientOptions.baseUrl - headers = genericModelClientOptions.headers - providerOptions = genericModelClientOptions.providerOptions - skipApiKeyFallback = genericModelClientOptions.skipApiKeyFallback - additionalProperties = - genericModelClientOptions.additionalProperties.toMutableMap() - } - - /** API key for the model provider */ - fun apiKey(apiKey: String) = apiKey(JsonField.of(apiKey)) - - /** - * Sets [Builder.apiKey] to an arbitrary JSON value. - * - * You should usually call [Builder.apiKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } - - /** Base URL for the model provider */ - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) - - /** - * Sets [Builder.baseUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.baseUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - - /** Custom headers for the model provider */ - fun headers(headers: Headers) = headers(JsonField.of(headers)) - - /** - * Sets [Builder.headers] to an arbitrary JSON value. - * - * You should usually call [Builder.headers] with a well-typed [Headers] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun headers(headers: JsonField) = apply { this.headers = headers } - - /** - * Provider-specific options passed through to the AI SDK provider constructor. For - * Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { - * project, location, googleAuthOptions }. - */ - fun providerOptions(providerOptions: ProviderOptions) = - providerOptions(JsonField.of(providerOptions)) - - /** - * Sets [Builder.providerOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.providerOptions] with a well-typed - * [ProviderOptions] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun providerOptions(providerOptions: JsonField) = apply { - this.providerOptions = providerOptions - } - - /** - * Alias for calling [providerOptions] with - * `ProviderOptions.ofBedrockApiKey(bedrockApiKey)`. - */ - fun providerOptions(bedrockApiKey: ProviderOptions.BedrockApiKeyProviderOptions) = - providerOptions(ProviderOptions.ofBedrockApiKey(bedrockApiKey)) - - /** - * Alias for calling [providerOptions] with - * `ProviderOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)`. - */ - fun providerOptions( - bedrockAwsCredentials: ProviderOptions.BedrockAwsCredentialsProviderOptions - ) = providerOptions(ProviderOptions.ofBedrockAwsCredentials(bedrockAwsCredentials)) - - /** - * Alias for calling [providerOptions] with - * `ProviderOptions.ofGoogleVertex(googleVertex)`. - */ - fun providerOptions(googleVertex: ProviderOptions.GoogleVertexProviderOptions) = - providerOptions(ProviderOptions.ofGoogleVertex(googleVertex)) - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use - * this when auth is carried through providerOptions instead of an API key. - */ - fun skipApiKeyFallback(skipApiKeyFallback: Boolean) = - skipApiKeyFallback(JsonField.of(skipApiKeyFallback)) - - /** - * Sets [Builder.skipApiKeyFallback] to an arbitrary JSON value. - * - * You should usually call [Builder.skipApiKeyFallback] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun skipApiKeyFallback(skipApiKeyFallback: JsonField) = apply { - this.skipApiKeyFallback = skipApiKeyFallback - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GenericModelClientOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GenericModelClientOptions = - GenericModelClientOptions( - apiKey, - baseUrl, - headers, - providerOptions, - skipApiKeyFallback, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GenericModelClientOptions = apply { - if (validated) { - return@apply - } - - apiKey() - baseUrl() - headers().ifPresent { it.validate() } - providerOptions().ifPresent { it.validate() } - skipApiKeyFallback() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (apiKey.asKnown().isPresent) 1 else 0) + - (if (baseUrl.asKnown().isPresent) 1 else 0) + - (headers.asKnown().getOrNull()?.validity() ?: 0) + - (providerOptions.asKnown().getOrNull()?.validity() ?: 0) + - (if (skipApiKeyFallback.asKnown().isPresent) 1 else 0) - - /** Custom headers for the model provider */ - class Headers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Headers]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Headers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(headers: Headers) = apply { - additionalProperties = headers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Headers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Headers = Headers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Headers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Headers && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Headers{additionalProperties=$additionalProperties}" - } - - /** - * Provider-specific options passed through to the AI SDK provider constructor. For - * Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { - * project, location, googleAuthOptions }. - */ - @JsonDeserialize(using = ProviderOptions.Deserializer::class) - @JsonSerialize(using = ProviderOptions.Serializer::class) - class ProviderOptions - private constructor( - private val bedrockApiKey: BedrockApiKeyProviderOptions? = null, - private val bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions? = null, - private val googleVertex: GoogleVertexProviderOptions? = null, - private val _json: JsonValue? = null, - ) { - - fun bedrockApiKey(): Optional = - Optional.ofNullable(bedrockApiKey) - - fun bedrockAwsCredentials(): Optional = - Optional.ofNullable(bedrockAwsCredentials) - - fun googleVertex(): Optional = - Optional.ofNullable(googleVertex) - - fun isBedrockApiKey(): Boolean = bedrockApiKey != null - - fun isBedrockAwsCredentials(): Boolean = bedrockAwsCredentials != null - - fun isGoogleVertex(): Boolean = googleVertex != null - - fun asBedrockApiKey(): BedrockApiKeyProviderOptions = - bedrockApiKey.getOrThrow("bedrockApiKey") - - fun asBedrockAwsCredentials(): BedrockAwsCredentialsProviderOptions = - bedrockAwsCredentials.getOrThrow("bedrockAwsCredentials") - - fun asGoogleVertex(): GoogleVertexProviderOptions = - googleVertex.getOrThrow("googleVertex") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - bedrockApiKey != null -> visitor.visitBedrockApiKey(bedrockApiKey) - bedrockAwsCredentials != null -> - visitor.visitBedrockAwsCredentials(bedrockAwsCredentials) - googleVertex != null -> visitor.visitGoogleVertex(googleVertex) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ProviderOptions = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitBedrockApiKey( - bedrockApiKey: BedrockApiKeyProviderOptions - ) { - bedrockApiKey.validate() - } - - override fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions - ) { - bedrockAwsCredentials.validate() - } - - override fun visitGoogleVertex( - googleVertex: GoogleVertexProviderOptions - ) { - googleVertex.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitBedrockApiKey( - bedrockApiKey: BedrockApiKeyProviderOptions - ) = bedrockApiKey.validity() - - override fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions - ) = bedrockAwsCredentials.validity() - - override fun visitGoogleVertex( - googleVertex: GoogleVertexProviderOptions - ) = googleVertex.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProviderOptions && - bedrockApiKey == other.bedrockApiKey && - bedrockAwsCredentials == other.bedrockAwsCredentials && - googleVertex == other.googleVertex - } - - override fun hashCode(): Int = - Objects.hash(bedrockApiKey, bedrockAwsCredentials, googleVertex) - - override fun toString(): String = - when { - bedrockApiKey != null -> "ProviderOptions{bedrockApiKey=$bedrockApiKey}" - bedrockAwsCredentials != null -> - "ProviderOptions{bedrockAwsCredentials=$bedrockAwsCredentials}" - googleVertex != null -> "ProviderOptions{googleVertex=$googleVertex}" - _json != null -> "ProviderOptions{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ProviderOptions") - } - - companion object { - - @JvmStatic - fun ofBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions) = - ProviderOptions(bedrockApiKey = bedrockApiKey) - - @JvmStatic - fun ofBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions - ) = ProviderOptions(bedrockAwsCredentials = bedrockAwsCredentials) - - @JvmStatic - fun ofGoogleVertex(googleVertex: GoogleVertexProviderOptions) = - ProviderOptions(googleVertex = googleVertex) - } - - /** - * An interface that defines how to map each variant of [ProviderOptions] to a value - * of type [T]. - */ - interface Visitor { - - fun visitBedrockApiKey(bedrockApiKey: BedrockApiKeyProviderOptions): T - - fun visitBedrockAwsCredentials( - bedrockAwsCredentials: BedrockAwsCredentialsProviderOptions - ): T - - fun visitGoogleVertex(googleVertex: GoogleVertexProviderOptions): T - - /** - * Maps an unknown variant of [ProviderOptions] to a value of type [T]. - * - * An instance of [ProviderOptions] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws StagehandInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw StagehandInvalidDataException("Unknown ProviderOptions: $json") - } - } - - internal class Deserializer : - BaseDeserializer(ProviderOptions::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ProviderOptions { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ProviderOptions(bedrockApiKey = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - ProviderOptions( - bedrockAwsCredentials = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { ProviderOptions(googleVertex = it, _json = json) }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // boolean). - 0 -> ProviderOptions(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(ProviderOptions::class) { - - override fun serialize( - value: ProviderOptions, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bedrockApiKey != null -> - generator.writeObject(value.bedrockApiKey) - value.bedrockAwsCredentials != null -> - generator.writeObject(value.bedrockAwsCredentials) - value.googleVertex != null -> generator.writeObject(value.googleVertex) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ProviderOptions") - } - } - } - - class BedrockApiKeyProviderOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val region: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("region") - @ExcludeMissing - region: JsonField = JsonMissing.of() - ) : this(region, mutableMapOf()) - - /** - * AWS region for Amazon Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun region(): String = region.getRequired("region") - - /** - * Returns the raw JSON value of [region]. - * - * Unlike [region], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("region") - @ExcludeMissing - fun _region(): JsonField = region - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BedrockApiKeyProviderOptions]. - * - * The following fields are required: - * ```java - * .region() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BedrockApiKeyProviderOptions]. */ - class Builder internal constructor() { - - private var region: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - bedrockApiKeyProviderOptions: BedrockApiKeyProviderOptions - ) = apply { - region = bedrockApiKeyProviderOptions.region - additionalProperties = - bedrockApiKeyProviderOptions.additionalProperties.toMutableMap() - } - - /** AWS region for Amazon Bedrock */ - fun region(region: String) = region(JsonField.of(region)) - - /** - * Sets [Builder.region] to an arbitrary JSON value. - * - * You should usually call [Builder.region] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun region(region: JsonField) = apply { this.region = region } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BedrockApiKeyProviderOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .region() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BedrockApiKeyProviderOptions = - BedrockApiKeyProviderOptions( - checkRequired("region", region), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BedrockApiKeyProviderOptions = apply { - if (validated) { - return@apply - } - - region() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (region.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BedrockApiKeyProviderOptions && - region == other.region && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(region, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BedrockApiKeyProviderOptions{region=$region, additionalProperties=$additionalProperties}" - } - - class BedrockAwsCredentialsProviderOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessKeyId: JsonField, - private val region: JsonField, - private val secretAccessKey: JsonField, - private val sessionToken: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("accessKeyId") - @ExcludeMissing - accessKeyId: JsonField = JsonMissing.of(), - @JsonProperty("region") - @ExcludeMissing - region: JsonField = JsonMissing.of(), - @JsonProperty("secretAccessKey") - @ExcludeMissing - secretAccessKey: JsonField = JsonMissing.of(), - @JsonProperty("sessionToken") - @ExcludeMissing - sessionToken: JsonField = JsonMissing.of(), - ) : this(accessKeyId, region, secretAccessKey, sessionToken, mutableMapOf()) - - /** - * AWS access key ID for Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun accessKeyId(): String = accessKeyId.getRequired("accessKeyId") - - /** - * AWS region for Amazon Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun region(): String = region.getRequired("region") - - /** - * AWS secret access key for Bedrock - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun secretAccessKey(): String = secretAccessKey.getRequired("secretAccessKey") - - /** - * Optional AWS session token for temporary credentials - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun sessionToken(): Optional = sessionToken.getOptional("sessionToken") - - /** - * Returns the raw JSON value of [accessKeyId]. - * - * Unlike [accessKeyId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("accessKeyId") - @ExcludeMissing - fun _accessKeyId(): JsonField = accessKeyId - - /** - * Returns the raw JSON value of [region]. - * - * Unlike [region], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("region") - @ExcludeMissing - fun _region(): JsonField = region - - /** - * Returns the raw JSON value of [secretAccessKey]. - * - * Unlike [secretAccessKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("secretAccessKey") - @ExcludeMissing - fun _secretAccessKey(): JsonField = secretAccessKey - - /** - * Returns the raw JSON value of [sessionToken]. - * - * Unlike [sessionToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("sessionToken") - @ExcludeMissing - fun _sessionToken(): JsonField = sessionToken - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BedrockAwsCredentialsProviderOptions]. - * - * The following fields are required: - * ```java - * .accessKeyId() - * .region() - * .secretAccessKey() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BedrockAwsCredentialsProviderOptions]. */ - class Builder internal constructor() { - - private var accessKeyId: JsonField? = null - private var region: JsonField? = null - private var secretAccessKey: JsonField? = null - private var sessionToken: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - bedrockAwsCredentialsProviderOptions: - BedrockAwsCredentialsProviderOptions - ) = apply { - accessKeyId = bedrockAwsCredentialsProviderOptions.accessKeyId - region = bedrockAwsCredentialsProviderOptions.region - secretAccessKey = bedrockAwsCredentialsProviderOptions.secretAccessKey - sessionToken = bedrockAwsCredentialsProviderOptions.sessionToken - additionalProperties = - bedrockAwsCredentialsProviderOptions.additionalProperties - .toMutableMap() - } - - /** AWS access key ID for Bedrock */ - fun accessKeyId(accessKeyId: String) = - accessKeyId(JsonField.of(accessKeyId)) - - /** - * Sets [Builder.accessKeyId] to an arbitrary JSON value. - * - * You should usually call [Builder.accessKeyId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accessKeyId(accessKeyId: JsonField) = apply { - this.accessKeyId = accessKeyId - } - - /** AWS region for Amazon Bedrock */ - fun region(region: String) = region(JsonField.of(region)) - - /** - * Sets [Builder.region] to an arbitrary JSON value. - * - * You should usually call [Builder.region] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun region(region: JsonField) = apply { this.region = region } - - /** AWS secret access key for Bedrock */ - fun secretAccessKey(secretAccessKey: String) = - secretAccessKey(JsonField.of(secretAccessKey)) - - /** - * Sets [Builder.secretAccessKey] to an arbitrary JSON value. - * - * You should usually call [Builder.secretAccessKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun secretAccessKey(secretAccessKey: JsonField) = apply { - this.secretAccessKey = secretAccessKey - } - - /** Optional AWS session token for temporary credentials */ - fun sessionToken(sessionToken: String) = - sessionToken(JsonField.of(sessionToken)) - - /** - * Sets [Builder.sessionToken] to an arbitrary JSON value. - * - * You should usually call [Builder.sessionToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun sessionToken(sessionToken: JsonField) = apply { - this.sessionToken = sessionToken - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BedrockAwsCredentialsProviderOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKeyId() - * .region() - * .secretAccessKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BedrockAwsCredentialsProviderOptions = - BedrockAwsCredentialsProviderOptions( - checkRequired("accessKeyId", accessKeyId), - checkRequired("region", region), - checkRequired("secretAccessKey", secretAccessKey), - sessionToken, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BedrockAwsCredentialsProviderOptions = apply { - if (validated) { - return@apply - } - - accessKeyId() - region() - secretAccessKey() - sessionToken() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessKeyId.asKnown().isPresent) 1 else 0) + - (if (region.asKnown().isPresent) 1 else 0) + - (if (secretAccessKey.asKnown().isPresent) 1 else 0) + - (if (sessionToken.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BedrockAwsCredentialsProviderOptions && - accessKeyId == other.accessKeyId && - region == other.region && - secretAccessKey == other.secretAccessKey && - sessionToken == other.sessionToken && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - accessKeyId, - region, - secretAccessKey, - sessionToken, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BedrockAwsCredentialsProviderOptions{accessKeyId=$accessKeyId, region=$region, secretAccessKey=$secretAccessKey, sessionToken=$sessionToken, additionalProperties=$additionalProperties}" - } - - class GoogleVertexProviderOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val googleAuthOptions: JsonField, - private val headers: JsonField, - private val location: JsonField, - private val project: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("googleAuthOptions") - @ExcludeMissing - googleAuthOptions: JsonField = JsonMissing.of(), - @JsonProperty("headers") - @ExcludeMissing - headers: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - location: JsonField = JsonMissing.of(), - @JsonProperty("project") - @ExcludeMissing - project: JsonField = JsonMissing.of(), - ) : this(googleAuthOptions, headers, location, project, mutableMapOf()) - - /** - * Optional Google auth options for Vertex AI - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun googleAuthOptions(): Optional = - googleAuthOptions.getOptional("googleAuthOptions") - - /** - * Custom headers for Vertex AI requests - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun headers(): Optional = headers.getOptional("headers") - - /** - * Google Cloud location for Vertex AI - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun location(): Optional = location.getOptional("location") - - /** - * Google Cloud project ID for Vertex AI - * - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun project(): Optional = project.getOptional("project") - - /** - * Returns the raw JSON value of [googleAuthOptions]. - * - * Unlike [googleAuthOptions], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("googleAuthOptions") - @ExcludeMissing - fun _googleAuthOptions(): JsonField = googleAuthOptions - - /** - * Returns the raw JSON value of [headers]. - * - * Unlike [headers], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("headers") - @ExcludeMissing - fun _headers(): JsonField = headers - - /** - * Returns the raw JSON value of [location]. - * - * Unlike [location], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("location") - @ExcludeMissing - fun _location(): JsonField = location - - /** - * Returns the raw JSON value of [project]. - * - * Unlike [project], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("project") - @ExcludeMissing - fun _project(): JsonField = project - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GoogleVertexProviderOptions]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GoogleVertexProviderOptions]. */ - class Builder internal constructor() { - - private var googleAuthOptions: JsonField = - JsonMissing.of() - private var headers: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var project: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - googleVertexProviderOptions: GoogleVertexProviderOptions - ) = apply { - googleAuthOptions = googleVertexProviderOptions.googleAuthOptions - headers = googleVertexProviderOptions.headers - location = googleVertexProviderOptions.location - project = googleVertexProviderOptions.project - additionalProperties = - googleVertexProviderOptions.additionalProperties.toMutableMap() - } - - /** Optional Google auth options for Vertex AI */ - fun googleAuthOptions(googleAuthOptions: GoogleAuthOptions) = - googleAuthOptions(JsonField.of(googleAuthOptions)) - - /** - * Sets [Builder.googleAuthOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.googleAuthOptions] with a well-typed - * [GoogleAuthOptions] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun googleAuthOptions(googleAuthOptions: JsonField) = - apply { - this.googleAuthOptions = googleAuthOptions - } - - /** Custom headers for Vertex AI requests */ - fun headers(headers: Headers) = headers(JsonField.of(headers)) - - /** - * Sets [Builder.headers] to an arbitrary JSON value. - * - * You should usually call [Builder.headers] with a well-typed [Headers] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun headers(headers: JsonField) = apply { this.headers = headers } - - /** Google Cloud location for Vertex AI */ - fun location(location: String) = location(JsonField.of(location)) - - /** - * Sets [Builder.location] to an arbitrary JSON value. - * - * You should usually call [Builder.location] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun location(location: JsonField) = apply { - this.location = location - } - - /** Google Cloud project ID for Vertex AI */ - fun project(project: String) = project(JsonField.of(project)) - - /** - * Sets [Builder.project] to an arbitrary JSON value. - * - * You should usually call [Builder.project] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun project(project: JsonField) = apply { this.project = project } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GoogleVertexProviderOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GoogleVertexProviderOptions = - GoogleVertexProviderOptions( - googleAuthOptions, - headers, - location, - project, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GoogleVertexProviderOptions = apply { - if (validated) { - return@apply - } - - googleAuthOptions().ifPresent { it.validate() } - headers().ifPresent { it.validate() } - location() - project() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (googleAuthOptions.asKnown().getOrNull()?.validity() ?: 0) + - (headers.asKnown().getOrNull()?.validity() ?: 0) + - (if (location.asKnown().isPresent) 1 else 0) + - (if (project.asKnown().isPresent) 1 else 0) - - /** Optional Google auth options for Vertex AI */ - class GoogleAuthOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val credentials: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("credentials") - @ExcludeMissing - credentials: JsonField = JsonMissing.of() - ) : this(credentials, mutableMapOf()) - - /** - * @throws StagehandInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun credentials(): Optional = - credentials.getOptional("credentials") - - /** - * Returns the raw JSON value of [credentials]. - * - * Unlike [credentials], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credentials") - @ExcludeMissing - fun _credentials(): JsonField = credentials - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GoogleAuthOptions]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GoogleAuthOptions]. */ - class Builder internal constructor() { - - private var credentials: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(googleAuthOptions: GoogleAuthOptions) = apply { - credentials = googleAuthOptions.credentials - additionalProperties = - googleAuthOptions.additionalProperties.toMutableMap() - } - - fun credentials(credentials: Credentials) = - credentials(JsonField.of(credentials)) - - /** - * Sets [Builder.credentials] to an arbitrary JSON value. - * - * You should usually call [Builder.credentials] with a well-typed - * [Credentials] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun credentials(credentials: JsonField) = apply { - this.credentials = credentials - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GoogleAuthOptions]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): GoogleAuthOptions = - GoogleAuthOptions(credentials, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): GoogleAuthOptions = apply { - if (validated) { - return@apply - } - - credentials().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (credentials.asKnown().getOrNull()?.validity() ?: 0) - - class Credentials - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val authProviderX509CertUrl: JsonField, - private val authUri: JsonField, - private val clientEmail: JsonField, - private val clientId: JsonField, - private val clientX509CertUrl: JsonField, - private val privateKey: JsonField, - private val privateKeyId: JsonField, - private val projectId: JsonField, - private val tokenUri: JsonField, - private val type: JsonField, - private val universeDomain: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("auth_provider_x509_cert_url") - @ExcludeMissing - authProviderX509CertUrl: JsonField = JsonMissing.of(), - @JsonProperty("auth_uri") - @ExcludeMissing - authUri: JsonField = JsonMissing.of(), - @JsonProperty("client_email") - @ExcludeMissing - clientEmail: JsonField = JsonMissing.of(), - @JsonProperty("client_id") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("client_x509_cert_url") - @ExcludeMissing - clientX509CertUrl: JsonField = JsonMissing.of(), - @JsonProperty("private_key") - @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), - @JsonProperty("private_key_id") - @ExcludeMissing - privateKeyId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - projectId: JsonField = JsonMissing.of(), - @JsonProperty("token_uri") - @ExcludeMissing - tokenUri: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("universe_domain") - @ExcludeMissing - universeDomain: JsonField = JsonMissing.of(), - ) : this( - authProviderX509CertUrl, - authUri, - clientEmail, - clientId, - clientX509CertUrl, - privateKey, - privateKeyId, - projectId, - tokenUri, - type, - universeDomain, - mutableMapOf(), - ) - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun authProviderX509CertUrl(): Optional = - authProviderX509CertUrl.getOptional("auth_provider_x509_cert_url") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun authUri(): Optional = authUri.getOptional("auth_uri") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun clientEmail(): Optional = - clientEmail.getOptional("client_email") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun clientId(): Optional = clientId.getOptional("client_id") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun clientX509CertUrl(): Optional = - clientX509CertUrl.getOptional("client_x509_cert_url") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun privateKey(): Optional = - privateKey.getOptional("private_key") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun privateKeyId(): Optional = - privateKeyId.getOptional("private_key_id") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun projectId(): Optional = projectId.getOptional("project_id") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun tokenUri(): Optional = tokenUri.getOptional("token_uri") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * @throws StagehandInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun universeDomain(): Optional = - universeDomain.getOptional("universe_domain") - - /** - * Returns the raw JSON value of [authProviderX509CertUrl]. - * - * Unlike [authProviderX509CertUrl], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("auth_provider_x509_cert_url") - @ExcludeMissing - fun _authProviderX509CertUrl(): JsonField = - authProviderX509CertUrl - - /** - * Returns the raw JSON value of [authUri]. - * - * Unlike [authUri], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("auth_uri") - @ExcludeMissing - fun _authUri(): JsonField = authUri - - /** - * Returns the raw JSON value of [clientEmail]. - * - * Unlike [clientEmail], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("client_email") - @ExcludeMissing - fun _clientEmail(): JsonField = clientEmail - - /** - * Returns the raw JSON value of [clientId]. - * - * Unlike [clientId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("client_id") - @ExcludeMissing - fun _clientId(): JsonField = clientId - - /** - * Returns the raw JSON value of [clientX509CertUrl]. - * - * Unlike [clientX509CertUrl], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("client_x509_cert_url") - @ExcludeMissing - fun _clientX509CertUrl(): JsonField = clientX509CertUrl - - /** - * Returns the raw JSON value of [privateKey]. - * - * Unlike [privateKey], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("private_key") - @ExcludeMissing - fun _privateKey(): JsonField = privateKey - - /** - * Returns the raw JSON value of [privateKeyId]. - * - * Unlike [privateKeyId], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("private_key_id") - @ExcludeMissing - fun _privateKeyId(): JsonField = privateKeyId - - /** - * Returns the raw JSON value of [projectId]. - * - * Unlike [projectId], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId - - /** - * Returns the raw JSON value of [tokenUri]. - * - * Unlike [tokenUri], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("token_uri") - @ExcludeMissing - fun _tokenUri(): JsonField = tokenUri - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [universeDomain]. - * - * Unlike [universeDomain], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("universe_domain") - @ExcludeMissing - fun _universeDomain(): JsonField = universeDomain - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [Credentials]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Credentials]. */ - class Builder internal constructor() { - - private var authProviderX509CertUrl: JsonField = - JsonMissing.of() - private var authUri: JsonField = JsonMissing.of() - private var clientEmail: JsonField = JsonMissing.of() - private var clientId: JsonField = JsonMissing.of() - private var clientX509CertUrl: JsonField = JsonMissing.of() - private var privateKey: JsonField = JsonMissing.of() - private var privateKeyId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var tokenUri: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var universeDomain: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(credentials: Credentials) = apply { - authProviderX509CertUrl = credentials.authProviderX509CertUrl - authUri = credentials.authUri - clientEmail = credentials.clientEmail - clientId = credentials.clientId - clientX509CertUrl = credentials.clientX509CertUrl - privateKey = credentials.privateKey - privateKeyId = credentials.privateKeyId - projectId = credentials.projectId - tokenUri = credentials.tokenUri - type = credentials.type - universeDomain = credentials.universeDomain - additionalProperties = - credentials.additionalProperties.toMutableMap() - } - - fun authProviderX509CertUrl(authProviderX509CertUrl: String) = - authProviderX509CertUrl(JsonField.of(authProviderX509CertUrl)) - - /** - * Sets [Builder.authProviderX509CertUrl] to an arbitrary JSON - * value. - * - * You should usually call [Builder.authProviderX509CertUrl] with a - * well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun authProviderX509CertUrl( - authProviderX509CertUrl: JsonField - ) = apply { this.authProviderX509CertUrl = authProviderX509CertUrl } - - fun authUri(authUri: String) = authUri(JsonField.of(authUri)) - - /** - * Sets [Builder.authUri] to an arbitrary JSON value. - * - * You should usually call [Builder.authUri] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun authUri(authUri: JsonField) = apply { - this.authUri = authUri - } - - fun clientEmail(clientEmail: String) = - clientEmail(JsonField.of(clientEmail)) - - /** - * Sets [Builder.clientEmail] to an arbitrary JSON value. - * - * You should usually call [Builder.clientEmail] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun clientEmail(clientEmail: JsonField) = apply { - this.clientEmail = clientEmail - } - - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) - - /** - * Sets [Builder.clientId] to an arbitrary JSON value. - * - * You should usually call [Builder.clientId] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun clientId(clientId: JsonField) = apply { - this.clientId = clientId - } - - fun clientX509CertUrl(clientX509CertUrl: String) = - clientX509CertUrl(JsonField.of(clientX509CertUrl)) - - /** - * Sets [Builder.clientX509CertUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.clientX509CertUrl] with a - * well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun clientX509CertUrl(clientX509CertUrl: JsonField) = - apply { - this.clientX509CertUrl = clientX509CertUrl - } - - fun privateKey(privateKey: String) = - privateKey(JsonField.of(privateKey)) - - /** - * Sets [Builder.privateKey] to an arbitrary JSON value. - * - * You should usually call [Builder.privateKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun privateKey(privateKey: JsonField) = apply { - this.privateKey = privateKey - } - - fun privateKeyId(privateKeyId: String) = - privateKeyId(JsonField.of(privateKeyId)) - - /** - * Sets [Builder.privateKeyId] to an arbitrary JSON value. - * - * You should usually call [Builder.privateKeyId] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun privateKeyId(privateKeyId: JsonField) = apply { - this.privateKeyId = privateKeyId - } - - fun projectId(projectId: String) = - projectId(JsonField.of(projectId)) - - /** - * Sets [Builder.projectId] to an arbitrary JSON value. - * - * You should usually call [Builder.projectId] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } - - fun tokenUri(tokenUri: String) = tokenUri(JsonField.of(tokenUri)) - - /** - * Sets [Builder.tokenUri] to an arbitrary JSON value. - * - * You should usually call [Builder.tokenUri] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tokenUri(tokenUri: JsonField) = apply { - this.tokenUri = tokenUri - } - - fun type(type: String) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [String] - * value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun universeDomain(universeDomain: String) = - universeDomain(JsonField.of(universeDomain)) - - /** - * Sets [Builder.universeDomain] to an arbitrary JSON value. - * - * You should usually call [Builder.universeDomain] with a - * well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun universeDomain(universeDomain: JsonField) = apply { - this.universeDomain = universeDomain - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Credentials]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Credentials = - Credentials( - authProviderX509CertUrl, - authUri, - clientEmail, - clientId, - clientX509CertUrl, - privateKey, - privateKeyId, - projectId, - tokenUri, - type, - universeDomain, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Credentials = apply { - if (validated) { - return@apply - } - - authProviderX509CertUrl() - authUri() - clientEmail() - clientId() - clientX509CertUrl() - privateKey() - privateKeyId() - projectId() - tokenUri() - type() - universeDomain() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (authProviderX509CertUrl.asKnown().isPresent) 1 else 0) + - (if (authUri.asKnown().isPresent) 1 else 0) + - (if (clientEmail.asKnown().isPresent) 1 else 0) + - (if (clientId.asKnown().isPresent) 1 else 0) + - (if (clientX509CertUrl.asKnown().isPresent) 1 else 0) + - (if (privateKey.asKnown().isPresent) 1 else 0) + - (if (privateKeyId.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (tokenUri.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) + - (if (universeDomain.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Credentials && - authProviderX509CertUrl == other.authProviderX509CertUrl && - authUri == other.authUri && - clientEmail == other.clientEmail && - clientId == other.clientId && - clientX509CertUrl == other.clientX509CertUrl && - privateKey == other.privateKey && - privateKeyId == other.privateKeyId && - projectId == other.projectId && - tokenUri == other.tokenUri && - type == other.type && - universeDomain == other.universeDomain && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - authProviderX509CertUrl, - authUri, - clientEmail, - clientId, - clientX509CertUrl, - privateKey, - privateKeyId, - projectId, - tokenUri, - type, - universeDomain, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Credentials{authProviderX509CertUrl=$authProviderX509CertUrl, authUri=$authUri, clientEmail=$clientEmail, clientId=$clientId, clientX509CertUrl=$clientX509CertUrl, privateKey=$privateKey, privateKeyId=$privateKeyId, projectId=$projectId, tokenUri=$tokenUri, type=$type, universeDomain=$universeDomain, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GoogleAuthOptions && - credentials == other.credentials && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(credentials, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GoogleAuthOptions{credentials=$credentials, additionalProperties=$additionalProperties}" - } - - /** Custom headers for Vertex AI requests */ - class Headers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Headers]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Headers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(headers: Headers) = apply { - additionalProperties = headers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Headers]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Headers = Headers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Headers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: StagehandInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Headers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Headers{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GoogleVertexProviderOptions && - googleAuthOptions == other.googleAuthOptions && - headers == other.headers && - location == other.location && - project == other.project && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - googleAuthOptions, - headers, - location, - project, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GoogleVertexProviderOptions{googleAuthOptions=$googleAuthOptions, headers=$headers, location=$location, project=$project, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GenericModelClientOptions && - apiKey == other.apiKey && - baseUrl == other.baseUrl && - headers == other.headers && - providerOptions == other.providerOptions && - skipApiKeyFallback == other.skipApiKeyFallback && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - apiKey, - baseUrl, - headers, - providerOptions, - skipApiKeyFallback, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GenericModelClientOptions{apiKey=$apiKey, baseUrl=$baseUrl, headers=$headers, providerOptions=$providerOptions, skipApiKeyFallback=$skipApiKeyFallback, additionalProperties=$additionalProperties}" - } - } - /** Logging verbosity level (0=quiet, 1=normal, 2=debug) */ class Verbose @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/StreamEvent.kt b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/StreamEvent.kt index 443104b..4584374 100644 --- a/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/StreamEvent.kt +++ b/stagehand-java-core/src/main/kotlin/com/browserbase/api/models/sessions/StreamEvent.kt @@ -30,8 +30,8 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Server-Sent Event emitted during streaming responses. Events are sent as `data: \n\n`. Key - * order: data (with status first), type, id. + * Server-Sent Event emitted during streaming responses. Events are sent as `event: \ndata: + * \n\n`, where the JSON payload has the shape `{ data, type, id }`. */ class StreamEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/ModelConfigTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/ModelConfigTest.kt index 1326d37..6e3b3d0 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/ModelConfigTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/ModelConfigTest.kt @@ -14,42 +14,27 @@ internal class ModelConfigTest { fun create() { val modelConfig = ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() - assertThat(modelConfig.modelName()).isEqualTo("openai/gpt-5-nano") + assertThat(modelConfig.modelName()).isEqualTo("openai/gpt-5.4-mini") assertThat(modelConfig.apiKey()).contains("sk-some-openai-api-key") assertThat(modelConfig.baseUrl()).contains("https://api.openai.com/v1") assertThat(modelConfig.headers()) .contains( ModelConfig.Headers.builder() - .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) assertThat(modelConfig.provider()).contains(ModelConfig.Provider.OPENAI) - assertThat(modelConfig.providerOptions()) - .contains( - ModelConfig.ProviderOptions.ofBedrockApiKey( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - ) - assertThat(modelConfig.skipApiKeyFallback()).contains(true) } @Test @@ -57,21 +42,15 @@ internal class ModelConfigTest { val jsonMapper = jsonMapper() val modelConfig = ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() val roundtrippedModelConfig = diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionActParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionActParamsTest.kt index ac1315c..31ef59b 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionActParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionActParamsTest.kt @@ -20,24 +20,15 @@ internal class SessionActParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -85,25 +76,15 @@ internal class SessionActParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -155,25 +136,15 @@ internal class SessionActParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -205,24 +176,15 @@ internal class SessionActParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExecuteParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExecuteParamsTest.kt index e2c6f96..f040cad 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExecuteParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExecuteParamsTest.kt @@ -19,47 +19,29 @@ internal class SessionExecuteParamsTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -73,6 +55,8 @@ internal class SessionExecuteParamsTest { ) .highlightCursor(true) .maxSteps(20.0) + .toolTimeout(30000.0) + .useSearch(true) .build() ) .frameId("frameId") @@ -111,49 +95,29 @@ internal class SessionExecuteParamsTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -167,6 +131,8 @@ internal class SessionExecuteParamsTest { ) .highlightCursor(true) .maxSteps(20.0) + .toolTimeout(30000.0) + .useSearch(true) .build() ) .frameId("frameId") @@ -209,49 +175,29 @@ internal class SessionExecuteParamsTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -265,6 +211,8 @@ internal class SessionExecuteParamsTest { ) .highlightCursor(true) .maxSteps(20.0) + .toolTimeout(30000.0) + .useSearch(true) .build() ) .frameId("frameId") @@ -279,47 +227,29 @@ internal class SessionExecuteParamsTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -334,6 +264,8 @@ internal class SessionExecuteParamsTest { ) .highlightCursor(true) .maxSteps(20.0) + .toolTimeout(30000.0) + .useSearch(true) .build() ) assertThat(body.frameId()).contains("frameId") diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExtractParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExtractParamsTest.kt index f14f0a4..d84a3f9 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExtractParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionExtractParamsTest.kt @@ -20,24 +20,15 @@ internal class SessionExtractParamsTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -74,25 +65,15 @@ internal class SessionExtractParamsTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -133,25 +114,15 @@ internal class SessionExtractParamsTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -175,24 +146,15 @@ internal class SessionExtractParamsTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("#main-content") diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionObserveParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionObserveParamsTest.kt index fc07b50..08f0c13 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionObserveParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionObserveParamsTest.kt @@ -20,24 +20,15 @@ internal class SessionObserveParamsTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -83,25 +74,15 @@ internal class SessionObserveParamsTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -151,25 +132,15 @@ internal class SessionObserveParamsTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -201,24 +172,15 @@ internal class SessionObserveParamsTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions.builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("nav") diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt index 0d05eca..0a8dffc 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/models/sessions/SessionStartParamsTest.kt @@ -159,27 +159,6 @@ internal class SessionStartParamsTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -344,27 +323,6 @@ internal class SessionStartParamsTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -542,27 +500,6 @@ internal class SessionStartParamsTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -719,30 +656,6 @@ internal class SessionStartParamsTest { assertThat(body.browserbaseSessionId()).contains("browserbaseSessionID") assertThat(body.domSettleTimeoutMs()).contains(5000.0) assertThat(body.experimental()).contains(true) - assertThat(body.modelClientOptions()) - .contains( - SessionStartParams.ModelClientOptions.ofBedrockApiKey( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) - ) assertThat(body.selfHeal()).contains(true) assertThat(body.systemPrompt()).contains("systemPrompt") assertThat(body.verbose()).contains(SessionStartParams.Verbose._1) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt index fce6e48..6941c36 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ErrorHandlingTest.kt @@ -242,33 +242,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -464,33 +437,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -686,33 +632,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -908,33 +827,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1130,33 +1022,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1352,33 +1217,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1574,33 +1412,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -1796,33 +1607,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2018,33 +1802,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2240,33 +1997,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2462,33 +2192,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2684,33 +2387,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -2906,33 +2582,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -3128,33 +2777,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -3350,33 +2972,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -3572,33 +3167,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -3792,33 +3360,6 @@ internal class ErrorHandlingTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt index b67f63c..392cc05 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/ServiceParamsTest.kt @@ -201,27 +201,6 @@ internal class ServiceParamsTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions.builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty("X-Custom-Header", JsonValue.from("value")) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) @@ -256,25 +235,15 @@ internal class ServiceParamsTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt index 78f3def..a21bd07 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/async/SessionServiceAsyncTest.kt @@ -40,25 +40,15 @@ internal class SessionServiceAsyncTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -107,25 +97,15 @@ internal class SessionServiceAsyncTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -197,49 +177,29 @@ internal class SessionServiceAsyncTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -253,6 +213,8 @@ internal class SessionServiceAsyncTest { ) .highlightCursor(true) .maxSteps(20.0) + .toolTimeout(30000.0) + .useSearch(true) .build() ) .frameId("frameId") @@ -285,49 +247,29 @@ internal class SessionServiceAsyncTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -341,6 +283,8 @@ internal class SessionServiceAsyncTest { ) .highlightCursor(true) .maxSteps(20.0) + .toolTimeout(30000.0) + .useSearch(true) .build() ) .frameId("frameId") @@ -375,25 +319,15 @@ internal class SessionServiceAsyncTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -434,25 +368,15 @@ internal class SessionServiceAsyncTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -527,25 +451,15 @@ internal class SessionServiceAsyncTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -595,25 +509,15 @@ internal class SessionServiceAsyncTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -836,33 +740,6 @@ internal class SessionServiceAsyncTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) diff --git a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt index 7d7349d..7923bb5 100644 --- a/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt +++ b/stagehand-java-core/src/test/kotlin/com/browserbase/api/services/blocking/SessionServiceTest.kt @@ -40,25 +40,15 @@ internal class SessionServiceTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -106,25 +96,15 @@ internal class SessionServiceTest { SessionActParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .timeout(30000.0) @@ -195,49 +175,29 @@ internal class SessionServiceTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -251,6 +211,8 @@ internal class SessionServiceTest { ) .highlightCursor(true) .maxSteps(20.0) + .toolTimeout(30000.0) + .useSearch(true) .build() ) .frameId("frameId") @@ -282,49 +244,29 @@ internal class SessionServiceTest { .cua(true) .executionModel( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .mode(SessionExecuteParams.AgentConfig.Mode.CUA) .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .provider(SessionExecuteParams.AgentConfig.Provider.OPENAI) @@ -338,6 +280,8 @@ internal class SessionServiceTest { ) .highlightCursor(true) .maxSteps(20.0) + .toolTimeout(30000.0) + .useSearch(true) .build() ) .frameId("frameId") @@ -372,25 +316,15 @@ internal class SessionServiceTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -430,25 +364,15 @@ internal class SessionServiceTest { SessionExtractParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("#main-content") @@ -522,25 +446,15 @@ internal class SessionServiceTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -589,25 +503,15 @@ internal class SessionServiceTest { SessionObserveParams.Options.builder() .model( ModelConfig.builder() - .modelName("openai/gpt-5-nano") + .modelName("openai/gpt-5.4-mini") .apiKey("sk-some-openai-api-key") .baseUrl("https://api.openai.com/v1") .headers( ModelConfig.Headers.builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .provider(ModelConfig.Provider.OPENAI) - .providerOptions( - ModelConfig.ProviderOptions.BedrockApiKeyProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .skipApiKeyFallback(true) .build() ) .selector("nav") @@ -829,33 +733,6 @@ internal class SessionServiceTest { .browserbaseSessionId("browserbaseSessionID") .domSettleTimeoutMs(5000.0) .experimental(true) - .modelClientOptions( - SessionStartParams.ModelClientOptions.BedrockApiKeyModelClientOptions - .builder() - .apiKey("bedrock-short-term-api-key") - .providerOptions( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .ProviderOptions - .builder() - .region("us-east-1") - .build() - ) - .baseUrl("https://api.openai.com/v1") - .headers( - SessionStartParams.ModelClientOptions - .BedrockApiKeyModelClientOptions - .Headers - .builder() - .putAdditionalProperty( - "X-Custom-Header", - JsonValue.from("value"), - ) - .build() - ) - .skipApiKeyFallback(true) - .build() - ) .selfHeal(true) .systemPrompt("systemPrompt") .verbose(SessionStartParams.Verbose._1) From 3d5776120f8d4542d9ca748f72cb1d846da43faf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2026 20:32:31 +0000 Subject: [PATCH 5/5] release: 3.20.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 10 ++++++++++ README.md | 8 ++++---- build.gradle.kts | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 911c623..d11c8fc 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.19.3" + ".": "3.20.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c3ce73..c9dd528 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 3.20.0 (2026-04-09) + +Full Changelog: [v3.19.3...v3.20.0](https://github.com/browserbase/stagehand-java/compare/v3.19.3...v3.20.0) + +### Features + +* [STG-1798] feat: support Browserbase verified sessions ([59ee151](https://github.com/browserbase/stagehand-java/commit/59ee1516eb17d6b8474b12d2722ff4627fa2557c)) +* Bedrock auth passthrough ([7d5037a](https://github.com/browserbase/stagehand-java/commit/7d5037abacedbee829f0fe238565ed81c211eba9)) +* Revert "[STG-1573] Add providerOptions for extensible model auth ([#1822](https://github.com/browserbase/stagehand-java/issues/1822))" ([c337e61](https://github.com/browserbase/stagehand-java/commit/c337e61dd9b2cc366bceec0e7119874acdc3b069)) + ## 3.19.3 (2026-04-03) Full Changelog: [v3.18.0...v3.19.3](https://github.com/browserbase/stagehand-java/compare/v3.18.0...v3.19.3) diff --git a/README.md b/README.md index 7179a61..5a108ce 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.browserbase.api/stagehand-java)](https://central.sonatype.com/artifact/com.browserbase.api/stagehand-java/3.19.3) -[![javadoc](https://javadoc.io/badge2/com.browserbase.api/stagehand-java/3.19.3/javadoc.svg)](https://javadoc.io/doc/com.browserbase.api/stagehand-java/3.19.3) +[![Maven Central](https://img.shields.io/maven-central/v/com.browserbase.api/stagehand-java)](https://central.sonatype.com/artifact/com.browserbase.api/stagehand-java/3.20.0) +[![javadoc](https://javadoc.io/badge2/com.browserbase.api/stagehand-java/3.20.0/javadoc.svg)](https://javadoc.io/doc/com.browserbase.api/stagehand-java/3.20.0) @@ -85,7 +85,7 @@ Most existing browser automation tools either require you to write low-level cod ### Gradle ```kotlin -implementation("com.browserbase.api:stagehand-java:3.19.3") +implementation("com.browserbase.api:stagehand-java:3.20.0") ``` ### Maven @@ -94,7 +94,7 @@ implementation("com.browserbase.api:stagehand-java:3.19.3") com.browserbase.api stagehand-java - 3.19.3 + 3.20.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 7d91da7..2fc0dbb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.browserbase.api" - version = "3.19.3" // x-release-please-version + version = "3.20.0" // x-release-please-version } subprojects {