diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index e294a783a..2a0dd335b 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,4 +1,4 @@
{
- ".": "2.29.0",
+ ".": "2.30.0",
"anthropic-java-aws": "0.2.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 7027e4e50..5a84c2e7b 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 91
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-ad9228826393d94e86ecf4c22853ae51b1d4094960c836238b3ab79a1044be32.yml
-openapi_spec_hash: dc43ed54947d427a084a891b7c4a783a
-config_hash: bbf09e23cb2e12b5bb8cbcee3044ceec
+configured_endpoints: 97
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-0df2c793ea4c3ad955e8e488be39d7041a0a95e2fe144dd69ae4d9fb72835190.yml
+openapi_spec_hash: b169b786bdf1f07d7f77f18f7b94abfa
+config_hash: ed43b84afda7441f472a59dda6badb05
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e38f62da9..785441317 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,25 @@
# Changelog
+## 2.30.0 (2026-05-06)
+
+Full Changelog: [v2.29.0...v2.30.0](https://github.com/anthropics/anthropic-sdk-java/compare/v2.29.0...v2.30.0)
+
+### Features
+
+* **api:** add support for Managed Agents multiagents and outcomes, webhooks, vault validation ([e641d5f](https://github.com/anthropics/anthropic-sdk-java/commit/e641d5fef03fb832064d933326be8b0294e4ab0c))
+* **api:** add support for Managed Agents multiagents and outcomes, webhooks, vault validation ([6067599](https://github.com/anthropics/anthropic-sdk-java/commit/60675993a7c520e7fb74d02dc797d64e854d58e8))
+* **client:** support proxy authentication ([d91fea2](https://github.com/anthropics/anthropic-sdk-java/commit/d91fea2762368d5b52296dddd36e1b9b67ff1bf5))
+
+
+### Bug Fixes
+
+* **api:** Adjust webhook configuration ([34ea5b4](https://github.com/anthropics/anthropic-sdk-java/commit/34ea5b41cb152df7abdc9d5e43949817c74d4375))
+
+
+### Chores
+
+* fix merge errors ([c390c20](https://github.com/anthropics/anthropic-sdk-java/commit/c390c200d0fb228caaebb7c14ae22fa72bec22b9))
+
## 2.29.0 (2026-05-05)
Full Changelog: [v2.28.0...v2.29.0](https://github.com/anthropics/anthropic-sdk-java/compare/v2.28.0...v2.29.0)
diff --git a/README.md b/README.md
index 7d505beb5..7fb8be0f2 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Full documentation is available at **[platform.claude.com/docs/en/api/sdks/java]
### Gradle
```kotlin
-implementation("com.anthropic:anthropic-java:2.29.0")
+implementation("com.anthropic:anthropic-java:2.30.0")
```
### Maven
@@ -24,7 +24,7 @@ implementation("com.anthropic:anthropic-java:2.29.0")
com.anthropic
anthropic-java
- 2.29.0
+ 2.30.0
```
diff --git a/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/AnthropicOkHttpClient.kt b/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/AnthropicOkHttpClient.kt
index f810c3ed3..4afb293ca 100644
--- a/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/AnthropicOkHttpClient.kt
+++ b/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/AnthropicOkHttpClient.kt
@@ -13,6 +13,7 @@ import com.anthropic.core.Timeout
import com.anthropic.core.http.AsyncStreamResponse
import com.anthropic.core.http.Headers
import com.anthropic.core.http.HttpClient
+import com.anthropic.core.http.ProxyAuthenticator
import com.anthropic.core.http.QueryParams
import com.fasterxml.jackson.databind.json.JsonMapper
import java.net.Proxy
@@ -51,6 +52,7 @@ class AnthropicOkHttpClient private constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
+ private var proxyAuthenticator: ProxyAuthenticator? = null
private var maxIdleConnections: Int? = null
private var keepAliveDuration: Duration? = null
private var sslSocketFactory: SSLSocketFactory? = null
@@ -83,6 +85,20 @@ class AnthropicOkHttpClient private constructor() {
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
fun proxy(proxy: Optional) = proxy(proxy.getOrNull())
+ /**
+ * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication
+ * Required`.
+ */
+ fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply {
+ this.proxyAuthenticator = proxyAuthenticator
+ }
+
+ /**
+ * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`.
+ */
+ fun proxyAuthenticator(proxyAuthenticator: Optional) =
+ proxyAuthenticator(proxyAuthenticator.getOrNull())
+
/**
* The maximum number of idle connections kept by the underlying OkHttp connection pool.
*
@@ -292,6 +308,11 @@ class AnthropicOkHttpClient private constructor() {
/** Alias for calling [Builder.authToken] with `authToken.orElse(null)`. */
fun authToken(authToken: Optional) = authToken(authToken.getOrNull())
+ fun webhookKey(webhookKey: String?) = apply { clientOptions.webhookKey(webhookKey) }
+
+ /** Alias for calling [Builder.webhookKey] with `webhookKey.orElse(null)`. */
+ fun webhookKey(webhookKey: Optional) = webhookKey(webhookKey.getOrNull())
+
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
fun headers(headers: Map>) = apply {
@@ -445,6 +466,7 @@ class AnthropicOkHttpClient private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
+ .proxyAuthenticator(proxyAuthenticator)
.maxIdleConnections(maxIdleConnections)
.keepAliveDuration(keepAliveDuration)
.dispatcherExecutorService(dispatcherExecutorService)
diff --git a/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/AnthropicOkHttpClientAsync.kt b/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/AnthropicOkHttpClientAsync.kt
index cceb51d63..c3a156c80 100644
--- a/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/AnthropicOkHttpClientAsync.kt
+++ b/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/AnthropicOkHttpClientAsync.kt
@@ -13,6 +13,7 @@ import com.anthropic.core.Timeout
import com.anthropic.core.http.AsyncStreamResponse
import com.anthropic.core.http.Headers
import com.anthropic.core.http.HttpClient
+import com.anthropic.core.http.ProxyAuthenticator
import com.anthropic.core.http.QueryParams
import com.fasterxml.jackson.databind.json.JsonMapper
import java.net.Proxy
@@ -51,6 +52,7 @@ class AnthropicOkHttpClientAsync private constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
+ private var proxyAuthenticator: ProxyAuthenticator? = null
private var maxIdleConnections: Int? = null
private var keepAliveDuration: Duration? = null
private var sslSocketFactory: SSLSocketFactory? = null
@@ -83,6 +85,20 @@ class AnthropicOkHttpClientAsync private constructor() {
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
fun proxy(proxy: Optional) = proxy(proxy.getOrNull())
+ /**
+ * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication
+ * Required`.
+ */
+ fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply {
+ this.proxyAuthenticator = proxyAuthenticator
+ }
+
+ /**
+ * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`.
+ */
+ fun proxyAuthenticator(proxyAuthenticator: Optional) =
+ proxyAuthenticator(proxyAuthenticator.getOrNull())
+
/**
* The maximum number of idle connections kept by the underlying OkHttp connection pool.
*
@@ -292,6 +308,11 @@ class AnthropicOkHttpClientAsync private constructor() {
/** Alias for calling [Builder.authToken] with `authToken.orElse(null)`. */
fun authToken(authToken: Optional) = authToken(authToken.getOrNull())
+ fun webhookKey(webhookKey: String?) = apply { clientOptions.webhookKey(webhookKey) }
+
+ /** Alias for calling [Builder.webhookKey] with `webhookKey.orElse(null)`. */
+ fun webhookKey(webhookKey: Optional) = webhookKey(webhookKey.getOrNull())
+
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
fun headers(headers: Map>) = apply {
@@ -445,6 +466,7 @@ class AnthropicOkHttpClientAsync private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
+ .proxyAuthenticator(proxyAuthenticator)
.maxIdleConnections(maxIdleConnections)
.keepAliveDuration(keepAliveDuration)
.dispatcherExecutorService(dispatcherExecutorService)
diff --git a/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/OkHttpClient.kt b/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/OkHttpClient.kt
index 9716b2933..acef12bd4 100644
--- a/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/OkHttpClient.kt
+++ b/anthropic-java-client-okhttp/src/main/kotlin/com/anthropic/client/okhttp/OkHttpClient.kt
@@ -10,9 +10,11 @@ import com.anthropic.core.http.HttpMethod
import com.anthropic.core.http.HttpRequest
import com.anthropic.core.http.HttpRequestBody
import com.anthropic.core.http.HttpResponse
+import com.anthropic.core.http.ProxyAuthenticator
import com.anthropic.errors.AnthropicIoException
import java.io.IOException
import java.io.InputStream
+import java.io.OutputStream
import java.net.Proxy
import java.time.Duration
import java.util.concurrent.CancellationException
@@ -22,10 +24,12 @@ import java.util.concurrent.TimeUnit
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
+import kotlin.jvm.optionals.getOrNull
import okhttp3.Call
import okhttp3.Callback
import okhttp3.ConnectionPool
import okhttp3.Dispatcher
+import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
@@ -35,6 +39,8 @@ import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import okio.BufferedSink
+import okio.buffer
+import okio.sink
class OkHttpClient
internal constructor(
@@ -47,7 +53,7 @@ internal constructor(
val call = newCall(preparedRequest, requestOptions)
return try {
- backend.prepareResponse(call.execute().toResponse())
+ backend.prepareResponse(call.execute().toHttpResponse())
} catch (e: IOException) {
throw AnthropicIoException("Request failed", e)
} finally {
@@ -66,7 +72,7 @@ internal constructor(
call.enqueue(
object : Callback {
override fun onResponse(call: Call, response: Response) {
- future.complete(backend.prepareResponse(response.toResponse()))
+ future.complete(backend.prepareResponse(response.toHttpResponse()))
}
override fun onFailure(call: Call, e: IOException) {
@@ -158,15 +164,6 @@ internal constructor(
return builder.build()
}
- /** `OkHttpClient` always requires a request body for some methods. */
- private fun requiresBody(method: HttpMethod): Boolean =
- when (method) {
- HttpMethod.POST,
- HttpMethod.PUT,
- HttpMethod.PATCH -> true
- else -> false
- }
-
private fun HttpRequest.resolveUrl(): HttpRequest {
return toBuilder().baseUrl(toUrl()).build()
}
@@ -182,41 +179,6 @@ internal constructor(
return builder.toString()
}
- private fun HttpRequestBody.toRequestBody(): RequestBody {
- val mediaType = contentType()?.toMediaType()
- val length = contentLength()
-
- return object : RequestBody() {
- override fun contentType(): MediaType? = mediaType
-
- override fun contentLength(): Long = length
-
- override fun isOneShot(): Boolean = !repeatable()
-
- override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream())
- }
- }
-
- private fun Response.toResponse(): HttpResponse {
- val headers = headers.toHeaders()
-
- return object : HttpResponse {
- override fun statusCode(): Int = code
-
- override fun headers(): Headers = headers
-
- override fun body(): InputStream = body!!.byteStream()
-
- override fun close() = body!!.close()
- }
- }
-
- private fun okhttp3.Headers.toHeaders(): Headers {
- val headersBuilder = Headers.builder()
- forEach { (name, value) -> headersBuilder.put(name, value) }
- return headersBuilder.build()
- }
-
companion object {
@JvmStatic fun builder() = Builder()
}
@@ -226,6 +188,8 @@ internal constructor(
private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
private var backend: Backend? = null
+
+ private var proxyAuthenticator: ProxyAuthenticator? = null
private var maxIdleConnections: Int? = null
private var keepAliveDuration: Duration? = null
private var dispatcherExecutorService: ExecutorService? = null
@@ -241,6 +205,10 @@ internal constructor(
fun backend(backend: Backend) = apply { this.backend = backend }
+ fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply {
+ this.proxyAuthenticator = proxyAuthenticator
+ }
+
/**
* Sets the maximum number of idle connections kept by the underlying [ConnectionPool].
*
@@ -291,6 +259,19 @@ internal constructor(
.callTimeout(timeout.request())
.proxy(proxy)
.apply {
+ proxyAuthenticator?.let { auth ->
+ proxyAuthenticator { route, response ->
+ auth
+ .authenticate(
+ route?.proxy ?: Proxy.NO_PROXY,
+ response.request.toHttpRequest(),
+ response.toHttpResponse(),
+ )
+ .getOrNull()
+ ?.toRequest(client = null)
+ }
+ }
+
dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) }
val maxIdleConnections = maxIdleConnections
@@ -331,3 +312,126 @@ internal constructor(
)
}
}
+
+private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient?): Request {
+ var body: RequestBody? = body?.toRequestBody()
+ if (body == null && requiresBody(method)) {
+ body = "".toRequestBody()
+ }
+
+ val builder = Request.Builder().url(toUrl()).method(method.name, body)
+ headers.names().forEach { name -> headers.values(name).forEach { builder.addHeader(name, it) } }
+
+ if (client != null) {
+ if (
+ !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0
+ ) {
+ builder.addHeader(
+ "X-Stainless-Read-Timeout",
+ Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(),
+ )
+ }
+ if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) {
+ builder.addHeader(
+ "X-Stainless-Timeout",
+ Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(),
+ )
+ }
+ }
+
+ return builder.build()
+}
+
+/** `OkHttpClient` always requires a request body for some methods. */
+private fun requiresBody(method: HttpMethod): Boolean =
+ when (method) {
+ HttpMethod.POST,
+ HttpMethod.PUT,
+ HttpMethod.PATCH -> true
+ else -> false
+ }
+
+private fun HttpRequest.toUrl(): String {
+ val builder = baseUrl!!.toHttpUrl().newBuilder()
+ pathSegments.forEach(builder::addPathSegment)
+ queryParams.keys().forEach { key ->
+ queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
+ }
+
+ return builder.toString()
+}
+
+private fun HttpRequestBody.toRequestBody(): RequestBody {
+ val mediaType = contentType()?.toMediaType()
+ val length = contentLength()
+
+ return object : RequestBody() {
+ override fun contentType(): MediaType? = mediaType
+
+ override fun contentLength(): Long = length
+
+ override fun isOneShot(): Boolean = !repeatable()
+
+ override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream())
+ }
+}
+
+private fun Request.toHttpRequest(): HttpRequest {
+ val builder = HttpRequest.builder().method(HttpMethod.valueOf(method)).baseUrl(url.toBaseUrl())
+ url.pathSegments.forEach(builder::addPathSegment)
+ url.queryParameterNames.forEach { name ->
+ url.queryParameterValues(name).filterNotNull().forEach { builder.putQueryParam(name, it) }
+ }
+ headers.forEach { (name, value) -> builder.putHeader(name, value) }
+ body?.let { builder.body(it.toHttpRequestBody()) }
+ return builder.build()
+}
+
+private fun HttpUrl.toBaseUrl(): String = buildString {
+ append(scheme).append("://").append(host)
+ if (port != HttpUrl.defaultPort(scheme)) {
+ append(":").append(port)
+ }
+}
+
+private fun RequestBody.toHttpRequestBody(): HttpRequestBody {
+ val mediaType = contentType()?.toString()
+ val length = contentLength()
+ val isOneShot = isOneShot()
+ val source = this
+ return object : HttpRequestBody {
+ override fun contentType(): String? = mediaType
+
+ override fun contentLength(): Long = length
+
+ override fun repeatable(): Boolean = !isOneShot
+
+ override fun writeTo(outputStream: OutputStream) {
+ val sink = outputStream.sink().buffer()
+ source.writeTo(sink)
+ sink.flush()
+ }
+
+ override fun close() {}
+ }
+}
+
+private fun Response.toHttpResponse(): HttpResponse {
+ val headers = headers.toHeaders()
+
+ return object : HttpResponse {
+ override fun statusCode(): Int = code
+
+ override fun headers(): Headers = headers
+
+ override fun body(): InputStream = body!!.byteStream()
+
+ override fun close() = body!!.close()
+ }
+}
+
+private fun okhttp3.Headers.toHeaders(): Headers {
+ val headersBuilder = Headers.builder()
+ forEach { (name, value) -> headersBuilder.put(name, value) }
+ return headersBuilder.build()
+}
diff --git a/anthropic-java-core/build.gradle.kts b/anthropic-java-core/build.gradle.kts
index e1ec6018b..b8c9f6431 100644
--- a/anthropic-java-core/build.gradle.kts
+++ b/anthropic-java-core/build.gradle.kts
@@ -22,6 +22,7 @@ dependencies {
api("com.fasterxml.jackson.core:jackson-core:2.18.2")
api("com.fasterxml.jackson.core:jackson-databind:2.18.2")
api("com.google.errorprone:error_prone_annotations:2.33.0")
+ api("com.standardwebhooks:standardwebhooks:1.1.0")
api("io.swagger.core.v3:swagger-annotations:2.2.31")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2")
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/ClientOptions.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/ClientOptions.kt
index 7cf748315..46a00b877 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/ClientOptions.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/ClientOptions.kt
@@ -112,6 +112,7 @@ private constructor(
* Defaults to 2.
*/
@get:JvmName("maxRetries") val maxRetries: Int,
+ private val webhookKey: String?,
private val credentialResult: CredentialResult?,
) {
@@ -128,6 +129,8 @@ private constructor(
*/
fun baseUrl(): String? = baseUrl
+ fun webhookKey(): Optional = Optional.ofNullable(webhookKey)
+
fun toBuilder() = Builder().from(this)
companion object {
@@ -159,6 +162,7 @@ private constructor(
private var timeout: Timeout = Timeout.default()
private var maxRetries: Int = 2
private var credentialResult: CredentialResult? = null
+ private var webhookKey: String? = null
@JvmSynthetic
internal fun from(clientOptions: ClientOptions) = apply {
@@ -174,6 +178,7 @@ private constructor(
responseValidation = clientOptions.responseValidation
timeout = clientOptions.timeout
maxRetries = clientOptions.maxRetries
+ webhookKey = clientOptions.webhookKey
credentialResult = clientOptions.credentialResult
}
@@ -303,6 +308,11 @@ private constructor(
this.credentialResult = credentials
}
+ fun webhookKey(webhookKey: String?) = apply { this.webhookKey = webhookKey }
+
+ /** Alias for calling [Builder.webhookKey] with `webhookKey.orElse(null)`. */
+ fun webhookKey(webhookKey: Optional) = webhookKey(webhookKey.getOrNull())
+
fun headers(headers: Headers) = apply {
this.headers.clear()
putAllHeaders(headers)
@@ -385,8 +395,21 @@ private constructor(
fun timeout(): Timeout = timeout
- /** Updates configuration using environment variables. */
+ /**
+ * Updates configuration using system properties and environment variables.
+ *
+ * See this table for the available options:
+ *
+ * |Setter |System property |Environment variable |Required|Default value|
+ * |------------|-----------------------------|-------------------------------|--------|-------------|
+ * |`webhookKey`|`anthropic.webhookSigningKey`|`ANTHROPIC_WEBHOOK_SIGNING_KEY`|false |- |
+ *
+ * System properties take precedence over environment variables.
+ */
fun fromEnv() = apply {
+ (System.getProperty("anthropic.webhookSigningKey")
+ ?: System.getenv("ANTHROPIC_WEBHOOK_SIGNING_KEY"))
+ ?.let { webhookKey(it) }
System.getenv("ANTHROPIC_CUSTOM_HEADERS")?.let { customHeadersEnv ->
for (line in customHeadersEnv.split("\n")) {
val colon = line.indexOf(':')
@@ -474,6 +497,7 @@ private constructor(
responseValidation,
timeout,
maxRetries,
+ webhookKey,
credentialResult,
)
}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/UnwrapWebhookParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/UnwrapWebhookParams.kt
new file mode 100644
index 000000000..c99374247
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/UnwrapWebhookParams.kt
@@ -0,0 +1,102 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.core
+
+import com.anthropic.core.http.Headers
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+class UnwrapWebhookParams
+private constructor(
+ private val body: String,
+ private val headers: Headers?,
+ private val secret: String?,
+) {
+
+ /** The raw JSON body of the webhook request. */
+ fun body(): String = body
+
+ /** The headers from the webhook request. */
+ fun headers(): Optional = Optional.ofNullable(headers)
+
+ /** The secret used to verify the webhook signature. */
+ fun secret(): Optional = Optional.ofNullable(secret)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [UnwrapWebhookParams].
+ *
+ * The following fields are required:
+ * ```java
+ * .body()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [UnwrapWebhookParams]. */
+ class Builder internal constructor() {
+
+ private var body: String? = null
+ private var headers: Headers? = null
+ private var secret: String? = null
+
+ @JvmSynthetic
+ internal fun from(unwrapWebhookParams: UnwrapWebhookParams) = apply {
+ body = unwrapWebhookParams.body
+ headers = unwrapWebhookParams.headers
+ secret = unwrapWebhookParams.secret
+ }
+
+ /** The raw JSON body of the webhook request. */
+ fun body(body: String) = apply { this.body = body }
+
+ /** The headers from the webhook request. */
+ fun headers(headers: Headers?) = apply { this.headers = headers }
+
+ /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */
+ fun headers(headers: Optional) = headers(headers.getOrNull())
+
+ /** The secret used to verify the webhook signature. */
+ fun secret(secret: String?) = apply { this.secret = secret }
+
+ /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */
+ fun secret(secret: Optional) = secret(secret.getOrNull())
+
+ /**
+ * Returns an immutable instance of [UnwrapWebhookParams].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .body()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): UnwrapWebhookParams =
+ UnwrapWebhookParams(checkRequired("body", body), headers, secret)
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is UnwrapWebhookParams &&
+ body == other.body &&
+ headers == other.headers &&
+ secret == other.secret
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(body, headers, secret) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() = "UnwrapWebhookParams{body=$body, headers=$headers, secret=$secret}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/EmptyHandler.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/EmptyHandler.kt
new file mode 100644
index 000000000..14eb80bc7
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/EmptyHandler.kt
@@ -0,0 +1,12 @@
+@file:JvmName("EmptyHandler")
+
+package com.anthropic.core.handlers
+
+import com.anthropic.core.http.HttpResponse
+import com.anthropic.core.http.HttpResponse.Handler
+
+@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandlerInternal
+
+private object EmptyHandlerInternal : Handler {
+ override fun handle(response: HttpResponse): Void? = null
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/SseHandler.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/SseHandler.kt
index 3e8b91ec9..dae5c33ca 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/SseHandler.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/SseHandler.kt
@@ -49,7 +49,21 @@ internal fun sseHandler(jsonMapper: JsonMapper): Handler yield(message)
+ "span.model_request_end",
+ "span.outcome_evaluation_start",
+ "span.outcome_evaluation_ongoing",
+ "span.outcome_evaluation_end",
+ "user.define_outcome",
+ "agent.thread_message_received",
+ "agent.thread_message_sent",
+ "agent.session_thread_message_received",
+ "agent.session_thread_message_sent",
+ "session.thread_created",
+ "session.thread_status_created",
+ "session.thread_status_running",
+ "session.thread_status_idle",
+ "session.thread_status_rescheduled",
+ "session.thread_status_terminated" -> yield(message)
"ping" -> continue
"error" -> {
throw SseException.builder()
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/ProxyAuthenticator.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/ProxyAuthenticator.kt
new file mode 100644
index 000000000..8376c20ce
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/ProxyAuthenticator.kt
@@ -0,0 +1,59 @@
+package com.anthropic.core.http
+
+import java.net.Proxy
+import java.nio.charset.Charset
+import java.nio.charset.StandardCharsets
+import java.util.Base64
+import java.util.Optional
+
+/**
+ * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication Required`.
+ *
+ * Implementations inspect the 407 [response] (typically its `Proxy-Authenticate` header) and return
+ * the request to retry with a `Proxy-Authorization` header set, or [Optional.empty] to abandon
+ * authentication and surface the 407 to the caller.
+ *
+ * Implementations must be thread-safe; they may be invoked concurrently from multiple HTTP calls.
+ */
+fun interface ProxyAuthenticator {
+
+ /**
+ * @param proxy the proxy that produced the challenge, or [Proxy.NO_PROXY] if the route is not
+ * yet established
+ * @param request the request that produced [response]
+ * @param response the 407 challenge response
+ * @return the retry request to send (typically [request] with a `Proxy-Authorization` header
+ * added), or [Optional.empty] to abandon authentication
+ */
+ fun authenticate(
+ proxy: Proxy,
+ request: HttpRequest,
+ response: HttpResponse,
+ ): Optional
+
+ companion object {
+
+ /**
+ * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the ISO-8859-1
+ * charset.
+ */
+ @JvmStatic
+ fun basic(username: String, password: String): ProxyAuthenticator =
+ basic(username, password, StandardCharsets.ISO_8859_1)
+
+ /**
+ * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the given [charset].
+ */
+ @JvmStatic
+ fun basic(username: String, password: String, charset: Charset): ProxyAuthenticator {
+ val token =
+ Base64.getEncoder().encodeToString("$username:$password".toByteArray(charset))
+ val headerValue = "Basic $token"
+ return ProxyAuthenticator { _, request, _ ->
+ Optional.of(
+ request.toBuilder().putHeader("Proxy-Authorization", headerValue).build()
+ )
+ }
+ }
+ }
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/QueryParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/QueryParams.kt
index 8fcc04414..3b6af1127 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/QueryParams.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/QueryParams.kt
@@ -43,27 +43,7 @@ private constructor(
is JsonBoolean -> put(key, value.value.toString())
is JsonNumber -> put(key, value.value.toString())
is JsonString -> put(key, value.value)
- is JsonArray ->
- put(
- key,
- value.values
- .asSequence()
- .mapNotNull {
- when (it) {
- is JsonMissing,
- is JsonNull -> null
- is JsonBoolean -> it.value.toString()
- is JsonNumber -> it.value.toString()
- is JsonString -> it.value
- is JsonArray,
- is JsonObject ->
- throw IllegalArgumentException(
- "Cannot comma separate non-primitives in query params"
- )
- }
- }
- .joinToString(","),
- )
+ is JsonArray -> value.values.forEach { put("$key[]", it) }
is JsonObject ->
value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) }
}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/errors/AnthropicWebhookException.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/errors/AnthropicWebhookException.kt
new file mode 100644
index 000000000..aa1c7b3f6
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/errors/AnthropicWebhookException.kt
@@ -0,0 +1,5 @@
+package com.anthropic.errors
+
+class AnthropicWebhookException
+@JvmOverloads
+constructor(message: String? = null, cause: Throwable? = null) : AnthropicException(message, cause)
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/AnthropicBeta.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/AnthropicBeta.kt
index 5551e8ad5..de6524b3c 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/AnthropicBeta.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/AnthropicBeta.kt
@@ -68,6 +68,8 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
@JvmField val ADVISOR_TOOL_2026_03_01 = of("advisor-tool-2026-03-01")
+ @JvmField val MANAGED_AGENTS_2026_04_01 = of("managed-agents-2026-04-01")
+
@JvmStatic fun of(value: String) = AnthropicBeta(JsonField.of(value))
}
@@ -96,6 +98,7 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
OUTPUT_300K_2026_03_24,
USER_PROFILES_2026_03_24,
ADVISOR_TOOL_2026_03_01,
+ MANAGED_AGENTS_2026_04_01,
}
/**
@@ -131,6 +134,7 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
OUTPUT_300K_2026_03_24,
USER_PROFILES_2026_03_24,
ADVISOR_TOOL_2026_03_01,
+ MANAGED_AGENTS_2026_04_01,
/**
* An enum member indicating that [AnthropicBeta] was instantiated with an unknown value.
*/
@@ -170,6 +174,7 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
OUTPUT_300K_2026_03_24 -> Value.OUTPUT_300K_2026_03_24
USER_PROFILES_2026_03_24 -> Value.USER_PROFILES_2026_03_24
ADVISOR_TOOL_2026_03_01 -> Value.ADVISOR_TOOL_2026_03_01
+ MANAGED_AGENTS_2026_04_01 -> Value.MANAGED_AGENTS_2026_04_01
else -> Value._UNKNOWN
}
@@ -207,6 +212,7 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
OUTPUT_300K_2026_03_24 -> Known.OUTPUT_300K_2026_03_24
USER_PROFILES_2026_03_24 -> Known.USER_PROFILES_2026_03_24
ADVISOR_TOOL_2026_03_01 -> Known.ADVISOR_TOOL_2026_03_01
+ MANAGED_AGENTS_2026_04_01 -> Known.MANAGED_AGENTS_2026_04_01
else -> throw AnthropicInvalidDataException("Unknown AnthropicBeta: $value")
}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentCreateParams.kt
index 4e8f381ce..67e5248de 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentCreateParams.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentCreateParams.kt
@@ -18,6 +18,8 @@ import com.anthropic.core.http.QueryParams
import com.anthropic.core.toImmutable
import com.anthropic.errors.AnthropicInvalidDataException
import com.anthropic.models.beta.AnthropicBeta
+import com.anthropic.models.beta.sessions.BetaManagedAgentsMultiagentParams
+import com.anthropic.models.beta.sessions.BetaManagedAgentsMultiagentRosterEntryParams
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
@@ -88,6 +90,15 @@ private constructor(
*/
fun metadata(): Optional = body.metadata()
+ /**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning session
+ * threads, each running an agent drawn from the `agents` roster.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun multiagent(): Optional = body.multiagent()
+
/**
* Skills available to the agent. Maximum 20.
*
@@ -147,6 +158,13 @@ private constructor(
*/
fun _metadata(): JsonField = body._metadata()
+ /**
+ * Returns the raw JSON value of [multiagent].
+ *
+ * Unlike [multiagent], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _multiagent(): JsonField = body._multiagent()
+
/**
* Returns the raw JSON value of [skills].
*
@@ -342,6 +360,43 @@ private constructor(
*/
fun metadata(metadata: JsonField) = apply { body.metadata(metadata) }
+ /**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning
+ * session threads, each running an agent drawn from the `agents` roster.
+ */
+ fun multiagent(multiagent: BetaManagedAgentsMultiagentParams?) = apply {
+ body.multiagent(multiagent)
+ }
+
+ /** Alias for calling [Builder.multiagent] with `multiagent.orElse(null)`. */
+ fun multiagent(multiagent: Optional) =
+ multiagent(multiagent.getOrNull())
+
+ /**
+ * Sets [Builder.multiagent] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.multiagent] with a well-typed
+ * [BetaManagedAgentsMultiagentParams] value instead. This method is primarily for setting
+ * the field to an undocumented or not yet supported value.
+ */
+ fun multiagent(multiagent: JsonField) = apply {
+ body.multiagent(multiagent)
+ }
+
+ /**
+ * Alias for calling [multiagent] with the following:
+ * ```java
+ * BetaManagedAgentsMultiagentParams.builder()
+ * .type(BetaManagedAgentsMultiagentParams.Type.COORDINATOR)
+ * .agents(agents)
+ * .build()
+ * ```
+ */
+ fun coordinatorMultiagent(agents: List) =
+ apply {
+ body.coordinatorMultiagent(agents)
+ }
+
/** Skills available to the agent. Maximum 20. */
fun skills(skills: List) = apply { body.skills(skills) }
@@ -617,6 +672,7 @@ private constructor(
private val description: JsonField,
private val mcpServers: JsonField>,
private val metadata: JsonField,
+ private val multiagent: JsonField,
private val skills: JsonField>,
private val system: JsonField,
private val tools: JsonField>,
@@ -636,6 +692,9 @@ private constructor(
@JsonProperty("metadata")
@ExcludeMissing
metadata: JsonField = JsonMissing.of(),
+ @JsonProperty("multiagent")
+ @ExcludeMissing
+ multiagent: JsonField = JsonMissing.of(),
@JsonProperty("skills")
@ExcludeMissing
skills: JsonField> = JsonMissing.of(),
@@ -647,6 +706,7 @@ private constructor(
description,
mcpServers,
metadata,
+ multiagent,
skills,
system,
tools,
@@ -697,6 +757,16 @@ private constructor(
*/
fun metadata(): Optional = metadata.getOptional("metadata")
+ /**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning
+ * session threads, each running an agent drawn from the `agents` roster.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun multiagent(): Optional =
+ multiagent.getOptional("multiagent")
+
/**
* Skills available to the agent. Maximum 20.
*
@@ -761,6 +831,15 @@ private constructor(
*/
@JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata
+ /**
+ * Returns the raw JSON value of [multiagent].
+ *
+ * Unlike [multiagent], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("multiagent")
+ @ExcludeMissing
+ fun _multiagent(): JsonField = multiagent
+
/**
* Returns the raw JSON value of [skills].
*
@@ -819,6 +898,7 @@ private constructor(
private var mcpServers: JsonField>? =
null
private var metadata: JsonField = JsonMissing.of()
+ private var multiagent: JsonField = JsonMissing.of()
private var skills: JsonField>? = null
private var system: JsonField = JsonMissing.of()
private var tools: JsonField>? = null
@@ -831,6 +911,7 @@ private constructor(
description = body.description
mcpServers = body.mcpServers.map { it.toMutableList() }
metadata = body.metadata
+ multiagent = body.multiagent
skills = body.skills.map { it.toMutableList() }
system = body.system
tools = body.tools.map { it.toMutableList() }
@@ -942,6 +1023,45 @@ private constructor(
*/
fun metadata(metadata: JsonField) = apply { this.metadata = metadata }
+ /**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning
+ * session threads, each running an agent drawn from the `agents` roster.
+ */
+ fun multiagent(multiagent: BetaManagedAgentsMultiagentParams?) =
+ multiagent(JsonField.ofNullable(multiagent))
+
+ /** Alias for calling [Builder.multiagent] with `multiagent.orElse(null)`. */
+ fun multiagent(multiagent: Optional) =
+ multiagent(multiagent.getOrNull())
+
+ /**
+ * Sets [Builder.multiagent] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.multiagent] with a well-typed
+ * [BetaManagedAgentsMultiagentParams] value instead. This method is primarily for
+ * setting the field to an undocumented or not yet supported value.
+ */
+ fun multiagent(multiagent: JsonField) = apply {
+ this.multiagent = multiagent
+ }
+
+ /**
+ * Alias for calling [multiagent] with the following:
+ * ```java
+ * BetaManagedAgentsMultiagentParams.builder()
+ * .type(BetaManagedAgentsMultiagentParams.Type.COORDINATOR)
+ * .agents(agents)
+ * .build()
+ * ```
+ */
+ fun coordinatorMultiagent(agents: List) =
+ multiagent(
+ BetaManagedAgentsMultiagentParams.builder()
+ .type(BetaManagedAgentsMultiagentParams.Type.COORDINATOR)
+ .agents(agents)
+ .build()
+ )
+
/** Skills available to the agent. Maximum 20. */
fun skills(skills: List) = skills(JsonField.of(skills))
@@ -1128,6 +1248,7 @@ private constructor(
description,
(mcpServers ?: JsonMissing.of()).map { it.toImmutable() },
metadata,
+ multiagent,
(skills ?: JsonMissing.of()).map { it.toImmutable() },
system,
(tools ?: JsonMissing.of()).map { it.toImmutable() },
@@ -1156,6 +1277,7 @@ private constructor(
description()
mcpServers().ifPresent { it.forEach { it.validate() } }
metadata().ifPresent { it.validate() }
+ multiagent().ifPresent { it.validate() }
skills().ifPresent { it.forEach { it.validate() } }
system()
tools().ifPresent { it.forEach { it.validate() } }
@@ -1183,6 +1305,7 @@ private constructor(
(if (description.asKnown().isPresent) 1 else 0) +
(mcpServers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(metadata.asKnown().getOrNull()?.validity() ?: 0) +
+ (multiagent.asKnown().getOrNull()?.validity() ?: 0) +
(skills.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (system.asKnown().isPresent) 1 else 0) +
(tools.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
@@ -1198,6 +1321,7 @@ private constructor(
description == other.description &&
mcpServers == other.mcpServers &&
metadata == other.metadata &&
+ multiagent == other.multiagent &&
skills == other.skills &&
system == other.system &&
tools == other.tools &&
@@ -1211,6 +1335,7 @@ private constructor(
description,
mcpServers,
metadata,
+ multiagent,
skills,
system,
tools,
@@ -1221,7 +1346,7 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "Body{model=$model, name=$name, description=$description, mcpServers=$mcpServers, metadata=$metadata, skills=$skills, system=$system, tools=$tools, additionalProperties=$additionalProperties}"
+ "Body{model=$model, name=$name, description=$description, mcpServers=$mcpServers, metadata=$metadata, multiagent=$multiagent, skills=$skills, system=$system, tools=$tools, additionalProperties=$additionalProperties}"
}
/**
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentUpdateParams.kt
index b16410f60..e76aeb19e 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentUpdateParams.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentUpdateParams.kt
@@ -18,6 +18,8 @@ import com.anthropic.core.http.QueryParams
import com.anthropic.core.toImmutable
import com.anthropic.errors.AnthropicInvalidDataException
import com.anthropic.models.beta.AnthropicBeta
+import com.anthropic.models.beta.sessions.BetaManagedAgentsMultiagentParams
+import com.anthropic.models.beta.sessions.BetaManagedAgentsMultiagentRosterEntryParams
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
@@ -97,6 +99,15 @@ private constructor(
*/
fun model(): Optional = body.model()
+ /**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning session
+ * threads, each running an agent drawn from the `agents` roster.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun multiagent(): Optional = body.multiagent()
+
/**
* Human-readable name. 1-256 characters. Omit to preserve. Cannot be cleared.
*
@@ -166,6 +177,13 @@ private constructor(
*/
fun _model(): JsonField = body._model()
+ /**
+ * Returns the raw JSON value of [multiagent].
+ *
+ * Unlike [multiagent], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _multiagent(): JsonField = body._multiagent()
+
/**
* Returns the raw JSON value of [name].
*
@@ -390,6 +408,43 @@ private constructor(
body.model(betaManagedAgentsModelConfigParams)
}
+ /**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning
+ * session threads, each running an agent drawn from the `agents` roster.
+ */
+ fun multiagent(multiagent: BetaManagedAgentsMultiagentParams?) = apply {
+ body.multiagent(multiagent)
+ }
+
+ /** Alias for calling [Builder.multiagent] with `multiagent.orElse(null)`. */
+ fun multiagent(multiagent: Optional) =
+ multiagent(multiagent.getOrNull())
+
+ /**
+ * Sets [Builder.multiagent] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.multiagent] with a well-typed
+ * [BetaManagedAgentsMultiagentParams] value instead. This method is primarily for setting
+ * the field to an undocumented or not yet supported value.
+ */
+ fun multiagent(multiagent: JsonField) = apply {
+ body.multiagent(multiagent)
+ }
+
+ /**
+ * Alias for calling [multiagent] with the following:
+ * ```java
+ * BetaManagedAgentsMultiagentParams.builder()
+ * .type(BetaManagedAgentsMultiagentParams.Type.COORDINATOR)
+ * .agents(agents)
+ * .build()
+ * ```
+ */
+ fun coordinatorMultiagent(agents: List) =
+ apply {
+ body.coordinatorMultiagent(agents)
+ }
+
/** Human-readable name. 1-256 characters. Omit to preserve. Cannot be cleared. */
fun name(name: String) = apply { body.name(name) }
@@ -695,6 +750,7 @@ private constructor(
private val mcpServers: JsonField>,
private val metadata: JsonField,
private val model: JsonField,
+ private val multiagent: JsonField,
private val name: JsonField,
private val skills: JsonField>,
private val system: JsonField,
@@ -715,6 +771,9 @@ private constructor(
@ExcludeMissing
metadata: JsonField = JsonMissing.of(),
@JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(),
+ @JsonProperty("multiagent")
+ @ExcludeMissing
+ multiagent: JsonField = JsonMissing.of(),
@JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
@JsonProperty("skills")
@ExcludeMissing
@@ -727,6 +786,7 @@ private constructor(
mcpServers,
metadata,
model,
+ multiagent,
name,
skills,
system,
@@ -783,6 +843,16 @@ private constructor(
*/
fun model(): Optional = model.getOptional("model")
+ /**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning
+ * session threads, each running an agent drawn from the `agents` roster.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun multiagent(): Optional =
+ multiagent.getOptional("multiagent")
+
/**
* Human-readable name. 1-256 characters. Omit to preserve. Cannot be cleared.
*
@@ -857,6 +927,15 @@ private constructor(
*/
@JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model
+ /**
+ * Returns the raw JSON value of [multiagent].
+ *
+ * Unlike [multiagent], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("multiagent")
+ @ExcludeMissing
+ fun _multiagent(): JsonField = multiagent
+
/**
* Returns the raw JSON value of [name].
*
@@ -921,6 +1000,7 @@ private constructor(
null
private var metadata: JsonField = JsonMissing.of()
private var model: JsonField = JsonMissing.of()
+ private var multiagent: JsonField = JsonMissing.of()
private var name: JsonField = JsonMissing.of()
private var skills: JsonField>? = null
private var system: JsonField = JsonMissing.of()
@@ -934,6 +1014,7 @@ private constructor(
mcpServers = body.mcpServers.map { it.toMutableList() }
metadata = body.metadata
model = body.model
+ multiagent = body.multiagent
name = body.name
skills = body.skills.map { it.toMutableList() }
system = body.system
@@ -1061,6 +1142,45 @@ private constructor(
Model.ofBetaManagedAgentsModelConfigParams(betaManagedAgentsModelConfigParams)
)
+ /**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning
+ * session threads, each running an agent drawn from the `agents` roster.
+ */
+ fun multiagent(multiagent: BetaManagedAgentsMultiagentParams?) =
+ multiagent(JsonField.ofNullable(multiagent))
+
+ /** Alias for calling [Builder.multiagent] with `multiagent.orElse(null)`. */
+ fun multiagent(multiagent: Optional) =
+ multiagent(multiagent.getOrNull())
+
+ /**
+ * Sets [Builder.multiagent] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.multiagent] with a well-typed
+ * [BetaManagedAgentsMultiagentParams] value instead. This method is primarily for
+ * setting the field to an undocumented or not yet supported value.
+ */
+ fun multiagent(multiagent: JsonField) = apply {
+ this.multiagent = multiagent
+ }
+
+ /**
+ * Alias for calling [multiagent] with the following:
+ * ```java
+ * BetaManagedAgentsMultiagentParams.builder()
+ * .type(BetaManagedAgentsMultiagentParams.Type.COORDINATOR)
+ * .agents(agents)
+ * .build()
+ * ```
+ */
+ fun coordinatorMultiagent(agents: List) =
+ multiagent(
+ BetaManagedAgentsMultiagentParams.builder()
+ .type(BetaManagedAgentsMultiagentParams.Type.COORDINATOR)
+ .agents(agents)
+ .build()
+ )
+
/** Human-readable name. 1-256 characters. Omit to preserve. Cannot be cleared. */
fun name(name: String) = name(JsonField.of(name))
@@ -1272,6 +1392,7 @@ private constructor(
(mcpServers ?: JsonMissing.of()).map { it.toImmutable() },
metadata,
model,
+ multiagent,
name,
(skills ?: JsonMissing.of()).map { it.toImmutable() },
system,
@@ -1301,6 +1422,7 @@ private constructor(
mcpServers().ifPresent { it.forEach { it.validate() } }
metadata().ifPresent { it.validate() }
model().ifPresent { it.validate() }
+ multiagent().ifPresent { it.validate() }
name()
skills().ifPresent { it.forEach { it.validate() } }
system()
@@ -1329,6 +1451,7 @@ private constructor(
(mcpServers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(metadata.asKnown().getOrNull()?.validity() ?: 0) +
(model.asKnown().getOrNull()?.validity() ?: 0) +
+ (multiagent.asKnown().getOrNull()?.validity() ?: 0) +
(if (name.asKnown().isPresent) 1 else 0) +
(skills.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (system.asKnown().isPresent) 1 else 0) +
@@ -1345,6 +1468,7 @@ private constructor(
mcpServers == other.mcpServers &&
metadata == other.metadata &&
model == other.model &&
+ multiagent == other.multiagent &&
name == other.name &&
skills == other.skills &&
system == other.system &&
@@ -1359,6 +1483,7 @@ private constructor(
mcpServers,
metadata,
model,
+ multiagent,
name,
skills,
system,
@@ -1370,7 +1495,7 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "Body{version=$version, description=$description, mcpServers=$mcpServers, metadata=$metadata, model=$model, name=$name, skills=$skills, system=$system, tools=$tools, additionalProperties=$additionalProperties}"
+ "Body{version=$version, description=$description, mcpServers=$mcpServers, metadata=$metadata, model=$model, multiagent=$multiagent, name=$name, skills=$skills, system=$system, tools=$tools, additionalProperties=$additionalProperties}"
}
/**
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgent.kt
index f3c48ef7f..3552445a4 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgent.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgent.kt
@@ -14,6 +14,7 @@ import com.anthropic.core.checkRequired
import com.anthropic.core.getOrThrow
import com.anthropic.core.toImmutable
import com.anthropic.errors.AnthropicInvalidDataException
+import com.anthropic.models.beta.sessions.BetaManagedAgentsMultiagent
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
@@ -42,6 +43,7 @@ private constructor(
private val mcpServers: JsonField>,
private val metadata: JsonField,
private val model: JsonField,
+ private val multiagent: JsonField,
private val name: JsonField,
private val skills: JsonField>,
private val system: JsonField,
@@ -71,6 +73,9 @@ private constructor(
@JsonProperty("model")
@ExcludeMissing
model: JsonField = JsonMissing.of(),
+ @JsonProperty("multiagent")
+ @ExcludeMissing
+ multiagent: JsonField = JsonMissing.of(),
@JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
@JsonProperty("skills") @ExcludeMissing skills: JsonField> = JsonMissing.of(),
@JsonProperty("system") @ExcludeMissing system: JsonField = JsonMissing.of(),
@@ -88,6 +93,7 @@ private constructor(
mcpServers,
metadata,
model,
+ multiagent,
name,
skills,
system,
@@ -147,6 +153,14 @@ private constructor(
*/
fun model(): BetaManagedAgentsModelConfig = model.getRequired("model")
+ /**
+ * Resolved coordinator topology with a concrete agent roster.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun multiagent(): Optional = multiagent.getOptional("multiagent")
+
/**
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
@@ -250,6 +264,15 @@ private constructor(
@ExcludeMissing
fun _model(): JsonField = model
+ /**
+ * Returns the raw JSON value of [multiagent].
+ *
+ * Unlike [multiagent], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("multiagent")
+ @ExcludeMissing
+ fun _multiagent(): JsonField = multiagent
+
/**
* Returns the raw JSON value of [name].
*
@@ -327,6 +350,7 @@ private constructor(
* .mcpServers()
* .metadata()
* .model()
+ * .multiagent()
* .name()
* .skills()
* .system()
@@ -350,6 +374,7 @@ private constructor(
null
private var metadata: JsonField? = null
private var model: JsonField? = null
+ private var multiagent: JsonField? = null
private var name: JsonField? = null
private var skills: JsonField>? = null
private var system: JsonField? = null
@@ -368,6 +393,7 @@ private constructor(
mcpServers = betaManagedAgentsAgent.mcpServers.map { it.toMutableList() }
metadata = betaManagedAgentsAgent.metadata
model = betaManagedAgentsAgent.model
+ multiagent = betaManagedAgentsAgent.multiagent
name = betaManagedAgentsAgent.name
skills = betaManagedAgentsAgent.skills.map { it.toMutableList() }
system = betaManagedAgentsAgent.system
@@ -481,6 +507,42 @@ private constructor(
*/
fun model(model: JsonField) = apply { this.model = model }
+ /** Resolved coordinator topology with a concrete agent roster. */
+ fun multiagent(multiagent: BetaManagedAgentsMultiagent?) =
+ multiagent(JsonField.ofNullable(multiagent))
+
+ /** Alias for calling [Builder.multiagent] with `multiagent.orElse(null)`. */
+ fun multiagent(multiagent: Optional) =
+ multiagent(multiagent.getOrNull())
+
+ /**
+ * Sets [Builder.multiagent] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.multiagent] with a well-typed
+ * [BetaManagedAgentsMultiagent] value instead. This method is primarily for setting the
+ * field to an undocumented or not yet supported value.
+ */
+ fun multiagent(multiagent: JsonField) = apply {
+ this.multiagent = multiagent
+ }
+
+ /**
+ * Alias for calling [multiagent] with the following:
+ * ```java
+ * BetaManagedAgentsMultiagent.builder()
+ * .type(BetaManagedAgentsMultiagent.Type.COORDINATOR)
+ * .agents(agents)
+ * .build()
+ * ```
+ */
+ fun coordinatorMultiagent(agents: List) =
+ multiagent(
+ BetaManagedAgentsMultiagent.builder()
+ .type(BetaManagedAgentsMultiagent.Type.COORDINATOR)
+ .agents(agents)
+ .build()
+ )
+
fun name(name: String) = name(JsonField.of(name))
/**
@@ -636,6 +698,7 @@ private constructor(
* .mcpServers()
* .metadata()
* .model()
+ * .multiagent()
* .name()
* .skills()
* .system()
@@ -656,6 +719,7 @@ private constructor(
checkRequired("mcpServers", mcpServers).map { it.toImmutable() },
checkRequired("metadata", metadata),
checkRequired("model", model),
+ checkRequired("multiagent", multiagent),
checkRequired("name", name),
checkRequired("skills", skills).map { it.toImmutable() },
checkRequired("system", system),
@@ -689,6 +753,7 @@ private constructor(
mcpServers().forEach { it.validate() }
metadata().validate()
model().validate()
+ multiagent().ifPresent { it.validate() }
name()
skills().forEach { it.validate() }
system()
@@ -721,6 +786,7 @@ private constructor(
(mcpServers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(metadata.asKnown().getOrNull()?.validity() ?: 0) +
(model.asKnown().getOrNull()?.validity() ?: 0) +
+ (multiagent.asKnown().getOrNull()?.validity() ?: 0) +
(if (name.asKnown().isPresent) 1 else 0) +
(skills.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (system.asKnown().isPresent) 1 else 0) +
@@ -1448,6 +1514,7 @@ private constructor(
mcpServers == other.mcpServers &&
metadata == other.metadata &&
model == other.model &&
+ multiagent == other.multiagent &&
name == other.name &&
skills == other.skills &&
system == other.system &&
@@ -1467,6 +1534,7 @@ private constructor(
mcpServers,
metadata,
model,
+ multiagent,
name,
skills,
system,
@@ -1481,5 +1549,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "BetaManagedAgentsAgent{id=$id, archivedAt=$archivedAt, createdAt=$createdAt, description=$description, mcpServers=$mcpServers, metadata=$metadata, model=$model, name=$name, skills=$skills, system=$system, tools=$tools, type=$type, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}"
+ "BetaManagedAgentsAgent{id=$id, archivedAt=$archivedAt, createdAt=$createdAt, description=$description, mcpServers=$mcpServers, metadata=$metadata, model=$model, multiagent=$multiagent, name=$name, skills=$skills, system=$system, tools=$tools, type=$type, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}"
}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentReference.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentReference.kt
new file mode 100644
index 000000000..6f16c3379
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentReference.kt
@@ -0,0 +1,382 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.agents
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkRequired
+import com.anthropic.errors.AnthropicInvalidDataException
+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 java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/** A resolved agent reference with a concrete version. */
+class BetaManagedAgentsAgentReference
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val id: JsonField,
+ private val type: JsonField,
+ private val version: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(),
+ ) : this(id, type, version, mutableMapOf())
+
+ /**
+ * @throws AnthropicInvalidDataException 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 id(): String = id.getRequired("id")
+
+ /**
+ * @throws AnthropicInvalidDataException 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 type(): Type = type.getRequired("type")
+
+ /**
+ * @throws AnthropicInvalidDataException 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 version(): Int = version.getRequired("version")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+
+ /**
+ * 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 [version].
+ *
+ * Unlike [version], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version
+
+ @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
+ * [BetaManagedAgentsAgentReference].
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .type()
+ * .version()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsAgentReference]. */
+ class Builder internal constructor() {
+
+ private var id: JsonField? = null
+ private var type: JsonField? = null
+ private var version: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(betaManagedAgentsAgentReference: BetaManagedAgentsAgentReference) =
+ apply {
+ id = betaManagedAgentsAgentReference.id
+ type = betaManagedAgentsAgentReference.type
+ version = betaManagedAgentsAgentReference.version
+ additionalProperties =
+ betaManagedAgentsAgentReference.additionalProperties.toMutableMap()
+ }
+
+ fun id(id: String) = id(JsonField.of(id))
+
+ /**
+ * Sets [Builder.id] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.id] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun id(id: JsonField) = apply { this.id = id }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] 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 version(version: Int) = version(JsonField.of(version))
+
+ /**
+ * Sets [Builder.version] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.version] with a well-typed [Int] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun version(version: JsonField) = apply { this.version = version }
+
+ 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 [BetaManagedAgentsAgentReference].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .type()
+ * .version()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsAgentReference =
+ BetaManagedAgentsAgentReference(
+ checkRequired("id", id),
+ checkRequired("type", type),
+ checkRequired("version", version),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsAgentReference = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ type().validate()
+ version()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 (id.asKnown().isPresent) 1 else 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (version.asKnown().isPresent) 1 else 0)
+
+ class Type @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 AGENT = of("agent")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ AGENT
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ AGENT,
+ /** An enum member indicating that [Type] 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) {
+ AGENT -> Value.AGENT
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ AGENT -> Known.AGENT
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsAgentReference &&
+ id == other.id &&
+ type == other.type &&
+ version == other.version &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(id, type, version, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsAgentReference{id=$id, type=$type, version=$version, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentCoordinator.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentCoordinator.kt
new file mode 100644
index 000000000..b85311282
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentCoordinator.kt
@@ -0,0 +1,376 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.agents
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkKnown
+import com.anthropic.core.checkRequired
+import com.anthropic.core.toImmutable
+import com.anthropic.errors.AnthropicInvalidDataException
+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 java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/** Resolved coordinator topology with a concrete agent roster. */
+class BetaManagedAgentsMultiagentCoordinator
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val agents: JsonField>,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("agents")
+ @ExcludeMissing
+ agents: JsonField> = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(agents, type, mutableMapOf())
+
+ /**
+ * Agents the coordinator may spawn as session threads, each resolved to a specific version.
+ *
+ * @throws AnthropicInvalidDataException 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 agents(): List = agents.getRequired("agents")
+
+ /**
+ * @throws AnthropicInvalidDataException 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 type(): Type = type.getRequired("type")
+
+ /**
+ * Returns the raw JSON value of [agents].
+ *
+ * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("agents")
+ @ExcludeMissing
+ fun _agents(): JsonField> = agents
+
+ /**
+ * 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
+
+ @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
+ * [BetaManagedAgentsMultiagentCoordinator].
+ *
+ * The following fields are required:
+ * ```java
+ * .agents()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsMultiagentCoordinator]. */
+ class Builder internal constructor() {
+
+ private var agents: JsonField>? = null
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(
+ betaManagedAgentsMultiagentCoordinator: BetaManagedAgentsMultiagentCoordinator
+ ) = apply {
+ agents = betaManagedAgentsMultiagentCoordinator.agents.map { it.toMutableList() }
+ type = betaManagedAgentsMultiagentCoordinator.type
+ additionalProperties =
+ betaManagedAgentsMultiagentCoordinator.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * Agents the coordinator may spawn as session threads, each resolved to a specific version.
+ */
+ fun agents(agents: List) = agents(JsonField.of(agents))
+
+ /**
+ * Sets [Builder.agents] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.agents] with a well-typed
+ * `List` value instead. This method is primarily for
+ * setting the field to an undocumented or not yet supported value.
+ */
+ fun agents(agents: JsonField>) = apply {
+ this.agents = agents.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [BetaManagedAgentsAgentReference] to [agents].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addAgent(agent: BetaManagedAgentsAgentReference) = apply {
+ agents =
+ (agents ?: JsonField.of(mutableListOf())).also {
+ checkKnown("agents", it).add(agent)
+ }
+ }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] 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 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 [BetaManagedAgentsMultiagentCoordinator].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .agents()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsMultiagentCoordinator =
+ BetaManagedAgentsMultiagentCoordinator(
+ checkRequired("agents", agents).map { it.toImmutable() },
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsMultiagentCoordinator = apply {
+ if (validated) {
+ return@apply
+ }
+
+ agents().forEach { it.validate() }
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ (agents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 COORDINATOR = of("coordinator")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ COORDINATOR
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ COORDINATOR,
+ /** An enum member indicating that [Type] 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) {
+ COORDINATOR -> Value.COORDINATOR
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ COORDINATOR -> Known.COORDINATOR
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsMultiagentCoordinator &&
+ agents == other.agents &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(agents, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsMultiagentCoordinator{agents=$agents, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentCoordinatorParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentCoordinatorParams.kt
new file mode 100644
index 000000000..997a71416
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentCoordinatorParams.kt
@@ -0,0 +1,413 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.agents
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkKnown
+import com.anthropic.core.checkRequired
+import com.anthropic.core.toImmutable
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.anthropic.models.beta.sessions.BetaManagedAgentsAgentParams
+import com.anthropic.models.beta.sessions.BetaManagedAgentsMultiagentRosterEntryParams
+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 java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning session
+ * threads, each running an agent drawn from the `agents` roster.
+ */
+class BetaManagedAgentsMultiagentCoordinatorParams
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val agents: JsonField>,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("agents")
+ @ExcludeMissing
+ agents: JsonField> = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(agents, type, mutableMapOf())
+
+ /**
+ * Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent ID
+ * string, a versioned `{"type":"agent","id","version"}` reference, or `{"type":"self"}` to
+ * allow recursive self-invocation. Entries must reference distinct agents (after resolving
+ * `self` and string forms); at most one `self`. Referenced agents must exist, must not be
+ * archived, and must not themselves have `multiagent` set (depth limit 1).
+ *
+ * @throws AnthropicInvalidDataException 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 agents(): List = agents.getRequired("agents")
+
+ /**
+ * @throws AnthropicInvalidDataException 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 type(): Type = type.getRequired("type")
+
+ /**
+ * Returns the raw JSON value of [agents].
+ *
+ * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("agents")
+ @ExcludeMissing
+ fun _agents(): JsonField> = agents
+
+ /**
+ * 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
+
+ @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
+ * [BetaManagedAgentsMultiagentCoordinatorParams].
+ *
+ * The following fields are required:
+ * ```java
+ * .agents()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsMultiagentCoordinatorParams]. */
+ class Builder internal constructor() {
+
+ private var agents: JsonField>? =
+ null
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(
+ betaManagedAgentsMultiagentCoordinatorParams:
+ BetaManagedAgentsMultiagentCoordinatorParams
+ ) = apply {
+ agents = betaManagedAgentsMultiagentCoordinatorParams.agents.map { it.toMutableList() }
+ type = betaManagedAgentsMultiagentCoordinatorParams.type
+ additionalProperties =
+ betaManagedAgentsMultiagentCoordinatorParams.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent
+ * ID string, a versioned `{"type":"agent","id","version"}` reference, or `{"type":"self"}`
+ * to allow recursive self-invocation. Entries must reference distinct agents (after
+ * resolving `self` and string forms); at most one `self`. Referenced agents must exist,
+ * must not be archived, and must not themselves have `multiagent` set (depth limit 1).
+ */
+ fun agents(agents: List) =
+ agents(JsonField.of(agents))
+
+ /**
+ * Sets [Builder.agents] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.agents] with a well-typed
+ * `List` value instead. This method is
+ * primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun agents(agents: JsonField>) = apply {
+ this.agents = agents.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [BetaManagedAgentsMultiagentRosterEntryParams] to [agents].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addAgent(agent: BetaManagedAgentsMultiagentRosterEntryParams) = apply {
+ agents =
+ (agents ?: JsonField.of(mutableListOf())).also {
+ checkKnown("agents", it).add(agent)
+ }
+ }
+
+ /**
+ * Alias for calling [addAgent] with
+ * `BetaManagedAgentsMultiagentRosterEntryParams.ofString(string)`.
+ */
+ fun addAgent(string: String) =
+ addAgent(BetaManagedAgentsMultiagentRosterEntryParams.ofString(string))
+
+ /**
+ * Alias for calling [addAgent] with
+ * `BetaManagedAgentsMultiagentRosterEntryParams.ofAgent(agent)`.
+ */
+ fun addAgent(agent: BetaManagedAgentsAgentParams) =
+ addAgent(BetaManagedAgentsMultiagentRosterEntryParams.ofAgent(agent))
+
+ /**
+ * Alias for calling [addAgent] with
+ * `BetaManagedAgentsMultiagentRosterEntryParams.ofSelf(self)`.
+ */
+ fun addAgent(self: BetaManagedAgentsMultiagentSelfParams) =
+ addAgent(BetaManagedAgentsMultiagentRosterEntryParams.ofSelf(self))
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] 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 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 [BetaManagedAgentsMultiagentCoordinatorParams].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .agents()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsMultiagentCoordinatorParams =
+ BetaManagedAgentsMultiagentCoordinatorParams(
+ checkRequired("agents", agents).map { it.toImmutable() },
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsMultiagentCoordinatorParams = apply {
+ if (validated) {
+ return@apply
+ }
+
+ agents().forEach { it.validate() }
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ (agents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 COORDINATOR = of("coordinator")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ COORDINATOR
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ COORDINATOR,
+ /** An enum member indicating that [Type] 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) {
+ COORDINATOR -> Value.COORDINATOR
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ COORDINATOR -> Known.COORDINATOR
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsMultiagentCoordinatorParams &&
+ agents == other.agents &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(agents, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsMultiagentCoordinatorParams{agents=$agents, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentSelfParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentSelfParams.kt
new file mode 100644
index 000000000..d2aff641d
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsMultiagentSelfParams.kt
@@ -0,0 +1,318 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.agents
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkRequired
+import com.anthropic.errors.AnthropicInvalidDataException
+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 java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side to a
+ * concrete agent reference.
+ */
+class BetaManagedAgentsMultiagentSelfParams
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of()
+ ) : this(type, mutableMapOf())
+
+ /**
+ * @throws AnthropicInvalidDataException 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 type(): Type = type.getRequired("type")
+
+ /**
+ * 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
+
+ @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
+ * [BetaManagedAgentsMultiagentSelfParams].
+ *
+ * The following fields are required:
+ * ```java
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsMultiagentSelfParams]. */
+ class Builder internal constructor() {
+
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(
+ betaManagedAgentsMultiagentSelfParams: BetaManagedAgentsMultiagentSelfParams
+ ) = apply {
+ type = betaManagedAgentsMultiagentSelfParams.type
+ additionalProperties =
+ betaManagedAgentsMultiagentSelfParams.additionalProperties.toMutableMap()
+ }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] 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 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 [BetaManagedAgentsMultiagentSelfParams].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsMultiagentSelfParams =
+ BetaManagedAgentsMultiagentSelfParams(
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsMultiagentSelfParams = apply {
+ if (validated) {
+ return@apply
+ }
+
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 = (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 SELF = of("self")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ SELF
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ SELF,
+ /** An enum member indicating that [Type] 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) {
+ SELF -> Value.SELF
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ SELF -> Known.SELF
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsMultiagentSelfParams &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsMultiagentSelfParams{type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationContentBlockLocation.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationContentBlockLocation.kt
index f973bf2ee..2951d2942 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationContentBlockLocation.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationContentBlockLocation.kt
@@ -68,6 +68,13 @@ private constructor(
.build()
/**
+ * The full text of the cited block range, concatenated.
+ *
+ * Always equals the contents of `content[start_block_index:end_block_index]` joined together.
+ * The text block is the minimal citable unit; this field is never a substring of a single
+ * block. Not counted toward output tokens, and not counted toward input tokens when sent back
+ * in subsequent turns.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -86,6 +93,11 @@ private constructor(
fun documentTitle(): Optional = documentTitle.getOptional("document_title")
/**
+ * Exclusive 0-based end index of the cited block range in the source's `content` array.
+ *
+ * Always greater than `start_block_index`; a single-block citation has `end_block_index =
+ * start_block_index + 1`.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -98,6 +110,8 @@ private constructor(
fun fileId(): Optional = fileId.getOptional("file_id")
/**
+ * 0-based index of the first cited block in the source's `content` array.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -221,6 +235,14 @@ private constructor(
betaCitationContentBlockLocation.additionalProperties.toMutableMap()
}
+ /**
+ * The full text of the cited block range, concatenated.
+ *
+ * Always equals the contents of `content[start_block_index:end_block_index]` joined
+ * together. The text block is the minimal citable unit; this field is never a substring of
+ * a single block. Not counted toward output tokens, and not counted toward input tokens
+ * when sent back in subsequent turns.
+ */
fun citedText(citedText: String) = citedText(JsonField.of(citedText))
/**
@@ -263,6 +285,12 @@ private constructor(
this.documentTitle = documentTitle
}
+ /**
+ * Exclusive 0-based end index of the cited block range in the source's `content` array.
+ *
+ * Always greater than `start_block_index`; a single-block citation has `end_block_index =
+ * start_block_index + 1`.
+ */
fun endBlockIndex(endBlockIndex: Long) = endBlockIndex(JsonField.of(endBlockIndex))
/**
@@ -289,6 +317,7 @@ private constructor(
*/
fun fileId(fileId: JsonField) = apply { this.fileId = fileId }
+ /** 0-based index of the first cited block in the source's `content` array. */
fun startBlockIndex(startBlockIndex: Long) = startBlockIndex(JsonField.of(startBlockIndex))
/**
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationContentBlockLocationParam.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationContentBlockLocationParam.kt
index 2ffb3366c..f6d734ac7 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationContentBlockLocationParam.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationContentBlockLocationParam.kt
@@ -56,6 +56,13 @@ private constructor(
)
/**
+ * The full text of the cited block range, concatenated.
+ *
+ * Always equals the contents of `content[start_block_index:end_block_index]` joined together.
+ * The text block is the minimal citable unit; this field is never a substring of a single
+ * block. Not counted toward output tokens, and not counted toward input tokens when sent back
+ * in subsequent turns.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -74,12 +81,19 @@ private constructor(
fun documentTitle(): Optional = documentTitle.getOptional("document_title")
/**
+ * Exclusive 0-based end index of the cited block range in the source's `content` array.
+ *
+ * Always greater than `start_block_index`; a single-block citation has `end_block_index =
+ * start_block_index + 1`.
+ *
* @throws AnthropicInvalidDataException 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 endBlockIndex(): Long = endBlockIndex.getRequired("end_block_index")
/**
+ * 0-based index of the first cited block in the source's `content` array.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -194,6 +208,14 @@ private constructor(
betaCitationContentBlockLocationParam.additionalProperties.toMutableMap()
}
+ /**
+ * The full text of the cited block range, concatenated.
+ *
+ * Always equals the contents of `content[start_block_index:end_block_index]` joined
+ * together. The text block is the minimal citable unit; this field is never a substring of
+ * a single block. Not counted toward output tokens, and not counted toward input tokens
+ * when sent back in subsequent turns.
+ */
fun citedText(citedText: String) = citedText(JsonField.of(citedText))
/**
@@ -236,6 +258,12 @@ private constructor(
this.documentTitle = documentTitle
}
+ /**
+ * Exclusive 0-based end index of the cited block range in the source's `content` array.
+ *
+ * Always greater than `start_block_index`; a single-block citation has `end_block_index =
+ * start_block_index + 1`.
+ */
fun endBlockIndex(endBlockIndex: Long) = endBlockIndex(JsonField.of(endBlockIndex))
/**
@@ -249,6 +277,7 @@ private constructor(
this.endBlockIndex = endBlockIndex
}
+ /** 0-based index of the first cited block in the source's `content` array. */
fun startBlockIndex(startBlockIndex: Long) = startBlockIndex(JsonField.of(startBlockIndex))
/**
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationSearchResultLocation.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationSearchResultLocation.kt
index 9ca339d76..d4749f54c 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationSearchResultLocation.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationSearchResultLocation.kt
@@ -67,18 +67,36 @@ private constructor(
.build()
/**
+ * The full text of the cited block range, concatenated.
+ *
+ * Always equals the contents of `content[start_block_index:end_block_index]` joined together.
+ * The text block is the minimal citable unit; this field is never a substring of a single
+ * block. Not counted toward output tokens, and not counted toward input tokens when sent back
+ * in subsequent turns.
+ *
* @throws AnthropicInvalidDataException 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 citedText(): String = citedText.getRequired("cited_text")
/**
+ * Exclusive 0-based end index of the cited block range in the source's `content` array.
+ *
+ * Always greater than `start_block_index`; a single-block citation has `end_block_index =
+ * start_block_index + 1`.
+ *
* @throws AnthropicInvalidDataException 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 endBlockIndex(): Long = endBlockIndex.getRequired("end_block_index")
/**
+ * 0-based index of the cited search result among all `search_result` content blocks in the
+ * request, in the order they appear across messages and tool results.
+ *
+ * Counted separately from `document_index`; server-side web search results are not included in
+ * this count.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -91,6 +109,8 @@ private constructor(
fun source(): String = source.getRequired("source")
/**
+ * 0-based index of the first cited block in the source's `content` array.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -219,6 +239,14 @@ private constructor(
betaCitationSearchResultLocation.additionalProperties.toMutableMap()
}
+ /**
+ * The full text of the cited block range, concatenated.
+ *
+ * Always equals the contents of `content[start_block_index:end_block_index]` joined
+ * together. The text block is the minimal citable unit; this field is never a substring of
+ * a single block. Not counted toward output tokens, and not counted toward input tokens
+ * when sent back in subsequent turns.
+ */
fun citedText(citedText: String) = citedText(JsonField.of(citedText))
/**
@@ -230,6 +258,12 @@ private constructor(
*/
fun citedText(citedText: JsonField) = apply { this.citedText = citedText }
+ /**
+ * Exclusive 0-based end index of the cited block range in the source's `content` array.
+ *
+ * Always greater than `start_block_index`; a single-block citation has `end_block_index =
+ * start_block_index + 1`.
+ */
fun endBlockIndex(endBlockIndex: Long) = endBlockIndex(JsonField.of(endBlockIndex))
/**
@@ -243,6 +277,13 @@ private constructor(
this.endBlockIndex = endBlockIndex
}
+ /**
+ * 0-based index of the cited search result among all `search_result` content blocks in the
+ * request, in the order they appear across messages and tool results.
+ *
+ * Counted separately from `document_index`; server-side web search results are not included
+ * in this count.
+ */
fun searchResultIndex(searchResultIndex: Long) =
searchResultIndex(JsonField.of(searchResultIndex))
@@ -267,6 +308,7 @@ private constructor(
*/
fun source(source: JsonField) = apply { this.source = source }
+ /** 0-based index of the first cited block in the source's `content` array. */
fun startBlockIndex(startBlockIndex: Long) = startBlockIndex(JsonField.of(startBlockIndex))
/**
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationSearchResultLocationParam.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationSearchResultLocationParam.kt
index 8aed61987..4641eac37 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationSearchResultLocationParam.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaCitationSearchResultLocationParam.kt
@@ -57,18 +57,36 @@ private constructor(
)
/**
+ * The full text of the cited block range, concatenated.
+ *
+ * Always equals the contents of `content[start_block_index:end_block_index]` joined together.
+ * The text block is the minimal citable unit; this field is never a substring of a single
+ * block. Not counted toward output tokens, and not counted toward input tokens when sent back
+ * in subsequent turns.
+ *
* @throws AnthropicInvalidDataException 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 citedText(): String = citedText.getRequired("cited_text")
/**
+ * Exclusive 0-based end index of the cited block range in the source's `content` array.
+ *
+ * Always greater than `start_block_index`; a single-block citation has `end_block_index =
+ * start_block_index + 1`.
+ *
* @throws AnthropicInvalidDataException 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 endBlockIndex(): Long = endBlockIndex.getRequired("end_block_index")
/**
+ * 0-based index of the cited search result among all `search_result` content blocks in the
+ * request, in the order they appear across messages and tool results.
+ *
+ * Counted separately from `document_index`; server-side web search results are not included in
+ * this count.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -81,6 +99,8 @@ private constructor(
fun source(): String = source.getRequired("source")
/**
+ * 0-based index of the first cited block in the source's `content` array.
+ *
* @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
@@ -210,6 +230,14 @@ private constructor(
betaCitationSearchResultLocationParam.additionalProperties.toMutableMap()
}
+ /**
+ * The full text of the cited block range, concatenated.
+ *
+ * Always equals the contents of `content[start_block_index:end_block_index]` joined
+ * together. The text block is the minimal citable unit; this field is never a substring of
+ * a single block. Not counted toward output tokens, and not counted toward input tokens
+ * when sent back in subsequent turns.
+ */
fun citedText(citedText: String) = citedText(JsonField.of(citedText))
/**
@@ -221,6 +249,12 @@ private constructor(
*/
fun citedText(citedText: JsonField) = apply { this.citedText = citedText }
+ /**
+ * Exclusive 0-based end index of the cited block range in the source's `content` array.
+ *
+ * Always greater than `start_block_index`; a single-block citation has `end_block_index =
+ * start_block_index + 1`.
+ */
fun endBlockIndex(endBlockIndex: Long) = endBlockIndex(JsonField.of(endBlockIndex))
/**
@@ -234,6 +268,13 @@ private constructor(
this.endBlockIndex = endBlockIndex
}
+ /**
+ * 0-based index of the cited search result among all `search_result` content blocks in the
+ * request, in the order they appear across messages and tool results.
+ *
+ * Counted separately from `document_index`; server-side web search results are not included
+ * in this count.
+ */
fun searchResultIndex(searchResultIndex: Long) =
searchResultIndex(JsonField.of(searchResultIndex))
@@ -258,6 +299,7 @@ private constructor(
*/
fun source(source: JsonField) = apply { this.source = source }
+ /** 0-based index of the first cited block in the source's `content` array. */
fun startBlockIndex(startBlockIndex: Long) = startBlockIndex(JsonField.of(startBlockIndex))
/**
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagent.kt
new file mode 100644
index 000000000..ec44e8602
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagent.kt
@@ -0,0 +1,373 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkKnown
+import com.anthropic.core.checkRequired
+import com.anthropic.core.toImmutable
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.anthropic.models.beta.agents.BetaManagedAgentsAgentReference
+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 java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/** Resolved coordinator topology with a concrete agent roster. */
+class BetaManagedAgentsMultiagent
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val agents: JsonField>,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("agents")
+ @ExcludeMissing
+ agents: JsonField> = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(agents, type, mutableMapOf())
+
+ /**
+ * Agents the coordinator may spawn as session threads, each resolved to a specific version.
+ *
+ * @throws AnthropicInvalidDataException 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 agents(): List = agents.getRequired("agents")
+
+ /**
+ * @throws AnthropicInvalidDataException 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 type(): Type = type.getRequired("type")
+
+ /**
+ * Returns the raw JSON value of [agents].
+ *
+ * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("agents")
+ @ExcludeMissing
+ fun _agents(): JsonField> = agents
+
+ /**
+ * 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
+
+ @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 [BetaManagedAgentsMultiagent].
+ *
+ * The following fields are required:
+ * ```java
+ * .agents()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsMultiagent]. */
+ class Builder internal constructor() {
+
+ private var agents: JsonField>? = null
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(betaManagedAgentsMultiagent: BetaManagedAgentsMultiagent) = apply {
+ agents = betaManagedAgentsMultiagent.agents.map { it.toMutableList() }
+ type = betaManagedAgentsMultiagent.type
+ additionalProperties = betaManagedAgentsMultiagent.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * Agents the coordinator may spawn as session threads, each resolved to a specific version.
+ */
+ fun agents(agents: List) = agents(JsonField.of(agents))
+
+ /**
+ * Sets [Builder.agents] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.agents] with a well-typed
+ * `List` value instead. This method is primarily for
+ * setting the field to an undocumented or not yet supported value.
+ */
+ fun agents(agents: JsonField>) = apply {
+ this.agents = agents.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [BetaManagedAgentsAgentReference] to [agents].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addAgent(agent: BetaManagedAgentsAgentReference) = apply {
+ agents =
+ (agents ?: JsonField.of(mutableListOf())).also {
+ checkKnown("agents", it).add(agent)
+ }
+ }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] 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 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 [BetaManagedAgentsMultiagent].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .agents()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsMultiagent =
+ BetaManagedAgentsMultiagent(
+ checkRequired("agents", agents).map { it.toImmutable() },
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsMultiagent = apply {
+ if (validated) {
+ return@apply
+ }
+
+ agents().forEach { it.validate() }
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ (agents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 COORDINATOR = of("coordinator")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ COORDINATOR
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ COORDINATOR,
+ /** An enum member indicating that [Type] 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) {
+ COORDINATOR -> Value.COORDINATOR
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ COORDINATOR -> Known.COORDINATOR
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsMultiagent &&
+ agents == other.agents &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(agents, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsMultiagent{agents=$agents, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagentParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagentParams.kt
new file mode 100644
index 000000000..c34398cfe
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagentParams.kt
@@ -0,0 +1,410 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkKnown
+import com.anthropic.core.checkRequired
+import com.anthropic.core.toImmutable
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.anthropic.models.beta.agents.BetaManagedAgentsMultiagentSelfParams
+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 java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * A coordinator topology: the session's primary thread orchestrates work by spawning session
+ * threads, each running an agent drawn from the `agents` roster.
+ */
+class BetaManagedAgentsMultiagentParams
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val agents: JsonField>,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("agents")
+ @ExcludeMissing
+ agents: JsonField> = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(agents, type, mutableMapOf())
+
+ /**
+ * Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent ID
+ * string, a versioned `{"type":"agent","id","version"}` reference, or `{"type":"self"}` to
+ * allow recursive self-invocation. Entries must reference distinct agents (after resolving
+ * `self` and string forms); at most one `self`. Referenced agents must exist, must not be
+ * archived, and must not themselves have `multiagent` set (depth limit 1).
+ *
+ * @throws AnthropicInvalidDataException 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 agents(): List = agents.getRequired("agents")
+
+ /**
+ * @throws AnthropicInvalidDataException 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 type(): Type = type.getRequired("type")
+
+ /**
+ * Returns the raw JSON value of [agents].
+ *
+ * Unlike [agents], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("agents")
+ @ExcludeMissing
+ fun _agents(): JsonField> = agents
+
+ /**
+ * 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
+
+ @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
+ * [BetaManagedAgentsMultiagentParams].
+ *
+ * The following fields are required:
+ * ```java
+ * .agents()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsMultiagentParams]. */
+ class Builder internal constructor() {
+
+ private var agents: JsonField>? =
+ null
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(betaManagedAgentsMultiagentParams: BetaManagedAgentsMultiagentParams) =
+ apply {
+ agents = betaManagedAgentsMultiagentParams.agents.map { it.toMutableList() }
+ type = betaManagedAgentsMultiagentParams.type
+ additionalProperties =
+ betaManagedAgentsMultiagentParams.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent
+ * ID string, a versioned `{"type":"agent","id","version"}` reference, or `{"type":"self"}`
+ * to allow recursive self-invocation. Entries must reference distinct agents (after
+ * resolving `self` and string forms); at most one `self`. Referenced agents must exist,
+ * must not be archived, and must not themselves have `multiagent` set (depth limit 1).
+ */
+ fun agents(agents: List) =
+ agents(JsonField.of(agents))
+
+ /**
+ * Sets [Builder.agents] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.agents] with a well-typed
+ * `List` value instead. This method is
+ * primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun agents(agents: JsonField>) = apply {
+ this.agents = agents.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [BetaManagedAgentsMultiagentRosterEntryParams] to [agents].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addAgent(agent: BetaManagedAgentsMultiagentRosterEntryParams) = apply {
+ agents =
+ (agents ?: JsonField.of(mutableListOf())).also {
+ checkKnown("agents", it).add(agent)
+ }
+ }
+
+ /**
+ * Alias for calling [addAgent] with
+ * `BetaManagedAgentsMultiagentRosterEntryParams.ofString(string)`.
+ */
+ fun addAgent(string: String) =
+ addAgent(BetaManagedAgentsMultiagentRosterEntryParams.ofString(string))
+
+ /**
+ * Alias for calling [addAgent] with
+ * `BetaManagedAgentsMultiagentRosterEntryParams.ofAgent(agent)`.
+ */
+ fun addAgent(agent: BetaManagedAgentsAgentParams) =
+ addAgent(BetaManagedAgentsMultiagentRosterEntryParams.ofAgent(agent))
+
+ /**
+ * Alias for calling [addAgent] with
+ * `BetaManagedAgentsMultiagentRosterEntryParams.ofSelf(self)`.
+ */
+ fun addAgent(self: BetaManagedAgentsMultiagentSelfParams) =
+ addAgent(BetaManagedAgentsMultiagentRosterEntryParams.ofSelf(self))
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] 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 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 [BetaManagedAgentsMultiagentParams].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .agents()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsMultiagentParams =
+ BetaManagedAgentsMultiagentParams(
+ checkRequired("agents", agents).map { it.toImmutable() },
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsMultiagentParams = apply {
+ if (validated) {
+ return@apply
+ }
+
+ agents().forEach { it.validate() }
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ (agents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 COORDINATOR = of("coordinator")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ COORDINATOR
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ COORDINATOR,
+ /** An enum member indicating that [Type] 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) {
+ COORDINATOR -> Value.COORDINATOR
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ COORDINATOR -> Known.COORDINATOR
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsMultiagentParams &&
+ agents == other.agents &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(agents, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsMultiagentParams{agents=$agents, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagentRosterEntryParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagentRosterEntryParams.kt
new file mode 100644
index 000000000..7eaadaa6d
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsMultiagentRosterEntryParams.kt
@@ -0,0 +1,314 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.BaseDeserializer
+import com.anthropic.core.BaseSerializer
+import com.anthropic.core.JsonValue
+import com.anthropic.core.allMaxBy
+import com.anthropic.core.getOrThrow
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.anthropic.models.beta.agents.BetaManagedAgentsMultiagentSelfParams
+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.Objects
+import java.util.Optional
+
+/** An entry in a multiagent roster: an agent ID string, a versioned agent reference, or `self`. */
+@JsonDeserialize(using = BetaManagedAgentsMultiagentRosterEntryParams.Deserializer::class)
+@JsonSerialize(using = BetaManagedAgentsMultiagentRosterEntryParams.Serializer::class)
+class BetaManagedAgentsMultiagentRosterEntryParams
+private constructor(
+ private val string: String? = null,
+ private val agent: BetaManagedAgentsAgentParams? = null,
+ private val self: BetaManagedAgentsMultiagentSelfParams? = null,
+ private val _json: JsonValue? = null,
+) {
+
+ fun string(): Optional = Optional.ofNullable(string)
+
+ /**
+ * Specification for an Agent. Provide a specific `version` or use the short-form
+ * `agent="agent_id"` for the most recent version
+ */
+ fun agent(): Optional = Optional.ofNullable(agent)
+
+ /**
+ * Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side
+ * to a concrete agent reference.
+ */
+ fun self(): Optional = Optional.ofNullable(self)
+
+ fun isString(): Boolean = string != null
+
+ fun isAgent(): Boolean = agent != null
+
+ fun isSelf(): Boolean = self != null
+
+ fun asString(): String = string.getOrThrow("string")
+
+ /**
+ * Specification for an Agent. Provide a specific `version` or use the short-form
+ * `agent="agent_id"` for the most recent version
+ */
+ fun asAgent(): BetaManagedAgentsAgentParams = agent.getOrThrow("agent")
+
+ /**
+ * Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side
+ * to a concrete agent reference.
+ */
+ fun asSelf(): BetaManagedAgentsMultiagentSelfParams = self.getOrThrow("self")
+
+ fun _json(): Optional = Optional.ofNullable(_json)
+
+ /**
+ * Maps this instance's current variant to a value of type [T] using the given [visitor].
+ *
+ * Note that this method is _not_ forwards compatible with new variants from the API, unless
+ * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the
+ * SDK gracefully, consider overriding [Visitor.unknown]:
+ * ```java
+ * import com.anthropic.core.JsonValue;
+ * import java.util.Optional;
+ *
+ * Optional result = betaManagedAgentsMultiagentRosterEntryParams.accept(new BetaManagedAgentsMultiagentRosterEntryParams.Visitor>() {
+ * @Override
+ * public Optional visitString(String string) {
+ * return Optional.of(string.toString());
+ * }
+ *
+ * // ...
+ *
+ * @Override
+ * public Optional unknown(JsonValue json) {
+ * // Or inspect the `json`.
+ * return Optional.empty();
+ * }
+ * });
+ * ```
+ *
+ * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and
+ * the current variant is unknown.
+ */
+ fun accept(visitor: Visitor): T =
+ when {
+ string != null -> visitor.visitString(string)
+ agent != null -> visitor.visitAgent(agent)
+ self != null -> visitor.visitSelf(self)
+ else -> visitor.unknown(_json)
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsMultiagentRosterEntryParams = apply {
+ if (validated) {
+ return@apply
+ }
+
+ accept(
+ object : Visitor {
+ override fun visitString(string: String) {}
+
+ override fun visitAgent(agent: BetaManagedAgentsAgentParams) {
+ agent.validate()
+ }
+
+ override fun visitSelf(self: BetaManagedAgentsMultiagentSelfParams) {
+ self.validate()
+ }
+ }
+ )
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 visitString(string: String) = 1
+
+ override fun visitAgent(agent: BetaManagedAgentsAgentParams) = agent.validity()
+
+ override fun visitSelf(self: BetaManagedAgentsMultiagentSelfParams) =
+ self.validity()
+
+ override fun unknown(json: JsonValue?) = 0
+ }
+ )
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsMultiagentRosterEntryParams &&
+ string == other.string &&
+ agent == other.agent &&
+ self == other.self
+ }
+
+ override fun hashCode(): Int = Objects.hash(string, agent, self)
+
+ override fun toString(): String =
+ when {
+ string != null -> "BetaManagedAgentsMultiagentRosterEntryParams{string=$string}"
+ agent != null -> "BetaManagedAgentsMultiagentRosterEntryParams{agent=$agent}"
+ self != null -> "BetaManagedAgentsMultiagentRosterEntryParams{self=$self}"
+ _json != null -> "BetaManagedAgentsMultiagentRosterEntryParams{_unknown=$_json}"
+ else ->
+ throw IllegalStateException("Invalid BetaManagedAgentsMultiagentRosterEntryParams")
+ }
+
+ companion object {
+
+ @JvmStatic
+ fun ofString(string: String) = BetaManagedAgentsMultiagentRosterEntryParams(string = string)
+
+ /**
+ * Specification for an Agent. Provide a specific `version` or use the short-form
+ * `agent="agent_id"` for the most recent version
+ */
+ @JvmStatic
+ fun ofAgent(agent: BetaManagedAgentsAgentParams) =
+ BetaManagedAgentsMultiagentRosterEntryParams(agent = agent)
+
+ /**
+ * Sentinel roster entry meaning "the agent that owns this configuration". Resolved
+ * server-side to a concrete agent reference.
+ */
+ @JvmStatic
+ fun ofSelf(self: BetaManagedAgentsMultiagentSelfParams) =
+ BetaManagedAgentsMultiagentRosterEntryParams(self = self)
+ }
+
+ /**
+ * An interface that defines how to map each variant of
+ * [BetaManagedAgentsMultiagentRosterEntryParams] to a value of type [T].
+ */
+ interface Visitor {
+
+ fun visitString(string: String): T
+
+ /**
+ * Specification for an Agent. Provide a specific `version` or use the short-form
+ * `agent="agent_id"` for the most recent version
+ */
+ fun visitAgent(agent: BetaManagedAgentsAgentParams): T
+
+ /**
+ * Sentinel roster entry meaning "the agent that owns this configuration". Resolved
+ * server-side to a concrete agent reference.
+ */
+ fun visitSelf(self: BetaManagedAgentsMultiagentSelfParams): T
+
+ /**
+ * Maps an unknown variant of [BetaManagedAgentsMultiagentRosterEntryParams] to a value of
+ * type [T].
+ *
+ * An instance of [BetaManagedAgentsMultiagentRosterEntryParams] 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 AnthropicInvalidDataException in the default implementation.
+ */
+ fun unknown(json: JsonValue?): T {
+ throw AnthropicInvalidDataException(
+ "Unknown BetaManagedAgentsMultiagentRosterEntryParams: $json"
+ )
+ }
+ }
+
+ internal class Deserializer :
+ BaseDeserializer(
+ BetaManagedAgentsMultiagentRosterEntryParams::class
+ ) {
+
+ override fun ObjectCodec.deserialize(
+ node: JsonNode
+ ): BetaManagedAgentsMultiagentRosterEntryParams {
+ val json = JsonValue.fromJsonNode(node)
+
+ val bestMatches =
+ sequenceOf(
+ tryDeserialize(node, jacksonTypeRef())?.let {
+ BetaManagedAgentsMultiagentRosterEntryParams(agent = it, _json = json)
+ },
+ tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let {
+ BetaManagedAgentsMultiagentRosterEntryParams(
+ self = it,
+ _json = json,
+ )
+ },
+ tryDeserialize(node, jacksonTypeRef